
/* STYLES FOR CHOOSE ADVENTURE GAME */

:root {
  --page-bg: #0b1020;
  --ink: #111827;
  --paper: rgba(255, 251, 239, 0.95);
  --paper-ink: #1f2937;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow-lg: 0 28px 80px rgba(0,0,0,.35);
  --shadow-md: 0 14px 34px rgba(0,0,0,.24);
  --accent: #00e5ff;
  --accent-2: #b94dff;
  --accent-dark: #1a1a3d;
  --book-border: #00e5ff;
  --button-text: #07111f;
  --theme-bg: url('assets/alien-planet.png');
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(112, 76, 255, .34), transparent 34rem),
    linear-gradient(160deg, #090d19, #11182d 55%, #080b14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: white;
}
button, input { font: inherit; }
button { cursor: pointer; }

.game-shell {
  position: relative;
  width: min(720px, 100vw);
  min-height: min(960px, 100svh);
  height: min(960px, 100svh);
  border-radius: 28px;
  overflow: hidden;
  background: #111827;
  box-shadow: var(--shadow-lg);
}
.screen { position: absolute; inset: 0; display: none; }
.screen.is-active { display: block; }

/* START */
.screen-start {
  background: linear-gradient(135deg, rgba(7,12,27,.96), rgba(19,25,52,.9));
}
.start-hero {
  position: absolute;
  inset: 0 0 58% 0;
  background-image:
    linear-gradient(180deg, transparent 48%, rgba(17,24,46,.35) 72%, #11182e 100%),
    var(--theme-bg);
  background-size: cover;
  background-position: center;
  filter: saturate(1.12) contrast(1.03);
}
.start-panel {
  position: absolute;
  inset: 34% 0 0;
  padding: clamp(26px, 5vw, 46px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: linear-gradient(180deg, rgba(17,24,46,.22), #11182e 10%);
}
.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .76rem;
  font-weight: 800;
}
h1, h2 { margin: 0; line-height: .96; letter-spacing: -.045em; }
h1 { font-size: clamp(2.7rem, 7vw, 4.8rem); max-width: 10ch; }
.start-form { margin-top: 30px; }
fieldset { padding: 0; margin: 0 0 22px; border: 0; }
legend, .name-field > span {
  display: block;
  margin-bottom: 10px;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 800;
  color: #cfd7ec;
}
.option-grid { display: grid; gap: 10px; }
.archetype-grid { grid-template-columns: repeat(4, 1fr); }
.theme-grid { grid-template-columns: repeat(5, 1fr); }
.choice-tile, .theme-tile {
  position: relative;
  min-width: 0;
  border: 2px solid rgba(255,255,255,.18);
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  transition: .18s ease;
  overflow: hidden;
}
.choice-tile { min-height: 76px; display: grid; place-items: center; gap: 2px; padding: 8px; text-align: center; font-size: .78rem; font-weight: 800; }
.choice-icon { font-size: 1.35rem; }
.choice-tile input, .theme-tile input { position: absolute; opacity: 0; }
.choice-tile:hover, .theme-tile:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: color-mix(in srgb, var(--accent) 72%, white);
  background-color: rgba(255,255,255,.12);
  box-shadow: 0 12px 24px rgba(0,0,0,.24), 0 0 22px color-mix(in srgb, var(--accent) 20%, transparent);
  filter: brightness(1.08) saturate(1.08);
}
.choice-tile:active, .theme-tile:active { transform: translateY(-1px) scale(.99); }
.choice-tile:focus-within, .theme-tile:focus-within {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, white);
  outline-offset: 3px;
}
.choice-tile:has(input:checked), .theme-tile:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 26%, transparent), 0 0 22px color-mix(in srgb, var(--accent) 22%, transparent);
  transform: translateY(-2px);
}
.theme-tile { aspect-ratio: 1.2; display: flex; align-items: end; padding: 8px; background-size: cover; background-position: center; }
.theme-tile span { position: relative; z-index: 1; font-size: .68rem; line-height: 1.05; font-weight: 900; text-shadow: 0 2px 6px #000; }
.theme-tile::after { content:""; position:absolute; inset:0; background:linear-gradient(transparent 34%, rgba(0,0,0,.8)); }
.theme-tile.alien { background-image:url('assets/alien-planet.png'); }
.theme-tile.camp { background-image:url('assets/summer-camp.png'); }
.theme-tile.jungle { background-image:url('assets/jungle-friends.png'); }
.theme-tile.magic { background-image:url('assets/magic-time-travel.png'); }
.theme-tile.pirate { background-image:url('assets/pirate-treasure.png'); }
.name-field { display:block; }
.name-field input {
  width: 100%;
  padding: 15px 16px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,.16);
  outline: none;
  color: white;
  background: rgba(255,255,255,.08);
}
.name-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.primary-button, .secondary-button, .choice-button {
  border: 0;
  border-radius: 999px;
  min-height: 52px;
  padding: 0 24px;
  font-weight: 900;
  letter-spacing: .015em;
  transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}
.primary-button { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--button-text); box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 34%, transparent); }
.secondary-button { color: white; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.4); }
.primary-button:hover, .secondary-button:hover, .choice-button:hover {
  transform: translateY(-3px) scale(1.015);
  filter: brightness(1.12) saturate(1.08);
  box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 34%, transparent);
}
.primary-button:active, .secondary-button:active, .choice-button:active { transform: translateY(0) scale(.985); }
.primary-button:focus-visible, .secondary-button:focus-visible, .choice-button:focus-visible, .icon-button:focus-visible {
  outline: 3px solid white;
  outline-offset: 3px;
}
.launch-button { width: 100%; margin-top: 18px; }

/* STORY */
.screen-story { isolation: isolate; }
.game-background, .end-background {
  position: absolute;
  inset: 0;
  background-image: var(--theme-bg);
  background-size: cover;
  background-position: center;
  filter: saturate(1.08) contrast(1.02);
  z-index: -2;
}
.screen-story::after, .screen-end::after {
  content:"";
  position:absolute;
  inset:0;
  z-index:-1;
  background: linear-gradient(180deg, rgba(3,8,22,.14), rgba(3,8,22,.04) 35%, rgba(3,8,22,.58) 100%);
  pointer-events:none;
}
.game-toolbar {
  position: absolute;
  top: 22px;
  left: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px 13px 18px;
  border-radius: 16px;
  color: white;
  background: rgba(7,12,27,.55);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.17);
}
.toolbar-kicker { display:block; color: var(--accent); text-transform:uppercase; letter-spacing:.1em; font-size:.68rem; font-weight:900; }
.toolbar-actions { display:flex; gap:8px; }
.icon-button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.1); color: white; font-size: 1.35rem; transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.icon-button:hover { transform: translateY(-2px) scale(1.06); background: color-mix(in srgb, var(--accent) 38%, rgba(255,255,255,.12)); box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 45%, transparent); }
.icon-button:active { transform: scale(.94); }
.story-stage {
  position: absolute;
  inset: 94px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 24px clamp(20px, 5vw, 72px) 34px;
}
.story-book {
  width: min(620px, 88vw);
  max-height: 48vh;
  overflow-y: auto;
  color: var(--paper-ink);
  background:
    linear-gradient(rgba(255,255,255,.16), rgba(255,255,255,.02)),
    var(--paper);
  border: 4px solid var(--book-border);
  border-radius: 22px;
  box-shadow:
    0 0 0 2px rgba(255,255,255,.45) inset,
    0 0 30px color-mix(in srgb, var(--book-border) 26%, transparent),
    var(--shadow-md);
  padding: clamp(24px, 4vw, 42px);
  animation: bookIn .34s ease both;
}
.story-meta { display:flex; justify-content:space-between; color: color-mix(in srgb, var(--accent-dark) 76%, white); font-size:.72rem; font-weight:900; text-transform:uppercase; letter-spacing:.11em; }
.story-book h2 { margin: 10px 0 18px; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(2rem, 4vw, 3.3rem); color: var(--accent-dark); }
.story-copy { font-family: Georgia, 'Times New Roman', serif; font-size: clamp(1rem, 1.8vw, 1.18rem); line-height: 1.65; }
.story-copy p { margin: 0 0 1em; }
.choice-area { width:min(620px,88vw); margin-top: 18px; }
.choice-area > p { margin: 0 0 10px; text-align:center; text-transform:uppercase; letter-spacing:.12em; font-size:.74rem; font-weight:900; text-shadow:0 2px 8px #000; }
.choice-buttons { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.choice-button { min-height:58px; padding:12px 18px; line-height:1.15; }
.choice-primary { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 58%, white)); color: var(--button-text); box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 38%, transparent); }
.choice-secondary { background: linear-gradient(135deg, var(--accent-2), color-mix(in srgb, var(--accent-2) 65%, black)); color:white; box-shadow: 0 8px 24px color-mix(in srgb, var(--accent-2) 38%, transparent); }

/* END */
.screen-end { isolation:isolate; }
.end-card {
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  width:min(600px,88vw);
  padding:clamp(30px,5vw,54px);
  text-align:center;
  border-radius:var(--radius-lg);
  background:rgba(9,15,34,.86);
  backdrop-filter:blur(18px);
  border:1px solid rgba(255,255,255,.22);
  box-shadow:var(--shadow-lg);
}
.end-card h2 { font-size:clamp(2.8rem,7vw,5.5rem); margin-bottom:20px; }
.ending-copy { color:#e7ecf7; line-height:1.7; font-size:1.05rem; }
.ending-actions { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-top:30px; }

/* THEMES */
.theme-alien { --accent:#00e5ff; --accent-2:#b94dff; --accent-dark:#26135f; --book-border:#00d9ff; --button-text:#07111f; --theme-bg:url('assets/alien-planet.png'); }
.theme-camp { --accent:#ff4da6; --accent-2:#ffb703; --accent-dark:#7a194c; --book-border:#ff3f9a; --button-text:#331126; --theme-bg:url('assets/summer-camp.png'); }
.theme-jungle { --accent:#22c55e; --accent-2:#ff8e2b; --accent-dark:#0b4d2e; --book-border:#52d34f; --button-text:#072414; --theme-bg:url('assets/jungle-friends.png'); }
.theme-magic { --accent:#8a2be2; --accent-2:#ffc93c; --accent-dark:#3e1c78; --book-border:#8b5cf6; --button-text:#18082c; --theme-bg:url('assets/magic-time-travel.png'); }
.theme-pirate { --accent:#00cfe8; --accent-2:#ffc107; --accent-dark:#083b66; --book-border:#00bdd8; --button-text:#062435; --theme-bg:url('assets/pirate-treasure.png'); }
.theme-magic .story-book, .theme-pirate .story-book { --paper:rgba(255,248,224,.96); }

@keyframes bookIn { from { opacity:0; transform:translateY(18px) scale(.98); } to { opacity:1; transform:none; } }

@media (max-width: 820px) {
  body { display:block; }
  .game-shell { width:100vw; min-height:100svh; height:100svh; box-shadow:none; border-radius:0; }
  .start-hero { inset:0 0 60% 0; background-image:linear-gradient(180deg, transparent 52%, #11182e 100%), var(--theme-bg); }
  .start-panel { inset:33% 0 0; padding:24px 20px 34px; justify-content:flex-start; background:linear-gradient(180deg, rgba(17,24,46,.3), #11182e 10%); }
  h1 { font-size:clamp(2.5rem,12vw,4.5rem); max-width:10ch; }
  .archetype-grid { grid-template-columns:repeat(4, minmax(70px,1fr)); overflow-x:auto; }
  .theme-grid { grid-template-columns:repeat(5, minmax(95px,1fr)); overflow-x:auto; padding-bottom:4px; }
  .story-stage { inset:84px 0 0; padding:18px 14px 22px; }
  .story-book { width:100%; max-height:52vh; border-width:3px; padding:24px 22px; }
  .choice-area { width:100%; }
  .choice-buttons { gap:10px; }
  .choice-button { min-height:64px; padding:10px 12px; font-size:.92rem; }
  .game-background, .end-background { background-position:center; }
  .theme-camp .game-background, .theme-camp .end-background { background-position:52% center; }
  .theme-magic .game-background, .theme-magic .end-background { background-position:56% center; }
  .ending-actions { grid-template-columns:1fr; }
}

@media (min-width: 821px) {
  body { padding: 24px; }
}

@media (hover: none) {
  .choice-tile:hover, .theme-tile:hover,
  .primary-button:hover, .secondary-button:hover, .choice-button:hover,
  .icon-button:hover { transform: none; }
}

/* V3 — portrait-first, fixed app canvas; only the story book scrolls */
.game-shell {
  width: min(560px, 100vw);
  height: min(920px, 100svh);
  min-height: min(720px, 100svh);
}

/* Start screen: tall visual lead, compact controls, no page scrolling */
.start-hero {
  inset: 0 0 50% 0;
  background-image:
    linear-gradient(
      180deg,
      transparent 0 62%,
      rgba(17,24,46,.18) 68%,
      rgba(17,24,46,.68) 82%,
      #11182e 100%
    ),
    var(--theme-bg);
  background-position: center top;
}
.start-panel {
  inset: 37% 0 0;
  overflow: hidden;
  padding: 18px 22px 20px;
  justify-content: flex-start;
  background: linear-gradient(180deg, rgba(17,24,46,0), #11182e 15%, #11182e 100%);
}
.title-lockup { flex: 0 0 auto; }
.eyebrow { margin-bottom: 4px; font-size: .63rem; }
h1 { font-size: clamp(2.05rem, 8vw, 3.35rem); max-width: 12ch; }
.start-form {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  min-height: 0;
}
fieldset { margin: 0; }
legend, .name-field > span { margin-bottom: 6px; font-size: .66rem; }
.option-grid { gap: 7px; }
.choice-tile, .theme-tile { border-radius: 11px; border-width: 1.5px; }
.choice-tile {
  min-height: 52px;
  padding: 5px 4px;
  font-size: .64rem;
}
.choice-icon { font-size: 1rem; }
.theme-tile {
  aspect-ratio: 1.35;
  min-height: 48px;
  padding: 6px;
}
.theme-tile span { font-size: .58rem; }
.name-field input {
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 10px;
}
.launch-button {
  min-height: 44px;
  margin-top: 0;
  padding-inline: 18px;
}

/* Story screen: fixed stage; the book is the only scrolling region */
.screen-story { overflow: hidden; }
.story-stage {
  inset: 82px 0 0;
  min-height: 0;
  overflow: hidden;
  justify-content: flex-end;
  padding: 16px 18px 22px;
}
.story-book {
  width: 100%;
  max-height: min(54svh, 500px);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 22px 24px;
}
.story-book h2 { font-size: clamp(1.7rem, 6vw, 2.5rem); margin: 8px 0 14px; }
.story-copy { font-size: clamp(.94rem, 2.6vw, 1.08rem); line-height: 1.55; }
.choice-area { width: 100%; margin-top: 12px; flex: 0 0 auto; }
.choice-area > p { margin-bottom: 7px; font-size: .66rem; }
.choice-buttons { grid-template-columns: 1fr 1fr; gap: 9px; }
.choice-button { min-height: 50px; padding: 8px 10px; font-size: .82rem; }

@media (max-width: 820px) {
  .game-shell { width: 100vw; height: 100svh; min-height: 100svh; }
  .start-hero {
    inset: 0 0 50% 0;
    background-image:
      linear-gradient(180deg, transparent 0 61%, rgba(17,24,46,.18) 67%, rgba(17,24,46,.72) 83%, #11182e 100%),
      var(--theme-bg);
  }
  .start-panel {
    inset: 37% 0 0;
    padding: 16px 16px 16px;
    overflow: hidden;
  }
  h1 { font-size: clamp(1.95rem, 9.5vw, 3rem); }
  .archetype-grid { grid-template-columns: repeat(4, 1fr); overflow: visible; }
  .theme-grid { grid-template-columns: repeat(5, 1fr); overflow: visible; padding-bottom: 0; }
  .story-stage { inset: 76px 0 0; padding: 12px 12px 16px; }
  .story-book { width: 100%; max-height: 55svh; padding: 19px 18px; }
  .choice-area { width: 100%; }
  .choice-button { min-height: 50px; padding: 8px; font-size: .8rem; }
}

/* Compact phones: preserve the full fixed canvas without scrolling the app */
@media (max-height: 760px) {
  .start-panel { inset: 35% 0 0; padding-top: 12px; }
  .eyebrow { display: none; }
  h1 { font-size: clamp(1.8rem, 8vw, 2.45rem); }
  .start-form { margin-top: 9px; gap: 7px; }
  legend, .name-field > span { margin-bottom: 4px; }
  .choice-tile { min-height: 44px; }
  .choice-icon { font-size: .9rem; }
  .theme-tile { min-height: 40px; }
  .name-field input { min-height: 38px; padding-block: 7px; }
  .launch-button { min-height: 40px; }
  .story-book { max-height: 50svh; }
}

/* V4 — targeted interface refinements from review notes */
[hidden] { display: none !important; }

/* Start screen */
.title-lockup h1 {
  max-width: none;
  white-space: nowrap;
  font-size: clamp(1.85rem, 6.8vw, 2.8rem);
}
.selection-description {
  margin: 6px 0 0;
  color: rgba(231, 236, 247, .72);
  font-size: .64rem;
  line-height: 1.35;
}
.name-field em {
  color: rgba(231, 236, 247, .58);
  font-style: normal;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}
.launch-button {
  font-size: 1rem;
}

/* Story screen */
.story-stage {
  justify-content: flex-start;
}
.story-book {
  flex: 1 1 auto;
  max-height: none;
}
.story-meta-top {
  justify-content: flex-start;
}
.story-meta-bottom {
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--accent-dark) 18%, transparent);
}
.story-book h2 {
  font-size: clamp(1.45rem, 5vw, 2.05rem);
}
.story-end-marker {
  margin-top: 24px;
  color: var(--accent-dark);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 800;
  text-align: center;
}
.choice-area > p {
  font-size: .86rem;
}
.choice-button {
  font-size: .96rem;
}
.choice-primary,
.choice-secondary {
  color: var(--button-text);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 38%, transparent);
}
.back-button {
  display: block;
  margin: 8px auto 0;
  padding: 4px 10px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.88);
  font-size: .76rem;
  font-weight: 800;
  text-shadow: 0 2px 8px #000;
}
.back-button:hover { color: white; }
.back-button:disabled {
  visibility: hidden;
  pointer-events: none;
}
.story-ending-actions {
  width: 100%;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 12px;
}
.story-ending-actions .primary-button,
.story-ending-actions .secondary-button {
  min-height: 50px;
  padding: 8px 10px;
  font-size: .96rem;
}

@media (max-width: 820px) {
  .title-lockup h1 { font-size: clamp(1.72rem, 7.5vw, 2.35rem); }
  .selection-description { font-size: .6rem; }
  .story-book { max-height: none; }
  .choice-area > p { font-size: .82rem; }
  .choice-button { font-size: .92rem; }
}

@media (max-height: 760px) {
  .title-lockup h1 { font-size: clamp(1.55rem, 6.8vw, 2rem); }
  .selection-description { font-size: .56rem; line-height: 1.25; }
  .story-book { max-height: none; }
}


/* V5 — stakeholder corrections only */

/* Start screen spacing and readability */
.title-lockup h1 {
  max-width: none;
  white-space: nowrap;
  font-size: clamp(1.62rem, 6.4vw, 2.55rem);
}
.start-form {
  margin-top: 18px;
  gap: 14px;
}
.start-form fieldset {
  margin: 0 0 4px;
}
legend,
.name-field > span {
  margin-bottom: 8px;
}
.selection-description {
  margin: 9px 1px 0;
  color: rgba(239, 243, 252, .86);
  font-size: .74rem;
  line-height: 1.45;
}

/* Story screen: preserve artwork; book remains the only scrolling region */
.story-stage {
  justify-content: flex-end;
}
.story-book {
  flex: 0 1 auto;
  width: 100%;
  max-height: min(46svh, 430px);
  overflow-y: auto;
}
.story-copy p:first-child::first-line {
  font-weight: 800;
}

/* Equal-value choices use the same solid theme color */
.choice-primary,
.choice-secondary {
  color: var(--button-text);
  background: var(--accent);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 38%, transparent);
}
.choice-primary:hover,
.choice-secondary:hover {
  background: color-mix(in srgb, var(--accent) 88%, white);
}

@media (max-width: 820px) {
  .title-lockup h1 { font-size: clamp(1.48rem, 6.8vw, 2.15rem); }
  .selection-description { font-size: .7rem; line-height: 1.42; }
  .story-book { max-height: 44svh; }
}

@media (max-height: 760px) {
  .start-form { margin-top: 12px; gap: 10px; }
  .selection-description { font-size: .64rem; line-height: 1.32; }
  .story-book { max-height: 41svh; }
}
