/* Self-hosted Cinema Editorial Typography */
@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/instrument-serif-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/instrument-serif-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/instrument-serif-400-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("./fonts/dm-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("./fonts/dm-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("./fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0c0c0d;
  --surface: #151517;
  --surface-2: #1d1d21;
  --surface-3: #26262b;
  --border: rgba(244, 239, 228, 0.1);
  --border-strong: rgba(244, 239, 228, 0.2);
  --text: #f4efe4;
  --text-secondary: #ccc6b9;
  --muted: #9b9589;
  --accent: #e4b64c;
  --accent-hover: #efc663;
  --accent-soft: rgba(228, 182, 76, 0.14);
  --accent-border: rgba(228, 182, 76, 0.42);
  --accent-ink: #14110a;
  --perfect: #3aa76d;
  --perfect-soft: rgba(58, 167, 109, 0.16);
  --perfect-ink: #7de2ab;
  --good: #d9a032;
  --good-soft: rgba(217, 160, 50, 0.16);
  --good-ink: #f4cf75;
  --close: #df7430;
  --close-soft: rgba(223, 116, 48, 0.16);
  --close-ink: #f6ae7c;
  --missed: #cf4646;
  --missed-soft: rgba(207, 70, 70, 0.16);
  --missed-ink: #f69696;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

[hidden] {
  display: none !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

::selection {
  background: rgba(228, 182, 76, 0.3);
  color: var(--text);
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 85% 42% at 50% -8%, rgba(228, 182, 76, 0.065), transparent 72%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(244, 239, 228, 0.16);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(244, 239, 228, 0.28);
}

.app-shell {
  max-width: 720px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Topbar */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  min-width: 0;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  height: 36px;
  padding: 0 10px 0 6px;
  margin-left: -6px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: color 0.16s var(--ease-out), background 0.16s var(--ease-out);
}

.back-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  min-width: 0;
}

.topbar-brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--text);
  white-space: nowrap;
}

.puzzle-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.4;
  transform: translateY(-2px);
}

.topbar-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  appearance: none;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 9px;
  height: 36px;
  min-width: 36px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.icon-btn.text-btn {
  font-size: 12px;
  padding: 0 12px;
  letter-spacing: 0.01em;
}

.icon-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

/* 5-Round Progress Stepper */
.progress-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.round-pills {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.round-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

.round-pill.active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.round-pill.perfect {
  border-color: rgba(58, 167, 109, 0.45);
  background: var(--perfect-soft);
}

.round-pill.good {
  border-color: rgba(217, 160, 50, 0.45);
  background: var(--good-soft);
}

.round-pill.close {
  border-color: rgba(223, 116, 48, 0.45);
  background: var(--close-soft);
}

.round-pill.missed {
  border-color: rgba(207, 70, 70, 0.45);
  background: var(--missed-soft);
}

.round-num {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.round-pill.active .round-num {
  background: var(--accent);
  color: var(--accent-ink);
}

.round-pill.perfect .round-num { background: var(--perfect); color: #06180f; }
.round-pill.good .round-num { background: var(--good); color: var(--accent-ink); }
.round-pill.close .round-num { background: var(--close); color: #190b03; }
.round-pill.missed .round-num { background: var(--missed); color: #fff; }

.round-tier {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.round-pill.active .round-tier,
.round-pill.perfect .round-tier,
.round-pill.good .round-tier,
.round-pill.close .round-tier,
.round-pill.missed .round-tier {
  color: var(--text);
}

.score-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 5px 11px;
  height: 34px;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.score-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-right: 3px;
}

.score-pill strong {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.score-max {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

/* Main Stage */
.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.play-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Cinema Frame Card — Zero Overlays on Image */
.frame-card {
  background: #070708;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.52);
}

.frame-slate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px 6px 14px;
  background: #111113;
  border-bottom: 1px solid var(--border);
  min-height: 36px;
}

.slate-round {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slate-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.timecode-chip {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: rgba(228, 182, 76, 0.1);
  border: 1px solid rgba(228, 182, 76, 0.25);
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.slate-zoom-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.slate-zoom-btn:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

.frame-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #050506;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  overflow: hidden;
}

.frame-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  transition: opacity 0.28s var(--ease-out);
}

/* Clue Strip — Crisp 2-Column Metadata Bar */
.clue-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 8px;
}

.clue-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  transition: border-color 0.22s var(--ease-out), background 0.22s var(--ease-out);
}

.clue-chip.unlocked {
  border-color: var(--accent-border);
  background: rgba(228, 182, 76, 0.05);
  animation: clueReveal 0.26s var(--ease-out);
}

@keyframes clueReveal {
  from {
    opacity: 0.4;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.clue-chip.locked {
  border-style: dashed;
  border-color: rgba(244, 239, 228, 0.14);
  background: rgba(21, 21, 23, 0.65);
}

.clue-head {
  display: flex;
  align-items: center;
  gap: 5px;
}

.clue-k {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.clue-chip.locked .clue-k {
  color: var(--muted);
}

.clue-lock-icon {
  color: var(--muted);
  flex-shrink: 0;
}

.clue-v {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
  overflow-wrap: break-word;
}

.clue-chip.locked .clue-v {
  color: var(--muted);
  font-weight: 400;
}

/* Guess Panel & Reveal Panel */
.guess-panel,
.reveal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.attempt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.attempt-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.attempt-pips {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pip {
  width: 26px;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
}

.pip.current {
  border-color: var(--accent);
  background: rgba(228, 182, 76, 0.35);
}

.pip.wrong {
  background: var(--missed);
  border-color: var(--missed);
}

.pip.skipped {
  background: #67635c;
  border-color: #67635c;
}

.pip.won {
  background: var(--perfect);
  border-color: var(--perfect);
}

.attempt-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stake-badge {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.guess-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: start;
}

.autocomplete-wrap {
  position: relative;
}

#guess-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #0d0d0f;
  color: var(--text);
  caret-color: var(--accent);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}

#guess-input::placeholder {
  color: #847e73;
}

#guess-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(228, 182, 76, 0.16);
}

.suggestions-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  margin: 0;
  padding: 5px;
  list-style: none;
  background: #1a1a1e;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65);
  max-height: 244px;
  overflow-y: auto;
}

.suggestions-list.open-up {
  top: auto;
  bottom: calc(100% + 6px);
  box-shadow: 0 -14px 36px rgba(0, 0, 0, 0.65);
}

.suggestions-list li {
  padding: 9px 11px;
  border-radius: 7px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 0.1s;
}

.suggestions-list li:hover,
.suggestions-list li.highlighted {
  background: rgba(228, 182, 76, 0.17);
  color: #fff;
}

.sugg-year {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  flex-shrink: 0;
}

/* Tactile Buttons */
.btn {
  appearance: none;
  height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn.secondary:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.btn.wide {
  width: 100%;
}

.status-msg {
  margin: 8px 0 0;
  font-size: 13px;
  color: #f4be6b;
  line-height: 1.4;
}

.status-msg:empty {
  display: none;
}

.attempt-history {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attempt-history:empty {
  display: none;
}

.attempt-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.attempt-row .attempt-name {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  min-width: 0;
}

.attempt-icon {
  flex-shrink: 0;
  color: var(--missed-ink);
}

.attempt-row.skipped .attempt-icon {
  color: var(--muted);
}

.attempt-row.skipped .attempt-name {
  color: var(--muted);
  font-style: italic;
}

.feedback-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.fb-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(244, 239, 228, 0.08);
  color: var(--text-secondary);
}

.fb-tag.hit {
  background: var(--perfect-soft);
  color: var(--perfect-ink);
}

/* Reveal Panel */
.reveal-panel {
  animation: clueReveal 0.25s var(--ease-out);
}

.reveal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.reveal-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 3px 10px;
  border-radius: 999px;
}

.reveal-badge.perfect { background: var(--perfect-soft); color: var(--perfect-ink); }
.reveal-badge.good { background: var(--good-soft); color: var(--good-ink); }
.reveal-badge.close { background: var(--close-soft); color: var(--close-ink); }
.reveal-badge.missed { background: var(--missed-soft); color: var(--missed-ink); }

.reveal-points {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.reveal-title {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(26px, 3.8vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--text);
}

.reveal-meta {
  margin: 0 0 3px;
  font-size: 13px;
  color: var(--muted);
}

.reveal-cast {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Summary View */
.summary-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.summary-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 20px;
  text-align: center;
}

.summary-heading {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(26px, 4.5vw, 34px);
  line-height: 1.1;
  color: var(--text);
}

.summary-score-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.summary-score {
  font-size: clamp(44px, 8vw, 60px);
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}

.summary-max {
  font-size: 20px;
  color: var(--muted);
}

.summary-subrow {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-pill {
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.summary-pill.accent {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.summary-emoji {
  margin: 14px 0 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.result-pip {
  width: 28px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: inline-block;
}

.result-pip.perfect { background: var(--perfect); }
.result-pip.good { background: var(--good); }
.result-pip.close { background: var(--close); }
.result-pip.missed { background: var(--missed); }

.summary-item-pip {
  width: 14px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  margin-bottom: 4px;
}

.summary-item-pip.perfect { background: var(--perfect); }
.summary-item-pip.good { background: var(--good); }
.summary-item-pip.close { background: var(--close); }
.summary-item-pip.missed { background: var(--missed); }

.summary-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.share-feedback {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--perfect-ink);
  font-weight: 600;
}

.share-feedback:empty {
  display: none;
}

.countdown-line {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.countdown-line:empty {
  display: none;
}

.summary-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.summary-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  transition: border-color 0.16s;
}

.summary-item:hover {
  border-color: var(--border-strong);
}

.summary-thumb {
  width: 120px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: #050506;
  cursor: zoom-in;
  display: block;
}

.summary-item-info {
  min-width: 0;
}

.summary-item-tier {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.summary-item-info h3 {
  margin: 2px 0 2px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 20px;
  line-height: 1.15;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-item-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-item-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.summary-item-pts {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 5, 6, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 14px;
}

.lightbox img {
  max-width: 96vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(21, 21, 23, 0.9);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.lightbox-close:hover {
  background: var(--surface-3);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(5, 5, 6, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 432px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.1;
}

.modal-close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface-2);
}

.modal-subhead {
  margin: 18px 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}

.stat-box strong {
  display: block;
  font-family: var(--mono);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-box span {
  font-size: 11px;
  color: var(--muted);
}

.tier-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tier-bar-row {
  display: grid;
  grid-template-columns: 88px 1fr 40px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.tier-track {
  height: 9px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.tier-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.tier-pct {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--muted);
}

.help-lead {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.help-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}

.help-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
}

.dot.perfect { background: var(--perfect); }
.dot.good { background: var(--good); }
.dot.close { background: var(--close); }
.dot.missed { background: var(--missed); }

.help-note {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  gap: 10px;
}

/* Mobile Responsive — Crisp 390px+ Craft */
@media (max-width: 600px) {
  .app-shell {
    padding: 10px 12px 18px;
    gap: 9px;
  }

  /* Compact 1-row topbar with zero wrapping */
  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding-bottom: 9px;
  }

  .back-label {
    display: none;
  }

  .back-link {
    width: 40px;
    height: 40px;
    padding: 0;
    margin-left: 0;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
  }

  .topbar-brand {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
  }

  .topbar-brand h1 {
    font-size: 22px;
    line-height: 1;
  }

  .puzzle-badge {
    font-size: 10px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    transform: none;
    line-height: 1.2;
  }

  .topbar-right {
    gap: 5px;
  }

  .icon-btn {
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
  }

  .icon-btn.text-btn {
    padding: 0 11px;
    font-size: 12px;
  }

  /* Stepper */
  .progress-bar {
    gap: 8px;
  }

  .round-tier {
    display: none;
  }

  .round-pill {
    justify-content: center;
    padding: 6px 4px;
  }

  .score-pill {
    padding: 5px 9px;
  }

  /* Frame slate */
  .frame-slate {
    padding: 5px 8px 5px 12px;
    min-height: 34px;
  }

  .slate-round {
    font-size: 10px;
    letter-spacing: 0.06em;
  }

  .timecode-chip {
    font-size: 11px;
    padding: 2px 7px;
  }

  /* Clues: full-width stacked editorial strips */
  .clue-bar {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .clue-chip {
    padding: 8px 11px;
  }

  /* Guess panel */
  .guess-panel,
  .reveal-panel {
    padding: 13px;
  }

  .guess-form {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .autocomplete-wrap {
    grid-column: 1 / -1;
  }

  #guess-input {
    height: 46px;
    font-size: 16px;
  }

  .btn {
    height: 46px;
  }

  /* Summary mobile */
  .summary-hero {
    padding: 18px 14px;
  }

  .summary-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .summary-actions .btn {
    padding: 0 12px;
    font-size: 13px;
  }

  .summary-item {
    grid-template-columns: 88px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 9px 10px;
  }

  .summary-thumb {
    width: 88px;
  }

  .summary-item-info h3 {
    font-size: 17px;
  }

  .app-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 3px;
    font-size: 11px;
  }
}

/* Option A: Mobile Dedicated Search Sheet */
.search-sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100dvh;
  z-index: 80;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: sheetIn 0.16s var(--ease-out);
}

@keyframes sheetIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sheet-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  gap: 8px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.sheet-context {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 8px 6px 6px;
  flex-shrink: 0;
}

.sheet-thumb {
  width: 76px;
  height: 43px;
  object-fit: cover;
  border-radius: 7px;
  background: #050506;
  flex-shrink: 0;
  cursor: zoom-in;
}

.sheet-meta {
  flex: 1;
  min-width: 0;
}

.sheet-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-sub {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 2px;
}

.sheet-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.sheet-clue {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(228, 182, 76, 0.08);
  border: 1px solid rgba(228, 182, 76, 0.25);
  border-radius: 9px;
  padding: 6px 10px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  flex-shrink: 0;
}

.sheet-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

#sheet-input {
  width: 100%;
  height: 46px;
  padding: 0 38px 0 13px;
  border-radius: 10px;
  border: 1.5px solid var(--accent);
  background: #101012;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  box-shadow: 0 0 0 3px rgba(228, 182, 76, 0.14);
}

.sheet-clear-btn {
  position: absolute;
  right: 6px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sheet-submit {
  height: 46px;
  padding: 0 16px;
}

.sheet-results {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sheet-results li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.sheet-results li:active,
.sheet-results li.highlighted {
  background: rgba(228, 182, 76, 0.18);
  border-color: rgba(228, 182, 76, 0.5);
}

.sheet-empty {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 20px 12px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
