.detective-root {
  --detective-ink: #233b4d;
  --detective-muted: #637989;
  --detective-green: #167b52;
  color: var(--detective-ink);
}

.detective-case,
.detective-demo {
  width: min(100%, 760px);
  margin-inline: auto;
}

.detective-top { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.detective-case-label { border-radius: 999px; padding: 7px 16px; background: #fff1ba; font-weight: 850; font-size: .88rem; color: #725012; }
.detective-phase { margin: 0; font-size: clamp(1.45rem, 4vw, 2rem); line-height: 1.2; text-align: center; letter-spacing: -.035em; }
.detective-help { max-width: 550px; margin: 12px auto 18px; color: var(--detective-muted); font-size: 1rem; text-align: center; line-height: 1.55; }

.detective-timer-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; max-width: 470px; margin: 0 auto 18px; }
.detective-timer-caption { color: var(--detective-muted); font-size: .88rem; font-weight: 700; }
.detective-timer { font-variant-numeric: tabular-nums; font-size: 1.1rem; font-weight: 900; }
.detective-time-progress { grid-column: 1 / -1; display: block; width: 100%; height: 10px; overflow: hidden; appearance: none; border: none; border-radius: 999px; background: #e9eef0; accent-color: #e5b243; }
.detective-time-progress::-webkit-progress-bar { border-radius: 999px; background: #e9eef0; }
.detective-time-progress::-webkit-progress-value { border-radius: 999px; background: #e5b243; }
.detective-time-progress::-moz-progress-bar { border-radius: 999px; background: #e5b243; }

.detective-scene { position: relative; overflow: hidden; isolation: isolate; padding: clamp(14px, 3vw, 24px); border: 1px solid #c6e0df; border-radius: 28px; background: linear-gradient(180deg, #e2f4f1 0%, #eff7e6 100%); }
.detective-scene::before { content: ''; position: absolute; z-index: -1; width: 120px; height: 120px; top: -48px; right: -24px; border-radius: 50%; background: #f9db86; box-shadow: 0 0 0 15px #fff4d04d; }
.detective-scene::after { content: ''; position: absolute; z-index: -1; width: 240px; height: 100px; left: -70px; bottom: -68px; border-radius: 50%; background: #c6dca4; transform: rotate(15deg); }
.detective-board { display: grid; grid-template-columns: repeat(var(--detective-columns, 3), minmax(0, 1fr)); gap: clamp(7px, 2vw, 13px); width: min(100%, 520px); margin-inline: auto; }
.detective-cell { position: relative; display: grid; place-items: center; box-sizing: border-box; min-width: 0; min-height: 66px; aspect-ratio: 1.12; padding: 16px 8px 10px; border: 2px solid #dce7e2; border-radius: clamp(12px, 2.8vw, 20px); background: #fffef8; color: var(--detective-ink); box-shadow: 0 4px 0 #b5cabb50; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.detective-cell:not(:disabled):hover { background: #fff8dc; border-color: #e4bd61; transform: translateY(-2px); }
.detective-cell:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 #b5cabb50; }
.detective-cell:focus-visible,
.detective-remembered:focus-visible { outline: 4px solid #3267c1; outline-offset: 4px; z-index: 1; }
.detective-cell:disabled { cursor: default; opacity: 1; }
.detective-cell-number { position: absolute; top: 6px; left: 9px; font-size: clamp(.55rem, 1.9vw, .7rem); font-weight: 800; color: var(--filipika-muted,#59485a); line-height: 1; }
.detective-symbol { font-size: clamp(2rem, 7.5vw, 3.8rem); line-height: 1.1; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; filter: drop-shadow(0 3px 1px #3d453314); }
.detective-empty { width: 40%; max-width: 42px; aspect-ratio: 1; border-radius: 50%; border: 2px dashed #d3ddd4; background: #f5f7ee; }
.detective-cell-mark { position: absolute; bottom: 5px; right: 6px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 1rem; line-height: 1; font-weight: 900; }
.detective-cell-found { border-color: #57a67b; background: #e5f6e9; box-shadow: 0 4px 0 #308b5740; }
.detective-cell-found .detective-cell-mark { background: #167b52; color: #fff; }
.detective-cell-wrong { border-color: #ce7880; background: #fff0ed; box-shadow: 0 4px 0 #9b424228; }
.detective-cell-wrong .detective-cell-mark { background: #af3e4b; color: #fff; }
.detective-cell-revealed { border: 3px dashed #b37a24; background: #fff5d4; }
.detective-cell-revealed .detective-cell-mark { background: #8a631d; color: #fff; }

.detective-remembered { display: block; margin: 20px auto 0; min-height: 48px; padding: 11px 25px; border: 2px solid #d8b55e; border-radius: 16px; background: #fff0b7; color: #654b15; font: inherit; font-weight: 850; cursor: pointer; box-shadow: 0 3px 0 #d8b55e50; }
.detective-remembered:hover { background: #ffe798; }
.detective-counters { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 18px; }
.detective-found-count,
.detective-mistakes { padding: 8px 14px; border-radius: 999px; font-size: .88rem; font-weight: 800; }
.detective-found-count { color: #28654b; background: #e8f3e9; }
.detective-mistakes { color: #80575b; background: #f8edef; }
.detective-status { min-height: 2.8em; max-width: 550px; margin: 15px auto 0; color: var(--detective-muted); text-align: center; font-size: .9rem; line-height: 1.5; }
.detective-reveal { margin-top: 15px; padding: 18px; border: 1px solid #dde8dd; border-radius: 20px; background: #f7faf4; }
.detective-reveal-title { margin: 0 0 10px; font-size: 1rem; }
.detective-change-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.detective-change { display: flex; align-items: center; gap: 16px; }
.detective-change-icons { flex: 0 0 auto; min-width: 105px; font-size: 1.55rem; line-height: 1.5; }
.detective-change-text { color: #516556; font-size: .86rem; line-height: 1.45; }

.detective-demo-title { margin: 0 0 20px; text-align: center; font-size: clamp(1.1rem, 3vw, 1.45rem); }
.detective-demo-scenes { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 3vw, 24px); }
.detective-demo-panel { padding: clamp(10px, 3vw, 22px); background: #eff6eb; border: 1px solid #dfebdc; border-radius: 22px; }
.detective-demo-label { margin: 0 0 12px; color: #667866; font-weight: 800; text-align: center; font-size: clamp(.7rem, 2.4vw, .9rem); }
.detective-demo .detective-board { gap: 8px; max-width: 240px; }
.detective-demo .detective-cell { min-height: 60px; cursor: default; }
.detective-demo .detective-symbol { font-size: clamp(1.7rem, 6vw, 3rem); }
.detective-demo-answer { margin: 18px 0 0; color: var(--detective-green); text-align: center; line-height: 1.5; font-size: .95rem; font-weight: 750; }
.detective-root [hidden] { display: none !important; }

@media (max-width: 430px) {
  .detective-help { font-size: .9rem; }
  .detective-cell { aspect-ratio: 1; min-height: 58px; padding: 14px 5px 8px; }
  .detective-scene { border-radius: 20px; padding: 11px; }
  .detective-cell-mark { width: 20px; height: 20px; font-size: .85rem; bottom: 3px; right: 3px; }
  .detective-change { gap: 10px; }
  .detective-change-icons { min-width: 88px; font-size: 1.3rem; }
  .detective-reveal { padding: 13px; }
  .detective-demo-panel { border-radius: 16px; }
}

@media (prefers-reduced-motion: no-preference) {
  .detective-cell { transition: transform 100ms ease, border-color 100ms ease, background 100ms ease; }
}


/* Keep each case and its next step in one comfortable viewport. */
.detective-play-area { scroll-margin-top: 8px; }
.detective-play-area:not([data-session-phase="demo"]) .game-board { padding: 12px; }
.detective-case .detective-top { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.detective-case .detective-case-label { padding: 6px 10px; font-size: .78rem; white-space: nowrap; }
.detective-case .detective-phase { font-size: clamp(1.05rem, 3.3vw, 1.45rem); text-align: left; }
.detective-case .detective-help { min-height: 2.8em; margin: 8px auto; font-size: .9rem; line-height: 1.4; }
.detective-controls { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 56px; margin-bottom: 8px; }
.detective-controls .detective-timer-row { flex: 1; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; margin: 0; }
.detective-controls .detective-timer-caption { font-size: .75rem; }
.detective-controls .detective-time-progress { height: 6px; }
.detective-controls .detective-remembered { flex: 0 0 auto; margin: 0; padding: 8px 12px; font-size: .9rem; }
.detective-controls .detective-counters { margin: 0; gap: 8px; }
.detective-case .detective-scene { padding: 10px; border-radius: 20px; }
.detective-case .detective-board { height: clamp(204px, calc(100svh - 430px), 400px); gap: 8px; grid-auto-rows: minmax(0, 1fr); max-width: 500px; }
.detective-case .detective-cell { aspect-ratio: auto; min-height: 44px; padding: 12px 4px 6px; border-radius: 13px; }
.detective-case .detective-symbol { font-size: clamp(1.7rem, 5svh, 3rem); }
.detective-case .detective-status { min-height: 0; margin: 8px auto 0; font-size: .8rem; line-height: 1.4; }
.detective-case .detective-reveal { margin-top: 8px; padding: 8px 12px; border-radius: 12px; }
.detective-case .detective-reveal-title { margin: 0; font-size: .85rem; cursor: pointer; }
.detective-case .detective-reveal[open] .detective-change-list { margin-top: 10px; }
.detective-play-area .round-feedback { grid-template-columns: auto 1fr auto; gap: 10px; margin: 8px 0; padding: 8px 12px; text-align: left; align-items: center; }
.detective-play-area #feedback-symbol { font-size: 30px; }
.detective-play-area .round-feedback h3 { justify-self: start; font-size: .95rem; }
.detective-play-area #round-stars { font-size: 1.15rem; letter-spacing: 2px; white-space: nowrap; }
/* The scene already contains the accessible change-by-change explanation. */
.detective-play-area #feedback-explanation { display: none; }
.detective-play-area:not([data-session-phase="demo"]) .actions { position: sticky; bottom: 8px; z-index: 3; margin-top: 8px; padding: 8px; border-radius: 16px; background: #fffffff2; box-shadow: 0 3px 18px #233b4d12; }
.detective-play-area #next { min-height: 48px; padding: 10px 18px; }
@media (max-width: 430px) {
  .detective-controls { gap: 8px; }
  .detective-controls .detective-timer-caption { max-width: 95px; }
  .detective-case .detective-board { gap: 6px; }
  .detective-case .detective-scene { padding: 8px; }
  .detective-play-area:not([data-session-phase="demo"]) .game-board { padding: 8px; }
  .detective-play-area .actions { gap: 6px; }
  .detective-play-area #cancel { padding-inline: 10px; font-size: .8rem; }
}
/* Decorative hills must not make the scene a hidden scroll container. */
.detective-case .detective-scene { overflow: clip; }
.detective-play-area { overflow-anchor: none; }
