/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg:           #0e0b0c;
  --surface:      #1b1214;
  --surface2:     #251719;
  --border:       #3e2b2e;
  --text:         #F5F2E7;
  --muted:        #9a8a8d;
  --primary:      #800020;
  --primary-dim:  #5D1916;
  --accent:       #D4AF37;
  --accent-dim:   #5D1916;
  --green:        #22c55e;
  --red:          #ef4444;
  --yellow:       #f59e0b;
  --radius:       4px;
  --btn-h:        48px;
  --font:         'Work Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Noto Serif', Georgia, serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 110px; /* anchor bar clearance — tallest unit is 320×100 */
}

/* ── Header / Navbar ─────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  position: sticky;
  top: 0;
  z-index: 400;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}
.logo-icon { font-size: 1.4rem; line-height: 1; }
.logo-text { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; font-family: var(--font-heading); }
.logo-text span { color: var(--accent); }

.header-actions { display: flex; align-items: center; gap: 8px; }

.streak-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 34px;
  padding: 0 10px;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  position: relative;
  cursor: default;
}
.streak-badge[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.streak-badge[data-tooltip]:hover::after,
.streak-badge[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.icon-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 34px; height: 34px;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--text); }

/* ── Ad slots ─────────────────────────────────────────────────────────────── */
.ad-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  max-width: 100%;
  overflow: hidden; /* prevent wide ad units (e.g. 728px leaderboard) from breaking layout */
}

/* Reserve space before ads load — prevents layout shift (CLS).
   Sized to the tallest unit each slot can serve across all breakpoints. */
#ad-header                              { min-height: 250px; } /* tallest: 300×250 / 970×250 */
#ad-incontent-top,
#ad-incontent-mid-1,
#ad-incontent-mid-2                     { min-height: 280px; } /* tallest: 336×280 */

/* ── Main layout ─────────────────────────────────────────────────────────── */
.game-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  position: relative; /* positioning context for the how-to overlay */
}

/* ── Below-game copy (Globle-style) ───────────────────────────────────────── */
.below-copy {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 16px 34px;
  color: var(--text);
}
.below-copy h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  margin: 10px 0 12px;
  letter-spacing: -0.02em;
}
.below-copy h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  margin: 22px 0 10px;
}
.below-copy p {
  margin: 0 0 16px;
  color: var(--text);
  line-height: 1.75;
  font-size: 1.06rem;
}
.below-steps {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.75;
  font-size: 1.06rem;
}
.below-steps li { margin: 10px 0; }

.ad-slot--between-copy {
  margin: 18px auto 8px;
  max-width: 720px;
}

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.progress-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.progress-dots {
  display: flex;
  gap: 6px;
}
.pdot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}
.pdot.correct { background: var(--green); }
.pdot.failed  { background: var(--red); }
.pdot.active  { background: var(--accent); }

/* ── Movie card ──────────────────────────────────────────────────────────── */
.movie-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  margin-bottom: 16px;
}

/* Poster — overflow:hidden here contains the blur/scale effect without
   clipping the autocomplete dropdown that lives outside this element */
.poster-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.poster-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0; left: 0;
  transition: filter 0.6s ease, transform 0.6s ease;
  filter: blur(16px);
  transform: scale(1.08);
}
.poster-img.blur-0 { filter: blur(0); transform: scale(1); }

.poster-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1b1214 0%, #251719 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 3rem;
}
.poster-placeholder span { font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; }

.reveal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.reveal-overlay.visible { opacity: 1; }
.reveal-title {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font-heading);
  color: #fff;
  text-align: center;
  padding: 0 16px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
.reveal-year {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
}

.poster-tagline {
  margin: 0;
  padding: 12px 16px 10px;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-body);
}

/* Genre — always-visible strip above the hint chips */
.genre-display {
  padding: 8px 16px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

/* Hints */
.hints-row {
  display: flex;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  justify-content: center;
  flex-wrap: wrap;
}
.hint-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  color: var(--muted);
  background: transparent;
  transition: all 0.3s ease;
  min-width: 96px;
  text-align: center;
}
.hint-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #a89a9d;
  opacity: 1;
}
.hint-icon {
  opacity: 0.35;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hint-text {
  display: none;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}
.hint-chip.revealed {
  border-style: solid;
  border-color: var(--accent-dim);
  background: rgba(245, 166, 35, 0.08);
  color: var(--accent);
  animation: hint-pop 0.4s ease;
}
.hint-chip.revealed .hint-label {
  opacity: 0.75;
}
.hint-chip.revealed .hint-icon {
  display: none;
}
.hint-chip.revealed .hint-text {
  display: block;
}

@keyframes hint-pop {
  0%   { transform: scale(0.85); opacity: 0; }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* Guess history */
.guess-history {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.guess-history:empty { display: none; }

.guess-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  animation: slide-in 0.2s ease;
}
.guess-item::before {
  content: '✗';
  color: var(--red);
  font-weight: 700;
  font-size: 0.75rem;
}
@keyframes slide-in {
  from { transform: translateX(-8px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Input area ──────────────────────────────────────────────────────────── */
.input-area {
  padding: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
}

.input-wrap { flex: 1; position: relative; }

.guess-input {
  width: 100%;
  height: var(--btn-h);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  padding: 0 14px;
  outline: none;
  font-family: var(--font);
  transition: border-color 0.15s;
}
.guess-input:focus { border-color: var(--accent); }
.guess-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.guess-input::placeholder { color: var(--muted); }

/* Autocomplete dropdown */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 200;
  max-height: 280px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.autocomplete-list:empty { display: none; }

.ac-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.selected { background: var(--surface); }
.ac-item .ac-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}
.ac-item .ac-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}
.ac-item .ac-year {
  float: right;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Submit button */
.submit-btn {
  background: var(--primary);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  height: var(--btn-h);
  padding: 0 18px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.submit-btn:hover:not(:disabled) { opacity: 0.88; }
.submit-btn:active:not(:disabled) { transform: scale(0.97); }
.submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Shake animation on wrong guess */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
.shake { animation: shake 0.4s ease; }

/* ── Between-movie message ───────────────────────────────────────────────── */
.result-banner {
  text-align: center;
  padding: 20px 16px;
  display: none;
}
.result-banner.visible { display: block; }
.result-banner .rb-icon { font-size: 2.5rem; margin-bottom: 8px; }
.result-banner .rb-title { font-size: 1.1rem; font-weight: 700; font-family: var(--font-heading); color: #fff; margin-bottom: 4px; }
.result-banner .rb-sub { font-size: 0.85rem; color: var(--muted); }
.result-banner .rb-answer { color: var(--accent); font-weight: 600; }
.next-btn {
  margin-top: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 22px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.next-btn:hover { background: var(--surface); }

/* Skip modal dialog buttons — match --btn-h, no top margin */
#skip-modal .next-btn {
  height: var(--btn-h);
  margin-top: 0;
  padding: 0 18px;
  justify-content: center;
}

/* ── Results screen ──────────────────────────────────────────────────────── */
#results-screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 32px 16px 24px;
  text-align: center;
}
#results-screen h2 {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font-heading);
  margin-bottom: 4px;
}
.results-date {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ── Results: poster strip ───────────────────────────────────────────────── */
.results-posters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto 22px;
  padding: 0 4px;
}

.results-poster-card {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: results-poster-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(0.06s * var(--i, 0));
}

@keyframes results-poster-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.results-poster-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.results-poster-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: linear-gradient(145deg, var(--surface2), var(--surface));
  color: var(--muted);
}

.results-poster-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 35%,
    rgba(14, 11, 12, 0.55) 100%
  );
}

.results-poster-card--miss .results-poster-shade {
  background: linear-gradient(
    180deg,
    rgba(14, 11, 12, 0.25) 0%,
    rgba(14, 11, 12, 0.75) 100%
  );
}

.results-poster-card--miss img,
.results-poster-card--miss .results-poster-ph {
  filter: grayscale(0.35) brightness(0.72);
}

.results-poster-badge {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(0.85rem, 3.8vw, 1.05rem);
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
}

.results-poster-card--hit {
  border-color: rgba(212, 175, 55, 0.5);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(212, 175, 55, 0.2);
}

.results-return {
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Modals (how-to, skip confirm) ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  transform: scale(0.95);
  transition: transform 0.3s;
}
.modal-overlay.visible .modal-box { transform: scale(1); }

.modal-box h2 { font-size: 1.2rem; font-weight: 700; font-family: var(--font-heading); margin-bottom: 4px; }

.score-display {
  font-size: 2.4rem;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--accent);
  margin-bottom: 4px;
}
.score-sub { font-size: 0.82rem; color: var(--muted); margin-bottom: 20px; }

.share-btn {
  width: 100%;
  background: #25D366;  /* WhatsApp green */
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
  transition: opacity 0.15s;
}
.share-btn:hover { opacity: 0.9; }

.copy-btn {
  width: 100%;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.copy-btn:hover { background: var(--surface); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
}
.modal-box { position: relative; }

/* How-to overlay sits inside .game-wrap (position: relative), so it covers
   only the game area — ads above and below the game remain fully visible.
   z-index 250 keeps it above the autocomplete dropdown (200) but below the
   fixed anchor bar (300). */
#how-modal {
  position: absolute;
  z-index: 250;
  border-radius: var(--radius);
}

.how-play-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  background: var(--primary);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  height: var(--btn-h);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}
.how-play-btn:hover { opacity: 0.88; }

/* ── How to play modal ───────────────────────────────────────────────────── */
.how-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
  text-align: left;
}
.how-step .step-num {
  width: 26px; height: 26px;
  flex-shrink: 0;
  background: var(--primary);
  color: var(--text);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.how-step .step-text { font-size: 0.85rem; color: var(--muted); line-height: 1.5; }
.how-step .step-text strong { color: var(--text); }
.hint-legend {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.hl-item { font-size: 0.82rem; color: var(--muted); display: flex; align-items: center; gap: 4px; }

/* ── Skip button ─────────────────────────────────────────────────────────── */
.skip-row {
  display: flex;
  justify-content: center;
  padding: 0 14px 14px;
  animation: fade-in 0.25s ease;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.skip-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 20px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.skip-btn:hover { border-color: var(--red); color: var(--red); }

/* ── Anchor bar ──────────────────────────────────────────────────────────── */
.anchor-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  gap: 0;
}

/* ── Dev tools (localhost only) ──────────────────────────────────────────── */
.dev-reset-btn {
  position: absolute;
  top: calc(100% + 6px);
  left: 12px;
  background: #0d0d14;
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.35);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.72rem;
  font-family: 'Courier New', monospace;
  cursor: pointer;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.dev-reset-btn--visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

@media (min-width: 520px) {
  .game-wrap { padding: 24px 16px; }
}
