/* Stable application chrome layered over the preserved Version 11 hero. */

:root {
  --ui-shell-cyan: #62e7f5;
  --ui-shell-mint: #86efb8;
  --ui-shell-yellow: #ffe27a;
  --ui-shell-ink: #071c27;
}

@media (min-width: 741px) {
  #title-heading {
    font-size: clamp(44px, 4.35vw, 68px);
    white-space: nowrap;
  }
}

.topbar {
  grid-template-columns: minmax(148px, 1fr) auto minmax(238px, 1fr);
}

.top-actions {
  min-width: 0;
  gap: 8px;
}

.top-actions .guide-button,
.top-actions .language-toggle,
.top-actions .app-menu-button {
  flex: 0 0 auto;
}

.app-menu-button {
  display: grid;
  grid-template-columns: 32px auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  min-width: 104px;
  min-height: 46px;
  padding: 5px 12px 5px 7px;
  border: 1px solid rgba(134, 239, 184, 0.42);
  border-radius: 999px;
  color: #efffff;
  background: linear-gradient(135deg, rgba(98, 231, 245, 0.14), rgba(134, 239, 184, 0.08));
  box-shadow: inset 0 0 18px rgba(98, 231, 245, 0.05);
  cursor: pointer;
  text-align: left;
}

.app-menu-button > span {
  grid-row: 1 / 3;
  display: grid;
  gap: 4px;
  width: 32px;
  height: 32px;
  place-content: center;
  border-radius: 50%;
  color: var(--ui-shell-ink);
  background: linear-gradient(145deg, var(--ui-shell-yellow), var(--ui-shell-mint));
}

.app-menu-button > span i {
  display: block;
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.app-menu-button b {
  align-self: end;
  font-size: 10px;
  line-height: 1.1;
}

.app-menu-button small {
  align-self: start;
  color: #8fd9de;
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 0.15em;
  line-height: 1.2;
}

.app-menu-button:hover,
.app-menu-button[aria-expanded="true"] {
  border-color: var(--ui-shell-cyan);
  box-shadow: 0 0 22px rgba(98, 231, 245, 0.18), inset 0 0 20px rgba(98, 231, 245, 0.08);
}

.app-menu-button:focus-visible,
.app-menu-close:focus-visible,
.app-menu-nav > :is(button, a):focus-visible {
  outline: 3px solid var(--ui-shell-yellow);
  outline-offset: 3px;
}

body.app-menu-open {
  overflow: hidden !important;
}

.ui-shell-status {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.app-menu[hidden] {
  display: none !important;
}

.app-menu {
  position: fixed;
  z-index: 11000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 24px);
}

.app-menu-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(98, 231, 245, 0.2), transparent 30%),
    radial-gradient(circle at 88% 92%, rgba(169, 135, 239, 0.2), transparent 34%),
    rgba(2, 11, 18, 0.88);
  backdrop-filter: blur(14px) saturate(1.15);
  cursor: default;
}

.app-menu-dialog {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(860px, 100%);
  max-height: min(820px, calc(100dvh - 24px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 30px;
  color: #efffff;
  background:
    radial-gradient(circle at 100% 0, rgba(169, 135, 239, 0.2), transparent 33%),
    linear-gradient(145deg, #071b28, #0c2932 58%, #101b2f);
  box-shadow: 0 38px 120px rgba(0, 0, 0, 0.62), inset 0 1px rgba(255, 255, 255, 0.09);
}

.app-menu-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  padding: 25px 27px 19px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.app-menu-header small {
  color: var(--ui-shell-cyan);
  font: 900 8px/1 ui-monospace, monospace;
  letter-spacing: 0.16em;
}

.app-menu-header h2 {
  margin: 7px 0 5px;
  color: #fff;
  font-size: clamp(25px, 3.6vw, 42px);
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.app-menu-header p {
  margin: 0;
  color: #a7c4c8;
  font-size: 11px;
  line-height: 1.55;
}

.app-menu-close {
  flex: 0 0 auto;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-size: 25px;
}

.app-menu-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 18px 22px 25px;
  scrollbar-color: var(--ui-shell-cyan) rgba(255, 255, 255, 0.06);
}

.app-menu-nav > :is(button, a) {
  position: relative;
  display: grid !important;
  grid-template-columns: 52px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 76px;
  height: auto;
  padding: 10px 14px 10px 10px !important;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 18px !important;
  color: #f4ffff !important;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.085), rgba(98, 231, 245, 0.035)) !important;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06) !important;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transform: none;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.app-menu-nav > :is(button, a):hover {
  border-color: rgba(98, 231, 245, 0.72) !important;
  background: linear-gradient(135deg, rgba(98, 231, 245, 0.13), rgba(169, 135, 239, 0.08)) !important;
  filter: none;
  transform: translateY(-2px);
}

.app-menu-nav > :is(button, a) > span {
  grid-row: 1 / 3;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 15px;
  color: var(--ui-shell-ink);
  background: linear-gradient(145deg, var(--ui-shell-yellow), var(--ui-shell-mint));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.7);
  font-size: 18px;
  font-weight: 950;
}

.app-menu-nav > :is(button, a) > b {
  align-self: end;
  color: #fff;
  font-size: 12px;
  line-height: 1.25;
  white-space: normal;
}

.app-menu-nav > :is(button, a) > small {
  align-self: start;
  color: #8edce3;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.3;
}

.app-menu-nav > :is(button, a) > :is(b, small) {
  display: block !important;
}

.app-menu-nav .crew-button > span {
  width: 48px;
  height: 48px;
  border-radius: 15px;
}

.app-menu-nav .collection-button::before {
  display: none;
}

.app-menu-nav .collection-button > span {
  color: #fff4b1;
  background: linear-gradient(145deg, #8c6fd1, #e7689b);
  font-size: 8px;
  line-height: 1.2;
  text-align: center;
}

.app-menu-nav .collection-button > b {
  color: var(--ui-shell-mint);
  font-size: 15px;
}

.app-menu-nav .best-score {
  grid-column: 1 / -1;
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border: 1px dashed rgba(255, 226, 122, 0.42);
  border-radius: 16px;
  color: #afc8c7;
  background: rgba(255, 226, 122, 0.055);
  font-size: 9px;
}

.app-menu-nav .best-score strong {
  color: var(--ui-shell-yellow);
  font-size: 24px;
}

#start-game.is-launching,
#expert-start.is-launching {
  transform: translateY(2px) scale(0.99);
  filter: brightness(1.12);
}

#start-game.is-launching {
  box-shadow: 3px 4px 0 rgba(99, 201, 239, 0.48), 0 0 34px rgba(255, 216, 93, 0.34);
}

#start-game.is-launching svg {
  animation: ui-shell-launch-arrow 420ms ease-in-out infinite alternate;
}

/* First-visit clarity: one mission, one route, one primary action. */
.title-entry-guide {
  width: min(100%, 680px);
  margin: 0 0 18px;
  padding: 15px;
  border: 1px solid rgba(255, 226, 122, 0.58);
  border-radius: 22px;
  color: #effffb;
  background:
    radial-gradient(circle at 96% 0, rgba(255, 226, 122, 0.13), transparent 34%),
    linear-gradient(135deg, rgba(7, 38, 43, 0.92), rgba(10, 55, 63, 0.88));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 18px 42px rgba(2, 21, 25, 0.18);
}

.title-entry-guide header small,
.title-entry-guide header b,
.title-entry-guide header p {
  display: block;
}

.title-entry-guide header small {
  color: var(--ui-shell-yellow);
  font-size: 8px;
  font-weight: 950;
  letter-spacing: 0.16em;
}

.title-entry-guide header b {
  margin-top: 5px;
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
}

.title-entry-guide header p {
  margin: 5px 0 0;
  color: #bfe7e2;
  font-size: 9px;
  line-height: 1.6;
}

.title-entry-guide header strong {
  color: var(--ui-shell-yellow);
}

.title-journey-route {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.title-journey-route li {
  position: relative;
  display: grid;
  grid-template-columns: 23px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 0 6px;
  min-height: 48px;
  align-content: center;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
}

.title-journey-route li.is-current {
  border-color: var(--ui-shell-yellow);
  background: linear-gradient(135deg, rgba(255, 226, 122, 0.2), rgba(134, 239, 184, 0.11));
  box-shadow: 0 0 22px rgba(255, 226, 122, 0.12);
}

.title-journey-route li > span {
  grid-row: 1 / 3;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  align-self: center;
  border-radius: 50%;
  color: var(--ui-shell-ink);
  background: #bfd6d2;
  font-size: 8px;
  font-weight: 950;
}

.title-journey-route li.is-current > span {
  background: var(--ui-shell-yellow);
}

.title-journey-route b {
  align-self: end;
  color: #fff;
  font-size: 8px;
  line-height: 1.2;
}

.title-journey-route small {
  align-self: start;
  color: #90b5b1;
  font-size: 6px;
  line-height: 1.3;
}

.title-entry-note {
  margin: 10px 0 0;
  color: #e8fff8;
  font-size: 9px;
  font-weight: 800;
}

.title-actions {
  display: grid !important;
  grid-template-columns: minmax(0, 1.35fr) minmax(180px, 0.65fr);
  gap: 10px !important;
}

.title-primary-choice,
.title-help-choice {
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 12px;
  border-radius: 19px;
}

.title-primary-choice {
  border: 2px solid rgba(255, 226, 122, 0.8);
  background: rgba(255, 226, 122, 0.1);
}

.title-primary-choice > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title-primary-choice > div b {
  color: #fff;
  font-size: 11px;
}

.title-primary-choice > div small {
  color: #ffeaa0;
  font-size: 8px;
  font-weight: 800;
}

.title-primary-choice #start-game {
  width: 100%;
}

.title-primary-choice p,
.title-help-choice small {
  margin: 0;
  color: #b8dcd7;
  font-size: 8px;
  line-height: 1.45;
}

.title-help-choice {
  border: 1px solid rgba(255, 255, 255, 0.17);
  background: rgba(255, 255, 255, 0.055);
}

.title-help-choice > b {
  color: #fff;
  font-size: 10px;
}

.title-help-choice .title-how-to {
  width: 100%;
}

.title-secondary-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.title-secondary-actions .opening-replay,
.title-secondary-actions .expert-start,
.title-secondary-actions .title-how-to {
  width: auto;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #b9dcd7;
  background: rgba(255, 255, 255, 0.055);
  font-size: 9px;
  text-align: center;
  text-decoration: none;
}

.title-actions > .atlas-title-button {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  min-height: 58px;
  box-shadow: none;
}

.title-actions > .atlas-title-button > span {
  width: 45px;
  height: 39px;
  font-size: 6px;
}

.future-context-details {
  width: min(100%, 680px);
  margin: 14px 0 12px;
}

.future-context-details > summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 56px;
  padding: 10px 13px;
  border: 1px dashed rgba(200, 240, 106, 0.46);
  border-radius: 17px;
  color: #eafff8;
  background: rgba(8, 36, 40, 0.82);
  cursor: pointer;
  list-style: none;
}

.future-context-details > summary::-webkit-details-marker {
  display: none;
}

.future-context-details > summary::after {
  content: "＋";
  color: var(--ui-shell-yellow);
  font-size: 20px;
  font-weight: 900;
}

.future-context-details[open] > summary::after {
  content: "−";
}

.future-context-details > summary span {
  padding: 5px 7px;
  border-radius: 999px;
  color: var(--ui-shell-ink);
  background: var(--ui-shell-mint);
  font-size: 7px;
  font-weight: 950;
}

.future-context-details > summary b,
.future-context-details > summary small {
  display: block;
}

.future-context-details > summary b {
  color: #fff;
  font-size: 10px;
}

.future-context-details > summary small {
  margin-top: 2px;
  color: #9bc2bd;
  font-size: 7px;
}

.future-context-details .future-context-card {
  width: 100%;
  margin: 0;
  border-top: 0;
  border-radius: 0 0 17px 17px;
}

#expert-start.is-launching {
  color: #fff;
  text-decoration-thickness: 3px;
}

@keyframes ui-shell-launch-arrow {
  to { transform: translateX(5px); }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: minmax(52px, 1fr) auto minmax(218px, 1fr);
    padding-inline: 14px;
  }

  .brand small {
    display: none;
  }

  .brand b {
    font-size: 14px;
  }
}

@media (max-width: 740px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    padding-inline: 8px;
  }

  .top-actions {
    justify-self: end;
    gap: 5px;
  }

  .app-menu-button {
    grid-template-columns: 34px;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    height: 44px;
    padding: 5px;
  }

  .app-menu-button > span {
    grid-row: auto;
    width: 34px;
    height: 34px;
  }

  .app-menu-button b,
  .app-menu-button small {
    display: none;
  }

  .app-menu-dialog {
    width: 100%;
    max-height: calc(100dvh - 12px);
    border-radius: 24px;
  }

  .app-menu-header {
    padding: 20px 18px 15px;
  }

  .app-menu-nav {
    grid-template-columns: 1fr;
    padding: 14px 15px 22px;
  }

  .app-menu-nav .best-score {
    grid-column: 1;
  }

  .title-entry-guide {
    padding: 12px;
    border-radius: 18px;
  }

  .title-journey-route {
    grid-template-columns: repeat(5, minmax(62px, 1fr));
    overflow-x: auto;
    padding-bottom: 5px;
    scroll-snap-type: x proximity;
  }

  .title-journey-route li {
    scroll-snap-align: start;
  }

  .title-actions {
    grid-template-columns: 1fr;
  }

  .title-primary-choice,
  .title-help-choice,
  .title-secondary-actions,
  .title-actions > .atlas-title-button {
    grid-column: 1;
  }

  .title-secondary-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .title-secondary-actions .opening-replay,
  .title-secondary-actions .expert-start {
    width: 100%;
  }

  .future-context-details > summary {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
}

@media (max-width: 430px) {
  .app-menu {
    padding: 0;
  }

  .app-menu-dialog {
    max-height: 100dvh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .app-menu-header h2 {
    font-size: 27px;
  }

  .app-menu-header p {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-menu-nav > :is(button, a),
  .app-menu-button,
  #start-game,
  #expert-start {
    transition: none !important;
  }

  #start-game.is-launching svg {
    animation: none;
  }
}
