/* ── Reset & base ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f13;
  --surface:   #1a1a22;
  --border:    #2e2e3a;
  --accent:    #e2b94b;
  --accent-dim:#a07d28;
  --text:      #e8e8f0;
  --muted:     #888899;
  --correct:   #4caf74;
  --wrong:     #c0392b;
  --radius:    10px;
  --poster-w:  140px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 60px;
}

/* ── Header ─────────────────────────────────── */
header {
  text-align: center;
  padding: 32px 0 20px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

#streak-display {
  display: none;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(226,185,75,0.12);
  border: 1px solid rgba(226,185,75,0.3);
  border-radius: 6px;
  padding: 4px 12px;
  cursor: default;
}

.site-logo {
  height: 2.2rem;
  width: auto;
  vertical-align: middle;
  margin-bottom: 4px;
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--accent);
}

header .subtitle {
  color: #c8c8d8;
  margin-top: 4px;
  font-size: 0.95rem;
}

#practice-banner {
  display: none;
  margin-top: 8px;
  background: rgba(100,180,255,0.1);
  border: 1px solid rgba(100,180,255,0.3);
  border-radius: 4px;
  color: #64b4ff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 3px 12px;
  text-transform: uppercase;
}

.header-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

#how-to-play-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

#how-to-play-btn:hover { color: var(--text); border-color: var(--muted); }

#stats-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

#stats-btn:hover { color: var(--text); border-color: var(--muted); }

#practice-btn {
  margin-top: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

#practice-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--muted);
}

#practice-btn:disabled { opacity: 0.45; cursor: default; }

/* ── Main container ──────────────────────────── */
main {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ── Clue grid ───────────────────────────────── */
#clue-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
}

.clue-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.35s ease;
}

.clue-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(226,185,75,0.12);
  border: 1px solid rgba(226,185,75,0.3);
  border-radius: 4px;
  padding: 3px 10px;
}

.clue-poster {
  width: var(--poster-w);
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  object-fit: cover;
  border: 2px solid var(--border);
  display: block;
  background: var(--surface);
  background-image: linear-gradient(90deg, var(--surface) 25%, #24243080 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.clue-poster-placeholder {
  width: var(--poster-w);
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 2rem;
}

.clue-hint-title {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  max-width: var(--poster-w);
  line-height: 1.3;
}

.clue-connection {
  font-size: 0.9rem;
  font-weight: 700;
  color: #f0ece0;
  background: rgba(192, 57, 43, 0.75);
  border: 1px solid var(--accent);
  text-align: center;
  max-width: var(--poster-w);
  margin-top: 4px;
  padding: 3px 10px;
  border-radius: 4px;
  animation: connectionPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes connectionPop {
  0%   { opacity: 0; transform: scale(0.5); }
  70%  { transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

/* ── Guess input ─────────────────────────────── */
#guess-section {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

#search-wrapper {
  position: relative;
  flex: 1;
}

#search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}

#search-input:focus {
  border-color: var(--accent);
}

#search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

#search-results.open { display: block; }

#search-results li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.1s;
}

#search-results li:hover,
#search-results li.active {
  background: rgba(255,255,255,0.06);
}

#search-results li img {
  width: 32px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--border);
}

.result-year {
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: auto;
  flex-shrink: 0;
}

#guess-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

#guess-btn:hover:not(:disabled) { background: #f0c84e; }
#guess-btn:disabled { opacity: 0.35; cursor: default; }

/* ── Guess history ───────────────────────────── */
#guess-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guess-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  animation: fadeIn 0.25s ease;
}

.guess-row .guess-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.guess-row .guess-name {
  flex: 1;
  font-size: 0.95rem;
}

.guess-row.wrong  { border-left: 3px solid var(--wrong); }
.guess-row.correct { border-left: 3px solid var(--correct); }

/* ── End screen ──────────────────────────────── */
#end-screen {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

#end-screen.hidden { display: none; }

#end-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: popIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

#end-close-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s;
}

#end-close-btn:hover { color: var(--text); }

#end-streak {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
}

#end-emoji   { font-size: 2.8rem; }
#end-title   { font-size: 1.4rem; font-weight: 800; }
#end-message { color: var(--muted); font-size: 0.9rem; }

#end-poster {
  width: 120px;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--border);
}

#end-movie-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
}

.community-stat {
  margin: 4px 0;
  font-size: 0.88rem;
  color: var(--muted);
}

#community-stats {
  margin: 10px 0 4px;
}

#share-btn {
  margin-top: 6px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 11px 28px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

#share-btn:hover { background: #f0c84e; }

#new-practice-btn {
  margin-top: 4px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 11px 28px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  display: none;
}

#new-practice-btn:hover { background: rgba(226,185,75,0.1); }

#next-puzzle {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#next-puzzle-label {
  font-size: 0.75rem;
  color: var(--muted);
}

#next-puzzle-countdown {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

/* ── Tutorial overlay ────────────────────────────── */
#tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}

#tutorial-overlay.hidden { display: none; }

#tutorial-card {
  background: #0d2b1a;
  border: 1px solid #1e6b3a;
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: popIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.tutorial-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  color: var(--accent);
}

.tutorial-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tutorial-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.step-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}

.step-text strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 3px;
}

.step-text p {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.step-text em {
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
}

#tutorial-got-it {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}

#tutorial-got-it:hover { background: #f0c84e; }

.tutorial-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: -8px;
}

/* ── Stats modal ─────────────────────────────────── */
#stats-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

#stats-modal.hidden { display: none; }

#stats-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 380px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: popIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

#stats-close-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s;
}

#stats-close-btn:hover { color: var(--text); }

.stats-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  color: var(--text);
}

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

.stat-cell { display: flex; flex-direction: column; gap: 4px; }

.stat-num {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stats-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

#stats-distribution {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dist-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  width: 12px;
  text-align: right;
  flex-shrink: 0;
}

.dist-bar {
  min-width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  transition: width 0.4s ease;
}

.dist-bar.filled {
  background: var(--accent);
  color: #000;
}

/* ── Animations ──────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── No puzzle state ─────────────────────────── */
#no-puzzle {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}

#no-puzzle h2 { color: var(--text); margin-bottom: 8px; }

/* ── Scrollbar ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
