:root {
  --bg: #f4efe5;
  --paper: #fffdf8;
  --ink: #18201c;
  --muted: #6f756f;
  --line: #dcd5c8;
  --accent: #f36f3d;
  --accent-dark: #ca4e25;
  --green: #195f49;
  --green-soft: #dfece5;
  --yellow: #f3c95b;
  --danger: #b84237;
  --shadow: 0 18px 50px rgba(48, 40, 29, .10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 20%, rgba(243, 111, 61, .07), transparent 30%),
    radial-gradient(circle at 85% 15%, rgba(25, 95, 73, .07), transparent 26%),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.hidden { display: none !important; }

.app-shell { width: min(1440px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(24, 32, 28, .11);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 45px; height: 45px; border-radius: 13px;
  display: grid; place-items: center;
  background: var(--ink); color: #fff; font-weight: 800; letter-spacing: -.04em;
  transform: rotate(-3deg);
}
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.round-pill, .connection-pill { padding: 9px 14px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.round-pill { background: var(--green-soft); color: var(--green); }
.connection-pill { background: #ede7dc; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.connection-pill span { width: 8px; height: 8px; border-radius: 50%; background: #b5ad9e; }
.connection-pill.online { color: var(--green); background: var(--green-soft); }
.connection-pill.online span { background: #31a16f; box-shadow: 0 0 0 4px rgba(49,161,111,.12); }
.connection-pill.error { color: var(--danger); background: #f7e4e1; }
.connection-pill.error span { background: var(--danger); }

.ghost-btn, .secondary-btn, .primary-btn, .danger-btn, .guess-btn, .lock-btn, .invite-slot-btn {
  border: 0; border-radius: 12px; font-weight: 800; transition: .18s ease;
}
.ghost-btn { background: transparent; border: 1px solid var(--line); padding: 10px 14px; color: var(--ink); }
.ghost-btn:hover { background: rgba(255,255,255,.45); }
.primary-btn { background: var(--ink); color: #fff; padding: 14px 18px; box-shadow: 0 5px 0 rgba(0,0,0,.12); }
.primary-btn:hover:not(:disabled) { transform: translateY(-1px); }
.primary-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.secondary-btn { background: #efe8db; color: var(--ink); padding: 14px 16px; }
.secondary-btn.compact { padding: 10px 13px; }
.danger-btn { background: var(--danger); color: #fff; padding: 14px 18px; }
.full { width: 100%; }

.screen { display: none; }
.screen.active { display: block; }

.setup-layout {
  min-height: calc(100vh - 89px);
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  align-items: center;
  gap: clamp(40px, 7vw, 100px);
  padding: 60px 5vw;
}
.eyebrow, .section-kicker, .card-label {
  font-size: 11px; font-weight: 900; letter-spacing: .16em; color: var(--accent-dark);
}
.hero-copy h1 {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(46px, 5.3vw, 78px);
  line-height: .99;
  letter-spacing: -.05em;
  margin: 18px 0 26px;
  max-width: 850px;
}
.hero-copy h1 span { color: var(--accent-dark); }
.hero-copy > p { max-width: 650px; color: var(--muted); font-size: 17px; line-height: 1.7; }
.feature-row { display: flex; gap: 16px; margin-top: 38px; }
.feature-row div { min-width: 102px; border-top: 2px solid var(--ink); padding-top: 9px; }
.feature-row strong { display: block; font-size: 22px; }
.feature-row span { color: var(--muted); font-size: 12px; }

.setup-card {
  background: rgba(255,253,248,.88);
  border: 1px solid rgba(24,32,28,.10);
  border-radius: 26px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.setup-card-head { display: flex; gap: 13px; align-items: center; margin-bottom: 22px; }
.mini-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--yellow); font-size: 20px; }
.setup-card h2 { margin: 0; font-family: "Fraunces", serif; font-size: 29px; }
.setup-card p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.lobby-toolbar { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 12px; font-size: 13px; font-weight: 800; }
.player-count-picker { display: flex; padding: 4px; gap: 3px; border-radius: 12px; background: #eee7db; }
.player-count-picker button { width: 34px; height: 30px; border: 0; border-radius: 9px; background: transparent; font-weight: 800; color: var(--muted); }
.player-count-picker button.active { background: var(--paper); color: var(--ink); box-shadow: 0 2px 8px rgba(24,32,28,.08); }
.player-inputs { display: grid; gap: 10px; }
.player-input-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 9px;
}
.player-number { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: #eee7db; font-size: 12px; font-weight: 900; }
.player-slot-field {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  display: flex;
  align-items: center;
  padding: 7px 8px 7px 15px;
  gap: 10px;
  transition: .18s ease;
}
.player-slot-field.joined { border-color: rgba(25,95,73,.28); background: #fbfefc; }
.player-slot-name { flex: 1; min-width: 0; }
.player-slot-name .placeholder { color: #a49d91; font-size: 14px; }
.player-slot-name strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.player-slot-name small { display: block; margin-top: 2px; color: var(--green); font-weight: 700; font-size: 11px; }
.invite-slot-btn {
  flex: 0 0 auto;
  background: #eee8de;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
}
.invite-slot-btn:hover { background: #e3d9ca; }
.slot-ready { font-size: 12px; color: var(--green); background: var(--green-soft); border-radius: 12px; padding: 8px 12px; font-weight: 900; }
.room-link-row { margin-top: 16px; padding: 13px 14px; border-radius: 15px; background: #f1eadf; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.room-link-row span { display: block; color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; }
.room-link-row strong { font-size: 14px; letter-spacing: .08em; }
.setup-actions { margin-top: 13px; }
.guest-waiting { display: flex; align-items: center; gap: 13px; padding: 16px; background: #f1eadf; border-radius: 16px; margin-top: 15px; }
.guest-waiting strong, .guest-waiting span { display: block; }
.guest-waiting span { color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.45; }
.waiting-spinner { width: 24px; height: 24px; border: 3px solid #d8cfc1; border-top-color: var(--ink); border-radius: 50%; animation: spin .9s linear infinite; }

.game-stage { padding: 32px 0 60px; }
.game-stage-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.game-stage-head h2 { margin: 5px 0 0; font-family: "Fraunces", serif; font-size: clamp(27px, 3vw, 42px); }
.game-stage-head p { margin: 0; color: var(--muted); font-size: 13px; }
.round-card {
  width: min(760px, 100%);
  min-height: 540px;
  margin: 0 auto 34px;
  padding: 31px;
  border-radius: 30px;
  background: var(--paper);
  border: 1px solid rgba(24,32,28,.12);
  box-shadow: 0 28px 70px rgba(48,40,29,.16), 0 4px 0 #d8d0c2;
  position: relative;
  transform-origin: center 80%;
}
.round-card.card-enter { animation: dealCard 1s cubic-bezier(.19,.82,.22,1) both; }
.card-deck-tab { position: absolute; width: 78%; height: 28px; border-radius: 22px 22px 0 0; background: #e0d7c8; left: 11%; top: -14px; z-index: -1; transform: rotate(1.2deg); }
.card-topline { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.question-progress { font-size: 12px; font-weight: 800; color: var(--muted); }
.secret-length { font-family: "Fraunces", serif; font-size: clamp(42px, 7vw, 74px); letter-spacing: -.05em; margin: 9px 0 22px; }
.questions-stack { display: grid; gap: 9px; }
.question-row { border: 1px solid var(--line); border-radius: 17px; background: #fff; min-height: 78px; padding: 15px 17px; display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; transition: .3s ease; }
.question-row.current { border-color: rgba(243,111,61,.45); box-shadow: 0 0 0 3px rgba(243,111,61,.08); }
.question-row.locked { background: #f2ede4; border-style: dashed; color: #aaa195; }
.question-index { width: 37px; height: 37px; border-radius: 12px; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 900; }
.question-row.locked .question-index { background: #d9d1c5; color: #8f877c; }
.question-copy { min-width: 0; }
.question-copy span { display: block; color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .1em; margin-bottom: 4px; }
.question-copy strong { font-size: 15px; line-height: 1.35; }
.question-row.locked .question-copy strong { filter: blur(4px); user-select: none; opacity: .48; }
.question-answer { display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 12px; font-weight: 800; }
.answer-letter { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--yellow); color: var(--ink); font-size: 18px; font-weight: 900; }
.host-question-actions { margin-top: 16px; }
.guest-question-note { text-align: center; margin-top: 16px; padding: 12px; border-radius: 13px; background: #eee8de; color: var(--muted); font-size: 12px; font-weight: 700; }

.players-panel { background: rgba(255,253,248,.56); border: 1px solid rgba(24,32,28,.09); border-radius: 24px; padding: 20px; }
.players-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 14px; }
.players-heading h2 { margin: 4px 0 0; font-family: "Fraunces", serif; font-size: 28px; }
.players-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.player-card { background: var(--paper); border: 1px solid var(--line); border-radius: 19px; padding: 15px; transition: .2s ease; }
.player-card.me { border-color: rgba(25,95,73,.48); box-shadow: 0 0 0 3px rgba(25,95,73,.08); }
.player-card.eliminated { opacity: .48; filter: grayscale(.55); }
.player-card-head { display: flex; align-items: center; gap: 9px; }
.avatar { width: 35px; height: 35px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 900; }
.player-meta { min-width: 0; flex: 1; }
.player-meta h3 { margin: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-score { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.player-state { padding: 5px 7px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-weight: 800; font-size: 9px; }
.eliminated .player-state { background: #f3dfdc; color: var(--danger); }
.letter-board { display: flex; flex-wrap: wrap; gap: 5px; margin: 15px 0; min-height: 37px; }
.letter-slot { width: 34px; height: 37px; border-radius: 10px; border: 1px dashed #c7beb0; background: #f5efe6; display: grid; place-items: center; transition: .15s; }
.letter-slot.drag-over { background: #e5efe9; border-color: var(--green); }
.letter-tile { width: 100%; height: 100%; border-radius: 9px; display: grid; place-items: center; background: var(--yellow); font-weight: 900; cursor: grab; box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.letter-tile:active { cursor: grabbing; }
.player-answer-area { border-top: 1px solid #e6ded2; padding-top: 11px; }
.answer-status { color: var(--muted); font-size: 10px; margin-bottom: 7px; min-height: 14px; }
.letter-picker { display: grid; grid-template-columns: 48px 1fr; gap: 7px; }
.letter-input { width: 48px; height: 42px; border: 1px solid var(--line); border-radius: 11px; text-align: center; text-transform: uppercase; font-weight: 900; outline: none; }
.letter-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(25,95,73,.09); }
.lock-btn { padding: 0 9px; background: var(--ink); color: #fff; font-size: 10px; }
.lock-btn.locked { background: var(--green); }
.guess-btn { width: 100%; margin-top: 8px; padding: 10px; border: 1px solid #d7b4ad; background: #fff4f1; color: var(--danger); font-size: 10px; }
.other-player-note { padding: 12px 8px; border-radius: 11px; background: #f1ece4; color: var(--muted); text-align: center; font-size: 10px; font-weight: 700; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20,24,22,.48); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 18px; }
.modal-card { width: min(470px, 100%); background: var(--paper); border-radius: 24px; padding: 28px; box-shadow: 0 28px 80px rgba(0,0,0,.24); position: relative; }
.modal-card h2 { font-family: "Fraunces", serif; font-size: 31px; margin: 7px 0 8px; }
.modal-card p { color: var(--muted); line-height: 1.55; font-size: 13px; }
.modal-close { position: absolute; right: 16px; top: 14px; width: 35px; height: 35px; border: 0; background: #eee8de; border-radius: 50%; font-size: 20px; }
.modal-card input { width: 100%; border: 1px solid var(--line); border-radius: 13px; padding: 14px; outline: none; margin: 10px 0; }
.modal-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(25,95,73,.09); }
.user-badge { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--ink); color: #fff; font-weight: 900; margin-bottom: 18px; transform: rotate(-3deg); }
.invite-link-box { display: grid; grid-template-columns: 1fr auto; gap: 7px; align-items: center; }
.invite-link-box input { margin: 0; min-width: 0; }
.rules-modal ol { margin: 18px 0 0; padding-left: 20px; }
.rules-modal li { padding: 6px 0 6px 4px; color: #4f5752; line-height: 1.45; }
.danger-note { background: #f8e9e6; color: var(--danger); padding: 11px 12px; border-radius: 12px; font-size: 11px; font-weight: 800; margin: 4px 0 12px; }
.result-modal { text-align: center; }
.result-burst { width: 58px; height: 58px; margin: 0 auto 13px; display: grid; place-items: center; border-radius: 50%; background: var(--yellow); font-size: 25px; animation: pop .45s ease both; }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 100; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 999px; font-size: 12px; font-weight: 800; box-shadow: 0 12px 30px rgba(0,0,0,.18); animation: toastIn .22s ease both; }

@keyframes dealCard {
  0% { transform: translateY(105vh) rotate(-520deg) scale(.62); opacity: 0; }
  65% { transform: translateY(-22px) rotate(8deg) scale(1.025); opacity: 1; }
  82% { transform: translateY(8px) rotate(-3deg) scale(.995); }
  100% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { 0% { transform: scale(.45) rotate(-20deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 1050px) {
  .setup-layout { grid-template-columns: 1fr; padding: 45px 6vw 70px; }
  .hero-copy { text-align: center; }
  .hero-copy > p { margin-left: auto; margin-right: auto; }
  .feature-row { justify-content: center; }
  .setup-card { width: min(650px, 100%); margin: 0 auto; }
  .players-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .app-shell { width: min(100% - 20px, 1440px); }
  .topbar { height: 76px; }
  .brand small, .connection-pill { display: none; }
  .topbar-actions { gap: 6px; }
  .ghost-btn { padding: 9px 10px; font-size: 11px; }
  .setup-layout { min-height: calc(100vh - 77px); padding: 34px 0 55px; gap: 35px; }
  .hero-copy h1 { font-size: 43px; }
  .hero-copy > p { font-size: 14px; }
  .feature-row { gap: 8px; }
  .feature-row div { min-width: 88px; }
  .setup-card { padding: 20px; border-radius: 21px; }
  .game-stage-head { align-items: start; flex-direction: column; }
  .round-card { padding: 20px 15px; border-radius: 23px; min-height: 0; }
  .question-row { grid-template-columns: 37px 1fr; }
  .question-answer { grid-column: 2; }
  .players-panel { padding: 12px; }
  .players-grid { grid-template-columns: 1fr; }
  .modal-card { padding: 23px; }
}

/* Hangman Trivia private-board + timed-round refinements */
.card-live-meta { display: flex; align-items: center; gap: 9px; }
.question-timer {
  min-width: 62px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  transition: .2s ease;
}
.question-timer.urgent { background: var(--danger); animation: timerPulse .8s ease-in-out infinite alternate; }
.question-row.past { opacity: .72; }
.question-row.past .question-index { background: #756e64; }
.answer-hidden-chip {
  white-space: nowrap;
  border-radius: 999px;
  background: #eee8de;
  color: #8d8375;
  padding: 7px 9px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
}

.players-panel { width: min(760px, 100%); margin: 0 auto; }
.players-grid { grid-template-columns: 1fr; }
.privacy-badge {
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.player-card { padding: 18px; }
.player-card.me { box-shadow: 0 0 0 3px rgba(25,95,73,.07), 0 12px 32px rgba(48,40,29,.06); }
.board-help { margin: 16px 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; }
.letter-board {
  gap: 8px;
  margin: 8px 0 18px;
  min-height: 56px;
  align-items: center;
}
.letter-slot {
  width: 50px;
  height: 54px;
  border-radius: 14px;
}
.letter-tile {
  border: 0;
  width: 100%;
  height: 100%;
  border-radius: 13px;
  font-size: 20px;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  touch-action: manipulation;
}
.letter-tile:hover:not(:disabled) { transform: translateY(-2px); }
.letter-tile.selected {
  transform: translateY(-10px) scale(1.03);
  box-shadow: 0 9px 18px rgba(90,67,17,.20), 0 2px 0 rgba(0,0,0,.12);
  outline: 3px solid rgba(243,111,61,.24);
}
.letter-tile:disabled { opacity: 1; cursor: default; }
.player-answer-area { padding-top: 14px; }
.answer-status { font-size: 11px; line-height: 1.4; }
.letter-picker { grid-template-columns: 62px 1fr; gap: 9px; }
.letter-input { width: 62px; height: 48px; font-size: 18px; }
.lock-btn { min-height: 48px; font-size: 12px; }
.guess-btn { min-height: 46px; margin-top: 10px; font-size: 12px; }

.opponents-wrap { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.opponents-label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .12em; }
.opponents-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.opponent-chip {
  min-width: 150px;
  flex: 1 1 150px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.56);
}
.opponent-chip.out { opacity: .48; filter: grayscale(.6); }
.opponent-avatar { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px; display: grid; place-items: center; background: #e7dfd2; font-size: 11px; font-weight: 900; }
.opponent-chip strong, .opponent-chip small { display: block; }
.opponent-chip strong { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.opponent-chip small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.guess-modal { text-align: center; }
.guess-clock {
  width: 92px;
  margin: 5px auto 16px;
  padding: 10px 12px;
  border-radius: 18px;
  background: var(--ink);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}
.guess-clock.urgent { background: var(--danger); animation: timerPulse .65s ease-in-out infinite alternate; }
.guess-modal input { text-align: center; text-transform: uppercase; font-weight: 900; font-size: 18px; letter-spacing: .04em; }

.answer-recap { display: grid; gap: 6px; margin: 18px 0; text-align: left; }
.recap-row {
  display: grid;
  grid-template-columns: 30px 1fr 34px;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 12px;
  background: #f1eadf;
}
.recap-row span { color: var(--muted); font-size: 10px; font-weight: 900; }
.recap-row strong { font-size: 12px; }
.recap-row b { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--yellow); font-size: 14px; }

@keyframes timerPulse {
  from { transform: scale(1); box-shadow: 0 0 0 0 rgba(184,66,55,.08); }
  to { transform: scale(1.035); box-shadow: 0 0 0 5px rgba(184,66,55,.08); }
}

@media (max-width: 680px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .app-shell { width: min(100% - 16px, 1440px); }
  .topbar { height: 68px; }
  .brand { gap: 8px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; font-size: 13px; }
  .brand strong { font-size: 13px; }
  .topbar-actions { gap: 5px; }
  .round-pill { padding: 7px 9px; font-size: 10px; }
  .ghost-btn { padding: 8px 9px; font-size: 10px; }
  .setup-layout { min-height: calc(100vh - 69px); padding: 28px 0 45px; gap: 30px; }
  .hero-copy h1 { font-size: clamp(37px, 11.5vw, 48px); }
  .hero-copy > p { font-size: 13px; line-height: 1.55; }
  .feature-row { margin-top: 26px; gap: 6px; }
  .feature-row div { min-width: 0; flex: 1; }
  .feature-row strong { font-size: 18px; }
  .feature-row span { font-size: 10px; }
  .setup-card { padding: 17px; }
  .player-input-row { grid-template-columns: 28px 1fr; gap: 7px; }
  .player-number { width: 28px; height: 28px; border-radius: 9px; }
  .player-slot-field { min-height: 50px; padding-left: 11px; }
  .player-slot-name .placeholder, .player-slot-name strong { font-size: 12px; }
  .invite-slot-btn, .slot-ready { padding: 7px 9px; font-size: 10px; }
  .room-link-row { align-items: stretch; flex-direction: column; }
  .room-link-row button { width: 100%; }

  .game-stage { padding: 20px 0 80px; }
  .game-stage-head { margin-bottom: 16px; gap: 8px; }
  .game-stage-head h2 { font-size: 29px; }
  .game-stage-head p { font-size: 11px; }
  .round-card { margin-bottom: 18px; padding: 18px 12px; border-radius: 22px; }
  .card-deck-tab { height: 20px; top: -10px; }
  .card-topline { align-items: flex-start; }
  .card-live-meta { align-items: flex-end; flex-direction: column; gap: 5px; }
  .question-progress { font-size: 10px; }
  .question-timer { min-width: 57px; padding: 7px 8px; font-size: 11px; }
  .secret-length { margin: 6px 0 14px; font-size: 45px; }
  .questions-stack { gap: 7px; }
  .question-row { min-height: 68px; padding: 11px 10px; grid-template-columns: 32px 1fr; gap: 9px; border-radius: 14px; }
  .question-index { width: 32px; height: 32px; border-radius: 10px; }
  .question-copy strong { font-size: 13px; }
  .question-copy span { font-size: 8px; }
  .answer-hidden-chip { grid-column: 2; justify-self: start; padding: 5px 7px; font-size: 7px; }
  .guest-question-note { font-size: 10px; }

  .players-panel { padding: 12px; border-radius: 19px; }
  .players-heading { align-items: center; }
  .players-heading h2 { font-size: 23px; }
  .privacy-badge { padding: 6px 8px; font-size: 8px; }
  .player-card { padding: 13px; }
  .board-help { margin-top: 13px; font-size: 10px; }
  .letter-board { gap: 6px; }
  .letter-slot { width: 44px; height: 49px; border-radius: 12px; }
  .letter-tile { border-radius: 11px; font-size: 18px; }
  .letter-picker { grid-template-columns: 54px 1fr; }
  .letter-input { width: 54px; }
  .opponents-strip { display: grid; grid-template-columns: 1fr; }
  .opponent-chip { min-width: 0; width: 100%; }

  .modal-backdrop { padding: 12px; align-items: end; }
  .modal-card { max-height: calc(100dvh - 24px); overflow-y: auto; border-radius: 24px 24px 18px 18px; padding: 21px 17px calc(20px + env(safe-area-inset-bottom)); }
  .modal-card h2 { font-size: 27px; }
  .invite-link-box { grid-template-columns: 1fr; }
  .invite-link-box button { width: 100%; }
  .guess-clock { margin-top: 2px; }
  .toast { bottom: calc(18px + env(safe-area-inset-bottom)); max-width: calc(100% - 24px); text-align: center; }
}

/* 500-question random deck + outcome states + compact mobile game board */
.result-modal {
  border: 1px solid rgba(24,32,28,.10);
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.result-modal.result-win {
  border: 2px solid rgba(25,95,73,.55);
  background: linear-gradient(180deg, #f3fbf6 0%, var(--paper) 58%);
  box-shadow: 0 30px 90px rgba(25,95,73,.26);
}
.result-modal.result-win .result-burst {
  background: #1f7f5c;
  color: #fff;
  box-shadow: 0 0 0 9px rgba(31,127,92,.10), 0 12px 30px rgba(31,127,92,.22);
}
.result-modal.result-win h2 { color: #145c42; }
.result-modal.result-win .recap-row b { background: #cfe9dc; color: #145c42; }
.result-modal.result-other {
  border-color: #d4cec2;
  background: #fffdf8;
  box-shadow: 0 28px 80px rgba(0,0,0,.20);
}
.result-modal.result-other .result-burst,
.result-modal.result-neutral .result-burst {
  background: #e7e3dc;
  color: #656b67;
  box-shadow: none;
}
.result-modal.result-other h2,
.result-modal.result-neutral h2 { color: #303733; }
.result-modal.result-other .recap-row b,
.result-modal.result-neutral .recap-row b { background: #e7e3dc; color: #4f5652; }

@media (max-width: 680px) {
  body.game-active {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding-bottom: 0;
  }
  .game-active .app-shell {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0 8px;
    overflow: hidden;
  }
  .game-active .topbar {
    height: 50px;
    min-height: 50px;
    padding: 0 1px;
  }
  .game-active .brand > span:last-child { display: none; }
  .game-active .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 11px; }
  .game-active .topbar-actions { gap: 4px; }
  .game-active .round-pill { padding: 6px 8px; font-size: 9px; }
  .game-active #rulesBtn { padding: 7px 8px; font-size: 9px; }
  .game-active main {
    height: calc(100vh - 50px);
    height: calc(100dvh - 50px);
    min-height: 0;
  }
  .game-active #gameScreen { height: 100%; min-height: 0; overflow: hidden; }
  .game-active .game-stage {
    height: 100%;
    min-height: 0;
    padding: 5px 0 calc(5px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 5px;
    overflow: hidden;
  }
  .game-active .game-stage-head {
    min-height: 20px;
    margin: 0;
    padding: 0 2px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }
  .game-active .game-stage-head > div { display: none; }
  .game-active .game-stage-head p {
    width: 100%;
    margin: 0;
    font-size: 9px;
    line-height: 1.15;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .game-active .round-card {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 8px 9px 9px;
    border-radius: 17px;
    box-shadow: 0 8px 24px rgba(48,40,29,.11), 0 2px 0 #d8d0c2;
  }
  .game-active .card-deck-tab,
  .game-active .card-label { display: none; }
  .game-active .card-topline { min-height: 25px; align-items: center; }
  .game-active .card-live-meta {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 7px;
  }
  .game-active .question-progress { font-size: 9px; }
  .game-active .question-timer { min-width: 54px; padding: 6px 8px; font-size: 10px; }
  .game-active .secret-length {
    margin: 1px 0 5px;
    font-size: 27px;
    line-height: 1;
  }
  .game-active .questions-stack { display: block; }
  .game-active .question-row:not(.current) { display: none; }
  .game-active .question-row.current {
    min-height: 67px;
    padding: 8px 9px;
    grid-template-columns: 29px 1fr;
    gap: 8px;
    border-radius: 12px;
  }
  .game-active .question-index { width: 29px; height: 29px; border-radius: 9px; font-size: 9px; }
  .game-active .question-copy span { margin-bottom: 2px; font-size: 7px; }
  .game-active .question-copy strong { font-size: 11.5px; line-height: 1.25; }
  .game-active .round-card.questions-complete .questions-stack { display: none; }
  .game-active .round-card.questions-complete .secret-length { margin-bottom: 7px; }
  .game-active .host-question-actions { margin-top: 5px; }
  .game-active .host-question-actions .primary-btn { padding: 9px 10px; font-size: 10px; }
  .game-active .guest-question-note { display: none !important; }

  .game-active .players-panel {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 7px;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .game-active .players-heading { margin-bottom: 4px; align-items: center; }
  .game-active .players-heading .section-kicker { display: none; }
  .game-active .players-heading h2 { margin: 0; font-size: 15px; line-height: 1; }
  .game-active .privacy-badge { padding: 4px 6px; font-size: 6.5px; }
  .game-active .players-grid { display: block; }
  .game-active .player-card {
    padding: 7px;
    border-radius: 13px;
  }
  .game-active .player-card-head { gap: 6px; }
  .game-active .avatar { width: 27px; height: 27px; border-radius: 8px; font-size: 10px; }
  .game-active .player-meta h3 { font-size: 10px; }
  .game-active .player-score { margin-top: 0; font-size: 7px; }
  .game-active .player-state { padding: 4px 5px; font-size: 7px; }
  .game-active .board-help { display: none; }
  .game-active .letter-board {
    width: 100%;
    min-height: 0;
    margin: 5px 0 7px;
    display: grid;
    grid-template-columns: repeat(var(--card-length), minmax(0, 1fr));
    gap: 4px;
    align-items: center;
  }
  .game-active .letter-slot {
    width: 100%;
    min-width: 0;
    height: clamp(33px, 6.2vh, 41px);
    border-radius: 9px;
  }
  .game-active .letter-tile { border-radius: 8px; font-size: 15px; }
  .game-active .letter-tile.selected { transform: translateY(-6px) scale(1.025); outline-width: 2px; }
  .game-active .player-answer-area { padding-top: 6px; }
  .game-active .answer-status {
    min-height: 10px;
    margin-bottom: 3px;
    font-size: 7.5px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .game-active .letter-picker { grid-template-columns: 43px 1fr; gap: 5px; }
  .game-active .letter-input { width: 43px; height: 38px; font-size: 15px; border-radius: 9px; }
  .game-active .lock-btn { min-height: 38px; padding: 0 7px; border-radius: 9px; font-size: 9px; }
  .game-active .guess-btn { min-height: 36px; margin-top: 5px; padding: 7px; border-radius: 9px; font-size: 9px; }

  .game-active .opponents-wrap { margin-top: 5px; padding-top: 5px; }
  .game-active .opponents-label { display: none; }
  .game-active .opponents-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }
  .game-active .opponent-chip {
    min-width: 0;
    width: auto;
    padding: 4px 5px;
    gap: 0;
    border-radius: 8px;
  }
  .game-active .opponent-avatar { display: none; }
  .game-active .opponent-chip > span:last-child { min-width: 0; width: 100%; }
  .game-active .opponent-chip strong { max-width: 100%; font-size: 8px; }
  .game-active .opponent-chip small { margin-top: 1px; font-size: 6.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 380px) and (max-height: 700px) {
  .game-active .round-card { padding-top: 6px; padding-bottom: 7px; }
  .game-active .secret-length { font-size: 23px; }
  .game-active .question-row.current { min-height: 58px; padding: 6px 7px; }
  .game-active .question-copy strong { font-size: 10.5px; }
  .game-active .players-heading h2 { font-size: 13px; }
  .game-active .letter-slot { height: 32px; }
  .game-active .letter-input,
  .game-active .lock-btn { height: 34px; min-height: 34px; }
  .game-active .guess-btn { min-height: 32px; }
  .game-active .opponent-chip { padding-top: 3px; padding-bottom: 3px; }
}

/* Hide the in-game headline once a match has started. The active round itself
   is the focus, especially on mobile where every vertical pixel matters. */
#gameScreen.active .game-stage-head {
  display: none;
}

@media (max-width: 680px) {
  .game-active .game-stage {
    grid-template-rows: auto minmax(0, 1fr);
    padding-top: 2px;
  }
}

/* Mobile keyboards: iOS auto-zooms focused text fields below 16px. Keep every
   gameplay text field at 16px or larger so opening the keyboard does not zoom
   or visually rescale the board. */
@media (max-width: 680px) {
  html,
  body.game-active {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  .game-active input[type="text"],
  .modal-backdrop input[type="text"] {
    font-size: 16px !important;
    touch-action: manipulation;
  }

  .game-active .letter-input {
    font-size: 16px !important;
  }
}

/* Always-visible shared round clock. On mobile it is pinned to the visual
   viewport so the on-screen keyboard cannot push it out of view. */
.game-timer-hud {
  min-width: 82px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 7px 20px rgba(24,32,28,.15);
  font-variant-numeric: tabular-nums;
  transition: background .2s ease, transform .2s ease;
}
.game-timer-hud span {
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .11em;
  opacity: .7;
}
.game-timer-hud strong {
  font-size: 12px;
  line-height: 1;
  letter-spacing: .04em;
}
.game-timer-hud.urgent {
  background: var(--danger);
  animation: timerPulse .8s ease-in-out infinite alternate;
}

@media (max-width: 680px) {
  .game-active .game-timer-hud {
    position: fixed;
    z-index: 120;
    top: calc(var(--visual-viewport-top, 0px) + 7px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    min-width: 92px;
    height: 36px;
    padding: 6px 10px;
    gap: 6px;
    border: 1px solid rgba(255,255,255,.10);
    box-shadow: 0 6px 20px rgba(24,32,28,.22);
  }
  .game-active .game-timer-hud.urgent {
    transform: translateX(-50%);
  }
  .game-active .game-timer-hud span { font-size: 7px; }
  .game-active .game-timer-hud strong { font-size: 12px; }
  .game-active #rulesBtn { display: none; }
  .game-active .round-pill { margin-left: auto; }
}
