/* Shared styles for the Wordle pages. After changing this file bump the
   ?v= on its <link> in every page so browsers fetch the new version. */

:root {
  color-scheme: dark;
  --bg: #070a08;
  --surface: #0f1411;
  --surface-2: #151c18;
  --surface-3: #1b241f;
  --border: #22302a;
  --border-strong: #31463b;
  --text: #e8f3ec;
  --muted: #93a59a;
  --faint: #5f7166;
  --accent: #51ff7a;
  --accent-strong: #3ee067;
  --accent-ink: #03140a;
  --glow: rgba(81, 255, 122, 0.3);
  --danger: #ff6b6b;

  --correct: #26b24b;
  --present: #d0ad2c;
  --absent: #3b433f;
  --empty: #111814;
  --tile-border: #26332c;
  --tile-text: #ffffff;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f5f2;
  --surface: #ffffff;
  --surface-2: #f5f8f6;
  --surface-3: #e9efeb;
  --border: #dbe4de;
  --border-strong: #c2d0c7;
  --text: #0e1a13;
  --muted: #536559;
  --faint: #879a8e;
  --accent: #0f9d3a;
  --accent-strong: #0b8430;
  --accent-ink: #ffffff;
  --glow: rgba(15, 157, 58, 0.22);
  --danger: #d63939;

  --correct: #5fa85a;
  --present: #c9b458;
  --absent: #7b8083;
  --empty: #ffffff;
  --tile-border: #d3d8d5;
  --shadow: 0 18px 40px rgba(20, 40, 28, 0.12);
}

/* Colour-blind friendly tiles, like the real Wordle's high contrast mode */
:root[data-contrast="high"] {
  --correct: #f5793a;
  --present: #85c0f9;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Soft glow and faint grid behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60rem 30rem at 15% -10%, var(--glow), transparent 60%),
    radial-gradient(40rem 25rem at 110% 10%, rgba(208, 173, 44, 0.08), transparent 60%),
    linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 44px 44px;
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.35) 45%, transparent 85%);
  opacity: 0.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.15; margin: 0; }
code, kbd, .mono { font-family: var(--mono); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main { flex: 1; }
main.container { padding-top: 32px; padding-bottom: 64px; }
.stack > * + * { margin-top: 24px; }

/* ---------- header / footer ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; gap: 16px; height: 64px; }
.site-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; min-width: 0; }
.site-nav a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.92rem;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-3); }

.header-search { position: relative; display: flex; align-items: center; }
.header-search .icon { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
.header-search input {
  width: 190px;
  height: 40px;
  padding: 0 14px 0 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  transition: width 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.header-search input::placeholder { color: var(--faint); }
.header-search input:focus { outline: none; width: 240px; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.icon-btn.search-link { display: none; color: var(--text); }
@media (max-width: 640px) {
  .header-search { display: none; }
  .icon-btn.search-link { display: inline-grid; }
}

.logo { display: flex; gap: 4px; align-items: center; color: inherit; }
.logo:hover { text-decoration: none; }
.logo .tile {
  width: 28px;
  font-size: 0.95rem;
  border-radius: 6px;
  border-width: 0;
}
.logo:hover .tile { animation: hop 0.5s ease calc(var(--i) * 60ms); }
@keyframes hop { 40% { transform: translateY(-6px) rotate(-4deg); } }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: var(--surface-3); }
.icon { width: 20px; height: 20px; flex: none; }

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  padding: 24px 0;
}
.site-footer .container { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }

/* ---------- buttons, inputs, chips ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 0 0 0 var(--glow);
}
.btn-primary:hover { background: var(--accent-strong); box-shadow: 0 0 24px var(--glow); }
.btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.88rem; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.field {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.field::placeholder { color: var(--faint); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }

.input-row { display: flex; gap: 8px; }
.form-hint { min-height: 1.4em; margin: 8px 0 0; font-size: 0.88rem; color: var(--muted); }
.form-hint.error { color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
}
.chip:hover { border-color: var(--border-strong); text-decoration: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--muted);
  white-space: nowrap;
}
.badge.win { background: color-mix(in srgb, var(--correct) 22%, transparent); color: var(--text); }
.badge.loss { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--text); }

/* ---------- cards & sections ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card-head h2 { font-size: 1.15rem; }
.card-head .sub { color: var(--muted); font-size: 0.9rem; }
.eyebrow {
  color: var(--accent);
  font: 700 0.78rem/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.grid-2 { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1.1fr 0.9fr; align-items: start; } }

.empty-state { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty-state h2 { color: var(--text); font-size: 1.4rem; margin-bottom: 8px; }
.empty-state .actions { margin-top: 20px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- tiles & boards ---------- */

.tile {
  --c: var(--empty);
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid var(--tile-border);
  background: var(--empty);
  color: var(--tile-text);
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1;
  user-select: none;
}
.tile[data-state="correct"] { --c: var(--correct); background: var(--c); border-color: transparent; }
.tile[data-state="present"] { --c: var(--present); background: var(--c); border-color: transparent; }
.tile[data-state="absent"] { --c: var(--absent); background: var(--c); border-color: transparent; }
:root[data-theme="light"] .tile[data-state="empty"] { color: var(--text); }

.board {
  display: grid;
  gap: 7px;
  width: min(100%, 340px);
  margin: 0 auto;
  perspective: 900px;
}
.board .row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.board .tile { font-size: clamp(1.4rem, 7vw, 2rem); }
.tile .letter { transition: opacity 0.25s ease, filter 0.25s ease; }
[data-letters="hidden"] .letter { opacity: 0; filter: blur(8px); }

/* Tiles flip over one at a time to show their colour, like the game */
.board.reveal .tile[data-state]:not([data-state="empty"]) {
  animation: flip 0.6s ease both;
  animation-delay: calc(var(--r) * 420ms + var(--c-i) * 110ms);
}
@keyframes flip {
  0% { transform: rotateX(0); background: var(--empty); border-color: var(--tile-border); }
  49.9% { transform: rotateX(-90deg); background: var(--empty); border-color: var(--tile-border); }
  50% { transform: rotateX(-90deg); background: var(--c); border-color: transparent; }
  100% { transform: rotateX(0); background: var(--c); border-color: transparent; }
}
.board.reveal .row.win-row .tile {
  animation: flip 0.6s ease both, bounce 0.6s ease both;
  animation-delay: calc(var(--r) * 420ms + var(--c-i) * 110ms), calc(var(--r) * 420ms + 900ms + var(--c-i) * 90ms);
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-22px); }
  70% { transform: translateY(4px); }
}

/* Spoiler-free coloured squares */
.mini {
  --s: 10px;
  display: grid;
  grid-template-columns: repeat(5, var(--s));
  gap: 2px;
  flex: none;
}
.mini span { width: var(--s); height: var(--s); border-radius: 2px; background: var(--surface-3); }
.mini span[data-state="correct"] { background: var(--correct); }
.mini span[data-state="present"] { background: var(--present); }
.mini span[data-state="absent"] { background: var(--absent); }
.mini-lg { --s: 16px; gap: 3px; }
.mini-lg span { border-radius: 3px; }

/* ---------- avatar ---------- */

.avatar {
  --size: 44px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  width: var(--size);
  height: var(--size);
  padding: calc(var(--size) / 9);
  border-radius: calc(var(--size) / 4);
  background: var(--surface-3);
  border: 1px solid var(--border);
  flex: none;
}
.avatar span { border-radius: 2px; }
.avatar span[data-state="none"] { background: color-mix(in srgb, var(--text) 5%, transparent); }
.avatar span[data-state="correct"] { background: var(--correct); }
.avatar span[data-state="present"] { background: var(--present); }
.avatar-lg { --size: 84px; gap: 3px; }
.chip .avatar { --size: 26px; gap: 1px; padding: 3px; border-radius: 7px; }
.lb-row .avatar { --size: 38px; gap: 1px; padding: 4px; }
.avatar-lg span { border-radius: 3px; }

/* ---------- profile header (stats, history, board pages) ---------- */

.profile { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -0.02em; word-break: break-word; }
.profile .meta { color: var(--muted); margin-top: 4px; }
.profile .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); width: max-content; max-width: 100%; overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 10px; color: var(--muted); font-weight: 600; white-space: nowrap; }
@media (max-width: 480px) {
  .tabs { width: 100%; }
  .tabs a { flex: 1; justify-content: center; padding: 8px 6px; font-size: 0.88rem; }
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--surface-3); color: var(--text); }

/* ---------- stats ---------- */

.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.stat .value { font: 800 2.2rem/1 var(--mono); letter-spacing: -0.03em; }
.stat .label { margin-top: 8px; color: var(--muted); font-size: 0.88rem; }
.stat .fx { position: absolute; right: 12px; top: 12px; font-size: 1.3rem; opacity: 0.9; }
.stat.hot { border-color: color-mix(in srgb, var(--present) 55%, var(--border)); }
.stat.hot .value { color: var(--present); }

.dist { display: grid; gap: 8px; }
.dist-row { display: grid; grid-template-columns: 1.6rem 1fr; align-items: center; gap: 10px; font-family: var(--mono); }
.dist-row .n { color: var(--muted); text-align: right; font-weight: 700; }
.dist-bar {
  --w: 0%;
  width: max(var(--w), 2.2rem);
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--absent);
  color: #fff;
  font-weight: 800;
  transform-origin: left;
  animation: grow 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i) * 70ms);
}
.dist-row.last .dist-bar { background: var(--correct); box-shadow: 0 0 18px color-mix(in srgb, var(--correct) 45%, transparent); }
.dist-row.miss .dist-bar { background: color-mix(in srgb, var(--danger) 70%, var(--absent)); }
@keyframes grow { from { transform: scaleX(0); } }

.form-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 40px)); gap: 6px; }
.form-day {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 8px;
  font: 800 0.9rem/1 var(--mono);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  color: var(--faint);
}
.form-day[data-result] { border: 0; color: #fff; }
.form-day[data-result="win"] { background: var(--correct); }
.form-day[data-result="loss"] { background: color-mix(in srgb, var(--danger) 70%, var(--absent)); }
a.form-day:hover { text-decoration: none; transform: translateY(-2px); }
.form-day.today { outline: 2px solid var(--accent); outline-offset: 2px; }

.today-card { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.today-card .text { flex: 1; min-width: 180px; }
.today-card .big { font: 800 1.6rem/1.1 var(--mono); }

/* ---------- history ---------- */

.stat-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { text-align: center; font: 700 0.7rem/1 var(--mono); color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; padding-bottom: 4px; }
.cal-day {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: #fff;
  font: 800 1.05rem/1 var(--mono);
  transition: transform 0.15s ease;
}
.cal-day .date { position: absolute; top: 5px; left: 7px; font-size: 0.64rem; font-weight: 600; color: var(--faint); }
.cal-day[data-level] { border-color: transparent; }
.cal-day[data-level] .date { color: rgba(255, 255, 255, 0.8); }
.cal-day.today { outline: 2px solid var(--accent); outline-offset: 2px; }
a.cal-day:hover { transform: translateY(-2px); text-decoration: none; }
@media (max-width: 480px) {
  .cal { gap: 4px; }
  .cal-day { border-radius: 7px; font-size: 0.85rem; }
  .cal-day .date { top: 3px; left: 4px; font-size: 0.55rem; }
}
.cal-key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: var(--surface-3); }
[data-level="1"] { background: var(--correct); }
[data-level="2"] { background: color-mix(in srgb, var(--correct) 72%, var(--surface-3)); }
[data-level="3"] { background: color-mix(in srgb, var(--correct) 48%, var(--surface-3)); }
[data-level="loss"] { background: color-mix(in srgb, var(--danger) 70%, var(--absent)); }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.8rem; margin-top: 14px; flex-wrap: wrap; }
.legend .cal-key:not(:first-child) { margin-left: 6px; }

.game-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.game-card:hover { transform: translateY(-3px); border-color: var(--border-strong); text-decoration: none; }
.game-card .date { font-size: 0.85rem; color: var(--muted); }

/* ---------- board page ---------- */

.board-stage { display: grid; gap: 22px; justify-items: center; text-align: center; }
.board-stage .headline { font: 800 1.1rem/1.2 var(--mono); }
.answer-row { display: grid; gap: 8px; justify-items: center; color: var(--muted); font-size: 0.9rem; }
.answer-tiles { display: flex; gap: 6px; }
.answer-row .tile { width: 38px; font-size: 1.1rem; }
.hold-btn { touch-action: none; min-width: 230px; }
.hold-btn .icon { transition: transform 0.2s ease; }
.hold-btn[aria-pressed="true"] .icon { transform: scale(1.2); }
.nav-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.kbd-hint { color: var(--faint); font-size: 0.82rem; }
@media (hover: none) { .kbd-hint { display: none; } } /* no keyboard on touch screens */
.kbd-hint kbd { padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--muted); }

/* ---------- home page ---------- */

.hero { display: grid; gap: 40px; align-items: center; padding: 24px 0 8px; }
@media (min-width: 900px) { .hero { grid-template-columns: 1.05fr 0.95fr; padding-top: 48px; } }
.hero-title { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 20px; }
.hero-title .tile {
  width: clamp(44px, 12vw, 72px);
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  animation: drop 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
  animation-delay: calc(var(--i) * 90ms);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
@keyframes drop { from { transform: translateY(-40px) rotate(-12deg); opacity: 0; } }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 34rem; margin: 0 0 24px; }
.hero p.lead strong { color: var(--text); }

.cmd {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 30rem;
  padding: 8px 8px 8px 18px;
  border-radius: 14px;
  background: #050806;
  border: 1px solid var(--border-strong);
  font-family: var(--mono);
  color: #d7ffe2;
  box-shadow: 0 0 0 1px rgba(81, 255, 122, 0.08), 0 12px 30px rgba(0, 0, 0, 0.35);
}
.cmd .prompt { color: #51ff7a; }
.cmd code { flex: 1; overflow-x: auto; white-space: nowrap; }
.countdown { margin-top: 18px; color: var(--muted); font-size: 0.95rem; }
.countdown .mono { color: var(--text); font-weight: 700; font-size: 1.05rem; }

.terminal {
  border-radius: 16px;
  overflow: hidden;
  background: #050806;
  border: 1px solid #1f2d25;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5), 0 0 60px rgba(81, 255, 122, 0.12);
  font-family: var(--mono);
  color: #cfe9d6;
}
.terminal-bar { display: flex; gap: 8px; align-items: center; padding: 12px 14px; background: #0c120e; border-bottom: 1px solid #1a261f; }
.terminal-bar i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; }
.terminal-bar i:nth-child(2) { background: #febc2e; }
.terminal-bar i:nth-child(3) { background: #28c840; }
.terminal-bar span { margin-left: 8px; font-size: 0.8rem; color: #6c8a76; }
.terminal-body { padding: 18px 20px 22px; min-height: 380px; font-size: 0.92rem; }
.terminal-body .line { min-height: 1.5em; white-space: pre-wrap; }
.terminal-body .prompt { color: #51ff7a; }
.terminal-body .dim { color: #5f7a68; }
.caret { display: inline-block; width: 0.6em; height: 1.1em; vertical-align: text-bottom; background: #51ff7a; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.term-board { display: grid; gap: 5px; width: 190px; margin: 12px 0 10px 2px; }
.term-board .row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.term-board .tile { font-size: 1rem; border-radius: 3px; border-width: 1px; }
.term-board .tile.pop { animation: pop 0.12s ease; }
@keyframes pop { 50% { transform: scale(1.12); } }
.term-board .tile.flip { animation: flip 0.5s ease both; animation-delay: calc(var(--c-i) * 120ms); }
.terminal .tile { --empty: #0b120e; --tile-border: #24342b; }

.leaderboard { display: grid; gap: 8px; }
.lb-row {
  display: grid;
  grid-template-columns: 2rem auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  animation: rise 0.45s ease both;
  animation-delay: calc(var(--i) * 60ms);
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.lb-rank { font: 800 1.1rem/1 var(--mono); color: var(--faint); text-align: center; }
.lb-row:nth-child(1) .lb-rank { color: #f5c542; }
.lb-row:nth-child(2) .lb-rank { color: #c9d3cf; }
.lb-row:nth-child(3) .lb-rank { color: #d9955b; }
.lb-name { font-weight: 700; color: var(--text); word-break: break-word; }
.lb-name:hover { text-decoration: underline; }
.lb-meta { color: var(--muted); font-size: 0.85rem; display: flex; gap: 12px; flex-wrap: wrap; }
.lb-today { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.lb-remove {
  width: 30px; height: 30px; border-radius: 8px; border: 0; background: transparent; color: var(--faint); cursor: pointer;
}
.lb-remove:hover { background: var(--surface-3); color: var(--text); }
.lb-right { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
@media (max-width: 560px) {
  .lb-row { grid-template-columns: 1.6rem auto 1fr; }
  .lb-right { grid-column: 2 / -1; justify-content: space-between; }
}

.steps { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); counter-reset: step; }
.step { padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.step::before {
  counter-increment: step;
  content: counter(step);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  border-radius: 9px;
  background: var(--correct);
  color: #fff;
  font: 800 1rem/1 var(--mono);
}
.step:nth-child(2)::before { background: var(--present); }
.step:nth-child(3)::before { background: var(--absent); }
.step h3 { font-size: 1.05rem; margin-bottom: 6px; }
.step p { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* ---------- skeleton loading ---------- */

.skeleton {
  border-radius: 10px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)) 0 0 / 300% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { to { background-position: -150% 0; } }

/* ---------- toast & dialog ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  transform: translate(-50%, 20px);
  opacity: 0;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

dialog {
  width: min(92vw, 420px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); }
.dialog-body { padding: 24px; display: grid; gap: 20px; }
.dialog-body h2 { font-size: 1.2rem; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting .desc { color: var(--muted); font-size: 0.85rem; }
.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-3); }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 0.88rem; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.switch { position: relative; width: 48px; height: 28px; border-radius: 999px; border: 0; background: var(--surface-3); cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform 0.2s ease, background 0.2s ease; }
.switch[aria-checked="true"] { background: var(--correct); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: #fff; }
.swatches { display: flex; gap: 4px; }
.swatches span { width: 18px; height: 18px; border-radius: 4px; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; }

@media (max-width: 640px) {
  main { padding-top: 20px; }
  .card { padding: 18px; }
  .site-nav a { padding: 8px 9px; font-size: 0.86rem; }
  .site-nav .wide { display: none; }
  .logo .tile { width: 22px; font-size: 0.8rem; }
  .profile .actions { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
