:root {
  color-scheme: light;
  --ink: #171b24;
  --muted: #525d70;
  --line: #dce1ea;
  --surface: #f4f6f9;
  --accent: #274bd0;
  --accent-dark: #1838aa;
  --accent-soft: #edf2ff;
  --danger: #a52c35;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: transparent; color: var(--ink); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:where(button, a, input, select, textarea):focus-visible { outline: 3px solid #3862f2; outline-offset: 3px; }
a { color: var(--accent-dark); text-underline-offset: 3px; }
p, h1, h2, h3 { margin: 0; }

.game { max-width: 768px; margin: 0 auto; padding: 8px clamp(8px, 2vw, 14px) 12px; }
.game.is-embedded { max-height: 100vh; overflow-y: auto; scrollbar-gutter: stable; }
.masthead, .mode-bar, .case-top, .game-footer, .dialog-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.masthead { min-height: 52px; }
h1, h2 { line-height: 1.13; font-weight: 750; letter-spacing: -.035em; }
h1 { font-size: clamp(1.75rem, 4.5vw, 2.125rem); }
h2 { font-size: clamp(1.4rem, 4vw, 1.75rem); }
.utilities, .modes, .clue-actions, .result-actions, .result-links { display: flex; align-items: center; gap: 8px; }

.utility, .primary, .clue, .plain {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px;
  background: #fff;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 650;
}
.utility:hover, .plain:hover, .clue:not(:disabled):hover { background: var(--surface); border-color: #adbbd5; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:not(:disabled):hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.primary:disabled { background: #e8ebf1; border-color: #e8ebf1; color: #566174; }

.mode-bar { margin: 5px 0 12px; border-bottom: 1px solid var(--line); }
.modes { gap: 4px; }
.modes button {
  min-height: 44px;
  padding: 7px 12px 5px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: .93rem;
  font-weight: 700;
  white-space: nowrap;
}
.modes button:hover { background: var(--surface); color: var(--ink); }
.modes button[aria-pressed=true] { color: var(--accent-dark); border-bottom-color: var(--accent); }
.mode-detail { color: var(--muted); font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.screen {
  isolation: isolate;
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #101620;
  color: white;
}
.screen .still, .screen video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.screen video.portrait { object-fit: contain; background: #101620; }
.screen::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: auto 0 0;
  height: 71px;
  pointer-events: none;
  background: linear-gradient(transparent, #0a0d17d9);
}
.scene-number { position: absolute; z-index: 2; top: 12px; left: 12px; background: #101620dc; }
.screen-chip { padding: 4px 7px; border-radius: 4px; color: #fff; font-size: .82rem; font-weight: 700; }
.timing { font-variant-numeric: tabular-nums; }
.player-controls {
  display: flex;
  position: absolute;
  z-index: 3;
  right: 10px;
  bottom: 5px;
  left: 10px;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.screen:has(.play.playing) .player-controls { padding-left: 42px; }
.replay {
  min-height: 41px;
  padding: 3px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  pointer-events: auto;
}
.replay:hover { background: #ffffff26; }
.play {
  display: grid;
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  place-items: center;
  transform: translate(-50%, -50%);
  width: 58px;
  height: 58px;
  padding: 0 0 1px 2px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #141a27;
  box-shadow: 0 2px 10px #0b12295c;
  font: 22px/1 "Segoe UI Symbol", sans-serif;
}
.play:not(.playing):hover { background: #dde6ff; }
.play.playing {
  left: 9px;
  top: auto;
  bottom: 6px;
  transform: none;
  width: 39px;
  height: 39px;
  padding: 0;
  border-radius: 5px;
  background: transparent;
  color: white;
  box-shadow: none;
  font-size: 18px;
}
.play.playing:hover { background: #ffffff26; }
.media-note {
  position: absolute;
  z-index: 5;
  right: 10px;
  bottom: 53px;
  left: 10px;
  width: max-content;
  max-width: calc(100% - 20px);
  margin: auto;
  border-radius: 5px;
  background: #101620ee;
  color: white;
  font-size: .875rem;
  font-weight: 650;
  text-align: center;
}
.media-note:not(:empty) { padding: 4px 8px; }
.film-progress { position: absolute; z-index: 3; inset: auto 0 0; height: 3px; background: #ffffff44; }
.film-progress div { height: 100%; width: 0; background: #6e94ff; }
.hints-panel { margin-top: 10px; border-left: 3px solid var(--accent); padding: 7px 11px; background: var(--accent-soft); font-size: .9rem; }
.hints-panel p:not([hidden]) + p:not([hidden]) { margin-top: 5px; }

.case { margin-top: 10px; }
.case-top { border-bottom: 1px solid var(--line); margin-bottom: 13px; padding: 2px 0 8px; }
.steps { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 0; margin: 0; list-style: none; color: var(--muted); font-size: .875rem; font-weight: 650; }
.steps li[aria-current=step] { color: var(--accent-dark); font-weight: 750; }
.steps li + li::before { content: "/"; margin-right: 7px; color: #78849a; }
.steps li[hidden] + li::before { content: none; }
.potential { color: var(--accent-dark); font-size: .9rem; font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums; }
.region-line { color: var(--accent-dark); font-size: .875rem; font-weight: 750; margin-bottom: 4px; }
.region-line:empty { display: none; }
.instruction { margin: 4px 0 11px; color: var(--muted); font-size: .94rem; }
.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.choices button {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 6px 8px;
  border: 1px solid #c8d2e3;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 680;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-align: left;
}
.choices button:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); }
.choices button.wrong { background: #fdf2f3; border-color: #edc9cd; color: var(--danger); text-decoration: line-through; }
.key { flex: none; display: grid; place-items: center; width: 20px; height: 22px; border-radius: 3px; background: #eaf0fb; color: #33466b; font-size: .75rem; font-weight: 750; text-decoration: none; }
.feedback { margin: 7px 0; color: var(--danger); font-size: .875rem; overflow-wrap: anywhere; }
.feedback:empty { display: none; }
.clue-actions { flex-wrap: wrap; margin-top: 11px; gap: 6px; }
.clue { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 5px 9px; background: var(--surface); }
.clue small { color: var(--muted); font-size: .76rem; white-space: nowrap; }
.clue:disabled:not([aria-pressed=true]) { color: var(--muted); }
.clue[aria-pressed=true] { background: var(--accent-soft); color: var(--accent-dark); }
.clue[aria-pressed=true] small { color: inherit; }

.city-entry { display: flex; position: relative; gap: 7px; }
.city-entry input { width: 100%; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid #adbad0; border-radius: 6px; background: #fff; color: var(--ink); }
.city-entry .primary { min-width: 83px; }
#suggestions { position: absolute; z-index: 6; top: 100%; right: 0; left: 0; padding: 3px; margin: 4px 0 0; border: 1px solid #bec9dc; border-radius: 6px; background: #fff; box-shadow: 0 7px 20px #1822372e; list-style: none; }
#suggestions li { padding: 8px; border-radius: 4px; cursor: pointer; font-size: .92rem; }
#suggestions li:hover, #suggestions li[aria-selected=true] { background: var(--accent-soft); }
.guesses, .stamps { padding: 0; margin: 8px 0 0; list-style: none; }
.guesses:empty { margin: 0; }
.guesses li, .stamps li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .875rem; }
.guesses li span:last-child { color: var(--accent-dark); font-weight: 700; text-align: right; white-space: nowrap; }
.result-country { color: var(--accent-dark); margin-top: 3px; font-weight: 700; }
.result-links { gap: 14px; flex-wrap: wrap; margin: 6px 0 11px; font-size: .9rem; font-weight: 650; }
.result-actions { flex-wrap: wrap; }
#share-fallback textarea { display: block; width: 100%; margin-top: 6px; resize: vertical; }
.game-footer { flex-wrap: wrap; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 3px; color: var(--muted); font-size: .85rem; }
.game-footer p { margin-right: auto; }
.game-footer label { font-weight: 650; }
.game-footer select { min-height: 40px; margin-left: 4px; border: 1px solid var(--line); border-radius: 5px; padding: 4px 8px; background: #fff; color: var(--ink); }
.plain { min-height: 40px; padding-inline: 7px; border-color: transparent; color: var(--muted); font-size: .83rem; text-decoration: underline; text-underline-offset: 3px; }

dialog { max-width: min(520px, calc(100% - 24px)); max-height: 85vh; overflow: auto; border: 1px solid var(--line); border-radius: 9px; padding: 18px; background: #fff; color: var(--ink); box-shadow: 0 12px 45px #171b2448; }
dialog::backdrop { background: #101620a6; }
dialog ol { padding-left: 24px; }
dialog li + li, .help-site { margin-top: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 13px 0; }
.stat-grid div { border: 1px solid var(--line); padding: 6px 9px; border-radius: 6px; background: var(--surface); font-size: .875rem; }
.stat-grid strong { display: block; font-size: 1.25rem; color: var(--accent-dark); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (max-width: 610px) {
  .mode-bar { align-items: flex-start; flex-direction: column; gap: 5px; padding-bottom: 5px; }
  .modes { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modes button { padding-inline: 3px; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  .modes button { font-size: .82rem; }
  .utilities { gap: 4px; }
  .utility { padding-inline: 8px; }
  .play:not(.playing) { width: 48px; height: 48px; font-size: 18px; }
}
