@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,600;0,700;1,600&display=swap');

:root {
  color-scheme: dark;
  --bg: #120e1d;
  --surface: #211931;
  --surface-hover: #342346;
  --line: #503c63;
  --text: #fff4fa;
  --muted: #dbcae9;
  --gold: #f6b3df;
  --red: #f3a5cb;
  --heading: 'Playfair Display', Georgia, serif;
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
a { color: var(--gold); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.top { position: relative; z-index: 2; padding: 0 max(5vw, 20px); height: 75px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #191123; }
.brand { display: inline-flex; gap: 12px; align-items: center; text-decoration: none; color: var(--text); font-weight: 700; font-size: .85rem; letter-spacing: .14em; }
.mark { display: grid; place-items: center; width: 30px; height: 38px; border: 1px solid #9c689e; border-radius: 5px; color: var(--gold); background: #352143; font-size: 1.3rem; letter-spacing: 0; }
.quiet { color: var(--muted); background: transparent; padding: 9px 12px; border: 1px solid transparent; border-radius: 8px; text-decoration: none; font-size: .88rem; font-weight: 600; }
.quiet:hover { color: var(--text); border-color: var(--line); }
main { max-width: 1450px; margin: 0 auto; padding: 0 max(5vw, 20px) 44px; }
.landing { isolation: isolate; position: relative; min-height: min(710px, calc(100svh - 76px)); display: grid; grid-template-columns: minmax(0,1.35fr) minmax(320px,.7fr); align-items: center; gap: clamp(24px,6vw,110px); padding: 56px 0; }
.hero-art { z-index: -1; position: absolute; inset: 0 calc(-1 * max(5vw, 20px)); background: linear-gradient(90deg,#120e1d 0%,#120e1dd9 25%,#120e1d30 65%,#120e1d70 100%), linear-gradient(0deg,#120e1d,#120e1d00 28%,#120e1d00 80%,#120e1d99), url('/table.webp') right 52% / cover no-repeat, radial-gradient(ellipse at 75% 62%, #73377e, #241936 54%, #120e1d 85%); }
.intro-content { position: relative; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--gold); letter-spacing: .17em; font-size: .85rem; font-weight: 700; margin: 0 0 16px; }
.eyebrow span { width: 8px; height: 8px; background: var(--gold); transform: rotate(45deg); margin-left: 2px; }
h1, h2, h3 { font-family: var(--heading); font-weight: 600; margin: 0; }
.intro h1 { font-size: clamp(3.8rem,7.5vw,8.1rem); line-height: .94; letter-spacing: -.063em; margin: 0 0 24px; text-wrap: balance; }
.intro h1 em { color: var(--gold); font-weight: 600; }
.lede { max-width: 435px; color: #eee0d8; font-size: clamp(1rem, 1.6vw, 1.26rem); line-height: 1.6; margin: 0 0 22px; }
.details { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: .88rem; margin: 0; }
.details span + span::before { content: '·'; color: var(--gold); margin-right: 16px; }
.panel { border: 1px solid var(--line); background: var(--surface); border-radius: 15px; padding: clamp(20px, 3vw, 33px); }
.entry { background: #211931f2; box-shadow: 0 18px 60px #080508a0; }
h2 { font-size: clamp(1.85rem,3vw,2.6rem); }
h3 { font-size: 1.5rem; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin: 20px 0 23px; border: 1px solid var(--line); border-radius: 9px; padding: 4px; background: #191022; }
.tabs button { padding: 10px 6px; background: transparent; border: 0; color: var(--muted); border-radius: 6px; font-weight: 700; font-size: .9rem; }
.tabs button[aria-pressed=true] { color: var(--text); background: #432852; }
label { display: block; margin: 0 0 7px; font-size: .9rem; font-weight: 700; color: var(--text); }
input, select { width: 100%; min-height: 49px; padding: 10px 12px; background: #161015; color: var(--text); border: 1px solid #634650; border-radius: 8px; margin-bottom: 16px; }
input::placeholder { color: #ae929a; opacity: 1; }
#room-code { text-transform: uppercase; letter-spacing: .08em; }
#room-code::placeholder { text-transform: none; letter-spacing: 0; }
.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; font-weight: 700; text-decoration: none; line-height: 1.35; text-align: center; }
.primary { background: var(--gold); color: #281431; }
.primary:not(:disabled):hover { background: #ffd1ee; }
.secondary { border-color: #866096; color: var(--text); background: #31233f; }
.secondary:not(:disabled):hover { background: var(--surface-hover); }
.entry .primary { width: 100%; }
.form-note, .muted { color: var(--muted); line-height: 1.55; }
.form-note { margin: 13px 0 0; font-size: .875rem; }
.notice { box-shadow: 0 8px 34px #0008; position: fixed; z-index: 3; bottom: 12px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); margin: 0; padding: 12px 17px; background: #34252e; border: 1px solid #855b65; border-radius: 8px; }
.notice.error { color: #ffc1b7; }
#game { padding-top: clamp(24px,5vw,62px); }
.game-head { display: flex; justify-content: space-between; align-items: end; gap: 15px; flex-wrap: wrap; margin-bottom: 25px; }
.game-head h1 { font-size: clamp(2.8rem,7vw,6rem); line-height: .99; letter-spacing: -.045em; }
.game-head .eyebrow { margin-bottom: 12px; }
.table-tools { display: grid; align-items: center; justify-items: end; gap: 3px; }
.room-code { font-weight: 700; font-size: 1.45rem; color: var(--gold); letter-spacing: .14em; font-variant-numeric: tabular-nums; }
.invite { display: flex; align-items: center; gap: clamp(16px, 3vw, 28px); flex-wrap: wrap; }
.invite-qr { flex: 0 1 auto; border-radius: 12px; overflow: hidden; background: #fff; }
.invite-qr img { width: clamp(128px, 19vw, 224px); height: auto; display: block; }
.display .invite-qr img { width: clamp(160px, 21vw, 300px); }
.invite p { margin: 0 0 6px; }
.game-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }
.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }
.player-list, .history { list-style: none; padding: 0; margin: 10px 0 0; }
.player-list li, .history li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 11px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.player-list li:first-child, .history li:first-child { border-top: 0; }
.player-list small { color: var(--muted); font-size: .82rem; text-align: right; }
.out { color: var(--muted); }
.count { color: var(--gold); font-size: .875rem; display: block; margin-bottom: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 15px; align-items: center; }
.clock { font-size: clamp(2.2rem,5vw,4.4rem); line-height: 1; color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 600; }
.clock.done { color: var(--red); }
.role { padding: 12px 0 8px; }
.role strong { font: 600 1.9rem var(--heading); display: block; color: var(--gold); }
.option-form { margin-top: 16px; }
.option-form select { margin-bottom: 8px; }
.hidden-role { letter-spacing: .08em; }
.game-grid p { line-height: 1.55; }
.display .game-grid { grid-template-columns: 1fr 1fr; }
.display .game-grid .panel { font-size: clamp(1.1rem,2vw,1.7rem); }
.display .game-grid h2 { font-size: clamp(2rem,5vw,4rem); }
details { padding: 9px 0; border-bottom: 1px solid var(--line); }
summary { cursor: pointer; color: var(--gold); }
dialog { width: min(570px, calc(100% - 26px)); max-height: calc(100% - 26px); overflow: auto; color: var(--text); border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 25px; }
dialog::backdrop { background: #0a0709bc; }
.dialog-close { float: right; }
dialog li { margin: 12px 0; line-height: 1.5; color: #f1dbe0; }
@media (max-width: 760px) {
  .top { height: 61px; }
  .landing { grid-template-columns: 1fr; gap: 22px; padding-top: 35px; align-content: start; }
  .hero-art { bottom: auto; height: 470px; background-position: center, center, 69% center, center; }
  .intro h1 { margin-bottom: 16px; font-size: clamp(2.9rem, 11vw, 6.2rem); }
  .lede { margin-bottom: 13px; }
  .entry { width: 100%; max-width: 500px; }
  .game-grid, .display .game-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }

.story-caption { padding: 13px 16px; border-left: 3px solid var(--gold); background: #191123; border-radius: 0 8px 8px 0; }
.receipt { border: 1px solid #745487; background: #301b41; padding: 14px 16px; border-radius: 9px; margin: 15px 0; overflow-wrap: anywhere; }
.receipt p { margin: 0; font-weight: 600; }
.receipt .actions { margin-top: 9px; }
#host-settings { margin-top: 15px; }
.game-head h1 { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .invite { gap: 13px; }
  .invite > div { min-width: 130px; flex: 1; }
  .game-grid .panel { padding: 17px; }
  .option-form .primary { width: 100%; }
  .game-head { margin-bottom: 16px; }
}

.current-move { border-color: var(--gold); background: #2a193a; }
.move-label { color: var(--gold); font-size: .85rem; font-weight: 700; letter-spacing: .12em; }
.statement-choices { display: grid; gap: 8px; margin-top: 16px; }
.statement-choices button { width: 100%; justify-content: flex-start; text-align: left; }
.talk-cue { margin: 14px 0; border: 1px solid #866096; background: #2d1e41; padding: 13px 16px; border-radius: 8px; }
.talk-cue p { margin: 5px 0 0; }
@media (max-width: 600px) {
  .game-head { gap: 8px; }
  .game-head h1 { font-size: clamp(2.2rem, 9vw, 3.6rem); }
  .table-tools { display: none; }
  .current-move .primary { width: 100%; }
}

.solo-button { width: 100%; margin-top: 12px; }
.read-aloud { border-color: #ad83bb; background: #281a3a; }

.seat-name { display: grid; gap: 0.1rem; min-width: 0; overflow-wrap: anywhere; }
.player-list .seat-name small { text-align: left; }
.read-aloud > p:last-of-type, .story-caption { white-space: pre-line; }
form[data-choose="extra-credit"] { display: grid; gap: 0.6rem; }
.release-version { text-align: center; font-size: 0.75rem; margin: 0 0 0.75rem; }

.brand-logo { width: 92px; height: auto; display: block; }
.hero-logo { display: block; width: min(100%, 520px); height: auto; }
.hero-art { background-image: linear-gradient(90deg,#120e1d 0%,#120e1d80 45%,#120e1d15 72%,#120e1daf 100%), linear-gradient(0deg,#120e1d,#120e1d00 25%,#120e1d00 80%,#120e1d99), url('/table.webp?v=1.5.0'), radial-gradient(ellipse at 75% 62%,#73377e,#241936 54%,#120e1d 85%); }
body[data-theme="mascot"] {
  --case-art: url('/mascot.webp');
  --surface: #2a142c;
  --surface-hover: #432344;
  --text: #fff4f8;
  --gold: #ff9cc7;
  --case-highlight: #ffc378;
  --line: #805381;
}
body[data-theme="science"] {
  --case-art: url('/science.webp');
  --surface: #201638;
  --surface-hover: #36265b;
  --text: #f6f2ff;
  --gold: #9fe8ff;
  --case-highlight: #c6b4ff;
  --line: #715e9c;
}
body[data-theme="mascot"], body[data-theme="science"] {
  background: linear-gradient(#120e1d78, #120e1de8), var(--case-art) center top / cover no-repeat fixed, var(--bg);
}
body[data-theme="the-deep"] {
  --bg: #04101e;
  --surface: #101e32;
  --surface-hover: #172b47;
  --text: #f1f6ff;
  --muted: #b8c8dc;
  --gold: #c7a8ff;
  --case-highlight: #77d9e6;
  --line: #6a85a7;
  color: var(--text);
  background: linear-gradient(#04101e34, #04101eaf), url('/the-deep.webp') center top / cover no-repeat fixed, var(--bg);
}
body[data-theme="the-deep"] .primary { color: #151024; }
body[data-theme="the-deep"] .primary:hover:not(:disabled) { background: #ded0ff; }
#room-form .checkbox-field { display: flex; align-items: center; gap: 8px; cursor: pointer; }
#room-form .checkbox-field input { width: 1.2rem; min-height: 0; height: 1.2rem; margin: 0; accent-color: var(--gold); }
.story-select { margin: 12px 0; max-width: 22rem; }
.story-select select { display: block; width: 100%; margin-top: 6px; }
.solo-settings { margin-top: 8px; }
.solo-settings label, .solo-menu label { display: block; margin: 8px 0 4px; }
.solo-settings select, .solo-menu select { width: min(100%, 16rem); }
body[data-theme]:not([data-theme=""]) .move-label { color: var(--case-highlight, var(--gold)); }
body[data-theme]:not([data-theme=""]) .primary:hover:not(:disabled) { background: var(--case-highlight, var(--gold)); }
body[data-theme]:not([data-theme=""]) .story-caption { background: var(--surface-hover); }
.guided-player .game-grid { grid-template-columns: 1fr; max-width: 810px; margin-inline: auto; }
.guided-player .game-head { flex-wrap: wrap; }
.guided-player .game-head .primary { margin-left: auto; }
.table-detail { padding: 12px 18px; }
.table-detail > summary { font-weight: 700; padding-block: 4px; }
.table-detail > .panel { border: 0; background: transparent; padding: 12px 0 0; }
#guide {
  width: min(550px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 14px 80px #08050de0;
}
#guide::backdrop { background: #0c0813af; }
.guide-bar {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 4px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.guide-bar h2 { font: 700 0.9rem/1.35 'DM Sans', system-ui, sans-serif; color: var(--muted); }
.guide-bar .clock { font-size: 1.25rem; }
#guide .panel { border: 0; border-radius: 0; background: var(--surface); padding: 16px 20px; }
#guide .panel > :last-child { margin-bottom: 0; }
#guide h2:not(#guide-title) { font-size: clamp(1.5rem, 6vw, 2rem); }
#guide p { line-height: 1.45; }
#guide .statement-choices { margin-top: 10px; gap: 6px; }
#guide blockquote { font-size: clamp(1.3rem, 6vw, 1.65rem); line-height: 1.35; margin: 12px 0; color: var(--gold); font-weight: 700; overflow-wrap: anywhere; }
#guide .read-aloud > p:not(.move-label), #guide .story-caption { max-height: 42dvh; overflow: auto; }
#guide .read-aloud > p:not(.move-label), #guide .story-caption > p { white-space: pre-line; }
#guide .option-form { margin-top: 10px; }
#guide input, #guide select { margin-bottom: 8px; }
#guide li { margin: 5px 0; color: var(--text); }
#guide .move-label { margin: 0 0 7px; }
#guide .actions:not(.panel .actions) { margin: 4px 20px 12px; }
#guide .guide-note, #guide-notice { margin: 5px 20px 14px; }
#guide-notice.error { color: #ffc4cd; }
@media (max-width: 760px) {
  .top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .top .brand { grid-column: 2; }
  .top #rules-button { grid-column: 3; justify-self: end; padding-inline: 6px; min-height: 44px; white-space: nowrap; }
  .brand-logo { width: 72px; }
  .hero-logo { width: min(75vw, 390px); margin-inline: auto; }
  .landing .intro h1 { margin: 0 0 9px; }
  body[data-theme="mascot"], body[data-theme="science"] {
    background-position: center top, 68% top, center top;
    background-attachment: scroll;
  }
  body[data-theme="the-deep"] {
    background-position: center top;
    background-attachment: scroll;
    background-size: auto max(100svh, 760px);
  }
}
@media (max-width: 480px) {
  .landing { padding-top: 18px; gap: 14px; }
  .landing .eyebrow { margin-bottom: 5px; }
  .hero-logo { width: min(68vw, 320px); }
  #guide .panel { padding: 13px 16px; }
  #guide .primary { min-height: 46px; }
  #guide .option-form .primary { width: 100%; }
}

#guide .role-ready {
  position: sticky;
  bottom: 0;
  padding-block: 8px;
  background: var(--surface);
}

.solo-story {
  --solo-panel: #101e32;
  --solo-raised: #172b47;
  --solo-line: #6a85a7;
  --solo-text: #f1f6ff;
  --solo-muted: #b8c8dc;
  --solo-clue: #77d9e6;
  --solo-accent: #c7a8ff;
  --solo-ink: #151024;
  width: min(100%, 48rem);
  margin: 0 auto;
  padding: clamp(20px, 5vw, 56px) 0 12px;
  color: var(--solo-text);
}
.solo-story-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 13px;
  padding: 9px 12px;
  border-radius: 12px;
  background: #04101e;
}
.solo-story-header h1 { font-size: clamp(1.25rem, 3.5vw, 1.65rem); }
.solo-tools { display: flex; flex-wrap: wrap; gap: 4px; }
.solo-story .quiet { min-height: 44px; color: var(--solo-muted); }
.solo-story .quiet:hover { color: var(--solo-text); border-color: var(--solo-line); }
.solo-story button:focus-visible, .solo-story summary:focus-visible { outline: 2px solid var(--solo-accent); outline-offset: 3px; }
.solo-card {
  overflow: hidden;
  border: 1px solid var(--solo-line);
  border-radius: 16px;
  background: var(--solo-panel);
  box-shadow: 0 20px 50px #0208158a;
}
.solo-card, .solo-dialog-sheet { padding: clamp(18px, 4.5vw, 38px); }
.solo-chapter { padding-bottom: 16px; border-bottom: 1px solid #425870; }
.solo-chapter > p { margin: 0 0 5px; color: var(--solo-clue); font-weight: 700; font-size: .85rem; }
.solo-chapter > h2 { font-size: clamp(1.7rem, 5vw, 2.5rem); line-height: 1.15; scroll-margin: 20px; }
.solo-chapter > h2:focus-visible { outline: 2px solid var(--solo-accent); outline-offset: 5px; }
.solo-scene { margin-top: 19px; overflow-wrap: anywhere; }
.solo-scene p, .solo-dialog-content p { margin: 0 0 13px; line-height: 1.65; }
.solo-reply > p:last-child, .solo-note > p:last-child { margin-bottom: 0; }
.solo-story .solo-speaker { margin-bottom: 6px; color: var(--solo-clue); font-size: .94rem; font-weight: 700; }
.solo-story .solo-reply { margin: 0 0 17px; border-inline-start: 3px solid var(--solo-clue); padding-inline-start: 14px; }
.solo-note { background: var(--solo-raised); padding: 13px 15px; border-radius: 8px; margin: 0 0 18px; }
.solo-note h3, .solo-dialog-content h3 { font-size: 1.17rem; margin: 0 0 7px; }
.solo-scene details, .solo-dialog-content details { margin-bottom: 13px; }
.solo-scene summary, .solo-dialog-content summary { color: var(--solo-accent); padding-block: 6px; }
.solo-form select { display: block; margin: 6px 0 0; border-color: var(--solo-line); background: var(--solo-raised); color: var(--solo-text); }
.solo-chapter > .solo-sidelines { margin: 9px 0 0; color: var(--solo-accent); }
.solo-options { display: grid; gap: 9px; margin-top: 24px; }
.solo-story .primary, .solo-story .secondary { width: 100%; min-height: 49px; padding: 11px 14px; }
.solo-story .primary { background: var(--solo-accent); color: var(--solo-ink); }
.solo-story .primary:not(:disabled):hover { background: #d8c3ff; }
.solo-story .secondary { justify-content: start; text-align: start; background: var(--solo-raised); border-color: var(--solo-line); color: var(--solo-text); }
.solo-story .secondary:not(:disabled):hover { background: #21395b; }
.solo-story .solo-restart { margin-top: 10px; background: #04101e; }
.solo-dialog {
  width: min(620px, calc(100% - 24px));
  padding: 0;
  color: var(--solo-text);
  background: var(--solo-panel);
  border-color: var(--solo-line);
}
.solo-dialog::backdrop { background: #020a14d9; }
.solo-dialog-sheet > header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 15px; }
.solo-dialog-sheet h2 { font-size: clamp(1.6rem, 4.5vw, 2rem); }
.solo-notes { list-style: none; margin: 0; padding: 0; }
.solo-notes > li { padding: 12px 0; border-top: 1px solid #425870; }
.solo-notes > li:last-child { padding-bottom: 0; }
