:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f3f5ef;
  background: #101f1d;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --ink: #f3f5ef;
  --muted: #afbeb4;
  --subtle: #94a89b;
  --mint: #c4f58c;
  --mint-ink: #15251f;
  --panel: #172925;
  --panel-raised: #1c322d;
  --panel-hover: #29463d;
  --line: #38534a;
  --focus: #e1ffb8;
  --coral: #ffad98;
  --amber: #ffd38f;
  --radius-card: 20px;
  --radius-control: 13px;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: #101f1d; scroll-behavior: smooth; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% -18%, rgba(73, 115, 93, .32), transparent 46rem),
    linear-gradient(180deg, #12231f 0%, #101f1d 45rem);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
::selection { color: var(--mint-ink); background: var(--mint); }

.app-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  padding: 18px clamp(16px, 4vw, 42px) max(14px, env(safe-area-inset-bottom));
}
.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(235, 246, 235, .1);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
  font-weight: 760;
  letter-spacing: -.7px;
  white-space: nowrap;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--mint-ink);
  background: var(--mint);
  font-size: 18px;
  font-weight: 850;
  box-shadow: 0 5px 18px rgba(196, 245, 140, .12);
}
.brand-light { margin-left: -8px; color: #9db1a4; font-weight: 530; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #c4d1c7;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 1.15px;
  white-space: nowrap;
}
.pill i {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 4px rgba(196, 245, 140, .09), 0 0 14px rgba(196, 245, 140, .6);
}

main {
  width: min(100%, 900px);
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  margin: 0 auto;
  padding: clamp(28px, 6vh, 68px) 0;
}
.screen { width: 100%; animation: arrive .22s ease-out both; }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.eyebrow, .phase, .invite-title, .code-label {
  color: var(--mint);
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 1.35px;
  line-height: 1.4;
  text-transform: uppercase;
}
.hero h1 {
  max-width: 700px;
  margin: 16px 0 18px;
  font-size: clamp(46px, 8vw, 76px);
  font-weight: 820;
  line-height: .98;
  letter-spacing: -.065em;
  text-wrap: balance;
}
.hero h1 span { color: var(--mint); }
.lead {
  max-width: 600px;
  margin: 0;
  color: #c2cec5;
  font-size: clamp(16px, 2.4vw, 18px);
  line-height: 1.65;
  text-wrap: pretty;
}
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 0; }
.btn {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-size: 14px;
  font-weight: 760;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .14s ease, background-color .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { cursor: not-allowed; opacity: .48; }
.primary { color: var(--mint-ink); background: var(--mint); box-shadow: 0 8px 22px rgba(196, 245, 140, .12); }
.primary:hover:not(:disabled) { background: #d2ffa2; box-shadow: 0 10px 26px rgba(196, 245, 140, .2); }
.secondary { color: var(--ink); background: #253b35; border-color: #405b50; }
.secondary:hover:not(:disabled) { background: #2c483e; border-color: #668070; }
.quiet { color: #d2ddd4; background: transparent; border-color: #405b50; }
.quiet:hover:not(:disabled) { background: #20352f; border-color: #668070; }
.small { min-height: 42px; padding: 10px 13px; font-size: 12px; }
.full { width: 100%; }

.how {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: clamp(34px, 6vh, 58px);
}
.how article, .card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: linear-gradient(150deg, rgba(28, 50, 44, .96), rgba(20, 38, 34, .97));
  box-shadow: 0 16px 44px rgba(0, 0, 0, .12);
}
.how article { padding: clamp(15px, 2vw, 20px); }
.how b { color: var(--mint); font-size: 10px; font-weight: 800; letter-spacing: 1.1px; }
.how h2 { margin: 12px 0 6px; font-size: 15px; font-weight: 720; letter-spacing: -.25px; }
.how p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.card { padding: clamp(18px, 3vw, 24px); }
.form-card { width: min(100%, 470px); margin: 0 auto; }
.form-card h1 { margin: 9px 0 6px; font-size: clamp(28px, 5vw, 36px); line-height: 1.12; letter-spacing: -.045em; }
.form-card > p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.field { display: block; margin: 22px 0 16px; }
.field span { display: block; margin-bottom: 8px; color: #d8e1d9; font-size: 11px; font-weight: 760; letter-spacing: .65px; }
.field input {
  width: 100%;
  min-height: 52px;
  padding: 13px 15px;
  border: 1px solid #526d61;
  border-radius: 12px;
  outline: none;
  color: #f8faf5;
  background: #10211e;
  font-size: 16px;
  line-height: 1.3;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.field input::placeholder { color: #92a599; }
.field input:focus-visible { border-color: var(--mint); box-shadow: 0 0 0 4px rgba(196, 245, 140, .13); }
.field input[name="roomCode"] { font-weight: 760; letter-spacing: .12em; text-transform: uppercase; }
.error { min-height: 20px; margin: 0 0 8px; color: var(--coral); font-size: 12px; line-height: 1.5; }
.back-button { margin-top: 13px; }

.topline { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 19px; }
.stage-heading { min-width: 0; }
.game-title { margin: 5px 0 0; font-size: clamp(27px, 4vw, 36px); font-weight: 790; line-height: 1.1; letter-spacing: -.05em; text-wrap: balance; }
.room-code {
  min-width: 128px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 9px 13px 10px;
  border: 1px dashed #6b8978;
  border-radius: 13px;
  color: var(--mint);
  background: rgba(38, 62, 55, .88);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.room-code:hover { border-color: var(--mint); background: #2b473d; transform: translateY(-1px); }
.code-label { color: #bed0c1; font-size: 8px; letter-spacing: .85px; }
.code-value { font-size: 18px; font-weight: 800; letter-spacing: .17em; font-variant-numeric: tabular-nums; }
.layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(240px, .8fr); align-items: start; gap: 14px; }
.layout > * { min-width: 0; }
.card h2 { margin: 0 0 6px; font-size: 17px; font-weight: 740; line-height: 1.3; letter-spacing: -.3px; }
.card .help { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.55; text-wrap: pretty; }
.card-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; }
.card-heading h2 { margin: 0; }
.count { flex: 0 0 auto; padding: 4px 8px; border: 1px solid #486458; border-radius: 999px; color: #d4e0d5; background: #243c34; font-size: 10px; font-weight: 750; font-variant-numeric: tabular-nums; }
.invite { display: grid; gap: 6px; min-width: 0; padding: 12px 13px; border: 1px solid #4b665a; border-radius: 13px; background: rgba(13, 29, 25, .5); }
.invite-title { color: #bacabe; font-size: 9px; letter-spacing: 1px; }
.invite-url { overflow-wrap: anywhere; color: #edf3ed; font-size: 12px; line-height: 1.45; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.player-list { display: grid; gap: 7px; margin: 16px 0 0; padding: 0; list-style: none; }
.player-list li { min-width: 0; display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid rgba(95, 124, 107, .18); border-radius: 12px; background: rgba(34, 57, 49, .83); }
.avatar { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid rgba(196, 245, 140, .15); border-radius: 10px; color: var(--mint); background: #3a5749; font-size: 12px; font-weight: 800; }
.player-name, .score-name { min-width: 0; overflow: hidden; color: #f0f4ed; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.presence { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; color: #c2d0c5; font-size: 10px; white-space: nowrap; }
.presence i { width: 7px; height: 7px; border-radius: 50%; background: #8ca294; }
.presence.is-online i { background: var(--mint); box-shadow: 0 0 9px rgba(196, 245, 140, .48); }
.presence.is-away { color: #9ca99f; }
.host { color: var(--mint); font-size: 9px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; }
.phase { display: inline-block; padding: 6px 9px; border: 1px solid rgba(196, 245, 140, .16); border-radius: 999px; color: var(--mint); background: rgba(43, 67, 56, .85); font-size: 9px; letter-spacing: .9px; }
.phase-muted { margin-bottom: 11px; color: #d2dfd4; border-color: #465e52; background: #243b33; }
.how-card .help { margin-top: 7px; }
.full-rules { margin: 0 0 15px; border: 1px solid #405b50; border-radius: 12px; color: #dce6dc; background: rgba(13, 29, 25, .45); }
.full-rules summary { min-height: 44px; display: flex; align-items: center; padding: 10px 12px; color: var(--mint); font-size: 13px; font-weight: 740; cursor: pointer; }
.full-rules summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 10px; }
.full-rules ol { display: grid; gap: 8px; margin: 0; padding: 0 18px 15px 34px; color: #c1d0c4; font-size: 12px; line-height: 1.55; }
.full-rules li { padding-left: 2px; }
.full-rules li strong { color: #edf5e9; }
.rules-tip { margin: 0 12px 13px; padding: 10px 11px; border-radius: 9px; color: #d6e5d7; background: #213b32; font-size: 12px; line-height: 1.5; }
.start-button { margin-top: 5px; }
.note { margin: 13px 0 0; color: #a8b8ad; font-size: 11px; line-height: 1.55; }
.waiting { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 12px; border: 1px solid #405b50; border-radius: 12px; color: #c2d0c5; background: #213a32; font-size: 12px; line-height: 1.5; text-align: center; }
.waiting b { color: var(--mint); font-variant-numeric: tabular-nums; }
.submitted { justify-content: flex-start; text-align: left; }
.success-mark { width: 25px; height: 25px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: #173021; background: var(--mint); font-weight: 900; }
.big-word { margin: 12px 0 6px; color: var(--mint); font-size: clamp(34px, 6vw, 51px); font-weight: 820; line-height: 1.05; letter-spacing: -.055em; overflow-wrap: anywhere; }
.secret { margin: 17px 0; padding: clamp(17px, 3vw, 23px); border: 1px solid #5c7a68; border-radius: 16px; background: linear-gradient(145deg, #244237, #1c332d); text-align: center; }
.secret p { max-width: 340px; margin: 0 auto; color: #c5d3c8; font-size: 13px; line-height: 1.5; }
.secret .eyebrow { display: block; color: #cce9ad; }
.secret.faker { border-color: #92704c; background: linear-gradient(145deg, #493a2b, #302a21); }
.secret.faker .eyebrow { color: var(--amber); }
.secret.faker .big-word { color: var(--amber); }
.clue-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 8px; margin-top: 14px; }
.clue { min-width: 0; display: grid; gap: 5px; padding: 11px 12px; border: 1px solid rgba(95, 124, 107, .18); border-radius: 12px; background: #223a32; }
.clue b { overflow: hidden; color: #bfd0c3; font-size: 10px; font-weight: 760; text-overflow: ellipsis; white-space: nowrap; }
.clue span { color: #f0f4ed; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.empty-state { grid-column: 1 / -1; padding: 14px; border: 1px dashed #4b6558; border-radius: 12px; color: var(--muted); font-size: 12px; text-align: center; }
.vote-list { display: grid; gap: 9px; margin: 17px 0 13px; }
.vote-item {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  padding: 11px 13px;
  border: 1px solid #405b50;
  border-radius: 13px;
  color: var(--ink);
  background: #213a32;
  text-align: left;
  cursor: pointer;
  transition: border-color .14s ease, background-color .14s ease, transform .14s ease;
}
.vote-item:hover { border-color: #83aa8f; background: #29463b; transform: translateY(-1px); }
.vote-item.selected { border-color: var(--mint); background: #2b493a; box-shadow: inset 0 0 0 1px rgba(196, 245, 140, .38); }
.vote-name { overflow: hidden; font-size: 13px; font-weight: 730; text-overflow: ellipsis; white-space: nowrap; }
.vote-clue { min-width: 0; overflow: hidden; color: #bbcbbf; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.vote-check { grid-column: 2; grid-row: 1 / span 2; width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid #5c7567; border-radius: 50%; color: transparent; font-size: 12px; }
.vote-item.selected .vote-check { border-color: var(--mint); color: var(--mint-ink); background: var(--mint); }
.result-card { overflow: hidden; }
.result-banner { display: flex; align-items: center; gap: 14px; margin: 0 0 23px; padding: clamp(18px, 4vw, 25px); border: 1px solid #55765d; border-radius: 16px; background: linear-gradient(120deg, #284534, #213b31); }
.result-banner h2 { margin: 0 0 5px; color: var(--mint); font-size: clamp(20px, 4vw, 27px); letter-spacing: -.04em; }
.result-banner p { margin: 0; color: #d2ded4; font-size: 13px; line-height: 1.5; }
.result-banner.miss { border-color: #806742; background: linear-gradient(120deg, #493a2c, #352e25); }
.result-banner.miss h2 { color: var(--amber); }
.result-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 13px; color: var(--mint-ink); background: var(--mint); font-size: 23px; }
.result-banner.miss .result-icon { color: #30271a; background: var(--amber); }
.result-layout { grid-template-columns: minmax(0, 1.1fr) minmax(230px, .9fr); }
.result-layout > section > h2, .result-layout > aside > h2 { margin: 0 0 11px; }
.subtle { color: var(--muted); font-size: 12px; line-height: 1.5; }
.score-list { display: grid; gap: 7px; margin: 12px 0 0; padding: 0; list-style: none; counter-reset: none; }
.score-row { min-width: 0; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid rgba(95, 124, 107, .18); border-radius: 12px; background: #223a32; }
.rank { width: 18px; flex: 0 0 auto; color: #aabbb0; font-size: 10px; font-weight: 750; text-align: center; font-variant-numeric: tabular-nums; }
.score-row .avatar { width: 28px; height: 28px; }
.score-row strong { flex: 0 0 auto; margin-left: auto; color: var(--mint); font-size: 14px; font-variant-numeric: tabular-nums; }
.next-round { margin-top: 14px; }
.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  width: max-content;
  max-width: min(92vw, 480px);
  padding: 12px 16px;
  transform: translate(-50%, 12px);
  border: 1px solid #d8e8d5;
  border-radius: 12px;
  color: #15251f;
  background: #f2f7e9;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .3);
  opacity: 0;
  pointer-events: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.copy-buffer { position: fixed; top: 0; left: -10000px; width: 1px; height: 1px; opacity: 0; }
footer { padding: 8px 0 2px; color: #9aac9f; font-size: 11px; line-height: 1.5; text-align: center; }

@media (max-width: 760px) {
  .app-shell { padding: 12px 18px max(12px, env(safe-area-inset-bottom)); }
  .topbar { min-height: 52px; }
  main { align-items: flex-start; padding: clamp(25px, 5vh, 42px) 0; }
  .layout, .result-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .lobby-layout .how-card { order: -1; }
  .how { gap: 9px; margin-top: 34px; }
  .how article { padding: 14px; }
  .how h2 { font-size: 13px; }
  .how p { font-size: 11px; }
  .form-card { margin: 3vh auto 0; }
}

@media (max-width: 520px) {
  .app-shell { padding-right: 14px; padding-left: 14px; }
  .brand { gap: 8px; font-size: 16px; }
  .brand-mark { width: 31px; height: 31px; border-radius: 10px; }
  .pill { gap: 6px; font-size: 8px; letter-spacing: .8px; }
  .pill i { width: 7px; height: 7px; }
  .hero h1 { margin-top: 14px; font-size: clamp(43px, 13vw, 62px); }
  .lead { font-size: 15px; line-height: 1.6; }
  .actions { display: grid; grid-template-columns: 1fr; gap: 9px; margin-top: 23px; }
  .actions .btn { width: 100%; }
  .how { grid-template-columns: 1fr; gap: 8px; margin-top: 25px; }
  .how article { display: grid; grid-template-columns: 1fr; padding: 13px 15px; }
  .how h2 { margin: 7px 0 3px; font-size: 14px; }
  .how p { font-size: 12px; }
  .topline { align-items: flex-start; gap: 8px; margin-bottom: 13px; }
  .game-title { font-size: clamp(25px, 7.4vw, 32px); }
  .room-code { min-width: 104px; padding: 8px 10px; }
  .code-label { font-size: 7px; letter-spacing: .45px; }
  .code-value { font-size: 16px; }
  .card { padding: 16px; border-radius: 17px; }
  .card .help { font-size: 12px; }
  .share-actions .btn { flex: 1 1 130px; }
  .presence { font-size: 9px; }
  .host { font-size: 8px; }
  .secret { padding: 18px 13px; }
  .result-banner { align-items: flex-start; gap: 11px; padding: 16px 13px; }
  .result-icon { width: 35px; height: 35px; border-radius: 11px; font-size: 19px; }
  .result-banner h2 { font-size: 19px; }
  .result-banner p { font-size: 12px; }
}

@media (max-width: 360px) {
  .app-shell { padding-right: 11px; padding-left: 11px; }
  .pill { font-size: 7px; }
  .room-code { min-width: 94px; }
  .code-label { max-width: 90px; white-space: nowrap; }
  .card { padding: 14px; }
  .player-list li { gap: 7px; padding: 8px; }
  .presence { gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (forced-colors: active) {
  .btn, .room-code, .vote-item, .field input, .card, .how article { border: 1px solid ButtonText; }
  .vote-item.selected, .btn:focus-visible { outline: 2px solid Highlight; }
}
