:root {
  --cream: #fbf1d3;
  --navy: #172033;
  --navy-2: #1f2a3a;
  --card: #2e3645;
  --line: #4a5262;
  --yellow: #f6d982;
  --text: #fdf3c8;
  --green: #6fc77d;
  --red: #d05a47;
  --orange: #d4903d;
  --head: 'Bungee', 'Arial Black', sans-serif;
  --body: 'Saira Extra Condensed', 'Arial Narrow', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; max-width: 100%; }
html { overflow-x: hidden; }
body { overflow-x: clip; }
body {
  background: var(--cream);
  color: var(--text);
  font-family: var(--body);
  font-weight: 600;
  font-size: 22px;
  min-height: 100vh;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,.3);
}
.brand { font-family: var(--head); font-size: 26px; color: var(--yellow); text-decoration: none; letter-spacing: 1px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--navy); color: var(--yellow);
  border: 2px solid var(--yellow); font-size: 22px; cursor: pointer;
}
#app { max-width: 1000px; margin: 28px auto 60px; padding: 0 14px; }
.panel {
  background: var(--navy);
  border-radius: 24px;
  padding: 28px 30px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  margin-bottom: 26px;
}
h1, h2 {
  font-family: var(--head);
  color: var(--yellow);
  text-align: center;
  margin: 6px 0 16px;
  text-shadow: 0 2px 0 rgba(0,0,0,.35);
  text-transform: uppercase;
  letter-spacing: 1px;
}
h1 { font-size: 40px; }
h2 { font-size: 30px; }
h3 { font-family: var(--head); color: var(--yellow); text-align: center; margin: 4px 0 12px; font-size: 24px; text-transform: uppercase; font-weight: 400; }
p.sub { text-align: center; margin: 0 0 18px; font-size: 24px; }
.muted { opacity: .75; }

.btn {
  font-family: var(--head);
  font-size: 20px;
  color: var(--yellow);
  background: var(--navy);
  border: 3px solid var(--yellow);
  border-radius: 12px;
  padding: 12px 22px;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform .08s, background .15s;
}
.btn:hover { background: #24304a; }
.btn:active { transform: translateY(2px); }
.btn.solid { background: var(--yellow); color: var(--navy); }
.btn.solid:hover { background: #ffe9a3; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.small { font-size: 15px; padding: 7px 12px; border-width: 2px; }
.center { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 16px; }

/* menu */
.len-picker { display: flex; justify-content: center; gap: 14px; margin: 14px 0 22px; flex-wrap: wrap; }
.len-picker button {
  font-family: var(--head); font-size: 34px; width: 110px; height: 90px;
  background: var(--navy-2); color: var(--text); border: 3px solid var(--line); border-radius: 16px; cursor: pointer;
}
.len-picker button small { display: block; font-family: var(--body); font-size: 18px; }
.len-picker button.on { background: var(--yellow); color: var(--navy); border-color: var(--yellow); }

/* progress */
.progress { display: flex; justify-content: space-between; font-size: 24px; margin-bottom: 8px; }
.progress b { color: var(--yellow); }
.bar { height: 10px; background: var(--navy-2); border-radius: 6px; overflow: hidden; margin-bottom: 18px; }
.bar > i { display: block; height: 100%; background: var(--yellow); transition: width .3s; }

/* clue */
.clue { text-align: center; }
.clue .big { font-family: var(--head); font-size: 46px; color: var(--text); margin: 10px 0 2px; }
.clue .label { font-size: 22px; color: var(--yellow); text-transform: uppercase; letter-spacing: 2px; }
.clue img.flag-big { width: 300px; max-width: 80%; border-radius: 12px; border: 4px solid var(--green); margin: 8px 0; }
.clue img.flag-big.plain { border-color: #4b8f4e; }

.card { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 14px 16px 12px; margin-bottom: 22px; }
.divider { height: 3px; background: var(--yellow); border: 0; margin: 22px 0; border-radius: 2px; }

/* inputs */
.field { position: relative; margin-bottom: 8px; }
.field label { display: block; text-align: center; font-size: 22px; margin-bottom: 4px; }
.field input {
  width: 100%; font: inherit; font-size: 26px; color: var(--text);
  background: #23304a; border: 3px solid var(--line); border-radius: 14px; padding: 8px 14px; outline: none;
}
.field input:focus { border-color: var(--yellow); }
.field input.ok { border-color: var(--green); background: #56705f; }
.field input.bad { border-color: var(--red); background: #6a4a4a; }
.fb { text-align: center; font-size: 19px; min-height: 24px; }
.fb.ok { color: var(--green); }
.fb.bad { color: #ff9a86; }
.ac-list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 15; margin: 2px 0 0; padding: 4px; list-style: none;
  background: #111a2b; border: 2px solid var(--yellow); border-radius: 12px; max-height: 260px; overflow-y: auto; display: none;
}
.ac-list li { padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 22px; }
.ac-list li:hover, .ac-list li.hl { background: #2b3b5c; }

/* flag picker */
.flag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin-top: 8px; }
.flag-opt {
  background: var(--navy-2); border: 3px solid transparent; border-radius: 10px; padding: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; aspect-ratio: 3 / 2;
}
.flag-opt img { max-width: 100%; max-height: 100%; border-radius: 3px; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.flag-opt:hover { border-color: #b9a560; }
.flag-opt.sel { border-color: var(--yellow); background: #3a4560; }
.flag-opt.ok { border-color: var(--green); background: #4f7a58; }
.flag-opt.bad { border-color: var(--red); background: #7b4640; }
.flag-opt.answer { border-color: var(--green); }
.flag-grid.locked .flag-opt { cursor: default; }

/* ranking */
.rank-row {
  display: flex; gap: 12px; background: #131c2d; border-radius: 12px; padding: 12px; min-height: 100px;
}
.rank-row.reveal { background: transparent; padding: 14px 4px 4px; }
.tile {
  flex: 1 1 0; min-width: 0; background: var(--navy-2); border-radius: 10px; padding: 14px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px;
  min-height: 112px; font-size: 22px; line-height: 1.1; user-select: none;
}
.tile .t-name { font-size: 23px; }
.tile .t-val { font-size: 21px; }
.tile img { width: 76%; border-radius: 4px; }
.tile.target { background: #3c4a66; border: 3px dashed var(--yellow); cursor: grab; touch-action: none; }
.tile.target.dragging { cursor: grabbing; box-shadow: 0 0 0 4px rgba(246,217,130,.35); }
.tile.target.locked { cursor: default; border-style: solid; }
.tile.target.ok { background: var(--green); border-color: var(--green); color: var(--navy); }
.tile.target.bad { background: var(--red); border-color: var(--red); }
.rank-row.reveal .tile { background: #243044; border: 1px solid #e8dcb0; }
.rank-row.reveal .tile.answer { background: var(--orange); border-color: #e8dcb0; }
.ends { display: flex; justify-content: space-between; font-size: 20px; text-transform: uppercase; padding: 6px 4px 0; }
.hint { text-align: center; font-size: 19px; opacity: .8; margin: -4px 0 8px; }

/* results */
.big-score { font-family: var(--head); font-size: 72px; text-align: center; color: var(--text); margin: 8px 0; }
.initials {
  display: block; margin: 12px auto; width: 190px; font-family: var(--head); font-size: 54px; text-align: center;
  text-transform: uppercase; letter-spacing: 8px; color: var(--yellow); background: #23304a; border: 3px solid var(--yellow); border-radius: 14px; padding: 6px 0 6px 8px;
}

/* tables / stats */
table { width: 100%; border-collapse: collapse; font-size: 22px; }
th { color: var(--yellow); text-align: left; font-weight: 700; border-bottom: 2px solid var(--line); padding: 6px 8px; text-transform: uppercase; font-size: 18px; }
td { padding: 6px 8px; border-bottom: 1px solid #2b3446; }
td.num, th.num { text-align: right; }
tr.me td { color: var(--yellow); }
.tabs { display: flex; justify-content: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { font-family: var(--head); font-size: 16px; padding: 8px 16px; background: var(--navy-2); color: var(--text); border: 2px solid var(--line); border-radius: 10px; cursor: pointer; }
.tabs button.on { background: var(--yellow); color: var(--navy); border-color: var(--yellow); }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-tile { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.stat-tile b { display: block; font-family: var(--head); font-size: 30px; color: var(--yellow); font-weight: 400; }
.hbar { display: grid; grid-template-columns: 130px 1fr 60px; gap: 10px; align-items: center; margin: 6px 0; }
.hbar .track { height: 18px; background: var(--navy-2); border-radius: 9px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--green); }
.hbar.best .track i { background: var(--yellow); }
.hbar span:last-child { text-align: right; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
select, .select {
  font: inherit; font-size: 22px; color: var(--text); background: #23304a; border: 2px solid var(--line); border-radius: 10px; padding: 6px 10px;
}
.check { display: flex; align-items: center; gap: 12px; font-size: 26px; margin: 8px 0; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--green); }
svg.trend { width: 100%; height: 200px; display: block; }

@media (max-width: 720px) {
  body { font-size: 18px; }
  .panel { padding: 18px 12px; border-radius: 18px; }
  .brand { font-size: 18px; }
  h1 { font-size: 28px; } h2 { font-size: 22px; }
  .clue .big { font-size: 30px; }
  .rank-row { gap: 6px; padding: 8px; }
  .tile { font-size: 16px; padding: 8px 2px; min-height: 90px; }
  .tile .t-name { font-size: 16px; } .tile .t-val { font-size: 15px; }
  .two-col { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 90px 1fr 48px; }
}

/* continent choices */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.choice { font: inherit; font-size: 24px; color: var(--text); background: var(--navy-2); border: 3px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; }
.choice:hover { border-color: #b9a560; }
.choice.sel { border-color: var(--yellow); background: #3a4560; }
.choice.ok { border-color: var(--green); background: #4f7a58; }
.choice.bad { border-color: var(--red); background: #7b4640; }
.choice[disabled] { cursor: default; }

/* settings modal */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 22, .72); display: flex; align-items: center; justify-content: center; padding: 14px; overflow-y: auto; }
.modal { background: var(--navy); border: 3px solid var(--yellow); border-radius: 22px; padding: 22px 26px; width: 100%; max-width: 460px; max-height: 94vh; overflow-y: auto; }
.switch-row { display: flex; align-items: center; justify-content: space-between; font-size: 26px; margin: 10px 0; cursor: pointer; }
.switch { appearance: none; width: 58px; height: 30px; border-radius: 15px; background: #3d4658; position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--text); transition: left .2s; }
.switch:checked { background: var(--green); }
.switch:checked::after { left: 31px; }
.modal hr { border: 0; height: 2px; background: var(--line); margin: 16px 0; }
.btn.danger { border-color: var(--red); color: #ff9a86; }
.btn.danger:hover { background: #3a2230; }

/* flag name tooltip after answers are checked */
.flag-grid.locked .flag-opt { position: relative; }
.flag-grid.locked .flag-opt:hover::after {
  content: attr(data-name); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--yellow); color: var(--navy); font-size: 20px; font-weight: 700; white-space: nowrap;
  padding: 4px 12px; border-radius: 8px; z-index: 10; pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.flag-grid.locked .flag-opt:hover { z-index: 11; }

/* fun fact side panel */
#app:has(.stage) { max-width: 1440px; }
.stage { display: flex; justify-content: center; align-items: flex-start; gap: 24px; }
.stage > .panel { flex: 0 1 1000px; min-width: 0; transition: flex-basis .45s ease; }
.stage.has-fact > .panel { flex-basis: 760px; }
.fact-panel {
  flex: 0 0 340px; position: sticky; top: 80px; background: var(--navy); border: 3px solid var(--yellow); border-radius: 22px;
  padding: 20px 22px; box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: factIn .45s ease both;
}
@keyframes factIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.fact-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.fact-head img { width: 64px; border-radius: 6px; box-shadow: 0 0 0 1px rgba(255,255,255,.3); }
.fact-kicker { font-family: var(--head); color: var(--yellow); font-size: 18px; text-transform: uppercase; }
.fact-country { font-size: 26px; line-height: 1.05; }
.fact-tag { display: inline-block; font-size: 17px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; padding: 3px 12px; border-radius: 999px; background: #3a4560; color: var(--text); margin-bottom: 10px; }
.fact-h { background: #7a5a2a; } .fact-g { background: #2f6b4a; } .fact-c { background: #6b3f6e; }
.fact-m { background: #8a3b32; } .fact-i { background: #b8731d; } .fact-x { background: #3a5a8a; }
.fact-text { font-size: 25px; line-height: 1.2; margin: 0 0 14px; min-height: 150px; }
.fact-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fact-arrow { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--yellow); background: var(--navy); color: var(--yellow); font-size: 30px; line-height: 1; padding: 0 0 4px; cursor: pointer; }
.fact-arrow:hover { background: var(--yellow); color: var(--navy); }
.fact-dots { display: flex; gap: 6px; }
.fact-dots i { cursor: pointer; }
.fact-dots i { width: 22px; height: 6px; border-radius: 3px; background: #3a4560; }
.fact-dots i.on { background: var(--yellow); }
@media (max-width: 1099px) {
  .stage { flex-direction: column; align-items: stretch; }
  .stage > .panel, .stage.has-fact > .panel { flex-basis: auto; }
  .fact-panel { flex: none; position: static; }
}

/* daily challenge card + dialogs */
.daily-card { background: var(--card); border: 3px solid var(--yellow); border-radius: 18px; padding: 16px 18px; margin: 4px 0 22px; text-align: center; }
.daily-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.daily-title { font-family: var(--head); color: var(--yellow); font-size: 24px; text-transform: uppercase; }
.streak { font-size: 24px; color: var(--orange); font-weight: 700; }
.daily-note { margin-top: 8px; font-size: 20px; opacity: .85; }
.dialog-back { z-index: 80; }
.dialog { max-width: 420px; text-align: center; }
.dialog-text { font-size: 24px; margin: 6px 0 14px; }

/* phones: rank tiles become a top-to-bottom list so names and values never collide */
@media (max-width: 720px) {
  .rank-card { display: flex; flex-direction: column; }
  .rank-card > h3 { order: -1; }
  .rank-card .ends { display: contents; }
  .rank-card .e-l { order: 0; text-align: left; font-size: 18px; margin-bottom: 4px; }
  .rank-card .e-l::before { content: '\25B2  '; }
  .rank-card .rank-row { order: 1; flex-direction: column; gap: 8px; min-height: 0; }
  .rank-card .rank-row.reveal { order: 2; margin-top: 8px; }
  .rank-card .e-g { order: 3; text-align: left; font-size: 18px; margin-top: 6px; }
  .rank-card .e-g::before { content: '\25BC  '; }
  .rank-row .tile {
    flex: none; flex-direction: row; justify-content: space-between; align-items: center; text-align: left; gap: 12px;
    min-height: 56px; padding: 10px 14px; overflow-wrap: anywhere;
  }
  .rank-row .tile .t-name { font-size: 20px; flex: 1 1 auto; }
  .rank-row .tile .t-val { font-size: 20px; flex: none; text-align: right; white-space: nowrap; }
  .rank-row .tile img { width: 64px; flex: none; }
  .rank-row .tile.target:not(.locked) .t-val { display: none; }
  .hint { font-size: 17px; }
}

/* never allow sideways scrolling on small screens */
#app, .stage, .panel, .card, .fact-panel { max-width: 100%; }
.stage > .panel, .fact-panel { min-width: 0; }
img, svg { max-width: 100%; }
table { display: block; overflow-x: auto; }
.topbar { min-width: 0; }
.brand { min-width: 0; overflow-wrap: anywhere; }
