/* ============================================================
   main.css – Termo Ranked
   Modern, beautiful, responsive redesign
   Fonts: Bebas Neue (brand) · Nunito (body) · Space Mono (mono)
   ============================================================ */

/* ─── 1. DESIGN TOKENS ─────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg-page:    #f2f5fc;
  --bg-surface: #ffffff;
  --bg-raised:  #e8edf6;
  --bg-active:  #dee4f0;

  /* Foreground */
  --fg:       #0b1221;
  --fg-muted: #4a5a7a;
  --fg-subtle:#97a8c4;

  /* Brand / Accent — rich forest green in light */
  --accent:      #15803d;
  --accent-hi:   #166534;
  --accent-soft: rgba(21, 128, 61, 0.12);
  --accent-glow: rgba(21, 128, 61, 0.28);

  /* Game feedback colours */
  --correct:     #22c55e;
  --correct-bg:  #15803d;
  --present:     #eab308;
  --present-bg:  #a16207;
  --absent:      #9ca3af;
  --absent-bg:   #6b7280;

  /* Podium */
  --gold:   #d97706;
  --silver: #94a3b8;
  --bronze: #b45309;

  /* Structure */
  --border:     rgba(0, 0, 0, 0.08);
  --border-str: rgba(0, 0, 0, 0.15);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 6px rgba(0,0,0,.04);
  --shadow:     0 3px 12px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.05);
  --shadow-md:  0 8px 28px rgba(0,0,0,.11), 0 3px 10px rgba(0,0,0,.06);
  --shadow-lg:  0 20px 60px rgba(0,0,0,.14), 0 8px 20px rgba(0,0,0,.08);

  /* Header */
  --hdr-bg: rgba(242, 245, 252, 0.9);
  --hdr-bd: rgba(0, 0, 0, 0.07);
  --hdr-h:  62px;

  /* Forms */
  --in-bg: #ffffff;
  --in-bd: rgba(0, 0, 0, 0.2);

  /* Modals */
  --m-bg:  #ffffff;
  --m-ov:  rgba(8, 14, 32, 0.55);

  /* Tiles */
  --tile-bd:   rgba(0,0,0,0.13);
  --tile-bd-f: rgba(0,0,0,0.35);

  /* Radius */
  --r-xs:  4px;
  --r-sm:  8px;
  --r:     12px;
  --r-lg:  18px;
  --r-xl:  28px;
  --r-max: 9999px;

  /* Transitions */
  --t:    0.17s ease;
  --t-md: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* Legacy aliases kept for any inline references */
  --bg-primary:   var(--bg-page);
  --bg-secondary: var(--bg-raised);
  --bg-card:      var(--bg-surface);
  --text-primary:   var(--fg);
  --text-secondary: var(--fg-muted);
  --text-muted:     var(--fg-subtle);
  --btn-primary-bg: var(--accent);
  --btn-primary-text: #fff;
  --btn-secondary-bg: var(--bg-raised);
  --input-bg:     var(--in-bg);
  --input-border: var(--in-bd);
  --border-color: var(--border);
  --header-bg:    var(--hdr-bg);
  --header-border:var(--hdr-bd);
  --modal-overlay:var(--m-ov);
  --radius:    var(--r-sm);
  --radius-lg: var(--r-lg);
  --shadow:    var(--shadow-sm);
  --transition: var(--t);
  --tile-border-default: var(--tile-bd);
  --tile-border-filled:  var(--tile-bd-f);
}

[data-theme="dark"] {
  /* Surfaces */
  --bg-page:    #080c18;
  --bg-surface: #0d1226;
  --bg-raised:  #141c34;
  --bg-active:  #1c2644;

  /* Foreground */
  --fg:       #d8e4f8;
  --fg-muted: #607ba0;
  --fg-subtle:#2e4368;

  /* Brand — electric lime green in dark */
  --accent:      #4ade80;
  --accent-hi:   #22c55e;
  --accent-soft: rgba(74, 222, 128, 0.1);
  --accent-glow: rgba(74, 222, 128, 0.22);

  /* Game feedback colours */
  --correct:     #4ade80;
  --correct-bg:  #15803d;
  --present:     #facc15;
  --present-bg:  #854d0e;
  --absent:      #9ca3af;
  --absent-bg:   #374151;

  /* Podium */
  --gold:   #fbbf24;
  --silver: #94a3b8;
  --bronze: #d97706;

  /* Structure */
  --border:     rgba(255,255,255,0.07);
  --border-str: rgba(255,255,255,0.13);
  --shadow-sm:  0 1px 4px rgba(0,0,0,.4);
  --shadow:     0 4px 16px rgba(0,0,0,.5);
  --shadow-md:  0 10px 35px rgba(0,0,0,.65);
  --shadow-lg:  0 24px 70px rgba(0,0,0,.85);

  /* Header */
  --hdr-bg: rgba(8, 12, 24, 0.88);
  --hdr-bd: rgba(255,255,255,0.06);

  /* Forms */
  --in-bg: #0d1226;
  --in-bd: rgba(255,255,255,0.14);

  /* Modals */
  --m-bg:  #0d1226;
  --m-ov:  rgba(0, 0, 0, 0.78);

  /* Tiles */
  --tile-bd:   rgba(255,255,255,0.1);
  --tile-bd-f: rgba(255,255,255,0.3);

  /* Legacy aliases */
  --bg-primary:   var(--bg-page);
  --bg-secondary: var(--bg-raised);
  --bg-card:      var(--bg-surface);
  --text-primary:   var(--fg);
  --text-secondary: var(--fg-muted);
  --text-muted:     var(--fg-subtle);
  --btn-primary-bg: var(--accent);
  --input-bg:     var(--in-bg);
  --input-border: var(--in-bd);
  --border-color: var(--border);
  --header-bg:    var(--hdr-bg);
  --header-border:var(--hdr-bd);
  --modal-overlay:var(--m-ov);
  --tile-border-default: var(--tile-bd);
  --tile-border-filled:  var(--tile-bd-f);
}

/* ─── 2. RESET ──────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-page);
  color: var(--fg);
  line-height: 1.55;
  min-height: 100vh;
  transition: background-color var(--t-md), color var(--t-md);
  position: relative;
}

/* Subtle dot-grid background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(0,0,0,0.045) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}
[data-theme="dark"] body::before {
  background-image: radial-gradient(circle, rgba(255,255,255,0.025) 1px, transparent 1px);
}
body > * { position: relative; z-index: 1; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t);
}
a:hover { text-decoration: underline; color: var(--accent-hi); }
img { display: block; max-width: 100%; }
ul, ol { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ─── 3. TYPOGRAPHY ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 800;
  line-height: 1.2;
  color: var(--fg);
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.875rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }
p  { margin-bottom: 0.9rem; color: var(--fg-muted); }
p:last-child { margin-bottom: 0; }
small { font-size: 0.8125rem; color: var(--fg-subtle); }

/* ─── 4. LAYOUT ─────────────────────────────────────────────── */
.container    { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }
.container-sm { max-width: 600px; }
.container-md { max-width: 820px; }
.section      { padding: 2.5rem 0; }
.divider      { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.main         { min-height: calc(100vh - var(--hdr-h)); }

/* ─── 5. HEADER / NAV ───────────────────────────────────────── */
.header {
  background: var(--hdr-bg);
  border-bottom: 1px solid var(--hdr-bd);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: background var(--t-md), border-color var(--t-md);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: var(--hdr-h);
}

/* Logo */
.logo {
  font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
  font-size: 1.85rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 0.2rem;
  transition: opacity var(--t);
}
.logo:hover { text-decoration: none; opacity: 0.8; }
.logo-termo  { color: var(--fg); }
.logo-ranked {
  color: var(--accent);
  text-shadow: 0 0 22px var(--accent-glow);
}

/* Nav */
.nav { display: flex; align-items: center; gap: 0.25rem; }
.nav-link {
  padding: 0.45rem 0.85rem;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-decoration: none;
  transition: background var(--t), color var(--t);
}
.nav-link:hover { background: var(--bg-raised); color: var(--fg); text-decoration: none; }
.nav-link.active { color: var(--fg); background: var(--bg-raised); font-weight: 700; }

.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.theme-toggle {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  transition: background var(--t), color var(--t), border-color var(--t);
}
.theme-toggle:hover { background: var(--bg-active); color: var(--fg); }

/* Keep icon-sun/moon compatibility */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.nav-toggle {
  display: none;
  width: 38px; height: 38px;
  flex-direction: column;
  justify-content: center;
  gap: 5px; padding: 8px;
  border-radius: var(--r-sm);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  transition: background var(--t);
}
.nav-toggle:hover { background: var(--bg-active); }
.nav-toggle span { display: block; height: 2px; background: var(--fg); border-radius: 2px; }

@media (max-width: 640px) {
  .nav-toggle { display: flex; }
  .nav {
    display: none;
    position: absolute;
    top: var(--hdr-h); left: 0; right: 0;
    background: var(--hdr-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--hdr-bd);
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem; gap: 0.25rem;
    box-shadow: var(--shadow-md);
  }
  .nav.open { display: flex; }
  .nav-link { padding: 0.65rem 0.85rem; }
}

/* ─── 6. MODALS ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--m-ov);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; visibility: hidden;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-18px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-content {
  background: var(--m-bg);
  border: 1px solid var(--border-str);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px;
  padding: 2rem;
  position: relative;
}
.modal-overlay.active .modal-content {
  animation: modal-in 0.28s cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-title { font-size: 1.3rem; font-weight: 800; color: var(--fg); }
.modal-close {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--fg-muted); font-size: 1.1rem;
  background: var(--bg-raised);
  transition: background var(--t), color var(--t);
}
.modal-close:hover { background: var(--bg-active); color: var(--fg); }
.modal-body   { color: var(--fg-muted); }
.modal-footer, .modal-switch {
  margin-top: 1.25rem; text-align: center;
  font-size: 0.875rem; color: var(--fg-muted);
}
.modal-footer a, .modal-switch a { font-weight: 700; color: var(--accent); }

/* ─── 7. FORMS ──────────────────────────────────────────────── */
.form-group { margin-bottom: 1.15rem; }
.form-group label {
  display: block;
  font-size: 0.85rem; font-weight: 700;
  color: var(--fg); margin-bottom: 0.4rem;
  letter-spacing: 0.01em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--in-bg);
  border: 1.5px solid var(--in-bd);
  border-radius: var(--r-sm);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.95rem; font-weight: 500;
  transition: border-color var(--t), box-shadow var(--t);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--fg-subtle); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-hint { margin-top: 0.35rem; font-size: 0.8rem; color: var(--fg-subtle); }

/* ─── 8. BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 0.9375rem; font-weight: 700;
  text-decoration: none;
  border: 2px solid transparent;
  transition: background var(--t), color var(--t), border-color var(--t),
              box-shadow var(--t), transform 0.1s ease;
  cursor: pointer; white-space: nowrap;
  letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.96); }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 2px 12px var(--accent-soft);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hi); border-color: var(--accent-hi);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-secondary {
  background: var(--bg-raised); color: var(--fg); border-color: var(--border-str);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-active); }

.btn-outline {
  background: transparent; color: var(--fg-muted); border-color: var(--border-str);
}
.btn-outline:hover:not(:disabled) {
  background: var(--bg-raised); color: var(--fg); border-color: var(--border-str);
}
.btn-danger {
  background: #dc2626; color: #fff; border-color: #dc2626;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }
.btn-share {
  background: #25d366; color: #fff; border-color: #25d366;
}
.btn-share:hover:not(:disabled) { background: #1da851; border-color: #1da851; }

.btn-full { width: 100%; }
.btn-sm   { padding: 0.4rem 0.9rem; font-size: 0.8125rem; }
.btn-lg   { padding: 0.8rem 1.8rem; font-size: 1rem; }

/* ─── 9. ALERTS / NOTIFICATIONS ─────────────────────────────── */
@keyframes alert-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.alert {
  display: flex; align-items: flex-start; gap: 0.6rem;
  padding: 0.8rem 1.1rem;
  border-radius: var(--r-sm);
  font-size: 0.9rem; font-weight: 600; line-height: 1.4;
  border-left: 3px solid transparent;
  animation: alert-in 0.22s ease;
  box-shadow: var(--shadow-sm);
}
.alert-success {
  background: rgba(22, 163, 74, 0.1); color: #15803d; border-left-color: #22c55e;
}
[data-theme="dark"] .alert-success {
  background: rgba(74, 222, 128, 0.1); color: #4ade80;
}
.alert-error {
  background: rgba(220, 38, 38, 0.1); color: #dc2626; border-left-color: #ef4444;
}
[data-theme="dark"] .alert-error {
  background: rgba(239, 68, 68, 0.12); color: #f87171;
}
.alert-warning {
  background: rgba(234, 179, 8, 0.1); color: #a16207; border-left-color: #eab308;
}
[data-theme="dark"] .alert-warning {
  background: rgba(250, 204, 21, 0.1); color: #facc15;
}
.alert-info {
  background: rgba(59, 130, 246, 0.1); color: #1d4ed8; border-left-color: #3b82f6;
}
[data-theme="dark"] .alert-info {
  background: rgba(96, 165, 250, 0.1); color: #93c5fd;
}
#message-container, .message-container {
  position: fixed;
  top: calc(var(--hdr-h) + 14px);
  left: 50%; transform: translateX(-50%);
  z-index: 500;
  display: flex; flex-direction: column; gap: 0.5rem;
  width: 90%; max-width: 400px;
  pointer-events: none;
}
#message-container .alert,
.message-container .alert { pointer-events: auto; }

/* ─── 10. CARDS ─────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: background var(--t-md), border-color var(--t-md);
}
.card-title {
  font-size: 0.78rem; font-weight: 800; color: var(--fg-subtle);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 1.2rem;
}

/* ─── 11. TABLES ────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead { background: var(--bg-raised); }
thead th {
  padding: 0.8rem 1rem;
  text-align: left; font-weight: 800; color: var(--fg-subtle);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--t); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-raised); }
tbody td { padding: 0.8rem 1rem; color: var(--fg); }

.current-user-row { background: var(--accent-soft) !important; }
.current-user-row:hover { filter: brightness(1.05); }
.current-user-row td { font-weight: 700; }

.player-link {
  color: var(--fg); font-weight: 700; text-decoration: none;
  transition: color var(--t);
}
.player-link:hover { color: var(--accent); text-decoration: none; }
.col-rank { width: 52px; text-align: center; font-weight: 800; font-size: 1.1rem; }

/* ─── 12. SPINNER / LOADING ─────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
.spinner-lg { width: 48px; height: 48px; border-width: 4px; }

.loading-spinner {
  display: flex; align-items: center; justify-content: center;
  gap: 0.75rem; padding: 2rem; color: var(--fg-muted); font-weight: 600;
}
.page-loader {
  position: fixed; inset: 0;
  background: var(--bg-page);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; transition: opacity 0.3s ease;
}
.page-loader.fade-out { opacity: 0; pointer-events: none; }

/* ─── 13. BADGES ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: var(--r-max);
  font-size: 0.7rem; font-weight: 800;
  letter-spacing: 0.03em; text-transform: uppercase; line-height: 1;
}
.badge-green  { background: rgba(22,163,74,0.14);  color: #15803d; }
[data-theme="dark"] .badge-green  { background: rgba(74,222,128,0.14); color: #4ade80; }
.badge-yellow { background: rgba(234,179,8,0.14);  color: #a16207; }
[data-theme="dark"] .badge-yellow { background: rgba(250,204,21,0.14); color: #facc15; }
.badge-gray   { background: rgba(107,114,128,0.14); color: var(--fg-muted); }
.badge-red    { background: rgba(220,38,38,0.12);   color: #dc2626; }
[data-theme="dark"] .badge-red    { background: rgba(248,113,113,0.12); color: #f87171; }
.badge-you    { background: var(--accent-soft); color: var(--accent); margin-left: 0.4rem; }
.badge-admin  { background: rgba(139,92,246,0.14); color: #7c3aed; }
[data-theme="dark"] .badge-admin  { background: rgba(167,139,250,0.14); color: #a78bfa; }

/* ─── 14. PAGINATION ────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; margin-top: 1.5rem;
}
.pagination-info { font-size: 0.85rem; font-weight: 600; color: var(--fg-muted); padding: 0 0.5rem; }
.page-btn {
  min-width: 36px; height: 36px; padding: 0 0.6rem;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border-str);
  background: var(--bg-surface); color: var(--fg-muted);
  font-size: 0.875rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t);
}
.page-btn:hover:not(:disabled) { background: var(--bg-raised); color: var(--fg); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── 15. STATS WIDGETS ─────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-box, .stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.1rem 1rem;
  text-align: center;
  transition: border-color var(--t), background var(--t-md), box-shadow var(--t);
}
.stat-box:hover, .stat-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.stat-box .stat-value,
.stat-card .stat-value {
  display: block;
  font-size: 2.1rem; font-weight: 900;
  color: var(--fg); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-box .stat-label,
.stat-card .stat-label {
  display: block;
  font-size: 0.68rem; color: var(--fg-subtle);
  margin-top: 0.35rem;
  text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700;
}

/* Stats summary bar (leaderboard) */
.stats-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 3rem;
  padding: 1.25rem 2rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.stats-bar-item { text-align: center; }
.stats-bar-value {
  display: block;
  font-size: 1.8rem; font-weight: 900;
  color: var(--fg); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stats-bar-label {
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--fg-subtle);
  font-weight: 700; margin-top: 0.25rem;
}

/* ─── 16. PAGE HEADER ───────────────────────────────────────── */
.page-header { text-align: center; padding: 2rem 0 1.5rem; }
.page-title   { font-size: clamp(1.75rem, 4vw, 2.25rem); font-weight: 900; }
.page-subtitle { color: var(--fg-muted); margin-top: 0.4rem; font-size: 1rem; margin-bottom: 0; }

/* ─── 17. PROFILE ───────────────────────────────────────────── */
.profile-card {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 1.5rem 1.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.profile-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px var(--accent-soft), 0 0 24px var(--accent-glow);
  letter-spacing: 0.05em;
}
.profile-info { display: flex; flex-direction: column; gap: 0.2rem; }
.profile-username { font-size: 1.5rem; font-weight: 900; color: var(--fg); }
.profile-since    { font-size: 0.85rem; color: var(--fg-muted); margin: 0; }

/* Guess distribution chart (profile page) */
.distribution-card { margin-top: 1.5rem; }
.distribution-chart { display: flex; flex-direction: column; gap: 0.45rem; }
.dist-row { display: flex; align-items: center; gap: 0.6rem; }
.dist-label {
  width: 18px;
  font-size: 0.85rem; font-weight: 800;
  color: var(--fg-muted); text-align: right; flex-shrink: 0;
}
.dist-bar-container {
  flex: 1; height: 22px;
  background: var(--bg-raised);
  border-radius: var(--r-max); overflow: hidden;
}
.dist-bar {
  height: 100%; background: var(--absent-bg);
  border-radius: var(--r-max);
  min-width: 2rem;
  display: flex; align-items: center;
  padding-right: 8px; justify-content: flex-end;
  font-size: 0.75rem; font-weight: 700; color: #fff;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.dist-bar.current { background: var(--correct-bg); }
.dist-bar[data-n="1"] { background: #16a34a; }
.dist-bar[data-n="2"] { background: #65a30d; }
.dist-bar[data-n="3"] { background: #ca8a04; }
.dist-bar[data-n="4"] { background: #ea580c; }
.dist-bar[data-n="5"] { background: #ef4444; }
.dist-bar[data-n="6"] { background: #b91c1c; }
.dist-count {
  width: 28px; font-size: 0.82rem; font-weight: 700;
  color: var(--fg-muted); text-align: right; flex-shrink: 0;
}
.dist-empty { font-size: 0.9rem; color: var(--fg-subtle); text-align: center; padding: 1rem; }

/* ─── 18. LANDING / HERO ─────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 4rem 1rem 3rem;
  max-width: 640px;
  margin: 0 auto;
}
.hero h1 {
  font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
  font-size: clamp(3.5rem, 12vw, 6rem);
  letter-spacing: 0.04em;
  color: var(--fg);
  line-height: 0.95;
  margin-bottom: 0.75rem;
}
.hero h1 .hero-accent { color: var(--accent); }
.hero-subtitle { font-size: 1.1rem; color: var(--fg-muted); margin-bottom: 2rem; }

/* Static tile preview in hero */
.hero-preview {
  display: flex; justify-content: center;
  gap: 6px; margin-bottom: 2.25rem;
}
.preview-tile {
  width: 52px; height: 52px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.85rem; color: #fff;
  border: 2px solid transparent;
}
.preview-tile.correct { background: var(--correct-bg); box-shadow: 0 0 14px var(--accent-glow); }
.preview-tile.present { background: var(--present-bg); }
.preview-tile.absent  { background: var(--absent-bg); }

.game-rules {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.35rem 1.5rem;
  margin-bottom: 2rem; text-align: left;
  box-shadow: var(--shadow-sm);
}
.game-rules h3 {
  font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--fg-subtle); margin-bottom: 0.75rem;
}
.game-rules ul { display: flex; flex-direction: column; gap: 0.45rem; }
.game-rules li { font-size: 0.9rem; color: var(--fg-muted); font-weight: 500; }
.game-rules li strong { color: var(--fg); font-weight: 700; }

.auth-buttons {
  display: flex; gap: 0.75rem;
  justify-content: center; flex-wrap: wrap;
}

/* ─── 19. EMPTY / ERROR STATES ──────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 3rem 1rem; text-align: center;
}
.empty-state-icon  { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.6; }
.empty-state-title { font-size: 1rem; font-weight: 800; color: var(--fg-muted); margin-bottom: 0.4rem; }
.empty-state-text  { font-size: 0.875rem; color: var(--fg-subtle); max-width: 300px; }
.error-state       { text-align: center; color: var(--fg-muted); padding: 2rem; font-size: 0.9rem; }

/* Rank colours */
.rank-1 { color: var(--gold);   font-size: 1.2rem; }
.rank-2 { color: var(--silver); font-size: 1.1rem; }
.rank-3 { color: var(--bronze); font-size: 1.05rem; }

/* ─── 20. UTILITIES ─────────────────────────────────────────── */
.hidden       { display: none !important; }
.invisible    { visibility: hidden; }
.flex         { display: flex; }
.inline-flex  { display: inline-flex; }
.grid         { display: grid; }
.block        { display: block; }
.inline-block { display: inline-block; }
.items-center    { align-items: center; }
.items-start     { align-items: flex-start; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-1          { flex: 1; }
.flex-wrap       { flex-wrap: wrap; }
.gap-1 { gap: 0.25rem; } .gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }    .gap-6 { gap: 1.5rem; }
.text-center { text-align: center; } .text-right { text-align: right; } .text-left { text-align: left; }
.text-sm { font-size: 0.875rem; } .text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; } .text-xl { font-size: 1.25rem; }
.font-bold { font-weight: 700; } .font-medium { font-weight: 500; }
.text-muted     { color: var(--fg-subtle); }
.text-secondary { color: var(--fg-muted); }
.text-success   { color: var(--correct); }
.text-danger    { color: #dc2626; }
.text-warning   { color: var(--present); }
.mt-1{margin-top:.25rem} .mt-2{margin-top:.5rem} .mt-3{margin-top:.75rem}
.mt-4{margin-top:1rem}   .mt-6{margin-top:1.5rem} .mt-8{margin-top:2rem}
.mb-1{margin-bottom:.25rem} .mb-2{margin-bottom:.5rem} .mb-3{margin-bottom:.75rem}
.mb-4{margin-bottom:1rem}   .mb-6{margin-bottom:1.5rem}
.p-4{padding:1rem} .px-4{padding-left:1rem;padding-right:1rem}
.py-2{padding-top:.5rem;padding-bottom:.5rem} .py-4{padding-top:1rem;padding-bottom:1rem}
.rounded      { border-radius: var(--r); }
.rounded-lg   { border-radius: var(--r-lg); }
.rounded-full { border-radius: var(--r-max); }
.shadow       { box-shadow: var(--shadow); }
.shadow-lg    { box-shadow: var(--shadow-md); }
.overflow-hidden { overflow: hidden; }
.w-full  { width: 100%; } .h-full { height: 100%; }
.pointer { cursor: pointer; } .no-select { user-select: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── 21. RESPONSIVE ────────────────────────────────────────── */
@media (min-width: 641px) {
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .stats-bar  { gap: 4rem; }
  h2 { font-size: 2rem; }
}
@media (min-width: 1025px) {
  .container { padding: 0 2rem; }
}
@media (max-width: 480px) {
  .profile-card   { flex-direction: column; text-align: center; }
  .stats-bar      { gap: 1.5rem; padding: 1rem; }
  .stats-bar-value { font-size: 1.4rem; }
}
@media print {
  .header, .modal-overlay, #message-container { display: none !important; }
}
