/* ============================================================
   PREMIER·DLE — style.css
   Aesthetic: Dark sports broadcast — editorial, high-contrast,
   premium. Inspired by Sky Sports / broadcast graphics.
   Font: Barlow Condensed (display) + Barlow (body)
   ============================================================ */

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

:root {
  /* Colours */
  --bg:           #0d0d0f;
  --surface:      #18181c;
  --surface-2:    #222228;
  --border:       #2e2e38;
  --text-primary: #f0f0f5;
  --text-muted:   #7a7a8e;
  --accent:       #00d4ff;       /* electric cyan — broadcast monitor glow */
  --accent-dim:   #00d4ff22;

  /* Feedback colours */
  --green:        #00c96e;
  --green-bg:     #00c96e22;
  --yellow:       #f5c400;
  --yellow-bg:    #f5c40022;
  --grey:         #3a3a48;
  --grey-text:    #6a6a7e;

  /* Typography */
  --font-display: 'Barlow Condensed', sans-serif;
  --font-body:    'Barlow', sans-serif;

  /* Layout */
  --max-w:        680px;
  --radius:       6px;
  --header-h:     64px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* Subtle scanline texture for broadcast feel */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255,255,255,0.012) 2px,
      rgba(255,255,255,0.012) 4px
    );
}

/* ── HEADER ─────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
}

.header-left  { display: flex; align-items: center; }
.header-right { display: flex; align-items: center; justify-content: flex-end; }

/* Logo */
.logo-wrap { text-align: center; }

.logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(22px, 5vw, 30px);
  letter-spacing: 0.06em;
  color: var(--text-primary);
  line-height: 1;
}

.logo-dot { color: var(--accent); }

.logo-sub {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Streak badge */
.streak-badge {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  cursor: default;
}

.streak-badge #streakCount {
  color: var(--accent);
}

/* Icon buttons */
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
  max-width: 440px;
  width: 100%;
  position: relative;
  animation: slideUp 0.25s ease;
}

.modal h2 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 26px;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.modal p {
  color: var(--text-muted);
  margin-bottom: 16px;
  font-size: 14px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover { color: var(--text-primary); }

/* Legend */
.legend { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }

.legend-row {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--text-muted);
}

.cell-demo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: var(--radius);
  min-width: 60px;
  text-align: center;
  display: inline-block;
}

.cell-demo.green  { background: var(--green-bg);  color: var(--green);  border: 1px solid var(--green); }
.cell-demo.yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow); }
.cell-demo.grey   { background: var(--grey);       color: var(--grey-text); border: 1px solid transparent; }

.legend-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Result player card */
.result-player {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 16px 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--green);
}

/* Countdown */
.next-label {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 16px;
}

.next-label strong { color: var(--accent); }

.share-confirm {
  font-size: 12px;
  color: var(--green);
  text-align: center;
  min-height: 18px;
  transition: opacity 0.3s;
}

/* ── MAIN LAYOUT ─────────────────────────────────────────── */
.game-container {
  flex: 1;
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── GUESS GRID ──────────────────────────────────────────── */
.guess-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1.6fr 1fr 1fr 1fr;
  gap: 4px;
  margin-bottom: 4px;
}

/* Header row */
.header-row {
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.cell-header {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 4px;
  text-align: center;
}

.cell-header:first-child { text-align: left; }

/* Guess row */
.guess-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1.6fr 1fr 1fr 1fr;
  gap: 4px;
  margin-bottom: 4px;
  opacity: 0;
  animation: rowReveal 0.35s ease forwards;
}

.guess-row:nth-child(1) { animation-delay: 0s; }
.guess-row:nth-child(2) { animation-delay: 0.05s; }
.guess-row:nth-child(3) { animation-delay: 0.1s; }
.guess-row:nth-child(4) { animation-delay: 0.15s; }
.guess-row:nth-child(5) { animation-delay: 0.2s; }
.guess-row:nth-child(6) { animation-delay: 0.25s; }
.guess-row:nth-child(7) { animation-delay: 0.3s; }
.guess-row:nth-child(8) { animation-delay: 0.35s; }

/* Individual cell */
.guess-cell {
  font-family: var(--font-display);
  font-size: clamp(11px, 2.5vw, 14px);
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 10px 6px;
  border-radius: var(--radius);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  position: relative;
  overflow: hidden;
  word-break: break-word;
  hyphens: auto;
  transition: transform 0.15s ease;
  /* Cell flip animation */
  transform-style: preserve-3d;
}

.guess-cell:first-child {
  text-align: left;
  justify-content: flex-start;
  padding-left: 10px;
  font-size: clamp(11px, 2.5vw, 13px);
}

/* Colour states */
.guess-cell.green {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(0, 201, 110, 0.35);
}

.guess-cell.yellow {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid rgba(245, 196, 0, 0.35);
}

.guess-cell.grey {
  background: var(--grey);
  color: var(--grey-text);
  border: 1px solid transparent;
}

/* Staggered flip-in for cells within a row */
.guess-row .guess-cell:nth-child(1) { animation: cellFlip 0.4s ease 0.0s both; }
.guess-row .guess-cell:nth-child(2) { animation: cellFlip 0.4s ease 0.07s both; }
.guess-row .guess-cell:nth-child(3) { animation: cellFlip 0.4s ease 0.14s both; }
.guess-row .guess-cell:nth-child(4) { animation: cellFlip 0.4s ease 0.21s both; }
.guess-row .guess-cell:nth-child(5) { animation: cellFlip 0.4s ease 0.28s both; }
.guess-row .guess-cell:nth-child(6) { animation: cellFlip 0.4s ease 0.35s both; }

/* Arrow indicator */
.arrow {
  font-size: 10px;
  margin-left: 3px;
  opacity: 0.85;
}

/* ── INPUT AREA ──────────────────────────────────────────── */
.input-area {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  position: relative;
}

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

.search-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Autocomplete dropdown */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.autocomplete-list[hidden] { display: none; }

.autocomplete-item {
  padding: 11px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--surface-2);
  color: var(--accent);
}

.autocomplete-item .item-club {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Guess button */
.btn-guess {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.1em;
  padding: 12px 22px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.btn-guess:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-guess:not(:disabled):hover { opacity: 0.88; }
.btn-guess:not(:disabled):active { transform: scale(0.97); }

/* Primary button (modals) */
.btn-primary {
  display: block;
  width: 100%;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.1em;
  padding: 14px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 20px;
  transition: opacity 0.2s;
}

.btn-primary:hover { opacity: 0.88; }

/* Guesses remaining */
.guesses-left {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  margin-top: 12px;
  text-transform: uppercase;
}

/* ── FOOTER ──────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 20px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  letter-spacing: 0.04em;
}

/* ── GAME OVER / DISABLED STATE ──────────────────────────── */
.input-area.disabled .search-input,
.input-area.disabled .btn-guess {
  opacity: 0.35;
  pointer-events: none;
}

/* ── KEYFRAMES ───────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

@keyframes cellFlip {
  0%   { opacity: 0; transform: scaleY(0.4) rotateX(60deg); }
  60%  { opacity: 1; transform: scaleY(1.05) rotateX(-6deg); }
  100% { opacity: 1; transform: scaleY(1) rotateX(0deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ── SCROLLBAR ───────────────────────────────────────────── */
.autocomplete-list::-webkit-scrollbar { width: 4px; }
.autocomplete-list::-webkit-scrollbar-track { background: var(--surface); }
.autocomplete-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 520px) {
  .game-container { padding: 16px 10px 32px; }

  /* Make grid horizontally scrollable on very small screens */
  .header-row,
  #guessBoard {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .guess-grid,
  .guess-row {
    min-width: 460px;
  }

  .guess-cell { font-size: 11px; padding: 8px 4px; min-height: 40px; }
  .guess-cell:first-child { padding-left: 8px; }
}

@media (max-width: 360px) {
  .logo { font-size: 20px; }
  .logo-sub { display: none; }
}
