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

:root {
  --green:   #1a9e60;
  --green-bg:#e6f7ef;
  --amber:   #c47d0e;
  --amber-bg:#fef3dc;
  --grey:    #6b7280;
  --grey-bg: #f3f4f6;
  --text:    #111827;
  --muted:   #6b7280;
  --border:  #e5e7eb;
  --surface: #ffffff;
  --page:    #f8f8f6;
  --accent:  #ffd000;
  --radius:  8px;
  --radius-lg: 12px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--page);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Header ── */
.site-header {
  background: #0d1117;
  border-bottom: 3px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
}
.logo-nrl   { color: var(--accent); }
.logo-guess { color: #ffffff; margin-left: 2px; }

.header-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.2);
  background: transparent;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }

/* ── Main layout ── */
.game-container {
  max-width: 780px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

/* ── Legend ── */
.clue-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 1.25rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.pip {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
}
.pip.correct { background: var(--green); }
.pip.close   { background: var(--amber); }
.pip.wrong   { background: var(--grey); }

/* ── Input row ── */
.guess-section { margin-bottom: 1rem; }
.input-row {
  display: flex;
  gap: 8px;
}
.autocomplete-wrap {
  flex: 1;
  position: relative;
}
#playerInput {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
#playerInput:focus { border-color: #0d1117; }

.ac-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.ac-dropdown.open { display: block; }
.ac-item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.ac-item:hover, .ac-item.active { background: var(--page); }

.guess-btn {
  height: 42px;
  padding: 0 22px;
  background: #0d1117;
  color: var(--accent);
  border: none;
  border-radius: var(--radius);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.guess-btn:hover { opacity: 0.85; }
.guess-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Toast ── */
.toast {
  min-height: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  padding: 0;
  margin-bottom: 0;
  border-radius: var(--radius);
  transition: all 0.2s;
}
.toast.show {
  padding: 9px 14px;
  margin-bottom: 12px;
}
.toast.info  { background: #eff6ff; color: #1d4ed8; }
.toast.win   { background: var(--green-bg); color: #14532d; }
.toast.lose  { background: #fef2f2; color: #991b1b; }

/* ── Counter ── */
.guess-counter {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  min-height: 18px;
}

/* ── Guess grid ── */
.grid-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.grid-header, .guess-row {
  display: grid;
  grid-template-columns: 160px 180px 80px 72px 80px 72px;
  gap: 4px;
  min-width: 640px;
}
.grid-header {
  margin-bottom: 6px;
}
.grid-header > div {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 8px;
}
.guess-row {
  margin-bottom: 4px;
}
.cell {
  border-radius: var(--radius);
  padding: 6px 8px;
  min-height: 46px;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  position: relative;
  animation: popIn 0.2s ease;
}
.cell.correct { background: var(--green);   color: #fff; }
.cell.close   { background: var(--amber);   color: #fff; }
.cell.wrong   { background: var(--grey);    color: #fff; }

.cell.col-prem, .cell.col-debut {
  justify-content: space-between;
  gap: 4px;
}
.arrow {
  font-size: 10px;
  opacity: 0.9;
  flex-shrink: 0;
}

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

/* ── Modals ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 440px;
  width: 100%;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.03em;
  margin-bottom: 12px;
}
.modal h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.25rem 0 8px;
}
.modal p { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.modal-close:hover { background: var(--page); }

/* How to play */
.how-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.how-row  { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.how-cols { font-size: 13px; color: var(--muted); padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.how-cols li strong { color: var(--text); }
.how-note { font-size: 12px; margin-top: 1rem; color: var(--muted); }

.btn-primary {
  margin-top: 1.5rem;
  width: 100%;
  height: 42px;
  background: #0d1117;
  color: var(--accent);
  border: none;
  border-radius: var(--radius);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }

/* Stats */
.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 1.25rem;
}
.stat-block {
  flex: 1;
  background: var(--page);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}
.stat-num   { font-family: 'Barlow Condensed', sans-serif; font-size: 28px; font-weight: 800; }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.05em; }

/* Distribution chart */
.dist-chart { display: flex; flex-direction: column; gap: 6px; }
.dist-row   { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dist-label { width: 16px; text-align: right; color: var(--muted); font-weight: 600; }
.dist-bar-wrap { flex: 1; background: var(--page); border-radius: 4px; height: 22px; overflow: hidden; }
.dist-bar {
  height: 100%;
  background: #0d1117;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  min-width: 22px;
  transition: width 0.4s ease;
  font-family: 'Barlow Condensed', sans-serif;
}

/* ── Responsive ── */
@media (max-width: 680px) {
  .grid-header > div:first-child,
  .cell:first-child { font-size: 11px; }
  .modal { padding: 1.5rem 1.25rem; }
}

/* ── Pro badge ── */
.pro-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--accent);
  color: #0d1117;
  border-radius: 4px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

/* ── Header text link ── */
.icon-btn--text {
  width: auto;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius);
}

/* ── Toast action buttons ── */
.toast-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 5px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255,255,255,0.2);
  color: inherit;
  text-decoration: none;
}
.toast-btn--ghost {
  background: transparent;
  opacity: 0.7;
}
.toast-btn--gold {
  background: var(--accent);
  color: #0d1117;
}
.toast-btn:hover { opacity: 0.85; }

/* ── Gold button ── */
.btn-gold {
  display: block;
  width: 100%;
  height: 44px;
  line-height: 44px;
  text-align: center;
  background: var(--accent);
  color: #0d1117;
  border: none;
  border-radius: var(--radius);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn-gold:hover { opacity: 0.88; }
.btn-gold--lg { height: 50px; line-height: 50px; font-size: 19px; }

/* ── How to play pro box ── */
.how-pro-box {
  background: #0d1117;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin: 1.25rem 0 1rem;
}
.how-pro-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.03em;
}
.how-pro-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  margin-bottom: 14px;
}

/* ── Stats pro sections ── */
.stats-pro-cta {
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--page);
  border-radius: var(--radius);
  text-align: center;
}
.stats-pro-cta p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.stats-pro-active {
  margin-top: 1rem;
  padding: 10px 14px;
  background: var(--green-bg);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Paywall screen ── */
.paywall-screen {
  min-height: calc(100vh - 57px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.paywall-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
}
.paywall-card--standalone {
  margin: 0 auto;
}
.paywall-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}
.paywall-card h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}
.paywall-card p {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 1.25rem;
}
.paywall-features {
  list-style: none;
  text-align: left;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1.5rem;
  color: var(--text);
}
.paywall-back {
  display: block;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  text-align: center;
}
.paywall-back:hover { color: var(--text); }

/* ── Checkout price display ── */
.checkout-price {
  margin: 1.5rem 0 1rem;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}
.checkout-amount {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 48px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.checkout-period {
  font-size: 13px;
  color: var(--muted);
}
.checkout-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ── Archive header ── */
.archive-header {
  margin-bottom: 1.5rem;
}
.archive-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}
.archive-sub {
  font-size: 14px;
  color: var(--muted);
}

/* ── Archive grid ── */
.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.archive-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.archive-card:hover {
  border-color: #0d1117;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.archive-card--won  { border-color: var(--green); background: var(--green-bg); }
.archive-card--played { border-color: var(--grey); }
.archive-card-date  { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.archive-card-puzzle { font-family: 'Barlow Condensed', sans-serif; font-size: 20px; font-weight: 700; }
.archive-card-result { font-size: 12px; margin-top: 4px; color: var(--muted); }
.archive-card--won .archive-card-result { color: var(--green); }
.archive-card-cta { font-size: 12px; margin-top: 4px; color: var(--accent); font-weight: 600; }

/* ── Archive puzzle modal ── */
.modal--wide { max-width: 760px; }
.archive-puzzle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 8px;
}
.archive-puzzle-date {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
}
.archive-puzzle-result {
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.archive-puzzle-result.win  { background: var(--green-bg); color: var(--green); }
.archive-puzzle-result.lose { background: #fef2f2; color: #991b1b; }

/* ── Auth form fields ── */
.auth-field { margin-bottom: 12px; }
.auth-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}
.auth-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.auth-input:focus { border-color: #0d1117; }
.auth-error {
  font-size: 13px;
  color: #dc2626;
  background: #fef2f2;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-top: 8px;
}
.auth-success {
  font-size: 13px;
  color: var(--green);
  background: var(--green-bg);
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-top: 8px;
}
.auth-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.auth-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-link:hover { color: var(--text); }

/* ── btn-primary small ── */
.btn-primary--sm {
  height: 34px;
  font-size: 13px;
  padding: 0 14px;
  width: auto;
}

/* ── Stats sign in nudge ── */
.stats-signin-nudge {
  background: var(--page);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.stats-signin-nudge p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* ── User dropdown menu ── */
.user-menu {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  min-width: 180px;
  overflow: hidden;
}
.user-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.user-menu-item:hover { background: var(--page); }
.user-menu-pro { display: flex; align-items: center; gap: 8px; cursor: default; }
.user-menu-pro:hover { background: none; }
.user-menu-upgrade { color: var(--amber); font-weight: 600; }
.user-menu-divider { height: 1px; background: var(--border); margin: 2px 0; }

/* ── Guess row animation ── */
.guess-row--new { animation: popIn 0.2s ease; }

/* ── Archive calendar ── */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-month-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.cal-nav-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  line-height: 1;
}
.cal-nav-btn:hover:not(:disabled) { background: var(--page); }
.cal-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.cal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
  min-height: 44px;
}
.cal-cell--empty { border: none; background: transparent; }
.cal-cell--future { opacity: 0.25; cursor: not-allowed; }
.cal-cell--today {
  border-color: #0d1117;
  background: #0d1117;
}
.cal-cell--today .cal-day-num { color: var(--accent); }
.cal-cell--won { border-color: var(--green); background: var(--green-bg); }
.cal-cell--won .cal-day-num { color: var(--green); }
.cal-cell--played { border-color: var(--grey); }
.cal-cell--available:hover { border-color: #0d1117; cursor: pointer; }

.cal-day-num {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.cal-result-dot {
  font-size: 9px;
  margin-top: 2px;
  line-height: 1;
}
.cal-cell--won .cal-result-dot { color: var(--green); }
.cal-cell--played .cal-result-dot { color: var(--grey); }

.cal-stats-bar {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  padding: 10px 0 4px;
  border-top: 1px solid var(--border);
}

/* ── Share button ── */
.share-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 1rem auto 0;
  padding: 10px 20px;
  background: #0d1117;
  color: var(--accent);
  border: none;
  border-radius: var(--radius);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: opacity 0.15s;
  width: 100%;
  justify-content: center;
}
.share-btn:hover { opacity: 0.85; }
.share-copied {
  text-align: center;
  font-size: 13px;
  color: var(--green);
  margin-top: 8px;
  font-weight: 500;
}
