:root {
  --ink: #3d241b;
  --ink-soft: #745243;
  --paper: #fffaf0;
  --paper-2: #f6ecd9;
  --gold: #f3bd4d;
  --gold-deep: #cc8627;
  --coral: #e96b5a;
  --green: #58a55c;
  --blue: #4f93b7;
  --brown: #6a351e;
  --brown-dark: #3a1d12;
  --line: rgba(92, 51, 31, 0.16);
  --shadow: 0 20px 60px rgba(56, 27, 15, 0.16);
  --soft-shadow: 0 12px 30px rgba(56, 27, 15, 0.1);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(246, 200, 95, 0.24), transparent 30%),
    radial-gradient(circle at 90% 0%, rgba(233, 107, 90, 0.15), transparent 26%),
    linear-gradient(180deg, #fff8e9 0%, #f6ead4 100%);
  font-family: Inter, ui-rounded, "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible {
  outline: 4px solid rgba(79, 147, 183, 0.3);
  outline-offset: 3px;
}

button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px clamp(14px, 2vw, 30px) calc(16px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.65);
  border-radius: 20px;
  background: rgba(255, 250, 240, 0.84);
  box-shadow: 0 10px 30px rgba(70, 36, 18, 0.08);
  backdrop-filter: blur(16px);
}

.brand-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 8px 3px 3px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.brand-button .brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, #ffd675, #eba739);
  box-shadow: inset 0 -4px 0 rgba(112, 55, 22, 0.12);
  font-size: 24px;
}
.brand-button strong { display: block; font-size: 1rem; line-height: 1.1; }
.brand-button small { display: block; margin-top: 3px; color: var(--ink-soft); font-size: .74rem; }

.top-actions { display: flex; gap: 8px; }
.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fffdf8;
  box-shadow: 0 6px 16px rgba(67, 34, 19, 0.07);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 800;
  transition: transform .2s ease, background .2s ease;
}
.icon-button:hover { transform: translateY(-2px); background: #fff3d8; }

.screen { display: none; animation: screenIn .45s ease both; }
.screen.is-active { display: block; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero-card {
  position: relative;
  min-height: clamp(340px, 50vw, 590px);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  isolation: isolate;
}
.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1.01);
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(43, 20, 11, .87) 0%, rgba(52, 26, 13, .55) 38%, rgba(52, 26, 13, .06) 72%),
    linear-gradient(0deg, rgba(36, 16, 9, .62) 0%, transparent 42%);
}
.hero-copy {
  position: absolute;
  z-index: 2;
  left: clamp(24px, 5vw, 74px);
  bottom: clamp(28px, 6vw, 72px);
  width: min(560px, 75%);
  color: white;
  text-shadow: 0 3px 16px rgba(0,0,0,.3);
}
.eyebrow, .section-kicker {
  display: inline-block;
  color: var(--gold-deep);
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.hero-copy .eyebrow { color: #ffd87b; }
.hero-copy h1 {
  margin: 10px 0 12px;
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: .98;
  letter-spacing: -.045em;
}
.hero-copy p {
  max-width: 520px;
  margin: 0;
  color: rgba(255,255,255,.9);
  font-size: clamp(.95rem, 1.8vw, 1.2rem);
  line-height: 1.6;
}

.setup-panel {
  position: relative;
  z-index: 4;
  width: min(1160px, calc(100% - 32px));
  margin: -42px auto 0;
  padding: clamp(22px, 4vw, 40px);
  border: 1px solid rgba(255,255,255,.85);
  border-radius: var(--radius-xl);
  background: rgba(255, 252, 246, .96);
  box-shadow: var(--shadow);
}
.setup-heading,
.board-topline,
.mission-panel-heading,
.game-header-card,
.case-info,
.game-tools,
.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.setup-heading h2,
.board-topline h2,
.mission-panel h2 {
  margin: 5px 0 0;
  font-size: clamp(1.25rem, 2.5vw, 1.8rem);
  letter-spacing: -.025em;
}
.record-chip, .category-chip {
  padding: 9px 13px;
  border-radius: 999px;
  background: #fff1cb;
  color: #8a551b;
  font-size: .82rem;
  font-weight: 800;
}

.setup-grid { display: grid; gap: 28px; margin-top: 28px; }
.choice-group { margin: 0; padding: 0; border: 0; }
.choice-group legend { margin-bottom: 12px; font-weight: 900; }
.segmented { display: grid; gap: 12px; }
.three-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-card {
  position: relative;
  display: grid;
  min-height: 112px;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 15px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: #f8f1e5;
  cursor: pointer;
  text-align: center;
  transition: transform .2s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.choice-card:hover { transform: translateY(-3px); background: #fff5dc; }
.choice-card.is-selected {
  border-color: var(--gold-deep);
  background: linear-gradient(180deg, #fff8df, #ffefbf);
  box-shadow: 0 10px 24px rgba(191, 121, 28, .14);
}
.choice-card.is-selected::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 9px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: .75rem;
  font-weight: 900;
}
.choice-icon { font-size: 1.65rem; }
.choice-card strong { font-size: .98rem; }
.choice-card small { color: var(--ink-soft); font-size: .76rem; }

.player-inputs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.player-inputs:not([hidden]) { display: grid; }
.player-inputs label { color: var(--ink-soft); font-size: .78rem; font-weight: 800; }
.player-inputs input {
  width: 100%;
  margin-top: 6px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  color: var(--ink);
  font-weight: 750;
}

.mission-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
  padding: 15px;
  border: 1px dashed rgba(109, 60, 31, .25);
  border-radius: 18px;
  background: #fffaf0;
}
.mission-preview img {
  width: 84px;
  height: 84px;
  flex: 0 0 auto;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: var(--soft-shadow);
}
.mission-preview span { color: var(--ink-soft); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.mission-preview strong { display: block; margin: 4px 0; font-size: 1.05rem; }
.mission-preview p { margin: 0; color: var(--ink-soft); font-size: .87rem; line-height: 1.5; }

.primary-button, .secondary-button, .text-button, .hint-button, .back-button {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 900;
  transition: transform .2s ease, filter .2s ease, opacity .2s ease;
}
.primary-button:hover, .secondary-button:hover, .hint-button:hover, .back-button:hover { transform: translateY(-2px); }
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 52px;
  padding: 13px 20px;
  background: linear-gradient(135deg, #e9a838, #d97a31);
  color: #351a0f;
  box-shadow: 0 12px 24px rgba(194, 111, 35, .25), inset 0 -4px 0 rgba(90, 43, 17, .12);
}
.start-button { width: 100%; margin-top: 18px; font-size: 1.05rem; }
.start-button b { font-size: 1.35rem; }
.secondary-button {
  min-height: 42px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}
.text-button { padding: 10px; background: transparent; color: var(--ink-soft); }

.game-header-card {
  margin-bottom: 14px;
  padding: 13px 16px;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 20px;
  background: rgba(255, 252, 246, .95);
  box-shadow: var(--soft-shadow);
}
.case-info { justify-content: flex-start; }
.case-info img {
  width: 58px;
  height: 58px;
  border-radius: 15px;
  object-fit: cover;
}
.case-info h1 { margin: 2px 0 1px; font-size: 1.3rem; }
.case-info p { margin: 0; color: var(--ink-soft); font-size: .78rem; }
.back-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: #f4e7d1;
  font-size: 1.2rem;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  padding: 13px 15px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 16px;
  background: rgba(255, 252, 246, .93);
  box-shadow: 0 8px 20px rgba(59, 31, 18, .06);
}
.stat-card span { display: block; color: var(--ink-soft); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.stat-card strong { display: block; margin-top: 4px; font-size: 1.18rem; }
.stat-card strong b { font: inherit; }

.multiplayer-board {
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 12px;
}
.multiplayer-board:not([hidden]) { display: grid; }
.player-score, .turn-indicator {
  padding: 12px 14px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: #f8f1e5;
}
.player-score { display: grid; gap: 2px; }
.player-score:last-child { text-align: right; }
.player-score span, .turn-indicator span { color: var(--ink-soft); font-size: .67rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.player-score strong { font-size: .95rem; }
.player-score b { color: var(--gold-deep); font-size: .78rem; }
.player-score.is-active { border-color: var(--gold-deep); background: #fff1c9; box-shadow: 0 8px 22px rgba(193, 125, 34, .12); }
.turn-indicator { display: grid; align-content: center; justify-items: center; min-width: 132px; background: var(--brown-dark); color: white; }
.turn-indicator span { color: #f4cd7a; }
.turn-indicator strong { margin-top: 2px; font-size: .85rem; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(300px, .75fr);
  gap: 14px;
  align-items: start;
}
.board-panel, .mission-panel {
  border: 1px solid rgba(255,255,255,.8);
  border-radius: var(--radius-lg);
  background: rgba(255, 252, 246, .95);
  box-shadow: var(--soft-shadow);
}
.board-panel { padding: clamp(15px, 2vw, 24px); }
.mission-panel { position: sticky; top: 90px; padding: 20px; }
.board-topline { margin-bottom: 14px; }
.board-topline h2 { font-size: clamp(1rem, 2vw, 1.35rem); }
.selected-word {
  min-width: 120px;
  padding: 9px 13px;
  border-radius: 12px;
  background: var(--brown-dark);
  color: #ffe39b;
  font-size: .95rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-align: center;
}

.word-grid {
  --grid-size: 6;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), minmax(0, 1fr));
  gap: clamp(4px, .65vw, 8px);
  width: min(100%, 780px);
  margin: 0 auto;
  padding: clamp(8px, 1.5vw, 14px);
  border: 2px solid rgba(104, 58, 31, .18);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.55), transparent),
    #ead7b7;
  box-shadow: inset 0 6px 20px rgba(82, 45, 25, .09);
  touch-action: none;
  user-select: none;
}
.letter-cell {
  position: relative;
  display: grid;
  aspect-ratio: 1;
  min-width: 0;
  place-items: center;
  border: 1px solid rgba(106, 53, 30, .18);
  border-radius: clamp(7px, 1.1vw, 13px);
  background: linear-gradient(145deg, #fffdf8, #f4e7d2);
  box-shadow: 0 4px 0 rgba(91, 50, 28, .16), 0 7px 12px rgba(71, 38, 22, .07);
  color: var(--brown-dark);
  cursor: pointer;
  font-size: clamp(.85rem, 2.1vw, 1.75rem);
  font-weight: 950;
  line-height: 1;
  transition: transform .12s ease, background .14s ease, color .14s ease, box-shadow .14s ease;
}
.letter-cell:hover { transform: translateY(-1px); background: #fff8e6; }
.letter-cell.is-selecting {
  transform: translateY(-2px) scale(1.03);
  background: #ffe39b;
  color: #492214;
  box-shadow: 0 3px 0 #bd7a27, 0 8px 18px rgba(190, 119, 28, .22);
}
.letter-cell.is-found {
  color: #fff;
  background: linear-gradient(145deg, #67b76b, #3f8e52);
  box-shadow: 0 3px 0 #276339, 0 8px 16px rgba(43, 112, 58, .2);
}
.letter-cell.is-hint { animation: hintPulse 1s ease-in-out 3; z-index: 2; }
.letter-cell.is-wrong { animation: wrongShake .38s ease; background: #ffd2cc; }
@keyframes hintPulse {
  0%,100% { box-shadow: 0 4px 0 rgba(91,50,28,.16), 0 0 0 0 rgba(233,107,90,.35); }
  50% { background: #ffbaa9; transform: scale(1.12); box-shadow: 0 4px 0 #ad4e40, 0 0 0 10px rgba(233,107,90,.1); }
}
@keyframes wrongShake { 0%,100%{transform:none} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }
.board-instruction { margin: 13px 0 0; color: var(--ink-soft); font-size: .76rem; text-align: center; }

.mission-panel-heading { align-items: flex-start; }
.hint-button {
  padding: 9px 11px;
  background: #fff0c8;
  color: #7a4c17;
  font-size: .78rem;
}
.hint-button:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.category-chip { display: inline-flex; margin: 14px 0; font-size: .73rem; }
.word-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.word-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  font-size: .8rem;
  font-weight: 900;
  letter-spacing: .04em;
  transition: opacity .2s ease, background .2s ease;
}
.word-item span:first-child {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  background: #f4e7d1;
  font-size: .68rem;
}
.word-item .word-text { overflow: hidden; text-overflow: ellipsis; }
.word-item.is-found { opacity: .6; background: #e4f3e4; text-decoration: line-through; }
.word-item.is-found span:first-child { background: var(--green); color: white; }
.progress-block { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.progress-copy { font-size: .75rem; font-weight: 800; }
.progress-copy span { color: var(--ink-soft); }
.progress-track { height: 10px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: #e8ddca; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--coral)); transition: width .35s ease; }
.detective-note {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  background: #f3e7d5;
}
.detective-note span { font-size: 1.35rem; }
.detective-note p { margin: 0; color: var(--ink-soft); font-size: .76rem; line-height: 1.5; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 17px 4px 2px;
  color: rgba(74, 43, 29, .68);
  font-size: .74rem;
  font-weight: 750;
}

.toast-region {
  position: fixed;
  z-index: 100;
  top: 86px;
  left: 50%;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100% - 28px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 12px 15px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 14px;
  background: rgba(56, 29, 18, .94);
  color: white;
  box-shadow: var(--shadow);
  font-size: .83rem;
  font-weight: 800;
  text-align: center;
  animation: toastIn .3s ease both;
  backdrop-filter: blur(12px);
}
.toast.success { background: rgba(43, 116, 63, .95); }
.toast.warning { background: rgba(179, 83, 55, .96); }
@keyframes toastIn { from { opacity:0; transform:translateY(-8px) scale(.97) } to { opacity:1; transform:none } }

.modal-backdrop {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(39, 19, 11, .68);
  backdrop-filter: blur(9px);
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  position: relative;
  width: min(580px, 100%);
  max-height: min(90vh, 760px);
  overflow: auto;
  padding: clamp(24px, 5vw, 38px);
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 26px;
  background: #fffaf0;
  box-shadow: 0 30px 100px rgba(0,0,0,.28);
  text-align: center;
  animation: modalIn .3s ease both;
}
@keyframes modalIn { from { opacity:0; transform:translateY(12px) scale(.96) } to { opacity:1; transform:none } }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: #f1e2cc;
  cursor: pointer;
  font-size: 1.4rem;
}
.modal-mascot {
  width: 118px;
  height: 118px;
  margin-bottom: 14px;
  border-radius: 25px;
  object-fit: cover;
  box-shadow: var(--soft-shadow);
}
.modal-card h2 { margin: 6px 0 10px; font-size: clamp(1.45rem, 4vw, 2rem); }
.modal-card > p { color: var(--ink-soft); line-height: 1.6; }
.instruction-list { display: grid; gap: 10px; margin: 22px 0; padding: 0; list-style: none; text-align: left; counter-reset: steps; }
.instruction-list li { position: relative; padding: 12px 12px 12px 48px; border-radius: 14px; background: #f6ecdc; color: var(--ink-soft); line-height: 1.5; counter-increment: steps; }
.instruction-list li::before { content: counter(steps); position: absolute; left: 12px; top: 12px; display:grid; width:26px; height:26px; place-items:center; border-radius:8px; background:var(--gold); color:var(--brown-dark); font-weight:950; }
.compact-modal { width: min(460px, 100%); }
.compact-modal .primary-button { width: 100%; margin-top: 12px; }
.compact-modal .text-button { width: 100%; margin-top: 6px; }
.star-row { margin-bottom: 10px; font-size: clamp(1.8rem, 6vw, 3rem); letter-spacing: .08em; filter: drop-shadow(0 4px 6px rgba(145, 89, 18, .2)); }
.result-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 20px 0; }
.result-stats article { padding: 13px 8px; border-radius: 14px; background: #f4e8d5; }
.result-stats span { display:block; color:var(--ink-soft); font-size:.67rem; font-weight:800; text-transform:uppercase; letter-spacing:.06em; }
.result-stats strong { display:block; margin-top:5px; font-size:1.05rem; }
.winner-banner { margin: -2px 0 18px; padding: 12px; border-radius: 14px; background: #fff0bd; color: #744617; font-weight: 950; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.confetti-piece {
  position: fixed;
  z-index: 260;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  animation: confettiFall 2.6s linear forwards;
  pointer-events: none;
}
@keyframes confettiFall { to { transform: translate3d(var(--drift), 110vh, 720deg); opacity: .15; } }

body.is-paused .game-layout,
body.is-paused .stats-row,
body.is-paused .multiplayer-board { filter: blur(12px); }

@media (max-width: 980px) {
  .game-layout { grid-template-columns: 1fr; }
  .mission-panel { position: static; }
  .word-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero-overlay { background: linear-gradient(0deg, rgba(38,18,9,.82) 0%, rgba(46,22,11,.28) 66%, transparent 100%); }
  .hero-copy { width: calc(100% - 48px); left: 24px; bottom: 28px; }
}

@media (max-width: 720px) {
  .app-shell { padding: 10px 10px calc(12px + var(--safe-bottom)); }
  .topbar { margin-bottom: 10px; border-radius: 16px; }
  .brand-button small { display: none; }
  .brand-button .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
  .icon-button { width: 38px; height: 38px; }
  .hero-card { min-height: 410px; border-radius: 22px; }
  .hero-image { object-position: 56% center; }
  .hero-copy { width: calc(100% - 36px); left: 18px; bottom: 22px; }
  .hero-copy h1 { font-size: clamp(2rem, 10vw, 3rem); }
  .setup-panel { width: calc(100% - 14px); margin-top: -20px; padding: 20px 14px; border-radius: 22px; }
  .setup-heading { align-items: flex-start; }
  .record-chip { font-size: .7rem; }
  .three-cols { grid-template-columns: repeat(3, minmax(88px, 1fr)); overflow-x: auto; padding-bottom: 4px; }
  .choice-card { min-height: 100px; padding: 12px 8px; }
  .choice-card small { font-size: .68rem; }
  .two-cols { grid-template-columns: 1fr; }
  .player-inputs:not([hidden]) { grid-template-columns: 1fr; }
  .mission-preview { align-items: flex-start; }
  .mission-preview img { width: 70px; height: 70px; }
  .game-header-card { align-items: flex-start; }
  .case-info img { display: none; }
  .game-tools { flex-direction: column; gap: 6px; }
  .game-tools .secondary-button { min-height: 36px; padding: 7px 9px; font-size: .72rem; }
  .stats-row { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .stat-card { padding: 10px 7px; text-align: center; }
  .stat-card span { font-size: .58rem; }
  .stat-card strong { font-size: .95rem; }
  .multiplayer-board { grid-template-columns: 1fr 1fr; }
  .turn-indicator { grid-column: 1 / -1; grid-row: 1; min-height: 50px; }
  .player-score:last-child { text-align: left; }
  .board-panel { padding: 12px; }
  .board-topline { align-items: flex-start; }
  .board-topline h2 { font-size: .94rem; }
  .selected-word { min-width: 88px; padding: 8px; font-size: .78rem; }
  .word-grid { gap: 4px; padding: 7px; border-radius: 16px; }
  .letter-cell { border-radius: 7px; box-shadow: 0 3px 0 rgba(91,50,28,.14); font-size: clamp(.68rem, 4vw, 1.15rem); }
  .mission-panel { padding: 16px; }
  .word-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  footer { flex-direction: column; align-items: center; text-align: center; }
}

@media (max-width: 430px) {
  .brand-button strong { font-size: .88rem; }
  .top-actions { gap: 5px; }
  .icon-button { width: 35px; height: 35px; border-radius: 11px; }
  .hero-card { min-height: 385px; }
  .hero-copy p { font-size: .86rem; }
  .setup-heading h2 { font-size: 1.25rem; }
  .choice-card { min-width: 92px; }
  .mission-preview { flex-direction: column; }
  .mission-preview img { width: 58px; height: 58px; }
  .case-info { gap: 8px; }
  .case-info h1 { font-size: 1.05rem; }
  .back-button { width: 36px; height: 36px; }
  .word-list { grid-template-columns: 1fr 1fr; gap: 6px; }
  .word-item { padding: 8px; font-size: .72rem; }
  .result-stats { grid-template-columns: 1fr; }
}

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

/* Teka-Teki Silang */
.puzzle-board[hidden],
.crossword-mission[hidden],
#wordSearchMission[hidden] { display: none !important; }

.crossword-board { width: 100%; }
.crossword-scroll {
  width: 100%;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(88, 47, 27, .15);
  border-radius: 18px;
  background:
    linear-gradient(45deg, rgba(83, 47, 27, .035) 25%, transparent 25%, transparent 75%, rgba(83, 47, 27, .035) 75%),
    linear-gradient(45deg, rgba(83, 47, 27, .035) 25%, transparent 25%, transparent 75%, rgba(83, 47, 27, .035) 75%),
    #eadbc4;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  overscroll-behavior: contain;
}
.crossword-grid {
  --cross-cell-size: clamp(34px, 4.2vw, 54px);
  display: grid;
  grid-template-columns: repeat(var(--cross-cols), var(--cross-cell-size));
  gap: 3px;
  width: max-content;
  min-width: 100%;
  justify-content: center;
  align-items: center;
  user-select: none;
}
.crossword-block,
.crossword-cell {
  width: var(--cross-cell-size);
  aspect-ratio: 1;
  border-radius: 7px;
}
.crossword-block {
  display: block;
  background: rgba(61, 36, 27, .88);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.crossword-cell {
  position: relative;
  display: grid;
  place-items: center;
  border: 2px solid rgba(83, 47, 27, .24);
  background: #fffdf7;
  color: var(--brown-dark);
  box-shadow: 0 3px 0 rgba(91,50,28,.18);
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.crossword-cell:hover { transform: translateY(-1px); background: #fff4d2; }
.crossword-cell.is-active {
  z-index: 2;
  border-color: var(--blue);
  background: #e8f5fb;
  box-shadow: 0 0 0 3px rgba(79, 147, 183, .2), 0 3px 0 rgba(91,50,28,.14);
}
.crossword-cell.is-solved {
  border-color: #3f8a49;
  background: #dff3df;
  color: #245a2c;
}
.crossword-cell.is-revealed {
  border-color: var(--gold-deep);
  background: #fff0bd;
}
.crossword-number {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: clamp(.48rem, 1.1vw, .65rem);
  font-weight: 950;
  line-height: 1;
}
.crossword-letter {
  padding-top: 4px;
  font-size: clamp(.9rem, 2.2vw, 1.35rem);
  font-weight: 950;
}

.crossword-mission { display: grid; gap: 14px; }
.active-clue-card {
  padding: 14px;
  border: 1px solid rgba(79, 147, 183, .25);
  border-radius: 16px;
  background: linear-gradient(145deg, #f0f9fd, #fffdf7);
}
.clue-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.clue-meta span {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--blue);
  color: white;
  font-size: .7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.clue-meta strong {
  color: var(--brown);
  font-size: .88rem;
  letter-spacing: .09em;
  text-align: right;
}
.active-clue-card p {
  margin: 0;
  color: var(--ink);
  font-size: .86rem;
  font-weight: 760;
  line-height: 1.5;
}
.crossword-answer-form { display: grid; gap: 7px; }
.crossword-answer-form label {
  color: var(--ink-soft);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.answer-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.crossword-answer-form input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 2px solid rgba(92, 51, 31, .18);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.crossword-answer-form input:disabled { background: #eee5d8; color: var(--ink-soft); }
.crossword-answer-form input.is-wrong { animation: inputShake .38s ease; border-color: var(--coral); background: #fff0ed; }
.crossword-answer-form .primary-button { width: 100%; min-height: 46px; }
@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.clue-list {
  display: grid;
  gap: 14px;
  max-height: 420px;
  overflow: auto;
  padding-right: 3px;
}
.clue-group { display: grid; gap: 7px; }
.clue-group h3 {
  margin: 0;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
  color: var(--gold-deep);
  font-size: .76rem;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.clue-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  padding: 9px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #f7efe3;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.clue-item:hover { transform: translateY(-1px); background: #fff4d7; }
.clue-item.is-active { border-color: var(--blue); background: #eaf7fc; }
.clue-item.is-solved { border-color: rgba(63, 138, 73, .35); background: #e6f4e4; }
.clue-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  background: var(--gold);
  color: var(--brown-dark);
  font-size: .76rem;
  font-weight: 950;
}
.clue-item.is-solved .clue-number { background: var(--green); color: white; }
.clue-copy { min-width: 0; }
.clue-copy strong {
  display: block;
  font-size: .75rem;
  line-height: 1.42;
}
.clue-copy small {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#soundButton { position: relative; }
#soundButton::after {
  content: "♫";
  position: absolute;
  right: 3px;
  bottom: 2px;
  color: var(--gold-deep);
  font-size: .55rem;
  font-weight: 950;
}

footer { justify-content: center; text-align: center; }

@media (max-width: 980px) {
  .crossword-grid { --cross-cell-size: clamp(33px, 6vw, 50px); }
  .clue-list { max-height: none; }
}

@media (max-width: 720px) {
  .crossword-scroll { padding: 7px; }
  .crossword-grid {
    --cross-cell-size: 34px;
    min-width: max-content;
    justify-content: start;
  }
  .crossword-block, .crossword-cell { border-radius: 5px; }
  .crossword-cell { border-width: 1px; box-shadow: 0 2px 0 rgba(91,50,28,.16); }
  .crossword-number { top: 2px; left: 3px; font-size: .46rem; }
  .crossword-letter { font-size: .94rem; }
  .clue-meta { align-items: flex-start; flex-direction: column; }
  .clue-meta strong { text-align: left; }
}

@media (max-width: 430px) {
  .crossword-grid { --cross-cell-size: 31px; gap: 2px; }
  .active-clue-card { padding: 11px; }
  .clue-item { grid-template-columns: 27px minmax(0, 1fr); padding: 8px; }
  .clue-number { width: 25px; height: 25px; }
}
