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

html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease !important;
}

/* Team colors (unchanged across themes) */
:root {
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --header-h: 56px;

  --csk: #f7d000;
  --mi: #004ba0;
  --rcb: #c8102e;
  --kkr: #3a225d;
  --srh: #ff6600;
  --rr: #f15a29;
  --gt: #1d4d8e;
  --dc: #004c97;
  --lsg: #a0e0d0;
  --pbks: #aa1e22;
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #0f0f13;
  --surface: #1a1a22;
  --border: #2e2e3a;
  --text: #f0f0f5;
  --muted: #8888a0;
}

/* Light theme */
[data-theme="light"] {
  --bg: #f4f4f8;
  --surface: #ffffff;
  --border: #d8d8e8;
  --text: #1a1a2e;
  --muted: #666688;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
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: 900px;
  margin: 0 auto;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
}

.logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  text-align: center;
}

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

.nav-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--border); color: var(--text); }

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

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--border); }
.hard-btn { font-size: 0.85rem; }
.hard-btn.hard-active { border-color: var(--yellow); color: var(--yellow); }

.streak-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.timer-display {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 36px;
  text-align: center;
}

.result-time {
  text-align: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 4px;
}

/* ===== MAIN ===== */
main {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 24px 16px 80px;
}

.subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.day-nav-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.day-nav-btn:hover:not(:disabled) { color: var(--text); }
.day-nav-btn:disabled { opacity: 0.25; cursor: default; }

.archive-badge {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: var(--yellow);
  font-weight: 600;
  margin-top: -8px;
  margin-bottom: 8px;
}

.yesterday-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 16px;
  opacity: 0.7;
}

/* ===== SEARCH ===== */
.search-wrap {
  position: relative;
  max-width: 420px;
  margin: 0 auto 12px;
}

#search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 1rem;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}
#search-input:focus { border-color: var(--green); }

#autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  list-style: none;
  overflow: hidden;
  z-index: 50;
  display: none;
}
#autocomplete-list.open { display: block; }
#autocomplete-list li {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.1s;
}
#autocomplete-list li:hover,
#autocomplete-list li.active { background: var(--border); }

.guess-counter {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.remaining-count {
  color: var(--green);
  font-weight: 600;
}

.btn-give-up {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  margin-left: 8px;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.15s, color 0.15s;
}
.btn-give-up:hover { background: var(--border); color: var(--text); }

/* ===== GRID ===== */
.grid-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

thead tr {
  background: var(--surface);
}

th {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  background: var(--surface);
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}
th.col-name { text-align: left; padding-left: 14px; }

/* ===== GUESS ROWS ===== */
#guess-rows td {
  padding: 6px 4px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
#guess-rows tr:last-child td { border-bottom: none; }

.cell-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 46px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 6px;
  color: #fff;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.25s ease, transform 0.25s ease;
  position: relative;
}
.cell-box.reveal {
  opacity: 1;
  transform: scale(1);
}
.cell-box.green  { background: var(--green); }
.cell-box.yellow { background: var(--yellow); color: #1a1a22; }
.cell-box.red    { background: var(--red); }

.help-arrow {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin: 0 2px;
  object-fit: contain;
}

.cell-box .arrow {
  width: 14px;
  height: 14px;
  margin-left: 4px;
  flex-shrink: 0;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

/* Team color overrides for green cells */
.cell-box.team-csk  { background: var(--csk); color: #1a1a22; }
.cell-box.team-mi   { background: var(--mi); }
.cell-box.team-rcb  { background: var(--rcb); }
.cell-box.team-kkr  { background: var(--kkr); }
.cell-box.team-srh  { background: var(--srh); color: #1a1a22; }
.cell-box.team-rr   { background: var(--rr); }
.cell-box.team-gt   { background: var(--gt); }
.cell-box.team-dc   { background: var(--dc); }
.cell-box.team-lsg  { background: var(--lsg); color: #1a1a22; }
.cell-box.team-pbks { background: var(--pbks); }

.player-name-cell {
  text-align: left;
  padding-left: 14px !important;
  font-weight: 600;
  font-size: 0.88rem;
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 380px;
  width: 90%;
  position: relative;
}

.modal h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  margin-bottom: 16px;
  text-align: center;
}

.modal p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 10px;
  line-height: 1.5;
}

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

/* legend */
.legend { margin: 14px 0; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.88rem;
  color: var(--muted);
}
.legend .cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  height: 36px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.8rem;
  color: #fff;
}
.legend .cell.green  { background: var(--green); }
.legend .cell.yellow { background: var(--yellow); color: #1a1a22; }
.legend .cell.red    { background: var(--red); }

/* stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat-box {
  background: var(--bg);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}
.stat-num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  display: block;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

.dist-label {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}
.dist-num { width: 14px; color: var(--muted); text-align: right; }
.dist-bar-wrap { flex: 1; background: var(--bg); border-radius: 4px; height: 22px; }
.dist-bar {
  background: var(--green);
  height: 100%;
  border-radius: 4px;
  min-width: 4px;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  transition: width 0.4s ease;
}

/* share */
.share-grid {
  font-size: 1.4rem;
  letter-spacing: 2px;
  line-height: 1.6;
  margin: 10px 0 16px;
  text-align: center;
  white-space: pre;
}

.btn-share {
  width: 100%;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: opacity 0.15s;
}
.btn-share:hover { opacity: 0.85; }

.copied-msg {
  text-align: center;
  color: var(--green);
  font-size: 0.85rem;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}
.copied-msg.show { opacity: 1; }

.countdown-label {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 10px;
}
.main-countdown {
  font-size: 0.95rem;
  margin: 16px 0 8px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 300;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== RESULT ===== */
#result-title {
  font-size: 1.4rem;
}
#result-answer {
  font-size: 1rem;
  text-align: center;
  margin-bottom: 8px;
}

.result-player-card {
  text-align: center;
  margin: 12px 0;
}
.result-player-card .player-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.result-player-card .player-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.result-player-card .player-stats .stat-tag {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ===== MOBILE ===== */
@media (max-width: 480px) {
  :root { --header-h: 50px; }

  /* Header */
  .header-inner { padding: 0 10px; }
  .logo { font-size: 1.1rem; }
  .icon-btn { width: 30px; height: 30px; font-size: 0.85rem; }
  .header-right { gap: 5px; }
  .timer-display { font-size: 0.75rem; min-width: 28px; }
  .streak-badge { font-size: 0.75rem; }

  /* Hide hard mode label on very small screens, keep icon */
  .hard-btn { font-size: 0.75rem; }

  /* Main */
  main { padding: 16px 10px 60px; }
  .subtitle { font-size: 0.85rem; margin-bottom: 14px; }

  /* Search */
  #search-input { padding: 10px 12px; font-size: 0.95rem; }

  /* Grid cells — more compact */
  .cell-box {
    min-width: 54px;
    min-height: 40px;
    font-size: 0.7rem;
    padding: 3px 4px;
    border-radius: 6px;
  }
  .cell-box .arrow { width: 11px; height: 11px; }
  th {
    font-size: 0.62rem;
    padding: 8px 4px;
    letter-spacing: 0.3px;
  }
  .player-name-cell {
    font-size: 0.75rem;
    padding-left: 8px !important;
  }
  #guess-rows td { padding: 4px 2px; }

  /* Modal */
  .modal { padding: 20px 16px; }
  .modal h2 { font-size: 1.1rem; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .stat-num { font-size: 1.3rem; }
}

/* ===== FOOTER ===== */
footer {
  margin-top: 48px;
  padding: 24px 16px 32px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.footer-links a:hover { color: var(--text); }

.footer-links svg {
  width: 20px;
  height: 20px;
  display: block;
}

.footer-momo span {
  font-size: 0.82rem;
  font-weight: 600;
  background: #e8714a;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  transition: background 0.2s;
}
.footer-momo:hover span {
  background: #d4613e;
}

footer p { line-height: 1.6; }
footer p a { color: var(--muted); text-decoration: underline; }
footer p a:hover { color: var(--text); }
