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

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #222633;
  --bg-input: #13151d;
  --border: #2a2e3d;
  --text: #e4e6ed;
  --text-muted: #8b8fa3;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --green: #00b894;
  --green-glow: rgba(0, 184, 148, 0.3);
  --red: #e17055;
  --yellow: #fdcb6e;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
}

html { font-size: 16px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Pages ─────────────────────────────────────────────────────────────────── */
.page { display: none; min-height: 100vh; }
.page.active { display: flex; flex-direction: column; }

/* ─── Home ──────────────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #1a1040 0%, #0f1117 50%, #0a1628 100%);
  padding: 4rem 2rem 3rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%, var(--accent-glow) 0%, transparent 50%),
              radial-gradient(circle at 70% 50%, var(--green-glow) 0%, transparent 50%);
  animation: heroGlow 8s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes heroGlow {
  0% { transform: translate(0, 0); }
  100% { transform: translate(2%, -2%); }
}
.hero-content { position: relative; z-index: 1; }

.logo {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -2px;
  margin-bottom: 0.5rem;
}
.logo-sm { font-size: 1.5rem; font-weight: 800; letter-spacing: -1px; }
.accent { color: var(--accent-light); }
.fr-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 0.35em;
  padding: 0.2em 0.5em;
  border-radius: 6px;
  vertical-align: super;
  letter-spacing: 1px;
  font-weight: 700;
}
.tagline { color: var(--text-muted); font-size: 1.2rem; max-width: 500px; margin: 0 auto; }

.home-actions {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
}
.home-actions .card:nth-child(4) { grid-column: 1 / -1; }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
.card-primary { border-color: var(--accent); box-shadow: 0 0 30px var(--accent-glow); }
.card-solo { border-color: var(--green); box-shadow: 0 0 20px var(--green-glow); }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  gap: 0.5rem;
}
.btn:hover { background: var(--bg-card-hover); border-color: var(--text-muted); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn-accent:hover { background: #7c6cf0; border-color: #7c6cf0; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-lg { width: 100%; padding: 0.9rem; font-size: 1.1rem; }

/* ─── Inputs ────────────────────────────────────────────────────────────────── */
.input-group { margin-bottom: 0.75rem; }
input[type="text"], select {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color var(--transition);
}
input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
select { cursor: pointer; }
select option { background: var(--bg-card); }

/* ─── How to Play ───────────────────────────────────────────────────────────── */
.how-to-play { display: flex; gap: 1.5rem; }
.step { flex: 1; text-align: center; }
.step-num {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
}
.step p { color: var(--text); font-size: 0.85rem; }

/* ─── Lobby ─────────────────────────────────────────────────────────────────── */
.lobby-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.lobby-title { display: flex; align-items: center; gap: 1rem; }
.lobby-status {
  background: var(--accent-glow);
  color: var(--accent-light);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}
.lobby-share { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.lobby-share code {
  background: var(--bg-input);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}

.lobby-content {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Player list */
.player-list { list-style: none; }
.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  transition: background var(--transition);
}
.player-list li:hover { background: var(--bg-card-hover); }
.player-name { font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.host-badge {
  background: var(--yellow);
  color: #000;
  font-size: 0.65rem;
  padding: 0.15em 0.5em;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
}
.ready-badge {
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 600;
}
.not-ready-badge {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Settings */
.setting-group { margin-bottom: 1rem; }
.setting-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.article-picker { display: flex; gap: 0.5rem; position: relative; }
.article-picker input { flex: 1; }
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 60px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 10;
  display: none;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.search-results.visible { display: block; }
.search-results div {
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background var(--transition);
}
.search-results div:hover { background: var(--bg-card-hover); }

/* ─── Game ──────────────────────────────────────────────────────────────────── */
.game-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.game-info { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.game-objective { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.article-tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}
.article-tag.start { background: rgba(108, 92, 231, 0.2); color: var(--accent-light); border: 1px solid var(--accent); }
.article-tag.end { background: rgba(0, 184, 148, 0.2); color: var(--green); border: 1px solid var(--green); }
.arrow { color: var(--text-muted); font-size: 1.2rem; }
.label { color: var(--text-muted); font-size: 0.85rem; font-weight: 600; margin-right: 0.25rem; }

.game-stats { display: flex; gap: 1.5rem; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.game-players-bar {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}
.player-bar-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  white-space: nowrap;
  padding: 0.25rem 0.6rem;
  background: var(--bg-input);
  border-radius: 20px;
  border: 1px solid var(--border);
}
.player-bar-item.finished { border-color: var(--green); background: rgba(0,184,148,0.1); }
.player-bar-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.player-bar-item.finished .player-bar-dot { background: var(--green); }

.game-content {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0;
}

.wiki-container {
  width: 100%;
  max-width: 960px;
  padding: 0 1.5rem 2rem;
}

.wiki-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.75rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.wiki-breadcrumb .crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.wiki-breadcrumb .crumb::after { content: '→'; margin: 0 0.25rem; color: var(--border); }
.wiki-breadcrumb .crumb:last-child::after { display: none; }
.wiki-breadcrumb .crumb.current { color: var(--accent-light); font-weight: 600; }

.wiki-article {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  line-height: 1.7;
  font-size: 0.95rem;
}
.wiki-article h1, .wiki-article h2, .wiki-article h3, .wiki-article h4 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 700;
}
.wiki-article h1 { font-size: 1.8rem; border-bottom: 2px solid var(--border); padding-bottom: 0.5rem; margin-top: 0; }
.wiki-article h2 { font-size: 1.3rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.wiki-article p { margin-bottom: 0.8em; }
.wiki-article ul, .wiki-article ol { margin-left: 1.5em; margin-bottom: 0.8em; }
.wiki-article img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.wiki-article table { border-collapse: collapse; width: 100%; margin-bottom: 1em; }
.wiki-article th, .wiki-article td {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  font-size: 0.85rem;
}
.wiki-article th { background: var(--bg-input); }
.wiki-article a {
  color: var(--accent-light);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-light);
  transition: color var(--transition);
}
.wiki-article a:hover { color: #fff; }
.wiki-article .infobox, .wiki-article .infobox_v2 {
  float: right;
  max-width: 300px;
  margin: 0 0 1rem 1.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.85rem;
}

/* Loading spinner */
.wiki-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--text-muted);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Results ───────────────────────────────────────────────────────────────── */
.results-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
  text-align: center;
}
.results-header h2 { color: var(--text-muted); font-weight: 400; margin-top: 0.5rem; }

.results-content {
  max-width: 900px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#results-podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 1rem;
  padding: 2rem 0 1.5rem;
}
.podium-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.podium-rank {
  font-size: 2rem;
  font-weight: 800;
}
.podium-rank.gold { color: var(--gold); }
.podium-rank.silver { color: var(--silver); }
.podium-rank.bronze { color: var(--bronze); }
.podium-name { font-weight: 700; font-size: 1.1rem; }
.podium-time { color: var(--text-muted); font-size: 0.9rem; }
.podium-bar {
  width: 80px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.results-table { width: 100%; border-collapse: collapse; }
.results-table th, .results-table td {
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.results-table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.results-table tr:hover td { background: var(--bg-card-hover); }

.path-display {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.path-display:last-child { border-bottom: none; }
.path-display h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.path-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}
.path-node {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.8rem;
}
.path-node.target { border-color: var(--green); background: rgba(0,184,148,0.1); color: var(--green); }
.path-arrow { color: var(--text-muted); font-size: 0.75rem; }

.results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding: 1rem 0 2rem;
}

/* ─── Victory overlay ───────────────────────────────────────────────────────── */
.victory-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.victory-card {
  background: var(--bg-card);
  border: 2px solid var(--green);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  box-shadow: 0 0 60px var(--green-glow);
  animation: scaleIn 0.4s ease;
}
@keyframes scaleIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.victory-card h2 { font-size: 1.8rem; color: var(--green); margin-bottom: 0.5rem; }
.victory-card .victory-stats { color: var(--text-muted); margin: 1rem 0; }
.victory-card .victory-stats span { color: var(--text); font-weight: 700; }

/* ─── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.6rem 1.2rem;
  border-radius: 20px;
  font-size: 0.9rem;
  z-index: 2000;
  animation: slideUp 0.3s ease;
  box-shadow: var(--shadow);
}
@keyframes slideUp { from { transform: translateX(-50%) translateY(20px); opacity: 0; } }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .home-actions { grid-template-columns: 1fr; }
  .lobby-content { grid-template-columns: 1fr; }
  .how-to-play { flex-direction: column; }
  .game-info { flex-direction: column; align-items: flex-start; }
  .hero { padding: 2.5rem 1rem 2rem; }
  .logo { font-size: 2.5rem; }
  .wiki-article { padding: 1rem; }
  .wiki-article .infobox, .wiki-article .infobox_v2 { float: none; max-width: 100%; margin: 0 0 1rem 0; }
}
