/* ===========================
   RANKLE — Daily Ranking Puzzle
   =========================== */

/* ── Light mode (default) ── */
:root {
  --bg:          #f2f2ee;
  --surface:     #ffffff;
  --surface2:    #ededea;
  --border:      #d4d4cc;
  --accent:      #4f46e5;
  --accent2:     #e83e6c;
  --gold:        #a07200;
  --silver:      #595959;
  --bronze:      #7a4d18;
  --text:        #111111;
  --text-muted:  #585852;
  --success:     #1b7a43;
  --error:       #bf2d3a;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius:    0px;
  --radius-sm: 0px;
  --shadow:    0 1px 10px rgba(0,0,0,0.08);
  --overlay:   rgba(0,0,0,0.48);
}


* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}


/* ── Header ── */
header {
  width: 100%;
  max-width: 680px;
  margin-top: 32px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

header.hidden-on-splash { display: none; }

header.header-entering {
  animation: headerSlideIn 0.45s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes headerSlideIn {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--text);
}

.date-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ── Main Container ── */
main {
  width: 100%;
  max-width: 680px;
  padding: 20px;
  flex: 1;
}

/* ── Screens ── */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; gap: 20px; }

/* ── Splash ── */
#splash-screen {
  align-items: center;
  text-align: center;
  padding-top: 0;
}

#splash-screen.exiting {
  animation: splashExit 0.3s ease forwards;
  pointer-events: none;
}

@keyframes splashExit {
  to { opacity: 0; transform: translateY(-24px); }
}

.splash-hero-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 32px;
  margin-bottom: 32px;
}

.splash-logo-hero {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--text);
}

.splash-date-hero {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

#game-screen.game-entering {
  animation: gameEnter 0.45s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes gameEnter {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.splash-hero {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.splash-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: -4px;
}

.splash-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  max-width: 400px;
}

.scoring-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  justify-content: center;
  width: 100%;
}

.scoring-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.scoring-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.scoring-icon {
  font-size: 0.82rem;
  letter-spacing: -2px;
}

.today-countries {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px;
  width: 100%;
}

.today-countries h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 14px;
  text-align: center;
}

.country-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.country-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 14px 6px 8px;
  font-size: 0.9rem;
}

.country-flag { font-size: 1.3rem; line-height: 1; }

.btn-primary {
  width: 240px;
  padding: 14px;
  margin-top: 16px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.3px;
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

/* ── Game Screen ── */
#game-screen { }

.progress-bar-wrap {
  background: var(--surface2);
  height: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.5s ease;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.q-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.category-tag {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent) 13%, var(--surface));
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px;
}

.question-text {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 8px;
}

.question-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Drop Zones ── */
.podium-section h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.podium {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drop-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 2px dashed var(--border);
  padding: 12px 16px;
  min-height: 60px;
  transition: border-color 0.15s, background 0.15s;
  cursor: default;
  position: relative;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  border-style: solid;
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}

.drop-zone.filled {
  border-style: solid;
  border-color: var(--border);
}

.medal-icon {
  font-size: 1.4rem;
  min-width: 32px;
  text-align: center;
}

.drop-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.drop-zone .country-card-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

/* ── Pool Cards ── */
.pool-section h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.country-pool {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.country-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  padding: 16px 10px 14px;
  flex: 1;
  min-width: 80px;
  min-height: 110px;
  cursor: grab;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s, opacity 0.15s;
  user-select: none;
}

.country-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.country-card.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.country-card.in-podium {
  opacity: 0.35;
  pointer-events: none;
}

.drag-handle { display: none; } /* hidden — column card layout has no room for handle */

.card-flag { font-size: 2.2rem; line-height: 1; }
.card-name { font-weight: 600; font-size: 14px; line-height: 1.3; white-space: normal; }
.card-code { font-size: 0.8rem; color: var(--text-muted); }

.btn-submit {
  width: 100%;
  padding: 14px;
  background: var(--surface);
  color: var(--text-muted);
  border: 2px solid var(--border);
  font-size: 1rem;
  font-weight: 700;
  cursor: not-allowed;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.btn-submit.ready {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  border-color: transparent;
  cursor: pointer;
}

.btn-submit.ready:hover { opacity: 0.88; transform: translateY(-1px); }

/* ── Result Overlay ── */
#result-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#result-overlay.visible { display: flex; }

.result-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 640px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.score-chip {
  font-size: 0.9rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
}

.score-chip.perfect { background: color-mix(in srgb, var(--success) 15%, var(--surface2)); color: var(--success); }
.score-chip.partial  { background: color-mix(in srgb, var(--gold)    15%, var(--surface2)); color: var(--gold); }
.score-chip.miss     { background: color-mix(in srgb, var(--error)   13%, var(--surface2)); color: var(--error); }

.answer-comparison { margin-bottom: 4px; }

/* ── Side-by-side result comparison ── */
.rc-metric-head {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
}

.result-cols-wrap {
  display: flex;
  align-items: stretch;
  position: relative;
}

.result-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.result-connector-spacer { width: 80px; flex-shrink: 0; }

.rc-col-head {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 4px;
  height: 22px;
  display: flex;
  align-items: center;
}

/* Desktop: mobile-only label hidden */
.rc-col-head-mobile { display: none; }

.rc {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  padding: 10px 6px 8px;
  flex: 1;           /* equal height within parent flex column */
  min-width: 0;
  min-height: 110px;
  box-sizing: border-box;
  gap: 3px;
  position: relative;
}

.your-rc { border-top-width: 3px; }
.rc-exact { border-top-color: #4caf7d; }
.rc-near  { border-top-color: #f5c518; }
.rc-miss  { border-top-color: var(--error); }

.rc-rank {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}
.rc-medal { font-size: 1.5rem; }

.rc-flag { font-size: 2rem; line-height: 1; }

.rc-name {
  font-size: 14px;
  font-weight: 600;
  white-space: normal;
  word-break: break-word;
  line-height: 1.2;
  text-align: center;
}

.rc-val {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  white-space: normal;
  line-height: 1.2;
}

.rc-year {
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.55;
  text-align: center;
  line-height: 1.2;
  margin-top: 1px;
}

.rc-miss-x {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--error) 18%, var(--surface2));
  color: var(--error);
  font-size: 0.7rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.rc-pts {
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  position: absolute;
  top: 6px;
  right: 7px;
  margin-top: 0;
}
.rc-pts-label { font-size: 11px; font-weight: 400; opacity: 0.75; }
.pts-exact { color: var(--success); }
.pts-near  { color: var(--gold); }
.pts-miss  { color: var(--text-muted); }

.rc-perfect-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--success);
  color: var(--bg);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 6px;
  text-transform: none;
  vertical-align: middle;
  white-space: nowrap;
}

.rc-svg-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 1;
}

.description-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 14px;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.read-more-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  margin-top: 6px;
}

.read-more-content {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.7;
}

.read-more-content.open { display: block; }

.source-link {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

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

.btn-next {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-next:hover { opacity: 0.88; transform: translateY(-1px); }

/* ── Final Screen ── */
#final-screen {
  align-items: center;
  text-align: center;
}

.final-emoji { font-size: 4rem; margin-bottom: 12px; }
.final-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 8px; }
.final-message { font-size: 20px; font-weight: 700; margin: 10px 0 6px; }
.final-max   { font-size: 1rem; color: var(--text-muted); margin-bottom: 6px; }
.final-bonus { font-size: 16px; color: var(--text-muted); margin-bottom: 16px; letter-spacing: 0.3px; }

.streak-box {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.streak-stat  { text-align: center; }
.streak-num   { font-size: 2rem; font-weight: 800; }
.streak-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.share-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 16px;
  width: 100%;
  font-family: monospace;
  font-size: 0.85rem;
  line-height: 1.8;
  text-align: center;
  color: var(--text-muted);
  white-space: pre;
}
.q4-row {
  display: inline-flex;
  gap: 4px;
  vertical-align: middle;
}
.q4-rect {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5em;
  height: 2.5em;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-weight: 800;
}
.q4-rect.hit  { color: var(--success); }
.q4-rect.miss { color: var(--text-muted); opacity: 0.3; }
.emoji-cell {
  display: inline-block;
  width: 2.5em;
  height: 2.5em;
  border-radius: 4px;
}
.emoji-cell.exact { background: var(--success); }
.emoji-cell.near  { background: #f5c518; }
.emoji-cell.miss  { background: var(--surface2); border: 1px solid var(--border); }
.share-grid {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.btn-share {
  width: 100%;
  padding: 14px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-share:hover { border-color: var(--accent); color: var(--accent); }

.btn-tomorrow {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 0.85rem;
  cursor: default;
}

/* ── Loading ── */
.loading-wrap {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  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); } }

.error-box {
  background: color-mix(in srgb, var(--error) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--error) 28%, transparent);
  padding: 20px;
  text-align: center;
  color: var(--error);
}

/* ── Footer ── */
footer {
  padding: 20px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

footer a { color: var(--accent); text-decoration: none; }

.sources-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  font-family: var(--font);
}
.sources-link:hover { text-decoration: underline; }

/* ── Sources Dialog ── */
#sources-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#sources-overlay.visible { display: flex; }

.sources-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.sources-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sources-title { font-size: 1.1rem; font-weight: 700; }

.sources-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.sources-close:hover { color: var(--text); border-color: var(--accent); }

.sources-list {
  list-style: none;
  overflow-y: auto;
  padding: 12px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sources-list li a {
  display: block;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.12s;
}
.sources-list li a:hover { background: var(--surface2); color: var(--accent); }

/* ── Q4 Bonus Round ── */
#q4-screen {
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px 16px 32px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.q4-header { text-align: center; }

.q4-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), #ff6584);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.q4-sub { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

.q4-question {
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
  color: var(--text);
  padding: 0 4px;
}

.q4-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

.q4-grid .q4-card:nth-child(4) { grid-column: 1; }
.q4-grid .q4-card:nth-child(5) { grid-column: 2; }

.q4-card {
  background: var(--surface);
  border: 2px solid var(--border);
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.q4-card:active { transform: scale(0.96); }

.q4-card.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.q4-card.revealed-correct {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
}
.q4-card.revealed-wrong {
  border-color: var(--error);
  background: color-mix(in srgb, var(--error) 8%, var(--surface));
  opacity: 0.7;
}
.q4-card.revealed-missed {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 6%, var(--surface));
  opacity: 0.55;
}

/* ── Revealed indicator badges (top-right corner) ── */
.q4-card.revealed-correct::after,
.q4-card.revealed-wrong::after,
.q4-card.revealed-missed::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  color: #fff;
}
.q4-card.revealed-correct::after {
  content: '✓';
  background: var(--success);
}
.q4-card.revealed-wrong::after {
  content: '✕';
  background: var(--error);
}
.q4-card.revealed-missed::after {
  content: '✓';
  background: var(--success);
  opacity: 0.6;
}

.q4-flag { font-size: 2rem; line-height: 1; }

.q4-name {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  line-height: 1.2;
}

/* ── Q4 Result Overlay ── */
#q4-result-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#q4-result-overlay.visible { display: flex; }

.q4-result-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 28px 24px 24px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.q4-multiplier {
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), #ff6584);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.q4-multiplier.perfect { background: linear-gradient(135deg, #f5c518, #ff9800); -webkit-background-clip: text; background-clip: text; }
.q4-multiplier.good    { background: linear-gradient(135deg, var(--accent), #ff6584); -webkit-background-clip: text; background-clip: text; }
.q4-multiplier.miss    { background: none; -webkit-text-fill-color: var(--text-muted); color: var(--text-muted); }

.q4-result-label { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.q4-result-calc  { font-size: 1rem; color: var(--text-muted); font-weight: 500; }

.q4-breakdown {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
}

.q4-bd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  padding: 4px 0;
}
.q4-bd-row .name { display: flex; align-items: center; gap: 6px; }
.q4-bd-icon { font-size: 1rem; }

/* ── Zone: selected state (tap-selected from zone) ── */
.drop-zone.zone-selected {
  border-color: var(--accent);
  border-style: solid;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* ── Zone remove button ── */
.zone-remove-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.62rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  z-index: 2;
  padding: 0;
  line-height: 1;
}
.zone-remove-btn:hover {
  background: color-mix(in srgb, var(--error) 15%, var(--surface));
  color: var(--error);
  border-color: var(--error);
}
/* Desktop: show remove button on hover over filled zone */
@media (min-width: 641px) {
  .drop-zone.filled:hover .zone-remove-btn { display: flex; }
}
/* Mobile: show remove button when zone is selected */
@media (max-width: 640px) {
  .drop-zone.zone-selected .zone-remove-btn { display: flex; }
}

/* ── Game hint instruction text ── */
.game-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
  padding: 2px 0;
}
.hint-desktop { display: inline; }
.hint-mobile  { display: none; }
@media (max-width: 640px) {
  .hint-desktop { display: none; }
  .hint-mobile  { display: inline; }
}

/* ── Tap-select & drag-highlight states ── */
.country-card.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
  transform: translateY(-2px);
}

.drop-zone.placement-target {
  border-color: var(--accent);
  border-style: dashed;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  animation: pulse-target 1.1s ease-in-out infinite;
}

@keyframes pulse-target {
  0%, 100% { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
  50%       { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); }
}

/* ── Responsive: result / q4 tweaks ── */
@media (max-width: 480px) {
  .splash-title    { font-size: 20px; }
  .question-text   { font-size: 1rem; }
  .q4-question     { font-size: 1rem; }
  .q4-grid         { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .q4-flag         { font-size: 1.6rem; }
}

/* ── Mobile game layout (≤ 640px) ── */
@media (max-width: 640px) {

  /* Section headings centred */
  .pool-section h3,
  .podium-section h3 {
    text-align: center;
  }

  /* ── Country pool → centered flex-wrap grid ── */
  .country-pool {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }

  .country-card {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    /* 3 per row with gaps */
    flex: 0 0 calc(33.33% - 8px);
    padding: 16px 8px 14px;
    gap: 8px;
    cursor: pointer;
    min-height: 110px;
  }

  .country-card .drag-handle { display: none; }
  .country-card .card-flag   { font-size: 2.6rem; line-height: 1; }
  .country-card .card-name   { font-size: 14px; line-height: 1.3; white-space: normal; }
  .country-card .card-code   { display: none; }

  /* ── Podium → horizontal 3 equal slots ── */
  .podium {
    flex-direction: row;
    gap: 8px;
  }

  .drop-zone {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 10px 6px 10px;
    min-height: 88px;
    text-align: center;
    gap: 4px;
  }

  /* Hide "drag or tap" hint text — medal icon is enough */
  .drop-zone .drop-label { display: none; }

  .drop-zone .medal-icon {
    font-size: 1.2rem;
    min-width: unset;
  }

  /* Country placed inside a slot: column layout */
  .drop-zone .country-card-inner {
    flex-direction: column !important;
    align-items: center !important;
    gap: 3px !important;
    justify-content: center;
    margin-top: 2px;
  }

  .drop-zone .country-card-inner .drag-handle { display: none; }
  .drop-zone .country-card-inner .card-flag   { font-size: 1.5rem; }
  .drop-zone .country-card-inner .card-name   {
    font-size: 12px;
    text-align: center;
    white-space: normal;
    line-height: 1.2;
  }
  .drop-zone .country-card-inner .card-code   { display: none; }

  /* ── Mobile result sheet: top-bottom layout ── */
  .result-sheet { padding: 16px 12px; }

  /* Wrap becomes vertical: your-row / spacer / correct-row */
  .result-cols-wrap { flex-direction: column; gap: 0; }

  /* Each side: CSS grid with 3 equal columns (heading spans all 3) */
  .result-side {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    overflow: visible;
    flex: none; /* prevent vertical stretch in the column flex parent */
  }

  /* Col heading spans all 3 grid columns, sits above the cards */
  .rc-col-head {
    grid-column: 1 / -1;   /* full width across all 3 columns */
    width: auto;
    height: auto;
    margin-bottom: 2px;
    font-size: 0.6rem;
    position: relative;
    z-index: 2;             /* appear above the SVG arrow overlay (z-index:1) */
  }

  /* Connector spacer: horizontal strip between rows */
  .result-connector-spacer {
    width: auto;
    height: 56px;
    flex-shrink: 0;
  }

  /* Color indicator: global already sets border-top */
  .your-rc  { border-top-width: 3px; border-left-width: 1.5px; }
  .rc-exact { border-top-color: #4caf7d; }
  .rc-near  { border-top-color: #f5c518; }
  .rc-miss  { border-top-color: var(--error); }

  /* Correct-order label: show between your-cards and spacer on mobile */
  .rc-col-head-mobile {
    display: flex;
    align-items: center;
    margin-top: 6px;
    margin-bottom: 0;
    padding: 0 4px;
    position: relative;
    z-index: 2;
  }
  .rc-col-head-desktop { display: none; }

  /* Individual result card: compact tile */
  .rc {
    padding: 7px 4px 6px;
    min-height: 100px;
    gap: 2px;
  }

  .rc-rank  { font-size: 0.9rem; }
  .rc-medal { font-size: 1.3rem; }
  .rc-flag  { font-size: 1.6rem; }
  .rc-name  { font-size: 14px; word-break: break-word; }
  .rc-val   { font-size: 12px; }
  .rc-year  { font-size: 9px; }
  .rc-pts   { position: static; font-size: 13px; text-align: center; margin-top: 2px; }
  .rc-pts-label { font-size: 10px; }
  /* Miss ✕ badge: circle centered on the bottom edge of the card */
  .rc-miss-x {
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--error) 18%, #ffffff);
    color: var(--error);
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    z-index: 3;
  }
  .rc-perfect-tag { font-size: 0.55rem; padding: 2px 5px; }
}
