/* Wikora styles. Colors are defined once here so the theme is easy to change. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1b1f2e;
  --muted: #667085;
  --border: #dde2ee;
  --primary: #4f46e5;
  --primary-text: #ffffff;
  --primary-soft: #eef0ff;
  --accent: #f59e0b;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1220;
    --surface: #181c2e;
    --text: #e7e9f3;
    --muted: #98a0b8;
    --border: #2a3047;
    --primary: #818cf8;
    --primary-text: #0f1220;
    --primary-soft: #23284a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font-body);
  min-height: 100vh;
}
h1, h2 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.error { color: var(--danger); min-height: 1.25em; margin: 0; font-size: .9rem; }
[hidden] { display: none !important; }

/* Building blocks */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.stack { display: flex; flex-direction: column; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .9rem; }
input, select {
  width: 100%;
  padding: .65rem .8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-weight: 400;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
input:disabled, select:disabled { opacity: .75; cursor: not-allowed; }
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: .65rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--primary); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-icon { padding: .55rem .7rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.badge { font-size: .75rem; background: var(--primary-soft); padding: .1rem .5rem; border-radius: 99px; }
.badge.gold { background: #fef3c7; color: #92400e; }

.brand { font-family: var(--font-display); font-weight: 700; font-size: 2.4rem; display: flex; align-items: center; gap: .5rem; justify-content: center; }
.brand.small { font-size: 1.25rem; justify-content: flex-start; }
.logo { color: var(--accent); }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  display: inline-block; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot { display: grid; place-items: center; min-height: 100vh; }

#toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translate(-50%, 1rem);
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Home */
.home { max-width: 460px; margin: 0 auto; padding: 3rem 16px; display: flex; flex-direction: column; gap: 1.25rem; }
.tagline { text-align: center; color: var(--muted); margin: 0; }
.join-row { display: flex; gap: .5rem; }
.join-row input { text-transform: uppercase; letter-spacing: .15em; }
.how ol { margin: 0; padding-left: 1.2rem; color: var(--muted); }

/* Lobby */
.lobby, .results { max-width: 980px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.lobby-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 1rem; align-items: start; }
.code-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.code { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; letter-spacing: .2em; }
.players { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.player { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.player.offline { opacity: .55; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700;
}
.player-name { font-weight: 600; }
.player-name em { font-weight: 400; color: var(--muted); }
.wins { font-size: .8rem; color: var(--muted); }

.picker { position: relative; display: flex; flex-direction: column; gap: .35rem; }
.picker-label { font-weight: 600; font-size: .9rem; }
.picker-row { display: flex; gap: .5rem; }
.picker-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10; margin: .25rem 0 0; padding: .25rem;
  list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 260px; overflow: auto;
}
.picker-results li { padding: .5rem .65rem; border-radius: 8px; cursor: pointer; }
.picker-results li:hover, .picker-results li.active { background: var(--primary-soft); }
.picker-results li.muted { cursor: default; }

/* Game */
.game-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem; padding: .6rem 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.timer { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; min-width: 4ch; font-variant-numeric: tabular-nums; }
.timer.urgent { color: var(--danger); }
.goal { flex: 1; display: flex; align-items: baseline; gap: .5rem; min-width: 0; }
.goal-title {
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; border: none; background: none; padding: 0;
  cursor: help; color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.clicks { font-weight: 600; white-space: nowrap; }
.goal-info { margin: .75rem 16px 0; display: flex; gap: 1rem; align-items: flex-start; }
.goal-info img { width: 96px; border-radius: 8px; }
.goal-info p { margin: 0; }
.game-body { display: grid; grid-template-columns: 1fr 260px; gap: 1rem; padding: 1rem 16px 5rem; max-width: 1280px; margin: 0 auto; }
.wiki-frame {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1.5rem; min-width: 0;
}
.wiki-title { font-family: Georgia, 'Times New Roman', serif; font-weight: 400; font-size: 2rem; border-bottom: 1px solid var(--border); padding-bottom: .5rem; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; font-size: .82rem; margin-bottom: .75rem; }
.crumb { background: var(--primary-soft); padding: .1rem .5rem; border-radius: 99px; }
.crumb.here { background: var(--primary); color: var(--primary-text); }
.sep { color: var(--muted); }
.loading { position: absolute; inset: 0; background: color-mix(in srgb, var(--surface) 70%, transparent); display: grid; place-items: start center; padding-top: 6rem; border-radius: var(--radius); }
.race-sidebar { position: sticky; top: 4.5rem; align-self: start; }
.racers { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.racers li { display: flex; flex-direction: column; }
.done-banner {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--primary); color: var(--primary-text); padding: .8rem 1.2rem; border-radius: 12px;
  font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center;
}

/* Results */
.results h1 { font-size: 2rem; }
.ranking { padding-left: 1.4rem; display: flex; flex-direction: column; gap: 1rem; margin: 1.5rem 0; }
.ranking li.finished::marker { color: var(--success); font-weight: 700; }
.rank-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .35rem; }

/* Phones and small screens */
@media (max-width: 760px) {
  .lobby-grid, .game-body { grid-template-columns: 1fr; }
  .race-sidebar { position: static; order: -1; }
  .two-col { grid-template-columns: 1fr; }
  .game-bar { flex-wrap: wrap; gap: .5rem 1rem; }
  .goal { order: 3; flex-basis: 100%; }
  .wiki-frame { padding: 1rem; }
  .brand { font-size: 2rem; }
}

/* Links that look like buttons */
a.btn { text-decoration: none; color: inherit; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
a.btn-primary { color: var(--primary-text); }
.back-daily { align-self: flex-start; }

/* Daily Wikora */
.daily { max-width: 820px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.daily-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 2rem 1.5rem; }
.daily-hero h1 { font-size: 2rem; margin: 0; }
.daily-hero > p { margin: 0; max-width: 560px; }
.matchup { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; width: 100%; }
.matchup-arrow { font-size: 2.2rem; color: var(--accent); font-weight: 700; }
.article-card { margin: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg); height: 100%; }
.article-img { aspect-ratio: 4 / 3; background: var(--primary-soft); display: grid; place-items: center; overflow: hidden; font-size: 3rem; }
.article-img img { width: 100%; height: 100%; object-fit: cover; }
.article-card figcaption { padding: .75rem; display: flex; flex-direction: column; gap: .15rem; }
.article-card strong { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.2; }
.small-cards .article-img { aspect-ratio: 16 / 9; }
.small-cards .article-card strong { font-size: 1.05rem; }
.btn-big { font-size: 1.2rem; padding: .85rem 3rem; border-radius: 12px; }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; width: 100%; }
.result-stats div { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: .75rem .5rem; display: flex; flex-direction: column; }
.result-stats strong { font-family: var(--font-display); font-size: 1.6rem; }
.result-stats span { color: var(--muted); font-size: .85rem; }
.result-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; }
.center-crumbs { justify-content: center; }
.game-body.solo { grid-template-columns: 1fr; max-width: 980px; }
.goal-thumb { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; align-self: center; }
span.goal-title { cursor: default; }

@media (max-width: 600px) {
  .matchup { grid-template-columns: 1fr; gap: .5rem; }
  .matchup-arrow { transform: rotate(90deg); font-size: 1.6rem; line-height: 1; }
  .article-card { flex-direction: row; text-align: left; }
  .article-img, .small-cards .article-img { aspect-ratio: auto; width: 110px; min-height: 96px; flex-shrink: 0; }
  .article-card figcaption { justify-content: center; }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .daily-hero { padding: 1.5rem 1rem; }
  .daily-hero h1 { font-size: 1.6rem; }
  .topbar .btn { padding: .5rem .7rem; font-size: .9rem; }
}
