:root {
  --bg: #0f1420;
  --panel: #19202e;
  --panel-2: #222b3d;
  --line: #2c374b;
  --text: #e7edf6;
  --muted: #93a1b5;
  --accent: #4ea1ff;
  --staying: #ffcf5c;
  --logged: #4ea1ff;
  --t1: #6b7787; --t2: #4f8f6e; --t3: #c7a14a; --t4: #d2783a; --t5: #d6504f;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; background: transparent; color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* full-screen looping video backdrop (shows on every view) */
.bg-video { position: fixed; inset: 0; z-index: -2; overflow: hidden; }
.bg-video video { width: 100%; height: 100%; object-fit: cover; }
.bg-video::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11,16,24,.80), rgba(11,16,24,.92));
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: rgba(25, 32, 46, .72);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; }
.tag {
  font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; margin-left: 6px;
}
.topnav { display: flex; align-items: center; gap: 16px; }
.navlink, .navlink:hover { background: none; border: none; }
.navlink { color: var(--accent); cursor: pointer; font: inherit; font-weight: 600; padding: 4px; text-decoration: none; }
.navlink:hover { text-decoration: underline; }
.user-chip { display: flex; align-items: center; gap: 10px; }

/* modal (how-to) */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center;
  justify-content: center; background: rgba(0, 0, 0, .6); padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { position: relative; width: 100%; max-width: 460px; padding: 22px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55); }
.modal-card h2 { margin: 0 0 8px; }
.modal-close { position: absolute; top: 8px; right: 12px; background: none; border: none;
  color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.howto-list { padding-left: 20px; margin: 12px 0; }
.howto-list li { margin: 8px 0; }
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: #ff7a7a; min-height: 18px; }

.card {
  background: rgba(25, 32, 46, .86); backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
button {
  cursor: pointer; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); padding: 9px 14px; border-radius: 9px; font-weight: 600;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #06121f; }
button.google { background: #fff; color: #1a1a1a; border-color: #fff; }
button.link { background: none; border: none; color: var(--accent); padding: 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
button.full { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; }
.gicon { width: 18px; height: 18px; }
.or-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0; }
.or-sep::before, .or-sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }
label { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); }
input, select {
  width: 100%; margin-top: 4px; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 14px;
}

.login, .onboard { max-width: 420px; margin: 6vh auto; }

/* game layout */
.game { display: grid; grid-template-columns: 1fr 360px; gap: 16px; }
.main-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 900px) { .game { grid-template-columns: 1fr; } }
.map-wrap { background: rgba(25, 32, 46, .86); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.howto {
  background: rgba(78, 161, 255, .14); border: 1px solid var(--accent); color: var(--text);
  border-radius: 10px; padding: 10px 14px; margin: 2px 2px 10px; font-weight: 600; text-align: center;
}
#map { width: 100%; }
.worldmap { width: 100%; height: auto; display: block; background: #0b1018; border-radius: 8px; }
.country { fill: #33415b; stroke: #0b1018; stroke-width: 0.4px; cursor: pointer; transition: fill .12s; }
.country:hover { fill: #46587a; }
.country.logged { fill: var(--logged); }
.country.staying { fill: var(--staying); }
.legend { font-size: 12.5px; color: var(--muted); margin: 8px 2px 2px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin: 0 4px 0 10px; }
.sw.staying { background: var(--staying); } .sw.logged { background: var(--logged); }

.staying-pick { margin: 0 0 12px; font-weight: 600; color: var(--text); }
.staying-pick select { border-color: var(--staying); }
.side .score-card { text-align: center; }
.big { font-size: 44px; font-weight: 800; color: var(--staying); line-height: 1; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; }
.panel-head h3 { margin: 0; }
.intro-toggle { cursor: pointer; user-select: none; }
.intro-toggle .chev { color: var(--muted); font-size: 12px; margin-right: 4px; }
.wiki { color: var(--accent); text-decoration: none; font-size: 13px; }
.subtle { margin: 14px 0 6px; color: var(--muted); font-size: 13px; }
.pill { float: right; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; color: var(--text); font-weight: 700; }

ul.met, ul.results, ol.lb { list-style: none; margin: 6px 0; padding: 0; }
ul.met { max-height: 240px; overflow-y: auto; padding-right: 4px; }
ul.met li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.met .flag-name { flex: 1; display: flex; align-items: center; }
.flag { width: 20px; height: 14px; object-fit: cover; border-radius: 2px; margin-right: 8px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12); flex: none; vertical-align: -2px; }
.tier { font-weight: 800; color: #06121f; border-radius: 6px; padding: 1px 8px; min-width: 24px; text-align: center; }
.t1 { background: var(--t1); } .t2 { background: var(--t2); } .t3 { background: var(--t3); }
.t4 { background: var(--t4); } .t5 { background: var(--t5); }
.x { padding: 0 8px; background: none; border: none; color: var(--muted); font-size: 18px; }
.x:hover { color: #ff7a7a; }
.add { margin-top: 12px; }
ul.results li {
  display: flex; justify-content: space-between; align-items: center; cursor: pointer;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; background: var(--bg);
}
ul.results li:hover { border-color: var(--accent); }

ol.lb li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
ol.lb .rank { width: 22px; text-align: center; color: var(--muted); font-weight: 700; }
ol.lb .who { flex: 1; }
ol.lb .when { color: var(--muted); font-size: 12px; white-space: nowrap; margin-right: 4px; }
ol.lb .pts { font-weight: 800; color: var(--staying); min-width: 28px; text-align: right; }
ol.lb li.me { background: rgba(78,161,255,.08); border-radius: 8px; padding-left: 6px; }

.foot { display: flex; justify-content: center; max-width: 1200px; margin: 0 auto; padding: 14px 20px; }
.foot a { text-decoration: none; }
pre { white-space: pre-wrap; color: #ff9a9a; }
