

[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --bg: #F6EEDC;
  --bg-accent: #EDE0C6;
  --panel: rgba(255, 253, 246, 0.72);
  --panel-strong: rgba(255, 253, 246, 0.97);
  --text: #1C2A39;
  --muted: #75664b;
  --primary: #C2412D;
  --on-primary: #ffffff;      
  --primary-deep: #1C3F5E;
  --soft-blue: #F3ECDB;
  --line: #E0D2B6;
  --orange: #B08A3E;
  --red: #C2412D;
  --correct: #1C7A4B;
  --wrong: #b3362d;
  --shadow: 0 24px 56px rgba(96, 72, 32, 0.18);
  --radius-xl: 36px;
  --radius-lg: 24px;
  
  --gold: #8f6b26;
  --gold-soft: #E7B96b;
  --navy: #1C3F5E;
  --navy-2: #2a5578;
  --paper-card: rgba(255, 255, 255, 0.55);
  --divider: #ECE2CC;
  --font-serif: "DM Serif Display", "Gowun Batang", "Apple SD Gothic Neo", serif;
  --font-latin-serif: "DM Serif Display", Georgia, serif;
  --font-mono: "Space Mono", ui-monospace, Menlo, monospace;
  
  --font-sans: "Avenir Next", "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --bg: #14293c;
    --bg-accent: #0f2130;
    --panel: rgba(255, 255, 255, 0.06);
    --panel-strong: rgba(22, 45, 66, 0.97);
    --text: #EAE1CC;
    --muted: #9fb4c8;
    --primary: #E2725B;
  --on-primary: #14202C;      
    --primary-deep: #E7B96b;
    --soft-blue: rgba(231, 185, 107, 0.10);
    --line: rgba(234, 225, 204, 0.16);
    --orange: #E7B96b;
    --red: #E2725B;
    --correct: #58b98a;
    --wrong: #E2725B;
    --shadow: 0 24px 56px rgba(0, 0, 0, 0.45);
    --gold: #E7B96b;
    --gold-soft: #E7B96b;
    --navy: #1C3F5E;
    --navy-2: #2a5578;
    --paper-card: rgba(255, 255, 255, 0.06);
    --divider: rgba(234, 225, 204, 0.12);
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #F6EEDC;
  --bg-accent: #EDE0C6;
  --panel: rgba(255, 253, 246, 0.72);
  --panel-strong: rgba(255, 253, 246, 0.97);
  --text: #1C2A39;
  --muted: #75664b;
  --primary: #C2412D;
  --on-primary: #ffffff;      
  --primary-deep: #1C3F5E;
  --soft-blue: #F3ECDB;
  --line: #E0D2B6;
  --orange: #B08A3E;
  --red: #C2412D;
  --correct: #1C7A4B;
  --wrong: #b3362d;
  --shadow: 0 24px 56px rgba(96, 72, 32, 0.18);
  --gold: #8f6b26;
  --gold-soft: #E7B96b;
  --navy: #1C3F5E;
  --navy-2: #2a5578;
  --paper-card: rgba(255, 255, 255, 0.55);
  --divider: #ECE2CC;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14293c;
  --bg-accent: #0f2130;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(22, 45, 66, 0.97);
  --text: #EAE1CC;
  --muted: #9fb4c8;
  --primary: #E2725B;
  --on-primary: #14202C;      
  --primary-deep: #E7B96b;
  --soft-blue: rgba(231, 185, 107, 0.10);
  --line: rgba(234, 225, 204, 0.16);
  --orange: #E7B96b;
  --red: #E2725B;
  --correct: #58b98a;
  --wrong: #E2725B;
  --shadow: 0 24px 56px rgba(0, 0, 0, 0.45);
  --gold: #E7B96b;
  --gold-soft: #E7B96b;
  --navy: #1C3F5E;
  --navy-2: #2a5578;
  --paper-card: rgba(255, 255, 255, 0.06);
  --divider: rgba(234, 225, 204, 0.12);
}

* { box-sizing: border-box; }

input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  font-family: var(--font-sans);
  color: var(--text);
  
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 30%),
    linear-gradient(168deg, #FCF8EF 0%, var(--bg) 55%, var(--bg-accent) 100%);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) body {
    background:
      radial-gradient(circle at top left, rgba(42, 85, 120, 0.35), transparent 32%),
      linear-gradient(168deg, #1C3F5E 0%, var(--bg) 55%, var(--bg-accent) 100%);
  }
}
html[data-theme="dark"] body {
    background:
      radial-gradient(circle at top left, rgba(42, 85, 120, 0.35), transparent 32%),
      linear-gradient(168deg, #1C3F5E 0%, var(--bg) 55%, var(--bg-accent) 100%);
  }

.page-title, .study-title, .results-title, .onboarding-title, .detail-meaning-title,
.credits-heading, .charge-title, .pro-title, .league-rank-line strong,
.fm-title, .home-brand, .results-percent-wrap, #results-percent {
  font-family: var(--font-serif);
}
.results-eyebrow, .study-count, .lb-day, .lb-live, .league-practice-badge {
  font-family: var(--font-mono);
  letter-spacing: 0.16em;
}

.app-shell {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 0 calc(40px + env(safe-area-inset-bottom, 0px));
}

.celebration-layer {
  position: fixed; inset: 0;
  pointer-events: none; overflow: hidden; z-index: 999;
}

.hero, .panel {
  backdrop-filter: blur(18px);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}
html[data-theme="dark"] .hero, html[data-theme="dark"] .panel { border: 1px solid rgba(226, 232, 240, 0.08); }

.hero {
  border-radius: var(--radius-xl);
  padding: 30px 22px 24px;
  min-height: min(82vh, 860px);
  display: flex; flex-direction: column; justify-content: flex-start;
  position: relative; overflow: hidden;
}

.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 999px; filter: blur(8px); opacity: 0.5;
}
.hero::before { top: -52px; right: -32px; width: 180px; height: 180px; background: radial-gradient(circle, rgba(255,255,255,0.9), transparent 65%); }
.hero::after { bottom: -44px; left: -20px; width: 210px; height: 210px; background: radial-gradient(circle, rgba(190,220,219,0.42), transparent 65%); }
html[data-theme="dark"] .hero::before { background: radial-gradient(circle, rgba(56,189,248,0.15), transparent 65%); }
html[data-theme="dark"] .hero::after { background: radial-gradient(circle, rgba(20,35,50,0.42), transparent 65%); }

.floating-flags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }

#study-regions-screen .study-page { position: relative; }
#study-regions-screen .page-topbar,
#study-regions-screen .study-regions-sub,
#study-regions-screen .study-regions-grid { position: relative; z-index: 1; }
.floating-flag {
  
  --ff-peak: 0.42;
  position: absolute; font-size: var(--ff-size, 1.6rem); opacity: var(--ff-peak);
  animation: float-flag var(--ff-dur, 10s) ease-in-out infinite;
  will-change: transform, opacity;
}
html[data-theme="dark"] .floating-flag { --ff-peak: 0.34; }

@keyframes float-flag {
  0%   { opacity: calc(var(--ff-peak) * 0.2); transform: translate(0, 0) rotate(0deg) scale(0.78); }
  18%  { opacity: var(--ff-peak); }
  38%  { transform: translate(var(--ff-dx, 0px), var(--ff-dy, -42px)) rotate(var(--ff-rot, 6deg)) scale(0.96); }
  68%  { opacity: var(--ff-peak); transform: translate(var(--ff-dx2, 28px), var(--ff-dy2, -16px)) rotate(calc(var(--ff-rot, 6deg) * -0.6)) scale(1); }
  100% { opacity: calc(var(--ff-peak) * 0.2); transform: translate(0, 0) rotate(0deg) scale(0.78); }
}

.floating-flag--img { display: inline-flex; }
.floating-flag--img img { width: calc(var(--ff-size, 1.6rem) * 1.5); height: auto; object-fit: contain; border-radius: 4px; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.14)); }

.practice-panel, .mania-panel { position: relative; overflow: hidden; }

body.has-tabbar.fit-screen .app-shell { height: auto; display: block; }
body.has-tabbar.fit-screen .screen:not([hidden]) { display: block; flex: none; min-height: 0; }
.practice-panel > :not(.floating-flags),
.mania-panel > :not(.floating-flags) { position: relative; z-index: 1; }

.eyebrow {
  margin: 0 0 10px; font-size: 0.7rem; letter-spacing: 0.28em;
  font-family: var(--font-mono); font-weight: 700;
  color: var(--gold); display: inline-block; padding: 6px 14px;
  border-radius: 999px; background: transparent;
  border: 1px solid var(--line);
}

h1 {
  margin: 0; font-size: clamp(2.4rem, 5vw, 4.2rem);
  line-height: 1.08; letter-spacing: -0.02em;
  font-family: var(--font-serif); font-weight: 700;
  color: var(--text);
}
.hero-copy { max-width: 640px; margin: 14px 0 0; color: var(--muted); font-size: 1rem; line-height: 1.7; }

.level-bar {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 10px;
  margin-top: 2px; padding: 10px 14px;
  border-radius: 20px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
}
html[data-theme="dark"] .level-bar { background: rgba(30,40,55,0.7); }
.level-badge {
  font-size: 0.85rem; font-weight: 900; color: #F3ECDB;
  padding: 4px 10px; border-radius: 10px;
  font-family: var(--font-latin-serif);
  background: var(--navy);
  white-space: nowrap;
}
.xp-track {
  flex: 1; height: 8px; border-radius: 999px;
  background: var(--line); overflow: hidden;
}

.xp-fill {
  position: relative;
  display: block;                 
  height: 100%; border-radius: inherit;
  background: repeating-linear-gradient(90deg, var(--primary) 0 6px, rgba(194,65,45,0.55) 6px 9px);
  transition: width 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}
.xp-fill::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.0) 35%,
    rgba(255,255,255,0.65) 50%,
    rgba(255,255,255,0.0) 65%,
    transparent 100%);
  transform: translateX(-120%);
  pointer-events: none;
}
.xp-fill.is-animating::after {
  animation: xp-shimmer-sweep 900ms ease-out 200ms 1;
}
@keyframes xp-shimmer-sweep {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}
.xp-label { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

.hero-summary {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-top: 16px;
}
.hero-summary--2up { grid-template-columns: repeat(2, 1fr); max-width: 360px; margin-left: auto; margin-right: auto; }
.summary-card {
  padding: 14px 10px 12px; border-radius: 20px; text-align: center;
  background: rgba(255,255,255,0.88); border: 1px solid var(--line);
  box-shadow: 0 10px 26px rgba(31,41,51,0.05);
}
html[data-theme="dark"] .summary-card { background: rgba(30,40,55,0.88); box-shadow: 0 10px 26px rgba(0,0,0,0.2); }
.summary-label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; }
.summary-card strong { font-size: 1.6rem; font-weight: 900; letter-spacing: -0.04em; }

.screen {
  opacity: 0; transform: translateY(18px) scale(0.98);
  pointer-events: none;
  transition: opacity 320ms cubic-bezier(0.4,0,0.2,1), transform 320ms cubic-bezier(0.4,0,0.2,1);
}
.screen[hidden] { display: none; }

.screen.is-active { opacity: 1; transform: none; pointer-events: auto; }

.home-screen { display: flex; flex-direction: column; gap: 10px; padding-top: 36px; padding-bottom: 12px; }

.quiz-panel.is-transitioning { opacity: 0; transform: translateY(16px) scale(0.985); }
.panel {
  border-radius: var(--radius-xl); padding: 20px;
  transition: opacity 220ms ease, transform 220ms ease;
}

.hero-actions { position: relative; z-index: 1; display: grid; gap: 10px; margin-top: 20px; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-bottom-row {
  position: relative; z-index: 1;
  
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin-top: 18px;
}

button {
  appearance: none; border: none; -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, color 140ms ease;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:active:not(:disabled) { transform: scale(0.96); transition-duration: 60ms; }
button:disabled { cursor: not-allowed; transform: none; opacity: 0.55; }

.primary-button, .secondary-button, .ghost-button, .option-button, .mode-button, .sub-button { border-radius: 20px; font-weight: 700; }

.primary-button {
  color: var(--on-primary, #fff); padding: 18px 24px; font-size: 1.12rem; width: 100%;
  border-radius: 24px; min-height: 62px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #159fe6);
  box-shadow: 0 16px 28px rgba(21,159,230,0.24);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-icon { font-size: 1.2rem; }

.mode-button {
  color: white; padding: 16px; font-size: 1rem; min-height: 56px;
  border-radius: 22px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.mode-button--time { background: linear-gradient(135deg, #f59e0b, #ef4444); box-shadow: 0 12px 24px rgba(245,158,11,0.2); }
.mode-button--survival { background: linear-gradient(135deg, #ef4444, #ec4899); box-shadow: 0 12px 24px rgba(239,68,68,0.2); }

.sub-button {
  color: white; padding: 14px; font-size: 0.95rem; min-height: 50px;
  border-radius: 20px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.sub-button--study { background: linear-gradient(135deg, var(--orange), var(--red)); box-shadow: 0 12px 24px rgba(255,83,71,0.18); }
.sub-button--review { background: linear-gradient(135deg, #8b5cf6, #ec4899); box-shadow: 0 12px 24px rgba(168,85,247,0.18); }

.icon-text-btn {
  color: var(--muted); font-size: 0.78rem; font-weight: 700;
  background: none; padding: 8px 4px; border-radius: 14px;
  
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 0; text-align: center; line-height: 1.15;
  word-break: keep-all; overflow-wrap: anywhere;
  transition: background 140ms ease;
}
.icon-text-btn > span:first-child { font-size: 1.3rem; line-height: 1; }
.icon-text-btn:hover { background: rgba(31,150,211,0.06); }

.secondary-button, .ghost-button { padding: 13px 18px; }
.secondary-button { color: white; background: linear-gradient(135deg, var(--primary), #159fe6); box-shadow: 0 16px 28px rgba(21,159,230,0.24); }
.ghost-button {
  color: var(--primary-deep); background: var(--soft-blue);
  border: 1px solid rgba(47,63,83,0.05);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
  border-radius: 999px; min-height: 46px; font-weight: 800;
}
html[data-theme="dark"] .ghost-button { border-color: rgba(56,189,248,0.12); box-shadow: none; }
.danger-button {
  color: white; background: linear-gradient(135deg, #b91c1c, #ef4444);
  padding: 10px 18px; border-radius: 14px; font-size: 0.88rem; font-weight: 700;
  border: none;
  white-space: nowrap;
  word-break: keep-all;
  flex-shrink: 0;
}

.stage-panel {
  background: var(--panel-strong);
  min-height: calc(100vh - var(--shell-pt) - var(--shell-pb));
  min-height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
}
.stage-list { display: grid; gap: 12px; }
.stage-card {
  display: grid; grid-template-columns: 56px 1fr auto auto; align-items: center;
  gap: 14px; width: 100%; padding: 18px 16px;
  border-radius: 24px; background: rgba(255,255,255,0.92);
  border: 1px solid rgba(47,63,83,0.06);
  box-shadow: 0 14px 28px rgba(31,41,51,0.05);
  text-align: start; position: relative; overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.stage-card::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 5px;
  background: var(--stage-color, var(--primary));
  
  border-start-start-radius: 0; border-end-start-radius: 0;
  border-start-end-radius: 4px; border-end-end-radius: 4px;
}
.stage-card:hover { transform: translateY(-2px); box-shadow: 0 18px 36px rgba(31,41,51,0.1); }
.stage-card:active { transform: scale(0.98); }
html[data-theme="dark"] .stage-card { background: rgba(30,40,55,0.92); border-color: rgba(226,232,240,0.06); box-shadow: 0 14px 28px rgba(0,0,0,0.15); }
.stage-card--locked { opacity: 0.5; }
.stage-card-icon { font-size: 2rem; text-align: center; }
.stage-card-name { margin: 0; font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em; text-wrap: balance; }  
.stage-card-count { margin: 2px 0 0; font-size: 0.82rem; color: var(--muted); }
.stage-card-stars { display: flex; gap: 2px; margin-top: 4px; }
.stage-star { font-size: 1rem; color: rgba(31,41,51,0.15); }
.stage-star--filled { color: #f59e0b; }
html[data-theme="dark"] .stage-star { color: rgba(226,232,240,0.15); }

html[data-theme="dark"] .stage-star--filled { color: #f59e0b; }
.stage-card-percent { font-size: 0.88rem; font-weight: 700; color: var(--primary); }

.stage-card-meta { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stage-card-arrow { font-size: 1.5rem; font-weight: 800; color: var(--muted); }

.stage-card-cost {
  position: static;
  padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, currentColor 12%, transparent);
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700;
  line-height: 1.5; color: var(--muted);
}
.stage-card-cost.is-locked { background: rgba(120, 20, 15, 0.88); color: #FFF1EE; }
.stage-card-cost:empty { display: none; }

.page-topbar {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 14px; margin-bottom: 18px;
}
.page-title { margin: 0; text-align: start; font-size: 1.9rem; font-weight: 900; letter-spacing: -0.03em; }

.settings-done-btn {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer; font: inherit; font-size: 19px; font-weight: 900; line-height: 1;
  color: #fff; -webkit-tap-highlight-color: transparent;
  background: linear-gradient(135deg, #1f96d3, #8b5cf6);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.32);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.settings-done-btn:active { transform: scale(0.9); box-shadow: 0 3px 8px rgba(124, 58, 237, 0.28); }
html[data-theme="dark"] .settings-done-btn {
  background: linear-gradient(135deg, #38bdf8, #a78bfa); box-shadow: 0 6px 16px rgba(56, 189, 248, 0.3);
}

.study-page, .study-detail-page {
  background: var(--panel-strong); overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.study-page {
  
  height: calc(100vh - var(--shell-pt) - var(--shell-pb));
  height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
  display: flex; flex-direction: column;
}
.study-count { margin: 4px 0 0; color: var(--muted); font-size: 0.98rem; white-space: nowrap; }

.study-search-wrap { display: block; margin-bottom: 10px; }
.study-search {
  width: 100%; padding: 16px 18px;
  border: 1px solid rgba(47,63,83,0.09); border-radius: 22px;
  background: rgba(255,255,255,0.92); font: inherit; color: var(--text);
  outline: none; transition: border-color 180ms ease, box-shadow 180ms ease;
}
.study-search:focus { border-color: rgba(0,119,182,0.4); box-shadow: 0 0 0 4px rgba(0,119,182,0.08); }
html[data-theme="dark"] .study-search { background: rgba(30,40,55,0.92); border-color: rgba(226,232,240,0.09); }
html[data-theme="dark"] .study-search:focus { border-color: rgba(56,189,248,0.4); box-shadow: 0 0 0 4px rgba(56,189,248,0.12); }

.study-list { display: grid; gap: 12px; flex: 1; min-height: 0; overflow-y: auto; overflow-x: clip; padding-right: 4px; padding-inline-end: 14px; margin-inline-end: -10px; align-content: start; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.study-row {
  display: grid; grid-template-columns: 86px 1fr auto; align-items: center;
  gap: 14px; width: 100%; padding: 14px 16px;
  border-radius: 24px; background: rgba(255,255,255,0.92);
  border: 1px solid rgba(47,63,83,0.06);
  box-shadow: 0 14px 28px rgba(31,41,51,0.05);
  text-align: start; transition: transform 180ms ease, box-shadow 180ms ease;
}
.study-row:hover { transform: translateY(-2px); box-shadow: 0 18px 36px rgba(31,41,51,0.1); border-color: rgba(31,150,211,0.15); }
.study-row:active { transform: scale(0.98); transition-duration: 80ms; }
html[data-theme="dark"] .study-row { background: rgba(30,40,55,0.92); border-color: rgba(226,232,240,0.06); box-shadow: 0 14px 28px rgba(0,0,0,0.15); }
html[data-theme="dark"] .study-row:hover { box-shadow: 0 18px 36px rgba(0,0,0,0.25); border-color: rgba(56,189,248,0.15); }
.study-row-animate { opacity: 0; transform: translateY(16px); animation: study-row-enter 350ms ease forwards; }
@keyframes study-row-enter { to { opacity: 1; transform: translateY(0); } }

.study-row-flag, .study-flag {
  width: 100%; height: 60px; object-fit: contain; border-radius: 14px;
  background: linear-gradient(135deg, #f5fbfc, #ffffff);
  padding: 8px; border: 1px solid rgba(47,63,83,0.05); transition: opacity 300ms ease;
}
.study-flag-loading { opacity: 0; }
html[data-theme="dark"] .study-row-flag, html[data-theme="dark"] .study-flag { background: linear-gradient(135deg, #1a2332, #253345); border-color: rgba(226,232,240,0.05); }
.study-title { margin: 0; font-size: 1.1rem; letter-spacing: -0.02em; color: #1794e7; font-weight: 800; }
html[data-theme="dark"] .study-title { color: #38bdf8; }
.study-row-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 0.92rem; }
.study-row-arrow { color: var(--primary-deep); font-size: 1.5rem; font-weight: 800; }
.study-empty {
  padding: 18px; border-radius: 18px; background: rgba(255,255,255,0.82);
  color: var(--muted); text-align: center;
}
html[data-theme="dark"] .study-empty { background: rgba(30,40,55,0.82); }

.region-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  white-space: nowrap; margin-top: 6px;
}
.region-badge--asia { background: rgba(239,68,68,0.1); color: #dc2626; border: 1px solid rgba(239,68,68,0.15); }
.region-badge--europe { background: rgba(59,130,246,0.1); color: #2563eb; border: 1px solid rgba(59,130,246,0.15); }
.region-badge--africa { background: rgba(234,179,8,0.1); color: #ca8a04; border: 1px solid rgba(234,179,8,0.15); }
.region-badge--americas { background: rgba(16,185,129,0.1); color: #059669; border: 1px solid rgba(16,185,129,0.15); }
.region-badge--oceania { background: rgba(139,92,246,0.1); color: #7c3aed; border: 1px solid rgba(139,92,246,0.15); }
.region-badge--antarctic { background: rgba(100,116,139,0.1); color: #64748b; border: 1px solid rgba(100,116,139,0.15); }
html[data-theme="dark"] .region-badge--asia { background: rgba(239,68,68,0.15); color: #f87171; }
html[data-theme="dark"] .region-badge--europe { background: rgba(59,130,246,0.15); color: #60a5fa; }
html[data-theme="dark"] .region-badge--africa { background: rgba(234,179,8,0.15); color: #facc15; }
html[data-theme="dark"] .region-badge--americas { background: rgba(16,185,129,0.15); color: #34d399; }
html[data-theme="dark"] .region-badge--oceania { background: rgba(139,92,246,0.15); color: #a78bfa; }
html[data-theme="dark"] .region-badge--antarctic { background: rgba(100,116,139,0.15); color: #94a3b8; }

.study-detail-page {
  min-height: calc(100vh - var(--shell-pt) - var(--shell-pb));
  min-height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
}
.study-detail-page .page-topbar { position: sticky; top: 0; z-index: 10; background: var(--panel-strong); padding-bottom: 10px; }

.study-detail-page .page-topbar { grid-template-columns: 1fr auto 1fr; }
.study-detail-page .page-topbar > .atlas-back { justify-self: start; }
.study-detail-page .page-topbar > .bookmark-btn { grid-column: 2; justify-self: center; }

.study-page > .page-topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--panel-strong); padding-bottom: 8px; margin-bottom: 6px;
}
.study-detail-card { display: grid; gap: 22px; }
.study-detail-visual { margin: 0; min-height: 220px; border-radius: 28px; }

.study-detail-visual img { max-height: 300px; object-fit: contain; }
#study-detail-flag {
  max-width: min(100%, 480px); max-height: 260px; object-fit: contain;
  border-radius: 20px; box-shadow: 0 22px 40px rgba(31,41,51,0.16);
  
  border: 1px solid rgba(47,63,83,0.10);
}
html[data-theme="dark"] #study-detail-flag { border-color: rgba(226,232,240,0.10); }
.study-detail-subtitle { margin: 6px 0 14px; color: var(--muted); font-size: 0.98rem; }
.study-detail-meta {
  display: grid; gap: 0; padding: 10px 20px; border-radius: 28px;
  background: rgba(255,255,255,0.92); border: 1px solid rgba(47,63,83,0.07);
  line-height: 1.55; font-size: 1rem;
}
html[data-theme="dark"] .study-detail-meta { background: rgba(30,40,55,0.92); border-color: rgba(226,232,240,0.07); }
.detail-meta-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.detail-meta-row:last-child { border-bottom: none; }
.detail-meta-icon {
  flex-shrink: 0; width: 36px; height: 36px; display: grid; place-items: center;
  font-size: 1.2rem; border-radius: 12px; background: rgba(31,150,211,0.06);
}
html[data-theme="dark"] .detail-meta-icon { background: rgba(56,189,248,0.08); }
.detail-meta-row strong { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 2px; letter-spacing: 0.02em; }

.quiz-panel {
  background: var(--panel-strong);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  
  isolation: isolate;
}

.top-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.top-bar-left { display: flex; align-items: center; gap: 8px; }
.top-bar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.question-number { color: var(--muted); font-weight: 700; margin: 0; }

.streak-badge {
  font-size: 0.82rem; font-weight: 800; padding: 4px 10px;
  border-radius: 999px; background: rgba(245,158,11,0.12);
  color: #f59e0b; border: 1px solid rgba(245,158,11,0.2);
  transition: transform 200ms ease;
}
.streak-badge--hot { background: rgba(239,68,68,0.12); color: #ef4444; border-color: rgba(239,68,68,0.2); animation: streak-pulse 600ms ease infinite; }
@keyframes streak-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }

.timer-badge {
  font-size: 0.85rem; font-weight: 800; padding: 4px 10px;
  border-radius: 999px; background: rgba(245,158,11,0.12);
  color: #f59e0b; border: 1px solid rgba(245,158,11,0.2);
}
.timer-badge--urgent { background: rgba(239,68,68,0.15); color: #ef4444; border-color: rgba(239,68,68,0.25); animation: timer-pulse 500ms ease infinite; }
@keyframes timer-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.lives-badge { font-size: 0.9rem; padding: 4px 8px; border-radius: 999px; background: rgba(239,68,68,0.08); }

.progress-track { width: 100%; height: 8px; overflow: hidden; border-radius: 999px; background: rgba(22,78,99,0.1); margin-top: 10px; position: relative; }
html[data-theme="dark"] .progress-track { background: rgba(56,189,248,0.1); }
.progress-fill {
  width: 0; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #14b8a6, #0ea5e9);
  transition: width 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 10px rgba(14, 184, 166, 0.45);
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.55) 50%, transparent 100%);
  transform: translateX(-120%);
  pointer-events: none;
}
.progress-fill.is-animating::after { animation: xp-shimmer-sweep 900ms ease-out 1; }

.answer-counts { display: flex; gap: 8px; font-weight: 700; font-size: 0.85rem; }
.answer-counts span { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 0.82rem; }
.score-correct { background: rgba(22,163,74,0.1); color: #16a34a; border: 1px solid rgba(22,163,74,0.2); }
.score-wrong { background: rgba(220,38,38,0.1); color: #dc2626; border: 1px solid rgba(220,38,38,0.2); }
html[data-theme="dark"] .score-correct { background: rgba(74,222,128,0.12); color: #4ade80; border-color: rgba(74,222,128,0.2); }
html[data-theme="dark"] .score-wrong { background: rgba(248,113,113,0.12); color: #f87171; border-color: rgba(248,113,113,0.2); }

.flag-frame {
  min-height: 212px; display: grid; place-items: center;
  margin: 12px 0; padding: 20px; border-radius: 26px;
  background: linear-gradient(135deg, #eaf6f7, rgba(255,255,255,0.96)),
    repeating-linear-gradient(45deg, rgba(31,150,211,0.03), rgba(31,150,211,0.03) 18px, transparent 18px, transparent 36px);
  border: 1px solid rgba(31,150,211,0.1);
}
html[data-theme="dark"] .flag-frame {
    background: linear-gradient(135deg, #1a2332, rgba(30,40,55,0.96)),
      repeating-linear-gradient(45deg, rgba(56,189,248,0.03), rgba(56,189,248,0.03) 18px, transparent 18px, transparent 36px);
    border-color: rgba(56,189,248,0.1);
  }
.flag-frame--quiz { min-height: 260px; padding: 24px; }

#flag-image {
  max-width: min(100%, 520px);
  max-height: 240px;
  object-fit: contain; border-radius: 18px;
  box-shadow: 0 22px 40px rgba(31,41,51,0.16);
}
.flag-enter { animation: flag-entrance 400ms cubic-bezier(0.34,1.56,0.64,1) forwards; }
@keyframes flag-entrance { from { opacity: 0; transform: scale(0.85) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.prompt { margin: 18px 0 14px; font-size: clamp(1.15rem, 2.4vw, 1.5rem); font-weight: 800; letter-spacing: -0.02em; }

.options-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.option-button {
  min-height: 64px; padding: 14px 16px; text-align: start;
  color: var(--text); background: rgba(255,255,255,0.88);
  border: 2px solid rgba(31,41,51,0.07); font-size: 0.95rem;
  line-height: 1.25; box-shadow: 0 12px 24px rgba(31,41,51,0.04);
  border-radius: 20px; font-weight: 600;
}
html[data-theme="dark"] .option-button { background: rgba(30,40,55,0.88); border-color: rgba(226,232,240,0.07); box-shadow: 0 12px 24px rgba(0,0,0,0.15); }
.option-button.correct { color: white; background: linear-gradient(135deg, #15803d, #22c55e); border-color: #22c55e; }
.option-button.wrong { color: white; background: linear-gradient(135deg, #b91c1c, #ef4444); border-color: #ef4444; }

.feedback-card {
  position: absolute; left: 50%; top: 14%; transform: translateX(-50%);
  z-index: 1200; width: min(92vw, 460px); margin: 0;
  padding: 16px 20px; border-radius: 20px;
  background: rgba(245,248,250,0.98); border: 1.5px solid rgba(31,41,51,0.08);
  box-shadow: 0 22px 60px rgba(15,23,42,0.34), 0 4px 14px rgba(15,23,42,0.18);
  line-height: 1.4; font-size: 1.04rem; font-weight: 600;
  display: flex; align-items: flex-start; gap: 12px;
  animation: feedback-pop 340ms cubic-bezier(.2,.9,.3,1.3) forwards;
}
.feedback-card[data-tone="correct"] { background: rgba(220,252,231,0.98); border-color: rgba(22,163,74,0.5); }
.feedback-card[data-tone="wrong"] { background: rgba(254,226,226,0.98); border-color: rgba(220,38,38,0.5); }
html[data-theme="dark"] .feedback-card { background: rgba(24,32,46,0.98); border-color: rgba(226,232,240,0.1); }
html[data-theme="dark"] .feedback-card[data-tone="correct"] { background: rgba(20,60,40,0.98); border-color: rgba(74,222,128,0.45); }
html[data-theme="dark"] .feedback-card[data-tone="wrong"] { background: rgba(70,24,28,0.98); border-color: rgba(248,113,113,0.45); }
.feedback-icon {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1rem; font-weight: 800; color: white;
}
.feedback-icon--correct { background: linear-gradient(135deg, #15803d, #22c55e); }
.feedback-icon--wrong { background: linear-gradient(135deg, #b91c1c, #ef4444); }
@keyframes feedback-enter { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes feedback-pop { from { opacity: 0; transform: translateX(-50%) translateY(-18px) scale(0.9); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
.feedback-card strong { display: block; margin-bottom: 4px; }
.footer-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }

#next-btn:not(:disabled) { animation: pulse-next 1.8s ease-in-out infinite; }
@keyframes pulse-next { 0%, 100% { box-shadow: 0 16px 28px rgba(21,159,230,0.24); } 50% { box-shadow: 0 16px 36px rgba(21,159,230,0.4), 0 0 0 6px rgba(21,159,230,0.08); } }

.results-panel { background: var(--panel-strong); text-align: center; padding: 30px 22px; }
.results-header { margin-bottom: 16px; }
.results-eyebrow { margin: 0 0 8px; font-size: 0.78rem; letter-spacing: 0.24em; color: var(--primary); }

.results-title {
  margin: 0; font-size: 2.2rem; font-weight: 400; letter-spacing: -0.01em;
  font-family: var(--font-latin-serif);
  color: var(--text);
}
html[data-theme="dark"] .results-title { color: var(--gold); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .results-title { color: var(--gold); }
}

.results-stars { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; }
.result-star { font-size: 2.4rem; color: rgba(31,41,51,0.12); opacity: 0; animation: star-pop 500ms ease forwards; }
.result-star--filled { color: #f59e0b; }
html[data-theme="dark"] .result-star { color: rgba(226,232,240,0.12); }
@keyframes star-pop { 0% { opacity: 0; transform: scale(0.3) rotate(-30deg); } 60% { transform: scale(1.3) rotate(5deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }

.score-ring-container { position: relative; width: 140px; height: 140px; margin: 0 auto 16px; }
.score-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring-bg { fill: none; stroke: rgba(31,41,51,0.06); stroke-width: 10; }
html[data-theme="dark"] .score-ring-bg { stroke: rgba(226,232,240,0.06); }
.score-ring-fill { fill: none; stroke: url(#score-gradient); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1200ms cubic-bezier(0.4,0,0.2,1); }
.score-ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.score-percent { font-size: 2rem; font-weight: 800; letter-spacing: -0.04em; color: var(--text); }
.score-sublabel { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }

.results-xp {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 999px; margin-bottom: 16px;
  background: rgba(245,158,11,0.1); color: #f59e0b; font-weight: 800; font-size: 1rem;
  border: 1px solid rgba(245,158,11,0.2);
  animation: xp-pop 500ms ease forwards;
}
.xp-earned-icon { font-size: 1.1rem; }
@keyframes xp-pop { 0% { opacity: 0; transform: scale(0.8); } 100% { opacity: 1; transform: scale(1); } }

.results-emoji { font-size: 2.4rem; margin: 0 0 16px; }

.results-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.results-stat { padding: 16px 10px; border-radius: 20px; background: rgba(255,255,255,0.88); border: 1px solid var(--line); }
html[data-theme="dark"] .results-stat { background: rgba(30,40,55,0.88); }
.results-stat-value { display: block; font-size: 1.8rem; font-weight: 800; letter-spacing: -0.04em; }
.results-stat--correct { color: #16a34a; }
.results-stat--wrong { color: #dc2626; }
.results-stat--total { color: var(--primary); }
html[data-theme="dark"] .results-stat--correct { color: #4ade80; }
html[data-theme="dark"] .results-stat--wrong { color: #f87171; }
html[data-theme="dark"] .results-stat--total { color: #38bdf8; }
.results-stat-label { display: block; font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.results-mode-label { color: var(--muted); font-size: 0.92rem; margin: 0 0 16px; }
.results-actions { display: grid; gap: 12px; }

.wrong-answers-section { text-align: start; margin-bottom: 20px; }
.wrong-answers-title { font-size: 1rem; font-weight: 800; margin: 0 0 10px; color: var(--text); }
.wrong-answers-list { display: grid; gap: 8px; max-height: 280px; overflow-y: auto; }
.wrong-answer-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 16px;
  background: rgba(220,38,38,0.04); border: 1px solid rgba(220,38,38,0.1);
}
html[data-theme="dark"] .wrong-answer-row { background: rgba(248,113,113,0.06); border-color: rgba(248,113,113,0.1); }
.wrong-answer-flag { width: 48px; height: 32px; object-fit: contain; border-radius: 6px; }
.wrong-answer-info { display: flex; flex-direction: column; gap: 2px; }
.wrong-answer-info strong { font-size: 0.9rem; }
.wrong-answer-info span { font-size: 0.78rem; color: var(--muted); }

.wrong-answer-row.is-openable {
  width: 100%; font: inherit; color: inherit; text-align: start; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.wrong-answer-row.is-openable:active { transform: scale(0.985); }
.wrong-answer-arrow { margin-inline-start: auto; font-size: 1.15rem; font-weight: 900; color: var(--muted); line-height: 1; }

.achievements-panel {
  background: var(--panel-strong);
  min-height: calc(100vh - var(--shell-pt) - var(--shell-pb));
  min-height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
}
.achievements-list { display: grid; gap: 10px; }
.achievement-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: 20px;
  background: rgba(255,255,255,0.88); border: 1px solid var(--line);
  transition: transform 140ms ease;
}
.achievement-card:hover { transform: translateY(-1px); }
html[data-theme="dark"] .achievement-card { background: rgba(30,40,55,0.88); }
.achievement-card--locked { opacity: 0.5; }
.achievement-card--done { border-color: rgba(245,158,11,0.2); }
.achievement-icon { font-size: 1.8rem; flex-shrink: 0; }
.achievement-info { flex: 1; }
.achievement-info strong { display: block; font-size: 0.95rem; margin-bottom: 2px; }
.achievement-info p { margin: 0; font-size: 0.82rem; color: var(--muted); }
.achievement-check { color: #22c55e; font-size: 1.2rem; font-weight: 800; }

.achievement-toast {
  position: fixed; top: calc(20px + env(safe-area-inset-top, 0px)); left: 50%;
  transform: translateX(-50%) translateY(-100px);
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-radius: 20px; z-index: 1000;
  background: rgba(255,255,255,0.96); border: 1px solid rgba(245,158,11,0.3);
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  transition: transform 400ms cubic-bezier(0.34,1.56,0.64,1);
  font-size: 0.9rem;
  
  pointer-events: none;
}
html[data-theme="dark"] .achievement-toast { background: rgba(28,35,45,0.96); }
.achievement-toast--visible { transform: translateX(-50%) translateY(0); }
.achievement-toast-icon { font-size: 1.6rem; }

.achievement-toast.is-msg {
  font-size: 0.95rem; padding: 13px 20px; gap: 10px;
  max-width: min(86vw, 380px); border-color: rgba(194,65,45,0.28);
}
.achievement-toast.is-msg strong { font-weight: 800; line-height: 1.35; }
.achievement-toast.is-msg .achievement-toast-icon { font-size: 1.25rem; }

.usage-panel {
  background: var(--panel-strong);
  min-height: calc(100vh - var(--shell-pt) - var(--shell-pb));
  min-height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
}
.usage-body { display: grid; gap: 2px; }
.usage-h {
  margin: 20px 2px 8px; font-size: 0.82rem; font-weight: 800;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.usage-body > .usage-h:first-child { margin-top: 4px; }

.usage-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }

.usage-tiles--4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.usage-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 12px 8px; border-radius: 16px; text-align: center;
  background: rgba(255,255,255,0.88); border: 1px solid var(--line);
}
html[data-theme="dark"] .usage-tile { background: rgba(30,40,55,0.88); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .usage-tile { background: rgba(30,40,55,0.88); }
}
.usage-tile-v { font-size: 1.05rem; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; }

.usage-tile-l { font-size: 0.7rem; font-weight: 700; color: var(--muted); line-height: 1.25; overflow-wrap: anywhere; }

.usage-rows { display: grid; gap: 1px; margin-top: 8px; }
.usage-row {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
}
.usage-row:nth-child(odd) { background: rgba(120,120,140,0.07); }
.usage-row-l { font-size: 0.88rem; font-weight: 700; color: var(--text); min-width: 0; }
.usage-row-v {
  display: inline-flex; align-items: baseline; gap: 8px;
  font-size: 0.88rem; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums;
}
.usage-stars { color: var(--gold, #b08a3e); letter-spacing: 1px; }
.usage-row-pct { color: var(--text); }

.usage-bars { display: grid; gap: 10px; }
.usage-bar {
  display: grid; grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 5px;
  align-items: baseline;
}
.usage-bar-n { font-size: 0.9rem; font-weight: 800; color: var(--text); min-width: 0; }
.usage-bar-v { font-size: 0.8rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.usage-bar-track {
  grid-column: 1 / -1; height: 7px; border-radius: 999px;
  background: rgba(120,120,140,0.16); overflow: hidden;
}
.usage-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--gold, #b08a3e); }
.usage-bar.is-done .usage-bar-fill { background: var(--correct, #1C7A4B); }
.usage-bar.is-done .usage-bar-n { color: var(--correct, #1C7A4B); }

.usage-wrongs { display: grid; gap: 1px; }
.usage-wrong {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 12px;
}
.usage-wrong:nth-child(odd) { background: rgba(120,120,140,0.07); }
.usage-wrong-flag {
  width: 40px; height: 27px; border-radius: 4px; object-fit: contain;
  background: rgba(120,120,140,0.12); border: 1px solid var(--line);
}
.usage-wrong-n { font-size: 0.9rem; font-weight: 700; color: var(--text); min-width: 0; }
.usage-wrong-c { font-size: 0.8rem; font-weight: 800; color: var(--wrong, #c2412d); white-space: nowrap; }

.usage-note { margin: 6px 2px 0; font-size: 0.78rem; font-weight: 700; color: var(--muted); }

.usage-note--top { margin: 0 2px 10px; }
.usage-empty {
  margin: 18px 2px 0; padding: 16px; border-radius: 16px; text-align: center;
  font-size: 0.86rem; font-weight: 700; line-height: 1.5; color: var(--muted);
  background: rgba(120,120,140,0.08); border: 1px dashed var(--line);
}
.usage-privacy {
  margin: 22px 2px 4px; font-size: 0.74rem; line-height: 1.5; color: var(--muted);
  opacity: 0.85; text-align: center;
}

.settings-panel { background: var(--panel-strong); min-height: 50vh; padding: 24px 20px 28px; }
.settings-list { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 22px 18px; border-radius: 22px;
  background: rgba(255,255,255,0.88); border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(31,41,51,0.05);
}
html[data-theme="dark"] .setting-row { background: rgba(30,40,55,0.88); box-shadow: 0 10px 24px rgba(0,0,0,0.2); }
.setting-row--danger { border-color: rgba(220,38,38,0.18); margin-top: 8px; }
.setting-row--danger + .setting-row--link { margin-top: 8px; }
.setting-info { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.setting-info > div { min-width: 0; flex: 1; }
.setting-icon { font-size: 1.5rem; flex-shrink: 0; }
.setting-info strong { font-size: 1rem; display: block; letter-spacing: -0.01em; }
.setting-desc {
  margin: 4px 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--muted);
}
.settings-section-divider { height: 8px; }

.toggle { position: relative; display: inline-block; width: 52px; height: 30px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: rgba(31,41,51,0.15); border-radius: 999px;
  transition: background 200ms ease;
}
.toggle-slider::before {
  content: ""; position: absolute; height: 24px; width: 24px;
  inset-inline-start: 3px; bottom: 3px; background: white; border-radius: 50%;
  transition: transform 200ms ease; box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-slider { background: linear-gradient(135deg, #14b8a6, #0ea5e9); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

html[dir="rtl"] .toggle input:checked + .toggle-slider::before { transform: translateX(-22px); }

.setting-row--theme { flex-direction: column; align-items: stretch; gap: 14px; }
.setting-row--theme .theme-seg { display: flex; width: 100%; }
.setting-row--theme .theme-seg-btn { flex: 1; text-align: center; padding-left: 0; padding-right: 0; }
.theme-seg { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; padding: 3px; border-radius: 12px; background: rgba(47, 63, 83, 0.07); }
.theme-seg-btn { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; padding: 7px 11px; border-radius: 9px; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .15s ease, color .15s ease; }
.theme-seg-btn.is-active { background: var(--panel-strong); color: var(--text); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); }
html[data-theme="dark"] .theme-seg { background: rgba(226, 232, 240, 0.08); }
html[data-theme="dark"] .theme-seg { background: rgba(226, 232, 240, 0.08); }
html[data-theme="light"] .theme-seg { background: rgba(47, 63, 83, 0.07); }
html[data-theme="dark"] .toggle-slider { background: rgba(226,232,240,0.15); }
.settings-version { text-align: center; color: var(--muted); font-size: 0.78rem; margin-top: 24px; }

.confetti {
  position: absolute; top: 50%; left: 50%;
  width: 12px; height: 22px; border-radius: 999px; opacity: 0;
  animation: confetti-burst 1050ms cubic-bezier(0.18,0.78,0.28,1) forwards;
  transform: translate(-50%, -50%) rotate(var(--rotation, 0deg)) translate(var(--travel-x, 0px), var(--travel-y, 0px)) scale(0.7);
}
.confetti::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: var(--confetti-color, #f97316); box-shadow: 0 8px 18px rgba(15,23,42,0.16);
}
@keyframes confetti-burst {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(0deg) translate(0, 0) scale(0.3); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--rotation, 0deg)) translate(var(--travel-x, 0px), var(--travel-y, 0px)) scale(1); }
}

@media (max-width: 640px) {
  
  body {
    --shell-pt: calc(12px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  body.has-tabbar {
    --shell-pt: calc(24px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(var(--tabbar-cover, calc(84px + env(safe-area-inset-bottom, 0px))) + var(--tabbar-gap, 20px));
  }
  .app-shell {
    width: min(calc(100vw - 16px), 100%);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  .hero, .panel { border-radius: 28px; padding: 16px; }
  .hero { min-height: min(84vh, 860px); padding: 24px 18px; }
  .hero-summary { grid-template-columns: repeat(2, 1fr); }
  .summary-card strong { font-size: 1.4rem; }

  .top-bar { flex-direction: column; align-items: flex-start; gap: 6px; }
  .top-bar-right { width: 100%; justify-content: space-between; }

  .flag-frame--quiz { min-height: 200px; padding: 16px; }
  #flag-image { max-height: 200px; }

  .options-grid { grid-template-columns: 1fr; }
  .option-button { min-height: 56px; padding: 12px 14px; font-size: 0.92rem; }
  .footer-actions { flex-direction: column; align-items: stretch; }

  .page-topbar { grid-template-columns: auto 1fr auto; gap: 10px; }
  .page-topbar .ghost-button { width: auto; min-height: 40px; padding: 8px 16px; font-size: 0.92rem; border-radius: 999px; }
  .page-title, .study-count { text-align: start; }
  .page-title { font-size: 1.4rem; }

  .study-row { grid-template-columns: 74px 1fr auto; gap: 12px; padding: 10px 12px; }
  .study-list { gap: 10px; }
  .study-row-flag, .study-flag { height: 52px; }

  .results-stats { gap: 8px; }
  .results-stat { padding: 12px 6px; }
  .results-stat-value { font-size: 1.5rem; }

  
  .stage-card { grid-template-columns: 44px 1fr auto auto; gap: 10px; padding: 14px 12px; }
  .stage-card-icon { font-size: 1.6rem; }

  .primary-button, .mode-button, .sub-button, .secondary-button, .ghost-button { width: 100%; }
  
  .setrun-row--sub > button { width: auto; }
}

@media (min-width: 740px) and (min-height: 700px) {   
  .hero-summary--2up { max-width: 440px; }
  .options-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  
  .quiz-screen .option-button { min-height: 72px; font-size: 1rem; padding: 16px 20px; }
  .flag-frame--quiz { min-height: 320px; padding: 32px; }
  #flag-image { max-height: 280px; max-width: 560px; }
  .study-list { grid-template-columns: repeat(2, 1fr); }
  .stage-list { grid-template-columns: repeat(2, 1fr); }
  .achievements-list { grid-template-columns: repeat(2, 1fr); }
  .wrong-answers-list { grid-template-columns: repeat(2, 1fr); }
  .results-stats { max-width: 400px; margin-left: auto; margin-right: auto; }
  
  .home-hud { max-width: 620px; margin-left: auto; margin-right: auto; }
  .hud-val { font-size: 1.32rem; }
  .passport-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 12px; }
  
  .passport-hero, .passport-continents, .passport-filter,
  .league-hero, .league-list, .league-note,
  
  .usage-body { width: 100%; max-width: 640px; margin-left: auto; margin-right: auto; }
  .detail-highlights, .study-detail-card { max-width: 680px; margin-left: auto; margin-right: auto; }
}

@media (min-width: 1024px) {
  .study-list { grid-template-columns: repeat(3, 1fr); }
  .stage-list { grid-template-columns: repeat(3, 1fr); }
  .achievements-list { grid-template-columns: repeat(3, 1fr); }
  .passport-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

body {
  --shell-pt: calc(16px + env(safe-area-inset-top, 0px));
  --shell-pb: calc(12px + env(safe-area-inset-bottom, 0px));
}

body.has-tabbar {
  --shell-pt: calc(24px + env(safe-area-inset-top, 0px));
  --shell-pb: calc(var(--tabbar-cover, calc(84px + env(safe-area-inset-bottom, 0px))) + var(--tabbar-gap, 20px));
}

@media (orientation: portrait) {
  body.has-tabbar .practice-panel,
  body.has-tabbar .mania-panel,
  body.has-tabbar #study-regions-screen > .panel {
    min-height: calc(100vh - var(--shell-pt) - var(--tabbar-cover, 118px) - var(--tabbar-gap, 20px));
    min-height: calc(100dvh - var(--shell-pt) - var(--tabbar-cover, 118px) - var(--tabbar-gap, 20px));
  }
}

.app-shell {
  
  padding-top: var(--shell-pt);
  padding-bottom: var(--shell-pb);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.primary-button--daily {
  background: linear-gradient(135deg, #f97316 0%, #ef4444 50%, #ec4899 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 6px;
  box-shadow: 0 12px 28px rgba(239, 68, 68, 0.28);
}
.primary-button--daily .btn-icon { font-size: 1.4rem; }
.daily-btn-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}
.daily-btn-title { font-weight: 700; font-size: 1.05rem; }
.daily-btn-sub { font-size: 0.78rem; opacity: 0.88; font-weight: 500; }
.primary-button--daily-done {
  background: linear-gradient(135deg, #10b981 0%, #0ea5e9 100%);
  box-shadow: 0 12px 24px rgba(16, 185, 129, 0.24);
}

.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  opacity: 0;
  transition: opacity 280ms ease-out;
}
.onboarding-overlay.is-active { opacity: 1; }
.onboarding-overlay[hidden] { display: none; }
.onboarding-card {
  background: var(--panel-strong);
  border-radius: 28px;
  max-width: 440px;
  width: 100%;
  padding: 32px 28px 24px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: translateY(18px) scale(0.98);
  transition: transform 300ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.onboarding-overlay.is-active .onboarding-card {
  transform: translateY(0) scale(1);
}
.onboarding-slides {
  position: relative;
  min-height: 220px;
}
.onboarding-slide {
  display: none;
  text-align: center;
  animation: onboarding-fade-in 320ms ease-out;
}
.onboarding-slide.is-active { display: block; }
@keyframes onboarding-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.onboarding-icon {
  display: inline-block;
  font-size: 3.2rem;
  margin-bottom: 14px;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.15));
}
.onboarding-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px 0;
  line-height: 1.3;
  
  word-break: keep-all; overflow-wrap: anywhere;
}
.onboarding-copy {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
  
  word-break: keep-all; overflow-wrap: anywhere;
}
.onboarding-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 4px 0;
}
.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  transition: all 220ms ease-out;
}
.onboarding-dot.is-active {
  background: var(--primary);
  width: 22px;
  height: 8px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(31, 150, 211, 0.35);
}
.onboarding-actions {
  display: flex;
  
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.onboarding-actions .primary-button {
  flex: 2 1 auto !important;
  width: auto !important;
  min-width: max-content;
  min-height: 48px;
  padding: 12px 18px !important;
  font-size: 1rem !important;
  white-space: nowrap;
  word-break: keep-all;
}
.onboarding-actions .ghost-button {
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: max-content;
  font-size: 0.9rem;
  padding: 10px 14px !important;
  white-space: nowrap;
  word-break: keep-all;
}

.confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9500;
  padding: 24px;
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.confirm-modal.is-active { opacity: 1; }
.confirm-modal[hidden] { display: none; }

.confirm-card {
  background: var(--panel-strong);
  border-radius: 22px;
  max-width: 380px;
  width: 100%;
  padding: 26px 24px 20px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.28);
  transform: scale(0.96);
  transition: transform 200ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
  
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.confirm-modal.is-active .confirm-card { transform: scale(1); }
.confirm-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--text);
}
.confirm-body {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 20px;
  white-space: pre-line;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  
  flex-wrap: wrap;
}
.confirm-actions > button { flex: 0 1 auto; min-width: 0; }

#confirm-modal .confirm-actions .ghost-button { font-size: 0.92rem; }
#confirm-modal .confirm-actions .danger-button,
#confirm-modal .confirm-actions .primary-button { font-size: 0.98rem; }
.confirm-alt[hidden] { display: none; }

.confirm-body { white-space: pre-line; }

.setting-row--link {
  width: 100%;
  cursor: pointer;
  text-align: start;
  
}
.setting-row--link:hover { transform: translateY(-1px); }
.setting-row--link:active { transform: scale(0.995); }
.setting-row--link .setting-info { pointer-events: none; }
.setting-row-arrow {
  font-size: 1.4rem;
  color: var(--muted);
  padding-left: 8px;
  flex-shrink: 0;
}

.credits-panel {
  max-height: 100%;
  overflow-y: auto;
}
.credits-body {
  padding: 4px 2px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.credits-section {
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 18px 16px;
}
html[data-theme="dark"] .credits-section {
    background: rgba(56, 189, 248, 0.08);
    border-color: rgba(226, 232, 240, 0.1);
  }
.credits-heading {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.credits-paragraph {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--muted);
}
.credits-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.credits-list li {
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}
.credits-list strong { margin-right: 4px; }
.credits-source { color: var(--primary); font-weight: 600; }

.credits-more-btn {
  font: inherit; font-size: 0.72rem; font-weight: 600;
  margin-left: 8px; padding: 2px 8px;
  color: var(--primary); background: none;
  border: 1px solid rgba(14, 165, 233, 0.35); border-radius: 8px; cursor: pointer;
}
.credits-attrib {
  max-height: 260px; overflow-y: auto;
  margin: 6px 0 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px;
}

.credits-attrib-row { display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; padding: 3px 0; font-size: 0.72rem; }
.credits-attrib-row a { min-width: 0; color: var(--primary); text-decoration: none; overflow-wrap: anywhere; }
.credits-attrib-meta { min-width: 0; margin-inline-start: auto; color: var(--muted); overflow-wrap: anywhere; }
.credits-license {
  font-size: 0.72rem;
  padding: 2px 8px;
  background: rgba(14, 165, 233, 0.12);
  border-radius: 8px;
  color: var(--primary);
  font-weight: 600;
  margin-left: auto;
}

.credits-oss-btn { margin: 2px 0 0; }
.credits-oss { margin-top: 10px; }
.credits-oss-item { padding: 10px 0; border-top: 1px solid var(--line); }
.credits-oss-item:first-child { border-top: 0; padding-top: 0; }
.credits-oss-name { margin: 0 0 6px; font-size: 0.8rem; font-weight: 700; color: var(--text); }
.credits-oss-item p {
  margin: 0 0 6px; font-size: 0.7rem; line-height: 1.5; color: var(--muted);
  overflow-wrap: anywhere;
}
.credits-oss-item .credits-oss-copy { color: var(--text); font-weight: 600; }
.credits-oss-item .credits-oss-sec { margin-top: 10px; color: var(--text); font-weight: 700; letter-spacing: 0.02em; }

@media (prefers-reduced-motion: reduce) {
  .onboarding-slide,
  .onboarding-card,
  .confirm-card,
  .confirm-modal,
  .onboarding-overlay {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 374px) {
  
  body {
    --shell-pt: calc(10px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  body.has-tabbar {
    --shell-pt: calc(20px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(var(--tabbar-cover, calc(84px + env(safe-area-inset-bottom, 0px))) + var(--tabbar-gap, 20px));
  }
  .app-shell {
    width: min(calc(100vw - 12px), 100%);
  }
  .hero { padding: 18px 14px; min-height: min(86vh, 760px); }
  .hero-copy { font-size: 0.9rem; line-height: 1.5; }
  h1 { font-size: clamp(2rem, 8.5vw, 2.6rem); }
  .hero-summary { gap: 8px; }
  .summary-card { padding: 10px 6px 8px; border-radius: 16px; }
  .summary-card strong { font-size: 1.2rem; }
  .summary-label { font-size: 0.7rem; }
  .primary-button { padding: 14px 16px; font-size: 1rem; min-height: 54px; }
  .mode-button { padding: 12px; font-size: 0.9rem; min-height: 48px; }
  .sub-button { padding: 12px; font-size: 0.88rem; min-height: 46px; }
  .flag-frame--quiz { min-height: 180px; padding: 12px; }
  #flag-image { max-height: 180px; }
  .option-button { min-height: 50px; font-size: 0.88rem; padding: 10px 12px; }
  .prompt { font-size: 1.05rem; }
  .daily-btn-title { font-size: 0.95rem; }
  .daily-btn-sub { font-size: 0.72rem; }
}

@media (min-width: 375px) and (max-width: 640px) and (orientation: portrait) {
  .app-shell {
    width: min(calc(100vw - 16px), 100%);
  }
  .hero { min-height: min(84vh, 840px); }
  
}

@media (min-width: 428px) and (max-width: 640px) and (orientation: portrait) {
  .hero { padding: 28px 22px; }
  .hero-summary { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .summary-card strong { font-size: 1.55rem; }
  .flag-frame--quiz { min-height: 230px; padding: 20px; }
  #flag-image { max-height: 220px; }
  .option-button { min-height: 62px; font-size: 0.96rem; padding: 14px 16px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .app-shell {
    width: min(calc(100vw - 16px), 100%);
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    padding-left: max(env(safe-area-inset-left, 0px), 8px);
    padding-right: max(env(safe-area-inset-right, 0px), 8px);
  }

  
  .hero {
    min-height: auto;
    padding: 14px 18px 16px;
    border-radius: 22px;
  }
  .hero-copy { display: none; }
  h1 { font-size: clamp(1.6rem, 3.8vw, 2.4rem); }
  .eyebrow { margin-bottom: 6px; padding: 4px 10px; font-size: 0.7rem; }
  .level-bar { margin-top: 10px; padding: 8px 12px; }
  .hero-summary { grid-template-columns: repeat(4, 1fr); margin-top: 10px; gap: 8px; }
  .summary-card { padding: 8px 6px; border-radius: 14px; }
  .summary-card strong { font-size: 1.1rem; }
  .summary-label { font-size: 0.66rem; }
  .hero-actions { margin-top: 12px; gap: 8px; }
  .action-row { grid-template-columns: 1fr 1fr 1fr; }
  .primary-button { padding: 12px 16px; font-size: 0.98rem; min-height: 48px; }
  .mode-button { padding: 10px; font-size: 0.88rem; min-height: 44px; }
  .sub-button { padding: 10px; font-size: 0.86rem; min-height: 42px; }
  .home-bottom-row { margin-top: 10px; }

  
  .quiz-panel {
    display: grid;
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
    grid-template-areas:
      "topbar   topbar"
      "progress progress"
      "media    options"
      "footer   footer";
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 7px 14px;
    align-items: stretch;
  }
  .quiz-panel .top-bar { grid-area: topbar; }
  .quiz-panel .progress-track { grid-area: progress; }
  .quiz-panel .flag-frame--quiz,
  .quiz-panel .quiz-map { grid-area: media; margin: 0; min-height: 0; align-self: center; }
  .quiz-panel .quiz-map { max-height: 100%; }
  .quiz-panel .flag-frame--quiz { padding: 10px; }
  .quiz-panel #flag-image { max-height: 38vh; max-width: 100%; }
  
  .quiz-panel:not(.quiz-panel--hunt) .prompt { display: none; }
  .quiz-panel .options-grid {
    grid-area: options;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 1fr;
    gap: 8px;
    align-content: stretch;
  }
  
  .quiz-panel .feedback-card {
    
    top: clamp(72px, 26%, 96px); margin-top: 0;
    width: min(78vw, 420px);
    padding: 10px 14px;
    font-size: 0.94rem;
    border-radius: 16px;
  }
  .quiz-panel .feedback-icon { width: 26px; height: 26px; font-size: 0.86rem; }
  .quiz-panel .footer-actions {
    grid-area: footer; margin-top: 0;
    flex-direction: row; justify-content: center; gap: 14px;
  }
  .quiz-panel .footer-actions button { flex: 0 1 240px; width: auto; }
  .quiz-panel .option-button {
    min-height: 0;
    font-size: 0.82rem;
    padding: 7px 10px;
    border-radius: 14px;
  }
  .quiz-panel .option-button .label { white-space: normal; line-height: 1.25; }

  
  .results-panel { padding: 20px 22px; }
  .results-title { font-size: 1.5rem; }
  .score-ring-container { width: 110px; height: 110px; }
  .score-percent { font-size: 1.5rem; }
  .results-stats { grid-template-columns: repeat(3, 1fr); }
  .results-actions { grid-template-columns: 1fr 1fr; gap: 10px; }

  
  .onboarding-card { max-width: 520px; padding: 20px 22px 18px; }
  .onboarding-slides { min-height: 150px; }
  .onboarding-icon { font-size: 2.4rem; margin-bottom: 8px; }
  .onboarding-title { font-size: 1.15rem; margin-bottom: 8px; }
}

@media (orientation: landscape) and (max-height: 600px) {
  
  .study-regions-grid, .practice-grid, .mode-grid, .mania-grid { grid-template-columns: repeat(3, 1fr); }
  
  #crest-games-grid { grid-template-columns: 1fr 1fr; }
  #crest-games-grid .study-region-card.featured { grid-column: auto; min-height: 74px; }
  .panel { padding-bottom: 16px; }
  .page-title { font-size: 1.2rem; }
  
}

@media (min-width: 768px) and (max-width: 1023px) and (min-height: 700px) {
  
  body {
    --shell-pt: calc(32px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(48px + env(safe-area-inset-bottom, 0px));
  }
  body.has-tabbar {
    --shell-pt: calc(32px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(var(--tabbar-cover, calc(84px + env(safe-area-inset-bottom, 0px))) + var(--tabbar-gap, 20px));
  }
  .app-shell {
    width: min(720px, calc(100vw - 40px));
  }
  .hero {
    padding: 40px 34px 32px;
    border-radius: 36px;
    min-height: min(72vh, 880px);
  }
  h1 { font-size: clamp(3rem, 5.6vw, 4rem); }
  .hero-copy { font-size: 1.08rem; max-width: 560px; }
  .hero-summary { gap: 14px; margin-top: 22px; }
  .summary-card { padding: 18px 12px 14px; border-radius: 22px; }
  .summary-card strong { font-size: 1.8rem; }
  .action-row { gap: 14px; }
  .primary-button { padding: 20px 28px; font-size: 1.18rem; min-height: 68px; }
  .mode-button, .sub-button { min-height: 60px; font-size: 1.02rem; }

  .panel { padding: 28px; border-radius: 32px; }
  .flag-frame--quiz { min-height: 340px; padding: 36px; }
  #flag-image { max-height: 320px; max-width: 600px; }
  .options-grid { gap: 16px; }
  
  .quiz-screen .option-button { min-height: 78px; font-size: 1.05rem; padding: 18px 22px; border-radius: 22px; }
  .prompt { font-size: 1.5rem; margin-bottom: 16px; }
}

@media (min-width: 1024px) and (max-width: 1365px) and (min-height: 700px) {
  
  body {
    --shell-pt: calc(36px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  body.has-tabbar {
    --shell-pt: calc(36px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(var(--tabbar-cover, calc(84px + env(safe-area-inset-bottom, 0px))) + var(--tabbar-gap, 20px));
  }
  .app-shell {
    width: min(960px, calc(100vw - 56px));
  }
  .hero {
    padding: 48px 44px 40px;
    border-radius: 40px;
    min-height: min(78vh, 900px);
  }
  h1 { font-size: clamp(3.4rem, 5.2vw, 4.8rem); }
  .hero-copy { font-size: 1.12rem; max-width: 640px; }

  
  .hero-actions {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .hero-actions > .primary-button { grid-column: 1 / -1; }
  .hero-actions > .primary-button--daily { grid-column: 1 / -1; }
  .action-row { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; gap: 14px; }

  .hero-summary { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .summary-card strong { font-size: 2rem; }
  .summary-card { padding: 22px 14px 16px; border-radius: 24px; }

  .panel { padding: 32px; border-radius: 36px; }
  .flag-frame--quiz { min-height: 380px; padding: 40px; }
  #flag-image { max-height: 340px; max-width: 680px; }
  .options-grid { gap: 18px; }
  
  .quiz-screen .option-button { min-height: 84px; font-size: 1.1rem; padding: 20px 24px; border-radius: 24px; }

  .study-list { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .stage-list { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .achievements-list { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .wrong-answers-list { grid-template-columns: repeat(2, 1fr); }
}

@media (orientation: landscape) and (min-width: 700px) and (max-width: 1365px) and (min-height: 601px) and (max-height: 900px) {
  .flag-frame--quiz { min-height: 0; padding: 20px; }
  
  #flag-image { max-height: min(28dvh, calc(100dvh - var(--shell-pt) - var(--shell-pb) - 400px)); }
  .quiz-screen .option-button { min-height: 64px; padding: 14px 20px; }
}

@media (orientation: landscape) and (min-width: 700px) and (max-width: 1365px) and (min-height: 601px) and (max-height: 699px) {
  #flag-image { max-height: min(28dvh, calc(100dvh - var(--shell-pt) - var(--shell-pb) - 370px)); }
}

@media (orientation: landscape) and (min-width: 700px) and (max-width: 1023px) and (min-height: 700px) and (max-height: 900px) {
  #flag-image { max-height: min(28dvh, calc(100dvh - var(--shell-pt) - var(--shell-pb) - 160px - 15rem)); }
}

@media (orientation: landscape) and (min-width: 700px) and (min-height: 501px) and (max-height: 600px) {
  .quiz-screen .quiz-panel {
    display: grid;
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
    gap: 10px 18px;
    align-items: stretch;
    
    height: calc(100vh - var(--shell-pt) - var(--shell-pb));
    height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
    max-height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
  }
  .quiz-screen .quiz-panel .top-bar { grid-area: topbar; }
  .quiz-screen .quiz-panel .progress-track { grid-area: progress; }
  .quiz-screen .quiz-panel .flag-frame--quiz,
  .quiz-screen .quiz-panel .quiz-map { grid-area: media; margin: 0; min-height: 0; align-self: center; }
  .quiz-screen .quiz-panel .quiz-map { max-height: 100%; }
  .quiz-screen .quiz-panel .flag-frame--quiz { padding: 14px; }
  
  .quiz-screen .quiz-panel:not(.quiz-panel--hunt) #flag-image { max-height: 40dvh; max-width: 100%; }
  
  .quiz-screen .quiz-panel:not(.quiz-panel--hunt) .prompt { display: none; }
  
  .quiz-screen .quiz-panel .options-grid { grid-area: options; grid-auto-rows: 1fr; align-content: stretch; }
  .quiz-screen .quiz-panel .option-button { min-height: 0; padding: 10px 16px; }
  .quiz-screen .quiz-panel .footer-actions {
    grid-area: footer; margin-top: 0;
    flex-direction: row; justify-content: center; gap: 14px;
  }
  .quiz-screen .quiz-panel .footer-actions button { flex: 0 1 240px; width: auto; }
  
  .quiz-screen .quiz-panel--hunt .options-grid { display: none; }
  .quiz-screen .quiz-panel--hunt .flag-frame--quiz { grid-area: options; align-self: start; justify-self: center; min-height: 0; }
  .quiz-screen .quiz-panel--hunt .prompt { font-size: 1rem; line-height: 1.3; }
  
  .quiz-screen #quiz-flag-frame.flag-frame--hunt { max-width: 210px; }
  .quiz-screen .flag-frame--hunt #flag-image { max-height: 130px; }
}

@media (min-width: 1366px) {
  
  body {
    --shell-pt: calc(44px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(64px + env(safe-area-inset-bottom, 0px));
  }
  body.has-tabbar {
    --shell-pt: calc(44px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(var(--tabbar-cover, calc(84px + env(safe-area-inset-bottom, 0px))) + var(--tabbar-gap, 20px));
  }
  .app-shell {
    width: min(1100px, calc(100vw - 72px));
  }
  .hero {
    padding: 56px 52px 44px;
    border-radius: 44px;
    min-height: min(76vh, 960px);
  }
  h1 { font-size: clamp(3.8rem, 5vw, 5.4rem); }
  .hero-copy { font-size: 1.18rem; max-width: 720px; }

  .hero-actions { grid-template-columns: 1fr 1fr; gap: 16px; }
  .hero-actions > .primary-button { grid-column: 1 / -1; }
  .hero-actions > .primary-button--daily { grid-column: 1 / -1; }
  .action-row { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; gap: 16px; }

  .hero-summary { grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 24px; }
  .summary-card { padding: 24px 16px 18px; border-radius: 26px; }
  .summary-card strong { font-size: 2.2rem; }

  .panel { padding: 36px; border-radius: 40px; }
  .flag-frame--quiz { min-height: 440px; padding: 48px; }
  #flag-image { max-height: 400px; max-width: 780px; }
  .options-grid { gap: 20px; }
  
  .quiz-screen .option-button { min-height: 92px; font-size: 1.16rem; padding: 22px 26px; border-radius: 26px; }
  .prompt { font-size: 1.7rem; }

  .study-list { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .stage-list { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .achievements-list { grid-template-columns: repeat(3, 1fr); gap: 16px; }

  .results-panel { padding: 44px 40px; }
  .results-title { font-size: 2.2rem; }
  .score-ring-container { width: 180px; height: 180px; }
  .score-percent { font-size: 2.6rem; }

  .onboarding-card { max-width: 560px; padding: 40px 36px 30px; }
  .onboarding-title { font-size: 1.6rem; }
  .onboarding-copy { font-size: 1.05rem; }
}

@media (orientation: landscape) and (min-width: 1366px) and (min-height: 601px) and (max-height: 1023px) {
  .flag-frame--quiz { min-height: 0; padding: 20px; }
  #flag-image { max-height: min(28dvh, calc(100dvh - var(--shell-pt) - var(--shell-pb) - 475px)); }
  .quiz-screen .option-button { min-height: 64px; padding: 14px 20px; }
}

@media (orientation: landscape) and (min-width: 1366px) and (min-height: 1024px) {
  :where(html:not([data-fold="v"])) body:has(#quiz-screen:not([hidden]) .quiz-panel:not(.quiz-panel--map)) {
    --shell-pt: calc(20px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(20px + env(safe-area-inset-bottom, 0px));
  }
}

@media (hover: hover) and (pointer: fine) {
  .option-button:hover:not(:disabled) {
    border-color: rgba(31,150,211,0.35);
    background: rgba(255,255,255,0.96);
  }
  @media (prefers-color-scheme: dark) {
    .option-button:hover:not(:disabled) {
      background: rgba(40,52,70,0.95);
      border-color: rgba(56,189,248,0.32);
    }
  }
}

.hero {
  padding: 18px 20px 18px !important;
  text-align: start;
  min-height: auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 7px;
}

h1 {
  font-size: clamp(1.75rem, 6.2vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  font-weight: 900;
  margin-top: 2px;
}
.hero-copy { margin: 6px auto 0; font-size: 0.9rem; color: var(--muted); max-width: 320px; line-height: 1.5; }

.hero-summary {
  display: flex !important;
  flex-direction: row !important;
  gap: 10px !important;
  margin: 0 !important;
  align-items: stretch;
  position: relative;
  z-index: 1;
}
.fm-stat {
  flex: 1 1 0;
  min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  padding: 14px 8px;
  height: auto;
  min-height: 76px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(31,41,51,0.05);
  text-align: center;
}
.fm-stat .v {
  font-size: 1.5rem; font-weight: 900; letter-spacing: -0.02em; line-height: 1;
  color: var(--text);
}
.fm-stat .l {
  font-size: 0.64rem; font-weight: 800; color: var(--muted);
  letter-spacing: 0.14em; text-transform: uppercase;
}
.fm-stat.hero .v {
  background: linear-gradient(135deg, #1f96d3 0%, #8b5cf6 50%, #ec4899 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.fm-stat.heat .v { color: #f59e0b; }
html[data-theme="dark"] .fm-stat { background: rgba(30,40,55,0.78); box-shadow: 0 10px 24px rgba(0,0,0,0.2); }
html[data-theme="dark"] .fm-stat.hero .v { background: linear-gradient(135deg, #38bdf8 0%, #a78bfa 50%, #f472b6 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
html[data-theme="dark"] .fm-stat.heat .v { color: #fbbf24; }

.hero-summary--2up { gap: 8px !important; max-width: 300px; margin: 2px auto 0 !important; }

.hero-summary--2up .fm-stat {
  flex-direction: row !important;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  min-height: 0 !important;
  padding: 7px 14px !important;
  border-radius: 999px;
}
.hero-summary--2up .fm-stat .v { font-size: 1.1rem; }
.hero-summary--2up .fm-stat .l { font-size: 0.6rem; letter-spacing: 0.08em; white-space: nowrap; }

.mode-grid {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}

.fm-mode {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end;
  gap: 4px;
  min-height: 128px;
  padding: 18px 16px;
  border-radius: 16px;
  color: var(--text);
  background: var(--paper-card);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  text-align: start;
  font-family: inherit;
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2), box-shadow 220ms ease;
  cursor: pointer;
}
.fm-mode:hover { transform: translateY(-3px) scale(1.01); box-shadow: 0 14px 26px -12px rgba(60,44,20,0.35); }
.fm-mode:active { transform: scale(0.98); }
.fm-mode .icon {
  font-size: 26px;
  margin-bottom: 6px;
  line-height: 1;
}
.fm-mode .t {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.fm-mode .d {
  font-weight: 500;
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--muted);
}
.fm-mode .corner {
  
  position: absolute; top: 12px; inset-inline-end: 12px;
  font-family: var(--font-mono);
  font-size: 0.58rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px;
  background: var(--paper-card);
  border: 1px solid var(--line);
  color: var(--gold);
}

.fm-mode .corner.cost {
  letter-spacing: 0; text-transform: none; font-size: 0.66rem;
  color: var(--gold);
}
.fm-mode .corner.cost.is-locked { color: var(--wrong); }
.fm-mode .corner.cost:empty { display: none; }

.fm-mode > .corner { max-width: calc(100% - 66px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fm-mode .corner-group { flex-wrap: wrap; justify-content: flex-end; }
.fm-mode .corner-group > .corner { flex: 0 0 auto; }

.fm-mode .corner-group {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px;
  justify-content: flex-end;
}

.fm-mode:not(.featured) > .corner-group {
  order: -1; margin-block-end: auto; align-self: stretch;
}

.fm-mode.featured > .corner-group { margin-inline-start: auto; align-self: center; }
.fm-mode .corner-group .corner { position: static; }

.fm-mode { --fm-badge-row: 26px; }
.fm-mode:not(.featured):has(> .corner-group) {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(var(--fm-badge-row), 1fr) auto auto;
  
  grid-template-areas: "icon badges" "space badges" "t t" "d d";
  align-items: start;
  column-gap: 8px; row-gap: 4px;   
}
.fm-mode:not(.featured):has(> .corner-group) > .icon { grid-area: icon; margin-bottom: 0; }
.fm-mode:not(.featured):has(> .corner-group) > .corner-group {
  grid-area: badges; order: 0; margin: 0; align-self: start; justify-self: stretch;
}
.fm-mode:not(.featured):has(> .corner-group) > .t { grid-area: t; }
.fm-mode:not(.featured):has(> .corner-group) > .d { grid-area: d; }

@media (orientation: landscape) and (max-height: 600px) {
  .fm-mode { --fm-badge-row: 0px; }
  .fm-mode:has(> .corner-group > .corner.cost:not(:empty)) { --fm-badge-row: 26px; }
}

.fm-mode.featured {
  grid-column: 1 / -1;
  min-height: 88px;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: linear-gradient(120deg, var(--navy), var(--navy-2));
  border: 1px solid rgba(20, 40, 60, 0.4);
  color: #F3ECDB;
  box-shadow: 0 10px 20px -8px rgba(28, 63, 94, 0.5);
}
.fm-mode.featured .t { color: #F3ECDB; }
.fm-mode.featured .d { color: #cdd8e2; }
.fm-mode.featured .corner {
  background: rgba(255,255,255,0.12);
  border-color: rgba(231,185,107,0.4);
  color: #E7B96b;
}
.fm-mode.featured .icon {
  font-size: 32px;
  margin: 0;
  flex: 0 0 auto;
}
.fm-mode.featured .body {
  display: flex; flex-direction: column; gap: 2px; flex: 1;
}
.fm-mode.featured .t { font-size: 1.1rem; }
.fm-mode.featured .d { font-size: 0.8rem; }

.fm-mode.survival {
  background: linear-gradient(120deg, var(--navy), var(--navy-2));
  border: 1px solid rgba(20, 40, 60, 0.4);
  color: #F3ECDB;
  box-shadow: 0 10px 20px -8px rgba(28, 63, 94, 0.5);
}
.fm-mode.survival .t { color: #F3ECDB; }
.fm-mode.survival .d { color: #cdd8e2; }
.fm-mode.survival .corner {
  background: rgba(255,255,255,0.12);
  border-color: rgba(231,185,107,0.4);
  color: #E7B96b;
}
.fm-mode.survival .corner.cost.is-locked { color: #ff9f8e; }

.fm-mode:disabled { opacity: 0.55; cursor: not-allowed; filter: saturate(0.5); }

.fm-mode.daily.primary-button--daily-done {
  border: 1.5px solid var(--correct);
  background: var(--soft-blue);
}
.fm-mode.daily.primary-button--daily-done .corner { color: var(--correct); }

.quiz-panel .top-bar {
  gap: 8px;
  align-items: center;
  padding-bottom: 6px;
}
.quiz-panel .top-bar-left,
.quiz-panel .top-bar-right {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.fm-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  font: 800 0.78rem/1 inherit;
  background: rgba(31,150,211,0.12);
  color: var(--primary);
  border: 1px solid rgba(31,150,211,0.2);
  white-space: nowrap;
}
.fm-chip strong { font-weight: 900; font-size: 0.82rem; }
.fm-chip.streak { background: rgba(245,158,11,0.14); color: #f59e0b; border-color: rgba(245,158,11,0.24); transition: transform 200ms ease; }
.fm-chip.streak.streak-badge--hot { background: rgba(239,68,68,0.14); color: #ef4444; border-color: rgba(239,68,68,0.28); animation: streak-pulse 600ms ease infinite; }
.fm-chip.timer { background: rgba(239,68,68,0.14); color: #ef4444; border-color: rgba(239,68,68,0.24); }
.fm-chip.timer.timer-badge--urgent { background: rgba(239,68,68,0.22); color: #dc2626; border-color: rgba(239,68,68,0.4); animation: timer-pulse 500ms ease infinite; }
.fm-chip.danger { background: rgba(239,68,68,0.1); color: #ef4444; border-color: rgba(239,68,68,0.22); }
.fm-chip.correct-chip { background: rgba(22,163,74,0.1); color: #16a34a; border-color: rgba(22,163,74,0.22); }
.fm-chip.wrong-chip { background: rgba(220,38,38,0.1); color: #dc2626; border-color: rgba(220,38,38,0.22); }
html[data-theme="dark"] .fm-chip { background: rgba(56,189,248,0.14); color: #38bdf8; border-color: rgba(56,189,248,0.22); }
html[data-theme="dark"] .fm-chip.correct-chip { background: rgba(74,222,128,0.12); color: #4ade80; border-color: rgba(74,222,128,0.22); }
html[data-theme="dark"] .fm-chip.wrong-chip { background: rgba(248,113,113,0.12); color: #f87171; border-color: rgba(248,113,113,0.22); }

.quiz-panel .answer-counts { display: none !important; }

.options-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
.option-button {
  display: flex !important;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.92);
  border: 2px solid rgba(31,41,51,0.07);
  box-shadow: 0 12px 24px rgba(31,41,51,0.04);
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--text);
  text-align: start;
}
.option-button .k {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: rgba(31,150,211,0.14);
  color: var(--primary);
  font: 900 0.92rem/1 inherit;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 180ms ease, color 180ms ease;
}
.option-button .label { flex: 1; min-width: 0; }

.option-flag {
  flex: 0 0 auto;
  width: 42px; height: 28px; object-fit: contain;
  border-radius: 4px;
  background: rgba(127,127,127,0.10);
}
.option-button.correct {
  background: linear-gradient(135deg, rgba(34,197,94,0.18), rgba(22,163,74,0.12));
  border-color: rgba(34,197,94,0.55);
  color: var(--correct);
}
.option-button.correct .k { background: #22c55e; color: #fff; }
.option-button.wrong {
  background: linear-gradient(135deg, rgba(239,68,68,0.16), rgba(185,28,28,0.10));
  border-color: rgba(239,68,68,0.55);
  color: var(--wrong);
}
.option-button.wrong .k { background: #ef4444; color: #fff; }
html[data-theme="dark"] .option-button { background: rgba(30,40,55,0.92); border-color: rgba(226,232,240,0.08); }
html[data-theme="dark"] .option-button .k { background: rgba(56,189,248,0.18); color: #38bdf8; }

@media (max-width: 640px) and (orientation: portrait) {
  .quiz-screen .flag-frame--quiz { min-height: 0; margin: 6px 0; padding: 10px; }
  .quiz-screen #flag-image { max-height: 22vh; max-width: 82%; }
  .quiz-screen .quiz-map { max-height: 54vh; margin: 6px auto; }
  
  .quiz-screen .prompt { margin: 14px 0 6px; }
  .quiz-screen .options-grid { gap: 7px; }
  .quiz-screen .option-button { min-height: 44px; padding: 8px 14px; }
  .quiz-screen #feedback-card { margin-top: 8px; }
  .quiz-screen .footer-actions { margin-top: 7px; }
}

.results-panel { padding: 26px 22px 22px; text-align: center; }
.results-header { margin-bottom: 14px; }
.result-hero { font-size: 3.4rem; margin: 0 0 4px; line-height: 1; }
.results-eyebrow {
  margin: 0 0 6px; font-size: 0.7rem; letter-spacing: 0.24em;
  font-weight: 800; text-transform: uppercase; color: var(--muted);
}
.results-title {
  margin: 0; font-size: 3.6rem; font-weight: 900;
  letter-spacing: -0.04em; line-height: 1;
  background: linear-gradient(135deg, #1f96d3 0%, #8b5cf6 50%, #ec4899 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.results-title #results-percent { background: none; -webkit-text-fill-color: currentColor; color: inherit; }
.results-mode-label { color: var(--muted); font-size: 0.88rem; margin: 6px 0 0; }

.results-best {
  display: inline-block;
  margin: 10px auto 0;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--muted);
  background: rgba(120,120,140,0.12);
  border: 1px solid rgba(120,120,140,0.2);
}
.results-best--new {
  color: #b45309;
  background: rgba(245,158,11,0.16);
  border-color: rgba(245,158,11,0.4);
  animation: best-pop 600ms ease;
}
html[data-theme="dark"] .results-best--new { color: #fbbf24; }
@keyframes best-pop { 0% { transform: scale(0.86); } 55% { transform: scale(1.08); } 100% { transform: scale(1); } }

.results-rank {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 14px 0 4px;
}
.results-rank-text { font-size: 1.02rem; font-weight: 900; color: var(--text); }
.results-rank-btn { font-size: 0.86rem; }

.results-stars { display: flex; justify-content: center; gap: 6px; margin: 12px 0 14px; }
.result-star { font-size: 1.9rem; }

.results-stats {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
  margin-bottom: 16px;
  text-align: center;
}
.results-stats .fm-stat { padding: 14px 10px; }
.results-stat-value { font-size: 1.6rem !important; font-weight: 900; letter-spacing: -0.03em; line-height: 1; }
.results-stat--correct { color: #16a34a !important; }
.results-stat--wrong { color: #dc2626 !important; }
.results-stat--total { color: var(--primary) !important; }
.results-stat--xp .results-stat-value {
  background: linear-gradient(90deg, #14b8a6, #0ea5e9);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.results-stat-label { font-size: 0.64rem !important; font-weight: 800 !important; letter-spacing: 0.14em !important; text-transform: uppercase !important; color: var(--muted) !important; }
html[data-theme="dark"] .results-stat--correct { color: #4ade80 !important; }
html[data-theme="dark"] .results-stat--wrong { color: #f87171 !important; }
html[data-theme="dark"] .results-stat--total { color: #38bdf8 !important; }

.results-actions { display: flex !important; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.results-actions .primary-button,
.results-actions .ghost-button { flex: 1; min-height: 52px; border-radius: 18px; }

.home-bottom-row {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.icon-text-btn {
  background: rgba(255,255,255,0.7);
  padding: 9px 4px;
  border-radius: 16px;
  border: 1px solid var(--line);
  font-weight: 700;
}
html[data-theme="dark"] .icon-text-btn { background: rgba(30,40,55,0.7); }

.stage-card { border-radius: 22px; }

.study-region-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.study-region-nav::-webkit-scrollbar { height: 0; }
.study-region-pill {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--muted);
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  transition: all 140ms ease;
}
.study-region-pill:hover { background: rgba(255,255,255,0.95); }
.study-region-pill.is-active { background: var(--primary); color: #fff; border-color: transparent; box-shadow: 0 6px 14px rgba(31,150,211,0.28); }
html[data-theme="dark"] .study-region-pill { background: rgba(30,40,55,0.72); }
html[data-theme="dark"] .study-region-pill:hover { background: rgba(40,52,70,0.95); }
html[data-theme="dark"] .study-region-pill.is-active { background: #38bdf8; color: #0f1419; }

.study-regions-sub {
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}
.study-regions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.study-region-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 4px;
  min-height: 128px;
  padding: 18px 16px;
  border-radius: 24px;
  color: #fff;
  border: none;
  text-align: start;
  font-family: inherit;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2), box-shadow 220ms ease;
}
.study-region-card:hover { transform: translateY(-3px) scale(1.01); box-shadow: 0 24px 42px rgba(0,0,0,0.2); }
.study-region-card:active { transform: scale(0.98); }
.study-region-card .srg-icon {
  font-size: 28px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25));
  margin-bottom: 6px;
  line-height: 1;
}
.study-region-card .srg-name {
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.study-region-card .srg-count {
  position: absolute;
  
  top: 12px; inset-inline-end: 12px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
}
.study-region-card.region--asia     { background: linear-gradient(135deg, #ef4444, #b91c1c); box-shadow: 0 16px 30px rgba(239,68,68,0.3); }
.study-region-card.region--europe   { background: linear-gradient(135deg, #3b82f6, #1d4ed8); box-shadow: 0 16px 30px rgba(59,130,246,0.3); }
.study-region-card.region--africa   { background: linear-gradient(135deg, #eab308, #ca8a04); box-shadow: 0 16px 30px rgba(234,179,8,0.3); }
.study-region-card.region--americas { background: linear-gradient(135deg, #10b981, #047857); box-shadow: 0 16px 30px rgba(16,185,129,0.3); }
.study-region-card.region--oceania  { background: linear-gradient(135deg, #8b5cf6, #6d28d9); box-shadow: 0 16px 30px rgba(139,92,246,0.3); }
.study-region-card.region--orgs     { background: linear-gradient(135deg, #0ea5e9, #0f766e); box-shadow: 0 16px 30px rgba(14,165,233,0.3); }
.study-region-card.region--world    { background: linear-gradient(135deg, #1f96d3, #8b5cf6, #ec4899); box-shadow: 0 16px 30px rgba(139,92,246,0.3); }

.crest-games-heading { margin: 22px 4px 10px; font-size: 0.86rem; font-weight: 800; letter-spacing: 0.04em; color: var(--muted); text-transform: uppercase; }
.crest-fantasy-note { margin: 10px 4px 0; font-size: 0.74rem; line-height: 1.45; color: var(--muted); text-align: center; }

.study-region-card.featured {
  grid-column: 1 / -1;
  min-height: 88px;
  flex-direction: row;
  align-items: center;
  gap: 14px;
}
.study-region-card.featured .srg-icon { margin: 0; font-size: 32px; }
.study-region-card.featured .srg-name { font-size: 1.1rem; }

.study-region-card.featured:has(> .corner.cost:not(:empty)) { padding-inline-end: 72px; }

@media (max-width: 374px) {
  .hero { padding: 24px 16px 20px; }
  h1 { font-size: clamp(1.9rem, 8vw, 2.3rem); }
  .mode-grid { gap: 10px; }
  .fm-mode { min-height: 112px; padding: 14px 12px; border-radius: 20px; }
  .fm-mode .icon { font-size: 24px; }
  .fm-mode .t { font-size: 0.95rem; }
  .fm-mode .d { font-size: 0.72rem; }
  .fm-mode.featured { min-height: 78px; padding: 12px 14px; }
  .fm-stat .v { font-size: 1.25rem; }
  .results-title { font-size: 2.8rem; }
  .result-hero { font-size: 2.6rem; }
}

@media (min-width: 641px) and (min-height: 601px) {   
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .options-grid { grid-template-columns: 1fr 1fr !important; }
}

@media (orientation: landscape) and (max-height: 500px) {
  html { font-size: 14px; }
  .app-shell {
    width: min(calc(100vw - 16px), 980px) !important;
    padding: var(--shell-pt) 0 var(--shell-pb) !important;
  }
  .hero { padding: 10px 14px 12px !important; gap: 8px !important; }
  .home-screen .hero { padding-top: max(10px, env(safe-area-inset-top, 0px)) !important; }
  h1 { font-size: clamp(1.4rem, 3vw, 1.9rem) !important; margin: 0 !important; }
  .hero-copy { display: none; }
  .level-bar { margin-top: 0; padding: 6px 10px; }
  .hero-summary { flex-direction: row !important; gap: 6px !important; margin: 0 !important; }
  .fm-stat { min-height: 52px !important; padding: 6px 6px !important; border-radius: 14px; }
  .fm-stat .v { font-size: 1.1rem !important; }
  .fm-stat .l { font-size: 0.56rem !important; letter-spacing: 0.1em; }
  .mode-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 8px !important; margin-top: 8px !important; }
  .fm-mode { min-height: 66px; padding: 10px 12px; border-radius: 14px; }
  .fm-mode .icon { font-size: 20px; margin-bottom: 2px; }
  .fm-mode .t { font-size: 0.82rem; }
  .fm-mode .d { display: none; }
  
  .fm-mode .corner:not(.cost) { display: none; }
  .fm-mode.featured { grid-column: 1 / -1; flex-direction: row; min-height: 52px; padding: 8px 14px; }
  .fm-mode.featured .icon { font-size: 22px; }
  .fm-mode.featured .d { display: block; font-size: 0.7rem; }
  .home-bottom-row { margin-top: 8px; gap: 12px; }
  .icon-text-btn { font-size: 0.8rem; padding: 6px 10px; }

  
  .study-regions-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .study-region-card { min-height: 72px; padding: 10px 12px; border-radius: 14px; }
  .study-region-card .srg-icon { font-size: 20px; margin-bottom: 2px; }
  .study-region-card .srg-name { font-size: 0.82rem; }
  .study-region-card .srg-count { font-size: 0.58rem; padding: 2px 6px; top: 6px; inset-inline-end: 6px; }
  .study-region-card.featured { min-height: 54px; padding: 8px 14px; flex-direction: row; }
}

@media (min-width: 768px) and (min-height: 700px) {
  .mode-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 24px; }
  .fm-mode { min-height: 158px; border-radius: 28px; padding: 22px 20px; }
  .fm-mode .icon { font-size: 36px; }
  .fm-mode .t { font-size: 1.25rem; }
  .fm-mode .d { font-size: 0.88rem; }
  .fm-mode.featured { grid-column: 1 / -1; min-height: 110px; padding: 20px 26px; }
  .fm-mode.featured .icon { font-size: 42px; }
  .fm-mode.featured .t { font-size: 1.4rem; }
  .hero-summary { gap: 16px !important; }
  .fm-stat { padding: 20px 14px; }
  .fm-stat .v { font-size: 2rem; }
  .fm-stat .l { font-size: 0.72rem; }
  .results-title { font-size: 4.6rem; }
  .results-stats { max-width: 520px; margin-left: auto; margin-right: auto; }
}

@media (min-width: 768px) and (max-width: 1365px) and (min-height: 601px) and (max-height: 699px) {
  .app-shell { width: min(900px, calc(100vw - 48px)); margin-left: auto; margin-right: auto; }
  .mode-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .study-regions-grid, .practice-grid, .mania-grid { grid-template-columns: repeat(3, 1fr); }
  .home-hud { max-width: 680px; margin-left: auto; margin-right: auto; }
}

.home-hud {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin: 0 0 14px;
}
.home-hud-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 6px 8px; border-radius: 16px;
  background: rgba(255,255,255,0.86); border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(31,41,51,0.05);
  text-align: center; position: relative;
  font: inherit; color: var(--text);
}
html[data-theme="dark"] .home-hud-cell { background: rgba(30,40,55,0.86); box-shadow: 0 8px 20px rgba(0,0,0,0.22); }
button.home-hud-cell {
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease, border-color 160ms ease;
}
button.home-hud-cell:active { transform: scale(0.95); }
.hud-ic { font-size: 1.05rem; line-height: 1; }
.hud-val { font-size: 1.18rem; font-weight: 900; letter-spacing: -0.03em; line-height: 1.1; }
.hud-lbl { font-size: 0.62rem; color: var(--muted); font-weight: 600; }
.hud-points { border-color: rgba(255,111,31,0.4); }
.hud-points .hud-val { color: var(--orange); }
.hud-plus {
  position: absolute; top: -5px; right: -5px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--orange); color: #fff; font-size: 0.78rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px rgba(255,111,31,0.45);
}
.hud-daily .hud-val { color: var(--primary); }
.hud-daily.is-done .hud-val { color: var(--correct); }
.hud-conquest .hud-val { color: var(--primary-deep); }

.charge-modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.58);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9600; padding: 24px;
  opacity: 0; transition: opacity 200ms ease-out;
}
.charge-modal.is-active { opacity: 1; }
.charge-modal[hidden] { display: none; }
.charge-card {
  position: relative;
  background: var(--panel-strong); border-radius: 24px;
  max-width: 400px; width: 100%; padding: 26px 22px 20px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.3);
  transform: scale(0.96) translateY(8px);
  transition: transform 220ms cubic-bezier(0.2,0.9,0.3,1.2);
  
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.charge-modal.is-active .charge-card { transform: scale(1) translateY(0); }
.charge-close {
  position: absolute; top: 12px; inset-inline-end: 12px;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--soft-blue); color: var(--muted);
  font-size: 1rem; cursor: pointer; line-height: 1;
}
.charge-header { text-align: center; margin-bottom: 2px; }
.charge-emoji { font-size: 2.2rem; display: block; line-height: 1; }
.charge-title { font-size: 1.25rem; font-weight: 800; margin: 6px 0 2px; color: var(--text); }
.charge-balance { font-size: 0.9rem; color: var(--muted); margin: 0; }
.charge-balance strong { color: var(--orange); font-size: 1.15rem; font-weight: 900; margin-left: 5px; }
.charge-sub {
  font-size: 0.84rem; color: var(--muted); line-height: 1.5;
  text-align: center; margin: 12px 4px 18px;
  
  word-break: keep-all; overflow-wrap: anywhere;
}
.charge-options { display: flex; flex-direction: column; gap: 10px; }
.charge-option {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 16px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,0.6);
  text-align: start; font: inherit; color: var(--text);
  transition: transform 120ms ease, box-shadow 160ms ease;
}
html[data-theme="dark"] .charge-option { background: rgba(255,255,255,0.05); }
.charge-option:active { transform: scale(0.98); }
.charge-option:disabled { opacity: 0.55; cursor: default; }
.charge-option--ad { border-color: rgba(31,150,211,0.42); }
.charge-option--iap { border-color: rgba(168,85,247,0.42); }
.charge-option-ic { font-size: 1.5rem; line-height: 1; }
.charge-option-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.charge-option-t { font-weight: 800; font-size: 0.98rem; }
.charge-option-d { font-size: 0.74rem; color: var(--muted); margin-top: 1px; }
.charge-option-reward { font-weight: 900; font-size: 1.1rem; color: var(--orange); white-space: nowrap; }
.charge-option--iap .charge-option-reward { color: #a855f7; }
.charge-status {
  margin: 0 2px 12px; padding: 10px 12px; border-radius: 12px;   
  font-size: 0.85rem; text-align: center; font-weight: 700;
  background: var(--soft-blue); color: var(--text);
}
.charge-status--ok { background: rgba(34,197,94,0.16); color: var(--correct); }
.charge-status--warn { background: rgba(255,111,31,0.15); color: var(--orange); }

.charge-restore { width: 100%; margin: 10px 0 0; font-size: 0.86rem; }

.charge-option[hidden] { display: none; }
.charge-option--pro .charge-option-reward { font-size: 1rem; }

.charge-free { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.charge-free-label { margin: 0 0 8px; font-size: 0.8rem; font-weight: 800; color: var(--muted); text-align: center; }
.charge-free-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.charge-free-btn {
  flex: 1 1 auto; min-height: 44px;   
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font: inherit; font-size: 0.88rem; font-weight: 700;
  line-height: 1.2; text-align: center; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.charge-free-btn[hidden] { display: none; }
.charge-free-btn:active { transform: scale(0.98); }
.charge-free-btn .wfi-slot { flex: none; font-size: 1.1rem; line-height: 1; }
.charge-free-count { font-weight: 900; color: var(--muted); }

.charge-free--emphasis .charge-free-label { color: var(--correct); }
.charge-free--emphasis .charge-free-btn { border-color: var(--correct); background: rgba(34, 197, 94, 0.08); }
.charge-restore[hidden] { display: none; }
.charge-legal {
  font-size: 0.68rem; color: var(--muted); line-height: 1.5;
  text-align: center; margin: 16px 6px 0; opacity: 0.85;
}

.detail-map-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 10px; min-height: 44px; padding: 8px 14px 8px 11px;   
  border: 1px solid rgba(31,150,211,0.32); border-radius: 999px;
  background: var(--soft-blue); color: var(--primary);
  font: inherit; font-size: 0.8rem; font-weight: 800; cursor: pointer;
  transition: transform 120ms ease, background 160ms ease, border-color 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.detail-map-btn:hover { background: rgba(31,150,211,0.14); border-color: rgba(31,150,211,0.5); }
.detail-map-btn:active { transform: scale(0.96); }
.detail-map-ic { width: 16px; height: 16px; fill: currentColor; flex: none; }
.detail-map-label { line-height: 1; }

.map-modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.58);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9600; padding: 24px;
  opacity: 0; transition: opacity 200ms ease-out;
}
.map-modal.is-active { opacity: 1; }
.map-modal[hidden] { display: none; }
.map-card {
  position: relative;
  background: var(--panel-strong); border-radius: 24px;
  max-width: 480px; width: 100%; padding: 22px 20px 16px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.3);
  transform: scale(0.96) translateY(8px);
  transition: transform 220ms cubic-bezier(0.2,0.9,0.3,1.2);
}
.map-modal.is-active .map-card { transform: scale(1) translateY(0); }
.map-close {
  position: absolute; top: 12px; inset-inline-end: 12px;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--soft-blue); color: var(--muted);
  font-size: 1rem; cursor: pointer; line-height: 1; z-index: 2;
}
.map-header { text-align: center; margin: 0 28px 14px; }
.map-modal-title { font-size: 1.2rem; font-weight: 800; margin: 2px 0 2px; color: var(--text); }
.map-modal-sub { font-size: 0.8rem; color: var(--muted); margin: 0; }

.map-canvas {
  --map-ocean: #a9d3ec;
  --map-land: #ecdcb6;
  --map-stroke: #b6975c;
  width: 100%; aspect-ratio: 1.42;   
  border-radius: 16px; overflow: hidden;
  background: var(--map-ocean);
  border: 1px solid var(--line);
}
.map-canvas svg .wf-map-hl path { stroke-width: 0.7; }   
.map-canvas.is-loading { opacity: 0.5; }
.map-canvas svg { display: block; width: 100%; height: 100%; }
.map-canvas svg path { fill: var(--map-land); stroke: var(--map-stroke); stroke-width: 0.4; }
.map-canvas svg #World,
.map-canvas svg #Ocean { fill: var(--map-ocean); stroke: none; }

.map-canvas svg .wf-map-hl path { fill: var(--orange) !important; stroke: #fff; stroke-width: 0.4; }

.wf-land-backdrop { fill: var(--map-land); stroke: none; pointer-events: none; }
.wf-map-marker { pointer-events: none; transform-box: fill-box; transform-origin: center; }
.wf-map-dot { fill: #ef4444; stroke: #fff; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.wf-map-ring { fill: none; stroke: #fff; stroke-width: 2.6; vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 1.4px rgba(0,0,0,0.7)); animation: wf-map-reticle 1.6s ease-in-out infinite; }
.wf-map-ping { fill: none; stroke: #fde047; stroke-width: 2.6; vector-effect: non-scaling-stroke;
  opacity: 0.9; animation: wf-map-ping 1.7s ease-out infinite; }
.wf-map-ping.wf-map-ping2 { animation-delay: 0.85s; }
@keyframes wf-map-ping {
  0%   { transform: scale(0.45); opacity: 0.95; }
  75%  { transform: scale(3.2);  opacity: 0; }
  100% { transform: scale(3.2);  opacity: 0; }
}
@keyframes wf-map-reticle { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.16); } }
@media (prefers-reduced-motion: reduce) { .wf-map-ping { animation: none; opacity: 0; } .wf-map-ring { animation: none; } }

.map-modal-note {
  margin: 12px 6px 0; padding: 10px 12px; border-radius: 12px;
  font-size: 0.82rem; text-align: center; font-weight: 700;
  background: var(--soft-blue); color: var(--muted);
}
.map-credit {
  font-size: 0.62rem; color: var(--muted); text-align: end;
  margin: 8px 4px 0; opacity: 0.65;
}
html[data-theme="dark"] .detail-map-btn { background: rgba(56,189,248,0.12); border-color: rgba(56,189,248,0.3); }
html[data-theme="dark"] .map-canvas { --map-ocean: #0e2032; --map-land: #c2cedd; --map-stroke: #33485f; }
html[data-theme="dark"] .wf-map-dot { fill: #f87171; stroke: #fff; }

.dailyflag-modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.58);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9650; padding: 24px;
  opacity: 0; transition: opacity 200ms ease-out;
}
.dailyflag-modal.is-active { opacity: 1; }
.dailyflag-modal[hidden] { display: none; }
.dailyflag-card {
  position: relative; text-align: center;
  background: var(--panel-strong); border-radius: 24px;
  max-width: 420px; width: 100%; padding: 24px 20px 18px;
  max-height: 92vh; overflow-y: auto;
  box-shadow: 0 24px 48px rgba(0,0,0,0.3);
  transform: scale(0.96) translateY(8px);
  transition: transform 220ms cubic-bezier(0.2,0.9,0.3,1.2);
}
.dailyflag-modal.is-active .dailyflag-card { transform: scale(1) translateY(0); }
.dailyflag-close {
  position: absolute; top: 12px; inset-inline-end: 12px;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--soft-blue); color: var(--muted);
  font-size: 1rem; cursor: pointer; line-height: 1; z-index: 2;
}
.dailyflag-eyebrow {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--orange);
  margin: 2px 0 14px;
}
.dailyflag-flagwrap {
  display: inline-block; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line); background: var(--soft-blue);
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  margin-bottom: 12px; line-height: 0;
}

.dailyflag-flag-btn {
  padding: 0; cursor: pointer; font: inherit; -webkit-tap-highlight-color: transparent;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.dailyflag-flag-btn:active { transform: scale(0.97); box-shadow: 0 3px 10px rgba(0,0,0,0.2); }
.dailyflag-tap {
  margin: -4px 0 12px; font-size: 0.74rem; color: var(--muted); opacity: 0.85;
}
.dailyflag-img {
  display: block; width: 176px; height: auto; max-height: 124px;
  object-fit: contain;
}
.dailyflag-name { font-size: 1.32rem; font-weight: 800; margin: 0 0 2px; color: var(--text); }
.dailyflag-sub { font-size: 0.85rem; color: var(--muted); margin: 0; }
.dailyflag-sub[hidden] { display: none; }
.dailyflag-map { margin: 14px 0 4px; }

.atlas-detail-map {
  
  width: 100%; aspect-ratio: 1.18; margin: 10px 0 4px;
  border-radius: 14px; overflow: hidden;
  background: var(--map-sea, #cfe4f2); border: 1px solid var(--line);
}
.atlas-detail-map svg { width: 100%; height: 100%; display: block; }

.atlas-detail-map svg .wf-map-hl path {
  fill: #C2412D !important; stroke: #6e1f12; stroke-width: 1.2; paint-order: stroke;
  filter: drop-shadow(0 2px 4px rgba(120, 30, 10, 0.6));
}
.atlas-detail-map[hidden] { display: none; }
.dailyflag-note {
  margin: 10px 6px 0; padding: 8px 12px; border-radius: 12px;
  font-size: 0.8rem; text-align: center; font-weight: 700;
  background: var(--soft-blue); color: var(--muted);
}
.dailyflag-note[hidden] { display: none; }
.dailyflag-ok { margin-top: 18px; width: 100%; }

.passport-map-wrap { margin: 6px -16px 18px; }
.passport-map {
  --map-ocean: #a9d3ec; --map-land: #e3e9ef; --map-stroke: #ffffff;
  
  width: 100%; aspect-ratio: var(--map-ar, 1000 / 507);
  border-radius: 16px; overflow: hidden;
  background: var(--map-ocean); border: 1px solid var(--line);
  pointer-events: none; 
}
.passport-map svg { display: block; width: 100%; height: 100%; }
.passport-map svg path { fill: var(--map-land); stroke: var(--map-stroke); stroke-width: 0.3; }
.passport-map svg #World,
.passport-map svg #Ocean { fill: var(--map-ocean); stroke: none; }
.passport-map svg .wf-mastered path { fill: var(--correct) !important; stroke: #fff; stroke-width: 0.3; }
.passport-map-legend {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  
  margin: 8px 18px 0; font-size: 0.78rem; color: var(--muted); font-weight: 700;
}
.pm-swatch { width: 13px; height: 13px; border-radius: 4px; display: inline-block; }
.pm-swatch--mastered { background: var(--correct); }
.pm-swatch--rest { background: #e3e9ef; border: 1px solid var(--line); margin-inline-start: 10px; }
html[data-theme="dark"] .passport-map { --map-ocean: #0e2032; --map-land: #2c3a4e; --map-stroke: #1b2c40; }
html[data-theme="dark"] .pm-swatch--rest { background: #2c3a4e; }

.quiz-map {
  
  --map-ocean: #a9d3ec; --map-land: #ecdcb6; --map-stroke: #9c7b43;
  width: 100%; aspect-ratio: 1.18;   
  border-radius: 18px; overflow: hidden;
  background: var(--map-ocean); border: 1px solid var(--line);
  margin: 0 auto;
}
.quiz-map[hidden] { display: none; }
.quiz-map svg { display: block; width: 100%; height: 100%; }
.quiz-map svg path { fill: var(--map-land); stroke: var(--map-stroke); stroke-width: 0.7; }
.quiz-map svg #World,
.quiz-map svg #Ocean { fill: var(--map-ocean); stroke: none; }
.quiz-map svg .wf-map-hl path {
  
  fill: #C2412D !important; stroke: #6e1f12; stroke-width: 1.2; paint-order: stroke;
  filter: drop-shadow(0 2px 4px rgba(120, 30, 10, 0.6));
}
html[data-theme="dark"] .quiz-map { --map-ocean: #16344a; --map-land: #d3c194; --map-stroke: #6b5328; }

.quiz-globe {
  background: radial-gradient(circle at 50% 36%, #16263f 0%, #0a1626 62%, #060d18 100%);
}
.quiz-globe canvas { display: block; width: 100%; height: 100%; }

.map-hint-btn {
  display: inline-flex; align-items: center; gap: 5px;
  margin: 2px auto 8px; padding: 6px 14px;
  font: inherit; font-size: 0.82rem; font-weight: 700;
  color: #92560b; background: #ffeec2; border: 1px solid #f2c879;
  border-radius: 999px; cursor: pointer;
  box-shadow: 0 1px 3px rgba(150, 100, 0, 0.18);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.map-hint-btn:active { transform: scale(0.96); }
.map-hint-btn[hidden] { display: none; }
html[data-theme="dark"] .map-hint-btn { color: #ffd98a; background: #3a2c10; border-color: #6b531f; }

.map-hint-card { margin: 0 auto 10px; max-width: 460px; }
.map-hint-card[hidden] { display: none; }
.map-hint-inner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 14px;
  background: linear-gradient(135deg, #fff6e0, #ffe7c0);
  border: 1px solid #f2c879; box-shadow: 0 2px 8px rgba(150, 100, 0, 0.15);
  animation: map-hint-pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
html[data-theme="dark"] .map-hint-inner { background: linear-gradient(135deg, #34280f, #2a2009); border-color: #6b531f; }
.map-hint-ico { font-size: 1.5rem; flex: none; line-height: 1; }
.map-hint-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.map-hint-region { font-size: 0.8rem; color: var(--muted); }

.map-hint-btn .clue-btn-head { font-weight: 800; }
.map-hint-btn .clue-btn-price { font-size: 0.76rem; opacity: 0.85; margin-inline-start: 6px; }

@keyframes map-hint-pop { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: none; } }

.detail-highlights {
  margin-top: 14px;
  padding: 18px 18px 16px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,111,31,0.08), rgba(255,255,255,0.9));
  border: 1px solid rgba(255,111,31,0.16);
}
.detail-highlights[hidden] { display: none; }
html[data-theme="dark"] .detail-highlights {
    background: linear-gradient(180deg, rgba(251,146,60,0.10), rgba(30,40,55,0.92));
    border-color: rgba(251,146,60,0.22);
  }
.detail-highlights-title {
  margin: 0 0 12px; font-size: 1rem; font-weight: 800; color: var(--text);
  letter-spacing: -0.01em;
}
.detail-highlights-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}

.detail-highlight-item {
  display: grid; grid-template-columns: var(--detail-mark) minmax(0, 1fr);
  align-items: center; column-gap: 11px;
  padding: 10px 14px; border-radius: 14px;
  background: rgba(255,255,255,0.85); border: 1px solid var(--line);
  font-size: 0.95rem; font-weight: 600; color: var(--text); line-height: 1.45;
}
html[data-theme="dark"] .detail-highlight-item { background: rgba(255,255,255,0.05); }
.detail-highlight-tx { min-width: 0; }

.detail-highlight-item--plain { display: block; }

.detail-meaning {
  margin-top: 14px;
  padding: 18px 18px 16px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(31,150,211,0.08), rgba(255,255,255,0.9));
  border: 1px solid rgba(31,150,211,0.16);
}
.detail-meaning[hidden] { display: none; }
html[data-theme="dark"] .detail-meaning {
    background: linear-gradient(180deg, rgba(56,189,248,0.10), rgba(30,40,55,0.92));
    border-color: rgba(56,189,248,0.22);
  }
.detail-meaning-title {
  margin: 0 0 12px; font-size: 1rem; font-weight: 800; color: var(--text);
  letter-spacing: -0.01em;
}
.detail-meaning-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.meaning-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px; border-radius: 14px;
  background: rgba(255,255,255,0.85); border: 1px solid var(--line);
}
html[data-theme="dark"] .meaning-item { background: rgba(255,255,255,0.05); }

:root { --detail-mark: 32px; }
.meaning-ic, .detail-highlight-ic {
  flex: none; width: var(--detail-mark); height: var(--detail-mark);
  font-size: var(--detail-mark); line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

.meaning-ic .wfi--color, .detail-highlight-ic .wfi--color {
  filter: drop-shadow(0 1px 1.5px rgba(16,42,67,0.14));
}
html[data-theme="dark"] .meaning-ic .wfi--color,
html[data-theme="dark"] .detail-highlight-ic .wfi--color {
  filter: drop-shadow(0 1px 2px rgba(2,10,16,0.42));
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .meaning-ic .wfi--color,
  html:not([data-theme="light"]) .detail-highlight-ic .wfi--color {
    filter: drop-shadow(0 1px 2px rgba(2,10,16,0.42));
  }
}

.meaning-ic:not(.wfi-slot), .detail-highlight-ic:not(.wfi-slot) { font-size: 1.15rem; }
.meaning-tx {
  font-size: 0.95rem; font-weight: 600; color: var(--text); line-height: 1.45;
}

@media (max-width: 360px) { :root { --detail-mark: 28px; } }

.detail-anthem {
  margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 3px 10px;
}
.detail-anthem[hidden] { display: none; }
.anthem-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 15px; border-radius: 999px; cursor: pointer;
  border: none; font: inherit; font-weight: 800; font-size: 0.82rem;
  color: #fff; background: linear-gradient(135deg, #1f96d3, #06a59c);
  box-shadow: 0 6px 14px -6px rgba(31,150,211,0.55);
  transition: transform 120ms ease, box-shadow 160ms ease, opacity 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.anthem-btn:active { transform: scale(0.96); }
.anthem-btn:disabled { opacity: 0.85; cursor: default; }
.anthem-btn.is-playing { background: linear-gradient(135deg, #ef4444, #ec4899); box-shadow: 0 6px 14px -6px rgba(239,68,68,0.5); }
.anthem-btn-ic { font-size: 0.95rem; line-height: 1; }
.anthem-btn.is-loading .anthem-btn-ic { animation: anthem-spin 1s linear infinite; display: inline-block; }
@keyframes anthem-spin { to { transform: rotate(360deg); } }
.anthem-credit { margin: 0; font-size: 0.66rem; font-weight: 600; color: var(--muted); line-height: 1.35; }
.anthem-credit--warn { color: var(--orange); font-weight: 700; }

.passport-panel { display: flex; flex-direction: column; }
.passport-hero {
  text-align: center; padding: 18px 16px 18px; margin-bottom: 14px;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(31,150,211,0.13), rgba(168,85,247,0.11));
  border: 1px solid var(--line);
}
.passport-hero-emoji { font-size: 1.9rem; line-height: 1; }
.passport-hero-pct { font-size: 2.9rem; font-weight: 900; letter-spacing: -0.04em; color: var(--primary); line-height: 1; margin-top: 4px; }
.passport-hero-sub { margin: 6px 0 12px; color: var(--muted); font-size: 0.9rem; }
.passport-hero-sub strong { color: var(--text); font-weight: 900; }
.passport-hero-track { height: 10px; border-radius: 999px; background: rgba(127,127,127,0.18); overflow: hidden; }
.passport-hero-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #1f96d3, #a855f7); transition: width 700ms cubic-bezier(0.2,0.9,0.3,1); }

.passport-continents { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.passport-continent {
  padding: 10px 12px; border-radius: 14px;
  background: rgba(127, 127, 127, 0.05);
  border: 1px solid rgba(127, 127, 127, 0.12);
}
.passport-continent-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.passport-continent-head .region-badge { flex: 0 0 auto; }
.passport-continent-count { margin-inline-start: auto; font-size: 0.86rem; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.passport-continent-pct { font-size: 0.92rem; font-weight: 900; color: var(--pc-accent, var(--primary)); font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: end; }
.passport-continent-track { height: 10px; border-radius: 999px; background: rgba(127,127,127,0.18); overflow: hidden; }
.passport-continent-fill {
  height: 100%; border-radius: 999px; min-width: 3px;
  background: var(--pc-accent, var(--primary));
  transition: width 600ms ease;
}

.passport-continent--asia { --pc-accent: #ef4444; }
.passport-continent--europe { --pc-accent: #3b82f6; }
.passport-continent--africa { --pc-accent: #eab308; }
.passport-continent--americas { --pc-accent: #10b981; }
.passport-continent--oceania { --pc-accent: #8b5cf6; }
.passport-continent--antarctic { --pc-accent: #64748b; }

.passport-filter { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.passport-chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(127,127,127,0.06); color: var(--text);
  font: inherit; font-size: 0.82rem; font-weight: 700; white-space: nowrap;
  transition: background 140ms ease, color 140ms ease;
}
.passport-chip.is-active { background: var(--primary); color: #fff; border-color: transparent; }

.passport-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.passport-stamp {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 8px 6px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.6); font: inherit; color: var(--text); text-align: center;
}
html[data-theme="dark"] .passport-stamp { background: rgba(255,255,255,0.04); }
button.passport-stamp { cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform 120ms ease; }
button.passport-stamp:active { transform: scale(0.94); }
.passport-stamp-flag { position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: rgba(127,127,127,0.1); }

.passport-stamp-flag img { width: 100%; height: 100%; object-fit: contain; display: block; }
.passport-stamp.is-locked .passport-stamp-flag img { filter: grayscale(1) opacity(0.3); }
.passport-stamp.is-locked .passport-stamp-name { color: var(--muted); opacity: 0.7; }
.passport-stamp-check {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #22c55e; color: #fff; font-size: 0.7rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(34,197,94,0.5);
}
.passport-stamp-name {
  font-size: 0.68rem; font-weight: 700; line-height: 1.2;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.passport-stamp-check { animation: stamp-pop 380ms cubic-bezier(0.2,0.9,0.3,1.5) both; }
@keyframes stamp-pop { 0% { transform: scale(0); opacity: 0; } 70% { transform: scale(1.25); } 100% { transform: scale(1); opacity: 1; } }
.passport-share {
  margin-top: 12px; padding: 9px 20px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,0.7); color: var(--text);
  font: inherit; font-size: 0.85rem; font-weight: 800;
  transition: transform 120ms ease;
}
html[data-theme="dark"] .passport-share { background: rgba(255,255,255,0.07); }
.passport-share:active { transform: scale(0.96); }

.combo-toast {
  position: absolute; left: 50%; top: 30%;
  z-index: 9700; pointer-events: none; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  animation: combo-pop 1.7s cubic-bezier(0.2,0.9,0.3,1) forwards;
}
.combo-toast strong { font-size: 1.5rem; font-weight: 900; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,0.45); letter-spacing: -0.02em; }
.combo-toast span { font-size: 1.15rem; font-weight: 900; color: #facc15; text-shadow: 0 2px 8px rgba(0,0,0,0.45); }
@keyframes combo-pop {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.6); }
  14% { opacity: 1; transform: translate(-50%, -6px) scale(1.12); }
  28% { transform: translate(-50%, -10px) scale(1); }
  78% { opacity: 1; transform: translate(-50%, -28px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -54px) scale(0.95); }
}

.league-hero { text-align: center; padding: 16px; margin-bottom: 14px; border-radius: 24px; background: linear-gradient(160deg, rgba(250,204,21,0.15), rgba(245,158,11,0.10)); border: 1px solid var(--line); }
.league-hero-emoji { font-size: 1.9rem; line-height: 1; }
.league-rank-line { margin: 6px 0 2px; font-size: 1rem; color: var(--muted); }
.league-rank-line strong { font-size: 1.8rem; font-weight: 900; color: var(--text); margin-left: 6px; letter-spacing: -0.03em; }
.league-reset { margin: 2px 0 0; font-size: 0.82rem; color: var(--muted); }
.league-lastweek { margin: 8px 0 0; font-size: 0.85rem; font-weight: 800; color: #d97706; }

.league-practice-badge { display: inline-block; margin-top: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em; color: var(--muted); border: 1px solid var(--line); background: rgba(255,255,255,0.55); }
html[data-theme="dark"] .league-practice-badge { background: rgba(255,255,255,0.06); }
.league-practice-note { margin: 8px auto 0; max-width: 460px; font-size: 0.78rem; line-height: 1.45; color: var(--muted); }
.league-row-bot { margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 0.66rem; font-weight: 800; color: var(--muted); border: 1px solid var(--line); background: rgba(255,255,255,0.5); vertical-align: 1px; }
html[data-theme="dark"] .league-row-bot { background: rgba(255,255,255,0.05); }
.league-list { display: flex; flex-direction: column; gap: 6px; }
.league-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,0.6); }
html[data-theme="dark"] .league-row { background: rgba(255,255,255,0.04); }
.league-row.is-podium { background: rgba(250,204,21,0.1); }
.league-row.is-you { border-color: var(--primary); background: rgba(31,150,211,0.13); box-shadow: 0 4px 14px rgba(31,150,211,0.12); }
.league-row-rank { width: 30px; text-align: center; font-weight: 900; font-size: 0.95rem; color: var(--muted); flex-shrink: 0; }
.league-row-name { flex: 1; font-weight: 700; font-size: 0.95rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.league-row.is-you .league-row-name { color: var(--primary); }
.league-row-xp { font-weight: 800; font-size: 0.88rem; color: var(--muted); flex-shrink: 0; }
.league-note { text-align: center; font-size: 0.76rem; color: var(--muted); margin: 14px 4px 0; }

.fm-mode.leaderboard { background: linear-gradient(120deg, var(--navy), var(--navy-2)); box-shadow: 0 10px 20px -8px rgba(28,63,94,0.5); }
.fm-mode.worldcup { background: var(--paper-card); border-inline-start: 5px solid var(--gold); box-shadow: 0 8px 16px -12px rgba(60,44,20,0.35); }
.fm-mode.leaderboard .corner { animation: lb-live-pulse 2s ease-in-out infinite; }
@keyframes lb-live-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

.lb-panel { display: flex; flex-direction: column; gap: 14px; }
.lb-header { display: flex; align-items: center; gap: 12px; }
.lb-back { width: 44px; min-height: 44px; padding: 0; font-size: 2rem; line-height: 1; flex-shrink: 0; }
.lb-headings { flex: 1; min-width: 0; }
.lb-headings h2 { margin: 0; font-size: 1.25rem; font-weight: 900; color: var(--text); letter-spacing: -0.02em; }
.lb-day { margin: 2px 0 0; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.lb-day-main { display: block; }
.lb-day-note {
  display: block;
  font-family: var(--font-sans);
  letter-spacing: normal;
  font-size: 0.92em;
  opacity: 0.8;
  margin-top: 1px;
}
.lb-live { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #fff; background: var(--red); padding: 4px 10px; border-radius: 999px; flex-shrink: 0; }

.lb-you { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; background: rgba(31,150,211,0.12); border: 1.5px solid var(--primary); }
.lb-you-rank { font-weight: 900; font-size: 1.05rem; color: var(--primary); min-width: 44px; }
.lb-you-name { flex: 1; font-weight: 800; color: var(--primary); }
.lb-you-score { font-weight: 800; font-size: 0.9rem; color: var(--text); }

.lb-status { text-align: center; color: var(--muted); font-size: 0.9rem; padding: 18px 0; }
.lb-status[hidden] { display: none; }

.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; background: var(--soft-blue); }
.lb-row.is-you { border: 1.5px solid var(--primary); background: rgba(31,150,211,0.13); box-shadow: 0 4px 14px rgba(31,150,211,0.12); }
.lb-rank { width: 34px; text-align: center; font-weight: 900; font-size: 1rem; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.lb-row.is-you .lb-rank { color: var(--primary); }
.lb-name { flex: 1; font-weight: 700; font-size: 0.95rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.lb-row.is-you .lb-name { color: var(--primary); }
.lb-score { font-weight: 800; font-size: 0.88rem; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }

.lb-cta-row { margin-top: 6px; }
.lb-play { width: 100%; }
.lb-fineprint { text-align: center; font-size: 0.74rem; color: var(--muted); margin: 6px 4px 0; line-height: 1.4; }

#nickname-modal h2 { margin: 0 0 8px; font-size: 1.15rem; font-weight: 800; color: var(--text); }
#nickname-modal .confirm-body { color: var(--muted); font-size: 0.9rem; margin: 0 0 14px; line-height: 1.45; }
.nickname-input { width: 100%; box-sizing: border-box; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--panel); color: var(--text); font-size: 1.05rem; font-family: inherit; font-weight: 700; }
.nickname-input:focus { outline: none; border-color: var(--primary); }
.nickname-error { color: var(--wrong); font-size: 0.82rem; margin: 8px 2px 0; }
.nickname-error[hidden] { display: none; }
#nickname-modal .confirm-actions { display: flex; gap: 10px; margin-top: 18px; }
#nickname-modal .confirm-actions button { flex: 1; }

.nick-gen { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 4px; padding: 12px 14px; border-radius: 14px; background: var(--soft-blue); border: 1.5px solid var(--line); }
.nick-gen-name { flex: 1 1 auto; font-weight: 900; font-size: 1.2rem; color: var(--primary); letter-spacing: -0.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nick-reroll { flex: 0 0 auto; width: auto; font-size: 0.85rem; padding: 9px 13px; white-space: nowrap; }

.lb-toast { position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px); background: var(--primary-deep); color: #fff; font-weight: 800; font-size: 0.95rem; padding: 14px 22px; border-radius: 999px; box-shadow: 0 16px 40px rgba(0,0,0,0.3); z-index: 9600; opacity: 0; transition: opacity 280ms ease, transform 280ms cubic-bezier(0.2,0.9,0.3,1.2); max-width: 86vw; text-align: center; }
.lb-toast.is-in { opacity: 1; transform: translate(-50%, 0); }

.lb-rankings { width: 100%; justify-content: center; font-size: 1rem; }

.lb-rank-card { max-width: 440px; max-height: 84vh; display: flex; flex-direction: column; position: relative; padding-top: 30px; }
.lb-modal-close { position: absolute; top: 12px; inset-inline-end: 14px; background: none; border: 0; font-size: 1.05rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 6px; -webkit-tap-highlight-color: transparent; }
.lbm-day { text-align: center; color: var(--muted); font-size: 0.82rem; margin: 2px 0 12px; }
.lbm-list { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; min-height: 0; padding-right: 2px; }

.lb-me {
  flex: 0 0 auto; padding: 2px 8px; border-radius: 999px;
  background: var(--primary, #1f96d3); color: #fff;
  font-size: 0.7rem; font-weight: 800; line-height: 1.6; white-space: nowrap;
}

.lb-result-note.is-best {
  display: inline-flex; align-items: center; gap: 7px;
  margin-left: auto; margin-right: auto;
  padding: 5px 14px; border-radius: 999px;
  color: #b45309; background: rgba(176, 138, 62, 0.12); border: 1px solid rgba(176, 138, 62, 0.3);
  font-weight: 800;
}
.lbr-note-ic { font-size: 1.15rem; flex: 0 0 auto; line-height: 1; }
html[data-theme="dark"] .lb-result-note.is-best { color: #fbbf24; }

.lb-row-ellipsis { justify-content: center; background: transparent; padding: 2px; }
.lb-ellipsis { color: var(--muted); font-weight: 900; font-size: 1.1rem; letter-spacing: 3px; }

.lb-result-card { max-width: 360px; text-align: center; }
.lb-result-emoji { font-size: 2.6rem; line-height: 1; margin-bottom: 4px; }
.lb-result-rank { font-size: 2.5rem; font-weight: 900; letter-spacing: -0.02em; margin: 2px 0; background: linear-gradient(135deg, #fbbf24 0%, #fb923c 45%, #7c3aed 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.lb-result-of { color: var(--muted); font-size: 0.85rem; margin: 0 0 8px; }
.lb-result-of[hidden] { display: none; }
.lb-result-score { font-weight: 800; color: var(--text); margin: 0; }
.lb-result-note { color: var(--muted); font-size: 0.86rem; margin: 8px 0 0; line-height: 1.4; }
.lb-result-note[hidden] { display: none; }

.lb-result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.lb-result-actions button { flex: 1 0 auto; width: auto; min-width: 0; white-space: nowrap; }   

.lb-result-actions .ghost-button { font-size: 1rem; }
.lb-result-actions .primary-button { font-size: 1.1rem; }

.lb-result-actions .ghost-button { flex: 1 1 calc(50% - 5px); }
.lb-result-actions .primary-button { flex: 1 0 100%; }

#lbr-share-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#lbr-share-btn .wfi-slot { width: 1em; height: 1em; flex: none; }

.rankboard-period { margin-top: 6px; }
.rankboard-period-note { margin: 6px 0 0; text-align: center; }
.rankboard-period-note[hidden] { display: none; }

.icon-text-btn.pro-cta { color: #b45309; }
.icon-text-btn.pro-cta span:last-child { font-weight: 800; }
html[data-theme="dark"] .icon-text-btn.pro-cta { color: #fbbf24; }
.icon-text-btn.pro-cta.is-pro-owned { color: #16a34a; }
html[data-theme="dark"] .icon-text-btn.pro-cta.is-pro-owned { color: #4ade80; }

.pro-card { position: relative; text-align: center; max-width: 360px; }
.pro-close { position: absolute; top: 12px; inset-inline-end: 12px; width: 32px; height: 32px; border: none; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; border-radius: 999px; }
.pro-hero { font-size: 2.6rem; line-height: 1; margin: 4px 0 8px; filter: drop-shadow(0 4px 10px rgba(251,191,36,0.4)); }
.pro-card .confirm-title { background: linear-gradient(135deg, #f59e0b, #ec4899); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.pro-benefits { list-style: none; margin: 16px 0; padding: 0; display: flex; flex-direction: column; gap: 11px; text-align: start; }
.pro-benefits li { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 0.95rem; color: var(--text); }
.pro-benefits li span:first-child { font-size: 1.2rem; width: 26px; text-align: center; flex-shrink: 0; }
.pro-price-row { margin: 4px 0 12px; }
.pro-price { font-size: 1.7rem; font-weight: 900; color: var(--text); letter-spacing: -0.02em; }
.pro-buy { width: 100%; background: linear-gradient(135deg, #f59e0b 0%, #f97316 50%, #ec4899 100%); }
.pro-buy:disabled { opacity: 0.55; }
.pro-restore { width: 100%; margin-top: 10px; font-size: 0.9rem; }
.pro-status { margin: 12px 0 0; font-size: 0.88rem; font-weight: 700; }
.pro-status.is-ok { color: var(--correct); }
.pro-status.is-warn { color: var(--orange); }
.pro-status[hidden] { display: none; }
.pro-fineprint { margin: 14px 0 0; font-size: 0.72rem; color: var(--muted); line-height: 1.4; }

.pro-lock-badge {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  color: #fff; background: linear-gradient(135deg, #f59e0b, #ec4899);
  padding: 2px 7px; border-radius: 999px; flex-shrink: 0;
}
.setting-row--link .pro-lock-badge { margin-left: auto; }
body.wf-pro .pro-lock-badge { display: none; }

.lb-customize { width: 100%; margin-top: 10px; }

.stats-ribbon {
  display: flex; margin: 2px 0 8px; padding: 11px 4px; border-radius: 20px;
  background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 26px rgba(92, 111, 128, 0.10); backdrop-filter: blur(12px);
}
html[data-theme="dark"] .stats-ribbon { border-color: rgba(226, 232, 240, 0.08); }
.ribbon-cell {
  flex: 1; position: relative; background: none; border: 0; font: inherit; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px 4px;
}
button.ribbon-cell { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button.ribbon-cell:active { transform: scale(0.96); }
.ribbon-cell + .ribbon-cell::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 16%; height: 68%; width: 1px; background: var(--line);
}
.ribbon-ic { font-size: 15px; line-height: 1; }
.ribbon-v { font-size: 20px; font-weight: 900; line-height: 1.1; }
.ribbon-l { font-size: 10.5px; color: var(--muted); }

.ribbon-flag {
  
  height: 35px; margin-bottom: 6px;
  
  width: auto; aspect-ratio: 3 / 2; object-fit: contain;
  border-radius: 5px; border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 2px 6px rgba(31, 41, 51, 0.12);
}
html[data-theme="dark"] .ribbon-flag { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }

.ribbon-flag:not([src]) { visibility: hidden; }

.ribbon-top { display: inline-flex; align-items: center; gap: 5px; height: 17px; line-height: 1; }
.ribbon-charge {
  padding: 1px 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
  font-family: var(--font-mono); font-size: 8.5px; font-weight: 800;
  letter-spacing: 0.02em; line-height: 1.6;
  pointer-events: none;                 
  white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
.ribbon-charge[hidden] { display: none; }
.ribbon-cell--points.is-pro .ribbon-ic,
.ribbon-cell--points.is-pro .ribbon-v { color: var(--gold, #C9A227); }

.home-progress .xp-track { flex: none; width: 100%; }
.section-eyebrow {
  margin: 18px 4px 10px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}

.practice-sub { margin: -2px 2px 14px; font-size: 13px; color: var(--muted); text-align: center; }
.practice-grid { margin-top: 4px; }
.mania-coming { text-align: center; padding: 44px 20px; color: var(--muted); }
.mania-coming-ic { font-size: 54px; display: block; margin-bottom: 12px; }
.mania-coming-t { margin: 0 0 6px; font-size: 18px; color: var(--text); }
.mania-coming-d { margin: 0 auto; max-width: 290px; font-size: 13px; line-height: 1.55; }

.nav-hamburger {
  position: fixed; z-index: 60;
  top: calc(10px + env(safe-area-inset-top, 0px)); inset-inline-start: calc(14px + var(--sai-start));
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 10px 26px rgba(47, 63, 83, 0.18), 0 2px 6px rgba(47, 63, 83, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  transition: transform 0.16s ease, box-shadow 0.2s ease;
}
html[data-theme="dark"] .nav-hamburger {
  background: rgba(24, 31, 43, 0.6); border-color: rgba(226, 232, 240, 0.12);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.nav-hamburger:active { transform: scale(0.92); box-shadow: 0 4px 12px rgba(47, 63, 83, 0.16); }

.nav-burger-ico { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nav-burger-ico i {
  display: block; height: 2.5px; border-radius: 2px;
  background: linear-gradient(90deg, #1f96d3, #8b5cf6); transition: width 0.18s ease;
}
.nav-burger-ico i:nth-child(1) { width: 19px; }
.nav-burger-ico i:nth-child(2) { width: 13px; }
.nav-burger-ico i:nth-child(3) { width: 16px; }
.nav-hamburger:active .nav-burger-ico i { width: 19px; }
html[data-theme="dark"] .nav-burger-ico i { background: linear-gradient(90deg, #38bdf8, #a78bfa); }

.drawer { position: fixed; inset: 0; z-index: 70; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.42); opacity: 0; transition: opacity 0.25s ease; }
.drawer.is-open .drawer-scrim { opacity: 1; }
.drawer-panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(78%, 320px);
  display: flex; flex-direction: column;
  
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: calc(22px + env(safe-area-inset-top, 0px)) 16px calc(18px + env(safe-area-inset-bottom, 0px));
  background: var(--panel-strong); backdrop-filter: blur(18px);
  border-right: 1px solid rgba(255, 255, 255, 0.6); box-shadow: 3px 0 24px rgba(47, 63, 83, 0.22);
  transform: translateX(-104%); transition: transform 0.3s cubic-bezier(0.22, 0.9, 0.3, 1);
}
html[data-theme="dark"] .drawer-panel { border-right-color: rgba(226, 232, 240, 0.08); }
.drawer.is-open .drawer-panel { transform: translateX(0); }

:root { --sai-start: env(safe-area-inset-left, 0px); --sai-end: env(safe-area-inset-right, 0px); }
html[dir="rtl"] { --sai-start: env(safe-area-inset-right, 0px); --sai-end: env(safe-area-inset-left, 0px); }

html[dir="rtl"] .drawer-panel {
  left: auto; right: 0;
  border-right: none; border-left: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: -3px 0 24px rgba(47, 63, 83, 0.22);
  transform: translateX(104%);
}
html[data-theme="dark"][dir="rtl"] .drawer-panel { border-left-color: rgba(226, 232, 240, 0.08); }
html[dir="rtl"] .drawer.is-open .drawer-panel { transform: translateX(0); }

.drawer-head { padding: 4px 6px 14px; }
.drawer-brand {
  margin: 0; font-size: 20px; font-weight: 900; letter-spacing: -0.02em;
  background: linear-gradient(135deg, #1f96d3 0%, #8b5cf6 50%, #ec4899 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.drawer-tag { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: 0.02em; }

.drawer-tag.is-pro { color: var(--gold, #b8860b); }
html[data-theme="dark"] .drawer-tag.is-pro { color: #fcd34d; }
.drawer-rows { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.drawer-row {
  display: flex; align-items: center; gap: 14px; padding: 13px 10px;
  border: 0; background: none; cursor: pointer; font: inherit; font-size: 15.5px; font-weight: 600;
  color: var(--text); border-radius: 12px; text-align: start;
}
.drawer-row:active { background: var(--soft-blue); }
.drawer-ic { width: 26px; text-align: center; font-size: 18px; }
.drawer-sep { height: 1px; background: var(--line); margin: 8px; }
.drawer-pro {
  
  position: sticky; bottom: 0;
  margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; border: 0; cursor: pointer; border-radius: 16px; font: inherit;
  font-size: 15px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #1f96d3 0%, #8b5cf6 50%, #ec4899 100%);
  box-shadow: 0 12px 24px rgba(124, 58, 237, 0.28);
}
.drawer-pro:active { transform: scale(0.98); }
.drawer-pro.is-pro-owned { background: linear-gradient(135deg, #10b981, #0ea5e9); box-shadow: 0 12px 24px rgba(16, 185, 129, 0.28); }

.tabbar {
  position: fixed; z-index: 55; 
  left: calc(16px + env(safe-area-inset-left, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 2px; padding: 7px 8px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 14px 36px rgba(47, 63, 83, 0.2), 0 3px 10px rgba(47, 63, 83, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
}
html[data-theme="dark"] .tabbar {
  background: rgba(22, 28, 40, 0.62); border-color: rgba(226, 232, 240, 0.1);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.tabbar-btn {
  flex: 1; position: relative; z-index: 0; border: 0; background: none; cursor: pointer; font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 8px 0; border-radius: 18px; color: var(--muted);
  -webkit-tap-highlight-color: transparent; transition: color 0.18s ease;
}
.tabbar-ic { font-size: 21px; line-height: 1; opacity: 0.6; filter: grayscale(0.3); transition: opacity 0.18s, transform 0.18s, filter 0.18s; }
.tabbar-l { font-size: 10px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.tabbar-btn:active .tabbar-ic { transform: scale(0.9); }
.tabbar-btn.is-active { color: var(--primary); }
.tabbar-btn.is-active .tabbar-ic { opacity: 1; filter: none; transform: translateY(-1px) scale(1.08); }
.tabbar-btn.is-active .tabbar-l { font-weight: 800; }

.tabbar-btn.is-active::before {
  content: ""; position: absolute; inset: 2px 5px; z-index: -1; border-radius: 16px;
  background: linear-gradient(135deg, rgba(31, 150, 211, 0.16), rgba(139, 92, 246, 0.14));
  box-shadow: inset 0 0 0 1px rgba(31, 150, 211, 0.18);
}
html[data-theme="dark"] .tabbar-btn.is-active::before {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(167, 139, 250, 0.16));
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.22);
}

@media (orientation: landscape) and (max-height: 500px) {
  
  body.has-tabbar .app-shell { padding-bottom: var(--shell-pb) !important; }
}

body.has-tabbar .panel > .page-topbar { padding-top: 30px; }

.mania-grid { margin-bottom: 6px; }

.mania-list-quiz { width: 100%; margin: 0 0 12px; }
.mania-flag-list { grid-template-columns: 1fr; }
@media (min-width: 520px) { .mania-flag-list { grid-template-columns: 1fr 1fr; } }
.mania-flag-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: var(--panel-strong); border: 1px solid var(--line); cursor: pointer;
  text-align: start; color: var(--text); font: inherit; width: 100%;
}
.mania-flag-row:active { transform: scale(0.98); }

.mania-flag-row img { width: 58px; height: 39px; object-fit: contain; border-radius: 6px; background: rgba(0,0,0,0.04); border: 1px solid rgba(47,63,83,0.10); flex: none; }
html[data-theme="dark"] .mania-flag-row img { background: rgba(255,255,255,0.05); border-color: rgba(226,232,240,0.10); }

.mania-flag-row .mania-fr-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mania-flag-row .mania-fr-name { font-weight: 800; font-size: 0.98rem; }
.mania-flag-row .mania-fr-en { font-size: 0.76rem; color: var(--muted); margin-top: 2px; }
.mania-flag-row .mania-fr-arrow { color: var(--primary-deep); font-size: 1.4rem; font-weight: 800; }

.mania-fr-tag {
  align-self: flex-start; margin-top: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 800; line-height: 1.5;
  color: #8a2b1c; background: rgba(194,65,45,0.12); border: 1px solid rgba(194,65,45,0.28);
}
html[data-theme="dark"] .mania-fr-tag { color: #ffb4a2; background: rgba(248,113,113,0.14); border-color: rgba(248,113,113,0.3); }
.mania-flag-row.is-frequent-wrong { border-color: rgba(194,65,45,0.35); }
html[data-theme="dark"] .mania-flag-row.is-frequent-wrong { border-color: rgba(248,113,113,0.3); }
.mania-detail-meta { display: flex; flex-direction: column; gap: 8px; }

.mania-meta-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 0.92rem; }
.mania-meta-k { flex: 0 0 auto; white-space: nowrap; color: var(--muted); }
.mania-meta-v { flex: 1 1 auto; min-width: 0; color: var(--text); font-weight: 700; text-align: end; overflow-wrap: anywhere; }

.mania-meta-row.is-long { flex-direction: column; align-items: stretch; gap: 3px; }
.mania-meta-row.is-long .mania-meta-v { text-align: start; font-weight: 600; line-height: 1.5; }
.mania-sym-text { margin: 0; color: var(--text); line-height: 1.6; font-size: 0.95rem; }

.trust-note {
  font-size: 0.76rem; line-height: 1.5; color: var(--muted);
  padding-top: 6px; border-top: 1px solid rgba(47, 63, 83, 0.08);
}
html[data-theme="dark"] .trust-note { border-top-color: rgba(255, 255, 255, 0.10); }

.trust-note-hidden { font-style: italic; }

.trust-note-link { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.trust-note-link:hover { opacity: 0.8; }
.meaning-item.trust-note { border-top: none; padding-top: 2px; }

.mania-asset-note {
  margin: 0 0 8px; padding: 8px 10px;
  border-inline-start: 3px solid var(--primary);
  border-start-start-radius: 0; border-end-start-radius: 0;
  border-start-end-radius: 8px; border-end-end-radius: 8px;
  background: rgba(47, 63, 83, 0.05);
  color: var(--muted); font-size: 0.86rem; line-height: 1.55;
}
html[data-theme="dark"] .mania-asset-note { background: rgba(255, 255, 255, 0.06); }
#mania-detail-flag { width: 100%; max-height: 210px; object-fit: contain; }

.mania-flag-row img.crest-row-img { width: 48px; height: 54px; background: #fff; border-radius: 8px; }
html[data-theme="dark"] .mania-flag-row img.crest-row-img { background: #f1f5f9; }
.crest-detail-visual { background: #fff; padding: 16px; border-radius: 18px; }
html[data-theme="dark"] .crest-detail-visual { background: #eef2f7; }
#crest-detail-img { width: 100%; max-height: 300px; object-fit: contain; }
.crest-detail-region { margin: 6px 0 0; font-size: 0.86rem; color: var(--muted); line-height: 1.45; }

.bookmark-btn { border: 0; background: none; cursor: pointer; font-size: 1.55rem; line-height: 1; color: var(--muted); min-height: 44px; padding: 8px 6px; -webkit-tap-highlight-color: transparent; }   
.bookmark-btn.is-on { color: #f59e0b; }
.bookmark-btn:active { transform: scale(0.9); }
.quiz-bookmark { cursor: pointer; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: 4px 10px; }
.quiz-bookmark.is-on { color: #f59e0b; }
.quiz-bookmark:active { transform: scale(0.92); }

.study-region-card.region--game { background: linear-gradient(135deg, #1e1b4b, #6d28d9 60%, #db2777); box-shadow: 0 16px 30px rgba(109,40,217,0.4); }
.study-region-card.region--game .srg-icon { font-size: 34px; }
.srg-game-body { display: flex; flex-direction: column; }
.srg-game-sub { font-size: 0.78rem; font-weight: 700; opacity: 0.85; margin-top: 2px; }

#crest-reigns-screen, #amem-screen, #froute-screen { opacity: 1; transform: none; pointer-events: auto; }

.study-region-card.region--reigns { background: linear-gradient(135deg, #4c1d95, #7c3aed 45%, #b91c1c); box-shadow: 0 16px 30px rgba(124,58,237,0.42); }
.study-region-card.region--reigns .srg-icon { font-size: 34px; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.4)); }

.study-region-card > .srg-badges {
  order: -1;                 
  margin-block-end: auto;    
  align-self: stretch;
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: space-between; align-items: flex-start;
}

.study-region-card > .srg-badges > .corner.cost,
.study-region-card > .srg-badges > .srg-count { position: static; inset: auto; }

.study-region-card > .srg-badges > .corner.cost {
  background: var(--hub-action-surface, rgba(194, 65, 45, 0.06));
  border: 1px solid var(--hub-action-line, rgba(194, 65, 45, 0.28));
  color: var(--primary);
  text-shadow: none;
}

.study-region-card .corner.cost {
  position: absolute; top: 10px; inset-inline-end: 10px;
  font-family: var(--font-mono); font-size: 0.66rem; font-weight: 700;
  padding: 4px 9px; border-radius: 999px;
  background: rgba(0,0,0,0.34); border: 1px solid rgba(255,255,255,0.22);
  color: #fcd34d;
}
.study-region-card .corner.cost.is-locked { color: #fca5a5; }
.study-region-card .corner.cost:empty { display: none; }
#crest-reigns-screen, #amem-screen, #froute-screen { position: fixed; inset: 0; z-index: 200; padding: 0 !important; margin: 0; max-width: none;
  background: radial-gradient(120% 90% at 50% -10%, #2a1a52 0%, #160d2e 48%, #0a0716 100%); }
.creigns-root { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px calc(10px + env(safe-area-inset-bottom, 0px));
  -webkit-user-select: none; user-select: none; overflow: hidden; touch-action: none; color: #f3e9d8; }
.creigns-root::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(70% 55% at 50% 42%, transparent 55%, rgba(0,0,0,0.55) 100%); z-index: 0; }

.creigns-top { position: relative; z-index: 3; width: 100%; max-width: 460px; display: flex; align-items: center; gap: 8px; }
.creigns-exit { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(255,255,255,0.12); color: #f3e9d8; font-size: 14px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.creigns-meters { flex: 1; display: flex; justify-content: space-around; gap: 6px; }
.creigns-meter { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 54px; transition: transform 0.18s; }
.creigns-meter-ring { position: relative; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--mc) calc(var(--mv,50) * 1%), rgba(255,255,255,0.10) 0); transition: background 0.5s cubic-bezier(.2,.8,.2,1); }
.creigns-meter-ring::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #1a1130; }
.creigns-meter-ico { position: relative; z-index: 1; font-size: 17px; line-height: 1; }
.creigns-meter-arrow { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); font-size: 13px; font-weight: 900; opacity: 0; transition: opacity 0.15s; }
.creigns-meter.show-up .creigns-meter-arrow { opacity: 1; color: #4ade80; }
.creigns-meter.show-down .creigns-meter-arrow { opacity: 1; color: #f87171; }
.creigns-meter.flash { animation: creigns-meter-pop 0.45s; }
@keyframes creigns-meter-pop { 30% { transform: scale(1.32); } }
.creigns-meter.danger .creigns-meter-ring { animation: creigns-danger 0.7s infinite; }
@keyframes creigns-danger { 50% { box-shadow: 0 0 0 3px rgba(248,113,113,0.7), 0 0 18px rgba(248,113,113,0.6); } }

.creigns-reign { position: relative; z-index: 3; margin-top: 8px; text-align: center; }
.creigns-year { font-size: 1.45rem; font-weight: 900; letter-spacing: -0.01em; color: #fcd34d; text-shadow: 0 2px 10px rgba(252,211,77,0.35); }
.creigns-best { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #a78bda; margin-top: 1px; }

.creigns-stage { position: relative; z-index: 2; flex: 1 1 auto; width: 100%; max-width: 360px; display: flex; align-items: center; justify-content: center; min-height: 0; }
.creigns-deck { position: relative; width: 100%; height: 100%; max-height: 460px; display: flex; align-items: center; justify-content: center; }
.creigns-card { position: absolute; width: min(82vw, 320px); max-height: 100%; display: flex; flex-direction: column; border-radius: 20px; overflow: hidden;
  background: linear-gradient(180deg, #fbf4e2, #efe2c4); box-shadow: 0 22px 50px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(120,80,30,0.25); will-change: transform; }
.creigns-card.behind1 { transform: translateY(14px) scale(0.94); filter: brightness(0.8); z-index: 1; }
.creigns-card.behind2 { transform: translateY(26px) scale(0.88); filter: brightness(0.62); z-index: 0; }
.creigns-card.active { z-index: 4; cursor: grab; }
.creigns-card.active:active { cursor: grabbing; }
.creigns-card.void { background: linear-gradient(180deg, #2b1840, #15091f); box-shadow: 0 22px 50px rgba(124,0,180,0.5), inset 0 0 0 1px rgba(180,80,255,0.4); color: #e9d5ff; }
.creigns-card-imgwrap { position: relative; flex: 1 1 auto; min-height: 120px; display: flex; align-items: center; justify-content: center; padding: 14px 14px 8px;
  background: radial-gradient(70% 70% at 50% 40%, rgba(124,58,237,0.16), transparent 70%); }
.creigns-card.void .creigns-card-imgwrap { background: radial-gradient(70% 70% at 50% 40%, rgba(168,40,255,0.4), transparent 72%); }
.creigns-card-img { max-width: 78%; max-height: 168px; object-fit: contain; filter: drop-shadow(0 8px 18px rgba(0,0,0,0.3)); pointer-events: none; }
.creigns-card-body { flex: none; padding: 8px 16px 16px; text-align: center; }
.creigns-who { font-size: 1.04rem; font-weight: 900; color: #3b2412; letter-spacing: -0.01em; }
.creigns-card.void .creigns-who { color: #f0d9ff; }
.creigns-role { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #9a6b2f; margin-top: 1px; }
.creigns-card.void .creigns-role { color: #c79bff; }
.creigns-text { margin-top: 9px; font-size: 0.92rem; line-height: 1.5; color: #4a341f; font-weight: 600; }
.creigns-card.void .creigns-text { color: #ddc7f5; }

.creigns-card-tint { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.08s; }
.creigns-card-tint.left { background: linear-gradient(90deg, rgba(37,99,235,0.42), transparent 60%); }
.creigns-card-tint.right { background: linear-gradient(270deg, rgba(202,138,4,0.45), transparent 60%); }
.creigns-pick { position: absolute; top: 16px; padding: 6px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 900; color: #fff; opacity: 0; transform: scale(0.8); transition: opacity 0.1s, transform 0.1s; max-width: 70%; }
.creigns-pick.left { left: 14px; background: #2563eb; transform-origin: left; }
.creigns-pick.right { right: 14px; background: #b45309; transform-origin: right; }

.creigns-choices { position: relative; z-index: 3; width: 100%; max-width: 360px; display: flex; gap: 8px; margin-top: 8px; }
.creigns-cbtn { flex: 1; padding: 11px 10px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.16); background: rgba(255,255,255,0.07); color: #f3e9d8; font: inherit; font-weight: 700; font-size: 0.82rem; line-height: 1.3; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform 0.12s, background 0.12s; }
.creigns-cbtn:active { transform: scale(0.96); }
.creigns-cbtn .creigns-cbtn-dir { display: block; font-size: 0.62rem; font-weight: 900; letter-spacing: 0.1em; opacity: 0.6; margin-bottom: 2px; }
.creigns-cbtn.left .creigns-cbtn-dir { color: #93c5fd; }
.creigns-cbtn.right .creigns-cbtn-dir { color: #fcd34d; }
.creigns-hint { position: relative; z-index: 3; margin-top: 7px; font-size: 0.68rem; color: #8b7bb5; letter-spacing: 0.04em; min-height: 1em; }

.creigns-fx { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.creigns-flash { position: absolute; inset: 0; pointer-events: none; z-index: 5; opacity: 0; }
.creigns-flash.go { animation: creigns-flash 0.4s ease-out; }
@keyframes creigns-flash { 0% { opacity: 0.5; } 100% { opacity: 0; } }
.creigns-float { position: absolute; font-size: 0.95rem; font-weight: 900; pointer-events: none; animation: creigns-float-up 0.9s ease-out forwards; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
@keyframes creigns-float-up { 0% { opacity: 0; transform: translateY(0) scale(0.6); } 18% { opacity: 1; transform: translateY(-8px) scale(1.1); } 100% { opacity: 0; transform: translateY(-60px) scale(1); } }
.creigns-spark { position: absolute; width: 7px; height: 7px; border-radius: 50%; pointer-events: none; }

.creigns-overlay { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 14px; padding: 26px;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: radial-gradient(80% 60% at 50% 40%, rgba(40,18,80,0.72), rgba(8,5,18,0.92)); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); text-align: center; }
.creigns-overlay > :first-child { margin-top: auto; }
.creigns-overlay > :last-child { margin-bottom: auto; }

.creigns-overlay .creigns-oactions {
  position: sticky; bottom: 0; z-index: 1;
  max-width: none; width: calc(100% + 52px); margin-inline: -26px;
  padding: 10px 26px calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: center;
  background: linear-gradient(to bottom, rgba(8,5,18,0), rgba(8,5,18,0.94) 34%);
}
.creigns-overlay .creigns-oactions button { max-width: 220px; }
.creigns-overlay[hidden] { display: none; }
.creigns-crown { font-size: 60px; filter: drop-shadow(0 8px 22px rgba(124,58,237,0.6)); animation: creigns-crown-bob 2.6s ease-in-out infinite; }
@keyframes creigns-crown-bob { 50% { transform: translateY(-7px) rotate(-3deg); } }
.creigns-otitle { margin: 0; font-size: 1.5rem; font-weight: 900; color: #fcd34d; letter-spacing: -0.02em; }
.creigns-odesc { margin: 0; max-width: 300px; line-height: 1.6; font-size: 0.94rem; color: #d6c8ee; }

.creigns-ometers {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  width: 100%; max-width: 300px; margin: 14px 0 10px;
}
.creigns-ometer {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.13);
}
.creigns-ometer-ic { display: inline-flex; align-items: center; font-size: 1.05rem; color: var(--m, #fff); }
.creigns-ometer-ic .wfi { width: 1.15em; height: 1.15em; }
.creigns-ometer-lb { font-size: 0.82rem; font-weight: 800; color: #efe7ff; white-space: nowrap; }
.creigns-orule { margin: 0; max-width: 300px; line-height: 1.6; font-size: 0.94rem; color: #d6c8ee; }

.creigns-odesc, .creigns-orule, .creigns-tutorial-hint { word-break: keep-all; }

.creigns-fantasy-note { margin: 14px 0 0; max-width: 300px; text-align: center; font-size: 0.72rem; line-height: 1.5; color: #a89bc4; }
.creigns-tutorial-hint {
  margin: 10px 0 0; max-width: 300px; text-align: center;
  font-size: 0.8rem; font-weight: 700; line-height: 1.5; color: #fcd34d;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.creigns-hint-ic { display: inline-flex; flex: 0 0 auto; font-size: 0.95rem; }
.creigns-hint-ic .wfi { width: 1.1em; height: 1.1em; }

.creigns-obest {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: -4px 0 2px; padding: 5px 12px; border-radius: 999px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.13);
  font-size: 0.8rem; font-weight: 800; color: #fcd34d; word-break: keep-all;
}

.creigns-best-ic { display: inline-flex; align-items: center; font-size: 0.86rem; margin-inline-end: 3px; }
.creigns-best-ic .wfi { width: 1.15em; height: 1.15em; }
.creigns-oend-name { font-size: 1.16rem; font-weight: 900; color: #fff; }
.creigns-ostats { display: flex; gap: 10px; }

.creigns-seen { width: 100%; max-width: 320px; }
.creigns-seen[hidden] { display: none; }
.creigns-seen-head, .creigns-ends-head { font-size: 0.76rem; letter-spacing: 0.04em; color: #c4b5fd; margin-bottom: 8px; }
.creigns-seen-row { display: flex; justify-content: center; gap: 10px; }
.creigns-seen-btn { flex: 1 1 0; min-width: 0; max-width: 100px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 6px 10px; border-radius: 14px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); color: #f3e9d8; }
.creigns-seen-img { width: 54px; height: 54px; object-fit: contain; border-radius: 10px; background: #fff; }

.creigns-seen-name { max-width: 100%; font-size: 0.72rem; line-height: 1.25; word-break: keep-all; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.creigns-seen-hint { margin: 8px 0 0; font-size: 0.72rem; line-height: 1.4; color: #a89bc4; }
.creigns-ends { width: 100%; max-width: 320px; }
.creigns-ends-head { display: flex; justify-content: center; gap: 8px; align-items: baseline; }
.creigns-ends-count { color: #fcd34d; font-size: 0.82rem; }
.creigns-ends-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.creigns-end-gem { width: 34px; height: 34px; padding: 0; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.10); color: #6b5f86; font-weight: 800; font-size: 0.9rem; }
.creigns-end-gem.is-found { background: rgba(124,58,237,0.28); border-color: rgba(167,139,250,0.55); color: #ede9fe; }
.creigns-end-gem.is-found.is-win { background: rgba(251,191,36,0.22); border-color: rgba(252,211,77,0.65); color: #fde68a; }
.creigns-end-gem.is-now { outline: 2px solid #fcd34d; outline-offset: 1px; }
.creigns-gem-ic { display: inline-flex; width: 20px; height: 20px; font-size: 0.95rem; line-height: 1; }
.creigns-gem-ic svg { width: 20px; height: 20px; }
.creigns-ends-cap { min-height: 1.2em; margin-top: 6px; font-size: 0.78rem; color: #d6c8ee; }
.creigns-ostat { flex: 1; min-width: 86px; padding: 10px 8px; border-radius: 14px; background: rgba(255,255,255,0.07); }
.creigns-ostat span { display: block; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #a78bda; }
.creigns-ostat b { font-size: 1.3rem; font-weight: 900; color: #fcd34d; }
.creigns-oactions { display: flex; gap: 12px; width: 100%; max-width: 320px; }
.creigns-oactions button { flex: 1; }
.creigns-newbest { font-size: 0.78rem; font-weight: 900; color: #4ade80; letter-spacing: 0.05em; animation: creigns-meter-pop 0.6s; }

.ribbon-cell { position: relative; }
.point-spend-chip {
  position: absolute; left: 50%; top: 2px; transform: translateX(-50%);
  font-weight: 800; font-size: 0.82rem; color: var(--primary);
  pointer-events: none; animation: pt-spend 900ms cubic-bezier(0.22, 0.9, 0.3, 1) forwards;
}
@keyframes pt-spend {
  0%   { opacity: 0; transform: translate(-50%, 6px) scale(0.9); }
  22%  { opacity: 1; transform: translate(-50%, -2px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -26px) scale(1); }
}
.ribbon-cell.is-spending .ribbon-v { animation: pt-bump 420ms ease-out; }
@keyframes pt-bump { 0%,100% { transform: scale(1); } 40% { transform: scale(1.14); } }
@media (prefers-reduced-motion: reduce) {
  .point-spend-chip { animation-duration: 1ms; }
  .ribbon-cell.is-spending .ribbon-v { animation: none; }
}

html[data-textsize="s"] { font-size: 15px; }
html[data-textsize="m"] { font-size: 16px; }   
html[data-textsize="l"] { font-size: 18px; }

.primary-button {
  background: var(--primary);
  box-shadow: 0 12px 22px -8px rgba(194, 65, 45, 0.45);
}
.secondary-button {
  background: var(--navy);
  box-shadow: 0 12px 22px -8px rgba(28, 63, 94, 0.45);
}
.ghost-button {
  color: var(--primary-deep);
  background: var(--paper-card);
  border: 1px solid var(--line);
  box-shadow: none;
}
.mode-button--time, .mode-button--survival { background: var(--navy); box-shadow: 0 10px 20px -8px rgba(28,63,94,0.4); }
.sub-button--study { background: var(--navy); box-shadow: 0 10px 20px -8px rgba(28,63,94,0.35); }
.sub-button--review { background: var(--primary); box-shadow: 0 10px 20px -8px rgba(194,65,45,0.35); }
.icon-text-btn:hover { background: rgba(176, 138, 62, 0.08); }

.page-title { font-weight: 700; }
.section-eyebrow {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

.stats-ribbon {
  background: var(--paper-card);
  border: 1px solid var(--line);
}
.ribbon-v { font-family: var(--font-latin-serif); font-weight: 700; }

.ribbon-cell--points .ribbon-v { color: var(--primary); }
.ribbon-cell--dailyflag .ribbon-v { color: var(--text); }
.ribbon-cell--conquest .ribbon-v { color: var(--navy); }

html[data-theme="dark"] .ribbon-cell--conquest .ribbon-v { color: var(--gold); }

.flag-frame {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px -10px rgba(60, 44, 20, 0.4);
}
.progress-track { background: var(--line); }
.progress-fill { background: var(--navy); }
html[data-theme="dark"] .progress-fill { background: var(--gold); }
.option-button {
  background: var(--paper-card);
  border: 1px solid var(--line);
  color: var(--text);
}
.option-button .k { background: var(--navy); color: #F3ECDB; }
.option-button.correct {
  color: #14532d;
  background: #EAF6EE;
  border: 1.5px solid var(--correct);
}
html[data-theme="dark"] .option-button.correct { color: #d9f3e4; background: rgba(28, 122, 75, 0.28); }
.option-button.correct .k { background: var(--correct); color: #fff; }
.option-button.wrong {
  color: #7f1d1d;
  background: #FBEFE9;
  border: 1.5px solid var(--wrong);
}
html[data-theme="dark"] .option-button.wrong { color: #f8d8cf; background: rgba(194, 65, 45, 0.26); }
.option-button.wrong .k { background: var(--wrong); color: #fff; }

.fm-chip { background: var(--paper-card); border: 1px solid var(--line); color: var(--text); }
.fm-chip.streak { background: rgba(176, 138, 62, 0.12); color: var(--gold); border-color: rgba(176, 138, 62, 0.3); }
.fm-chip.timer { background: rgba(194, 65, 45, 0.1); color: var(--primary); border-color: rgba(194, 65, 45, 0.25); }
.fm-chip.correct-chip { background: rgba(28, 122, 75, 0.1); color: var(--correct); border-color: rgba(28, 122, 75, 0.25); }
.fm-chip.wrong-chip { background: rgba(179, 54, 45, 0.1); color: var(--wrong); border-color: rgba(179, 54, 45, 0.25); }

.study-region-card,
.study-region-card.region--asia, .study-region-card.region--europe,
.study-region-card.region--africa, .study-region-card.region--americas,
.study-region-card.region--oceania, .study-region-card.region--orgs,
.study-region-card.region--world, .study-region-card.region--reigns,
.study-region-card.region--game {
  background: var(--paper-card);
  color: var(--text);
  border: 1px solid var(--line);
  
  border-inline-start-width: 5px;
  box-shadow: 0 8px 16px -12px rgba(60, 44, 20, 0.35);
}
.study-region-card.region--asia     { border-inline-start-color: #C2412D; }
.study-region-card.region--europe   { border-inline-start-color: #1C3F5E; }
.study-region-card.region--africa   { border-inline-start-color: #B08A3E; }
.study-region-card.region--americas { border-inline-start-color: #1C7A4B; }
.study-region-card.region--oceania  { border-inline-start-color: #4a6b8a; }
.study-region-card.region--orgs     { border-inline-start-color: #2a7a8c; }
.study-region-card.region--world    { border-inline-start-color: var(--gold); }
.study-region-card.region--reigns   { border-inline-start-color: #6d4a8c; }
.study-region-card.region--game     { border-inline-start-color: #6d4a8c; }
.study-region-card .srg-name { font-family: var(--font-serif); font-weight: 700; color: var(--text); text-shadow: none; }
.study-region-card .srg-count {
  font-family: var(--font-mono);
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  text-shadow: none;
}
.study-region-card .srg-icon { filter: none; text-shadow: none; }

.tabbar {
  background: rgba(251, 247, 238, 0.9);
  border: 1px solid var(--line);
}
html[data-theme="dark"] .tabbar { background: rgba(18, 38, 55, 0.92); border-color: var(--line); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .tabbar { background: rgba(18, 38, 55, 0.92); border-color: var(--line); }
}
.tabbar-btn.is-active::before { background: rgba(194, 65, 45, 0.1); }
html[data-theme="dark"] .tabbar-btn.is-active::before { background: rgba(231, 185, 107, 0.12); }

.passport-panel {
  background: linear-gradient(168deg, #1C3F5E, #16314a);
  border-color: rgba(20, 40, 60, 0.5);
  color: #EAE1CC;
}
.passport-panel .page-title,
.passport-panel .passport-hero-label,
.passport-panel h2, .passport-panel h3 { color: #EAE1CC; }
.passport-panel .passport-hero-pct {
  font-family: var(--font-latin-serif);
  font-weight: 400;
  color: #E7B96b;
}
.passport-panel .ghost-button {
  color: #EAE1CC;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(234, 225, 204, 0.25);
}
.passport-panel .study-count,
.passport-panel .passport-hero-sub { color: #9fb4c8; }

.league-hero {
  background: var(--paper-card);
  border: 1px solid var(--line);
}
.league-row.is-podium { background: rgba(176, 138, 62, 0.13); }
.league-row.is-you {
  border-color: var(--primary);
  border-left: 3px solid var(--primary);
  background: rgba(194, 65, 45, 0.08);
  box-shadow: none;
}
.league-row.is-you .league-row-name { color: var(--primary); }
.league-row-rank { font-family: var(--font-latin-serif); }
.league-row-xp { font-family: var(--font-latin-serif); }
.league-lastweek { color: var(--gold); }

.charge-balance strong {
  font-family: var(--font-latin-serif);
  color: var(--primary);
}
.charge-title { font-weight: 700; }

.toggle input:checked + .toggle-slider { background: var(--correct); }
.theme-seg { background: rgba(176, 138, 62, 0.12); }
.theme-seg-btn.is-active { background: var(--navy); color: #F3ECDB; box-shadow: none; }

.settings-done-btn {
  background: var(--navy);
  box-shadow: 0 6px 14px -6px rgba(28, 63, 94, 0.5);
}
html[data-theme="dark"] .settings-done-btn {
  background: var(--navy); box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.5);
}
.nav-burger-ico i { background: var(--navy); }
html[data-theme="dark"] .nav-burger-ico i { background: var(--gold); }
.pro-lock-badge { background: var(--primary); }
.icon-text-btn.pro-cta { color: var(--gold); }
html[data-theme="dark"] .icon-text-btn.pro-cta { color: var(--gold); }

.charge-option--ad { border-color: var(--line); }
.charge-option--ad .charge-option-reward { color: var(--correct); }
.charge-option--iap { border: 1.5px solid var(--primary); background: rgba(194, 65, 45, 0.06); }
.charge-option--iap .charge-option-reward { color: var(--primary); }
.charge-option-reward { font-family: var(--font-latin-serif); font-weight: 700; }

.results-stat { background: var(--paper-card); }
html[data-theme="dark"] .results-stat { background: var(--paper-card); }
.results-stat-value { font-family: var(--font-latin-serif); font-weight: 700; }
.results-stat--correct { color: var(--correct); }
.results-stat--wrong { color: var(--wrong); }
.results-stat--total { color: var(--navy); }
html[data-theme="dark"] .results-stat--correct { color: var(--correct); }
html[data-theme="dark"] .results-stat--wrong { color: var(--wrong); }
html[data-theme="dark"] .results-stat--total { color: var(--gold); }
.result-star--filled { color: var(--gold); }

.results-title {
  font-family: var(--font-latin-serif);
  font-weight: 400;
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--text);
}
html[data-theme="dark"] .results-title { color: var(--gold); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .results-title { color: var(--gold); }
}
.results-stat--total { color: var(--navy) !important; }
html[data-theme="dark"] .results-stat--total { color: var(--gold) !important; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .results-stat--total { color: var(--gold) !important; }
}
.results-stat--xp .results-stat-value {
  background: none; -webkit-text-fill-color: currentColor; color: var(--gold);
}

.fm-stat.hero .v,
html[data-theme="dark"] .fm-stat.hero .v {
  background: none; -webkit-text-fill-color: currentColor;
  color: var(--text); font-family: var(--font-latin-serif);
}
.fm-stat.heat .v, html[data-theme="dark"] .fm-stat.heat .v { color: var(--gold); }

.primary-button--daily { background: var(--primary); box-shadow: 0 12px 22px -8px rgba(194,65,45,0.45); }
.anthem-btn.is-playing { background: var(--primary); box-shadow: 0 6px 14px -7px rgba(194,65,45,0.5); }

.drawer-brand {
  background: none; -webkit-text-fill-color: currentColor;
  color: var(--text); font-family: var(--font-serif); font-weight: 700;
}
.drawer-pro { background: var(--navy); box-shadow: 0 10px 20px -8px rgba(28,63,94,0.5); }
.drawer-pro.is-pro-owned { background: var(--correct); box-shadow: 0 10px 20px -8px rgba(28,122,75,0.4); }

.lb-result-rank {
  background: none; -webkit-text-fill-color: currentColor;
  color: var(--gold); font-family: var(--font-latin-serif); font-weight: 700;
}
.pro-card .confirm-title {
  background: none; -webkit-text-fill-color: currentColor;
  color: var(--text); font-family: var(--font-serif); font-weight: 700;
}
.pro-buy { background: var(--primary); }

.primary-button, .sub-button--review, .primary-button--daily,
.pro-buy, .anthem-btn.is-playing { color: var(--on-primary, #fff); }

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .nav-burger-ico i { background: var(--gold); }
  html:not([data-theme="light"]) .option-button.correct { color: #d9f3e4; background: rgba(28, 122, 75, 0.28); }
  html:not([data-theme="light"]) .option-button.wrong { color: #f8d8cf; background: rgba(194, 65, 45, 0.26); }
  html:not([data-theme="light"]) .progress-fill { background: var(--gold); }
  html:not([data-theme="light"]) .ribbon-cell--conquest .ribbon-v { color: var(--gold); }
  html:not([data-theme="light"]) .tabbar-btn.is-active::before { background: rgba(231, 185, 107, 0.12); }
  html:not([data-theme="light"]) .settings-done-btn { box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.5); }
  html:not([data-theme="light"]) .results-stat--correct { color: var(--correct) !important; }
  html:not([data-theme="light"]) .results-stat--wrong { color: var(--wrong) !important; }
}

.study-region-card.srg-accent--atlas { border-inline-start-color: #2a7a8c; }  
.study-region-card.srg-accent--gold  { border-inline-start-color: var(--gold); } 
.study-region-card.srg-accent--drill { border-inline-start-color: #1C3F5E; }  

.study-region-card.featured { justify-content: flex-start; }
.study-region-card.featured .srg-game-body { flex: 0 1 auto; min-width: 0; }

html[data-theme="dark"] .fm-chip { background: var(--paper-card); border-color: var(--line); color: var(--text); }
html[data-theme="dark"] .fm-chip.streak { background: rgba(231, 185, 107, 0.14); color: var(--gold); border-color: rgba(231, 185, 107, 0.32); }
html[data-theme="dark"] .fm-chip.timer { background: rgba(226, 114, 91, 0.14); color: var(--primary); border-color: rgba(226, 114, 91, 0.3); }
html[data-theme="dark"] .fm-chip.danger { background: rgba(226, 114, 91, 0.12); color: var(--primary); border-color: rgba(226, 114, 91, 0.26); }
html[data-theme="dark"] .fm-chip.correct-chip { background: rgba(88, 185, 138, 0.12); color: var(--correct); border-color: rgba(88, 185, 138, 0.28); }
html[data-theme="dark"] .fm-chip.wrong-chip { background: rgba(226, 114, 91, 0.12); color: var(--wrong); border-color: rgba(226, 114, 91, 0.28); }
html[data-theme="dark"] .option-button { background: var(--paper-card); border: 1px solid var(--line); color: var(--text); }
html[data-theme="dark"] .option-button .k { background: var(--gold); color: #1C2A39; }
html[data-theme="dark"] .flag-frame { background: var(--panel-strong); border-color: var(--line); box-shadow: 0 8px 18px -10px rgba(0, 0, 0, 0.55); }
html[data-theme="dark"] .progress-track { background: var(--line); }
html[data-theme="dark"] .study-region-pill.is-active { background: var(--primary); border-color: var(--primary); color: #FCF8EF; }
html[data-theme="dark"] .study-search:focus { border-color: rgba(231, 185, 107, 0.5); box-shadow: 0 0 0 3px rgba(231, 185, 107, 0.18); }
html[data-theme="dark"] .hero::before { background: radial-gradient(circle, rgba(231, 185, 107, 0.12), transparent 65%); }
html[data-theme="dark"] .ghost-button { color: var(--primary-deep); background: var(--paper-card); border-color: var(--line); }

.study-title { color: var(--text); }
html[data-theme="dark"] .study-title { color: var(--text); }

.anthem-btn { background: var(--navy); box-shadow: 0 6px 14px -7px rgba(28, 63, 94, 0.55); }

.passport-hero { background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(234, 225, 204, 0.22); }
.passport-hero-fill { background: linear-gradient(90deg, #E7B96b, #C2412D); }

.passport-panel .passport-chip { color: #cfe0ee; background: rgba(255, 255, 255, 0.07); border-color: rgba(234, 225, 204, 0.25); }
.passport-panel .passport-hero-sub { color: #bcd0e0; }
.passport-panel .passport-hero-sub strong { color: #E7B96b; }
.passport-panel .passport-continent-count,
.passport-panel .passport-map-legend { color: #9fb4c8; }
.passport-panel .passport-continent-label { color: #bcd0e0; }

.passport-panel .passport-continent {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(234, 225, 204, 0.16);
}
.passport-panel .passport-continent-track { background: rgba(255, 255, 255, 0.12); }
.passport-panel .passport-continent--asia { --pc-accent: #f87171; }
.passport-panel .passport-continent--europe { --pc-accent: #60a5fa; }
.passport-panel .passport-continent--africa { --pc-accent: #facc15; }
.passport-panel .passport-continent--americas { --pc-accent: #34d399; }
.passport-panel .passport-continent--oceania { --pc-accent: #a78bfa; }
.passport-panel .passport-continent--antarctic { --pc-accent: #94a3b8; }
.passport-panel [class*="region-badge"] { background: rgba(255, 255, 255, 0.1); color: #EAE1CC; }

.lb-you { background: rgba(194, 65, 45, 0.1); }
.lb-row.is-you { background: rgba(194, 65, 45, 0.1); box-shadow: none; }

.tabbar-btn.is-active::before { box-shadow: inset 0 0 0 1px rgba(194, 65, 45, 0.18); }
html[data-theme="dark"] .tabbar-btn.is-active::before { box-shadow: inset 0 0 0 1px rgba(231, 185, 107, 0.24); }

.results-stat--correct { color: var(--correct) !important; }
.results-stat--wrong { color: var(--wrong) !important; }
html[data-theme="dark"] .results-stat--correct { color: var(--correct) !important; }
html[data-theme="dark"] .results-stat--wrong { color: var(--wrong) !important; }

.detail-meaning { background: var(--paper-card); border: 1px solid var(--line); }
html[data-theme="dark"] .detail-meaning { background: var(--paper-card); border-color: var(--line); }
.detail-map-btn { border-color: var(--line); background: var(--paper-card); color: var(--primary-deep); }
.detail-map-btn:hover { border-color: var(--gold); background: rgba(176, 138, 62, 0.08); }
html[data-theme="dark"] .detail-map-btn { background: var(--paper-card); border-color: var(--line); color: var(--primary-deep); }
.detail-meta-icon { background: rgba(176, 138, 62, 0.12); }

.progress-fill { box-shadow: none; }
.credits-section { background: var(--paper-card); border-color: var(--line); }
html[data-theme="dark"] .credits-section { background: var(--paper-card); border-color: var(--line); }
.results-best--new { color: var(--gold); background: rgba(176, 138, 62, 0.12); border-color: rgba(176, 138, 62, 0.3); }
html[data-theme="dark"] .icon-text-btn.pro-cta.is-pro-owned { color: var(--correct); }
@media (hover: hover) {
  .option-button:hover { border-color: var(--gold); }
}

html[dir="rtl"] .eyebrow, html[dir="rtl"] .section-eyebrow, html[dir="rtl"] .results-eyebrow,
html[dir="rtl"] .study-count, html[dir="rtl"] .lb-day, html[dir="rtl"] .lb-live,
html[dir="rtl"] .league-practice-badge { letter-spacing: 0; }

:root:lang(ar), :root:lang(ar) * { letter-spacing: 0 !important; }

html[dir="rtl"] [data-wfi="action_back"] > .wfi,
html[dir="rtl"] [data-wfi="action_forward"] > .wfi { transform: scaleX(-1); }

.results-actions {
  position: sticky;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  margin-top: 16px;
  padding: 10px;
  border-radius: 24px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.results-actions .primary-button,
.results-actions .ghost-button {
  min-height: 56px;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: 16px;
  
  word-break: keep-all;
  padding-inline: 16px;
}

.creigns-oactions .primary-button,
.creigns-oactions .ghost-button {
  min-height: 54px;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: 16px;
  
  word-break: keep-all;
  padding-inline: 14px;
}

.footer-actions .ghost-button,
.footer-actions .secondary-button {
  min-height: 54px;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: 16px;
}

.fm-mode--fav { border-inline-start: 5px solid var(--gold); }
.fm-mode--fav .icon { filter: none; }

.fm-mode--favquiz { border-inline-start: 5px solid var(--primary); }

.quiz-map svg path { vector-effect: non-scaling-stroke; stroke-width: 1.6px; }
.quiz-map svg .wf-map-hl path { stroke-width: 2px; }

.map-canvas svg path { vector-effect: non-scaling-stroke; stroke-width: 0.8px; }
.map-canvas svg .wf-map-hl path { stroke-width: 1.2px; }

.map-canvas svg .wf-sub-hl path { paint-order: stroke; }

.map-cat-modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9600; padding: 24px;
}
.map-cat-modal[hidden] { display: none; }
.map-cat-card {
  position: relative;
  background: var(--panel-strong, #fff);
  border-radius: 24px;
  padding: 22px 20px 18px;
  width: min(420px, 100%);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  animation: mapCatIn 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes mapCatIn { from { transform: translateY(14px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
.map-cat-title { margin: 0 0 14px; font-size: 1.15rem; text-align: center; }
.map-cat-options { display: grid; gap: 10px; }
.map-cat-option {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: start; 
  border: 1.5px solid var(--line, rgba(15, 23, 42, 0.12));
  border-radius: 16px;
  background: var(--paper-card, rgba(255, 255, 255, 0.55));
  padding: 14px 14px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}
.map-cat-option:active { transform: scale(0.98); }
.map-cat-option:disabled { opacity: 0.45; cursor: default; }
.map-cat-ic { font-size: 1.5rem; }
.map-cat-body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.map-cat-t { font-weight: 700; line-height: 1.3; }
.map-cat-d { font-size: 0.82rem; opacity: 0.72; line-height: 1.35; }

.map-cat-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 7px; }
.map-cat-badge {
  font-size: 0.68rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(46, 125, 90, 0.14); color: #2e7d5a;
  white-space: nowrap;
}
.map-cat-badge--hard { background: rgba(199, 62, 29, 0.14); color: #c73e1d; }
html[data-theme="dark"] .map-cat-badge { background: rgba(110, 231, 183, 0.16); color: #6ee7b7; }
html[data-theme="dark"] .map-cat-badge--hard { background: rgba(248, 113, 113, 0.18); color: #f87171; }

.map-cat-option .corner.cost {
  position: static;
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.68rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: var(--hub-action-surface, rgba(194, 65, 45, 0.06));
  border: 1px solid var(--hub-action-line, rgba(194, 65, 45, 0.28));
  color: var(--primary);
  white-space: nowrap;
}
.map-cat-option .corner.cost.is-locked { border-color: rgba(179, 54, 45, 0.5); color: var(--wrong); }
.map-cat-option .corner.cost:empty { display: none; }

#crest-list-quiz-btn .corner.cost,
#mania-list-quiz-btn .corner.cost,
#results-retry-btn .corner.cost {
  position: static;
  display: inline-block;
  margin-inline-start: 10px;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(20, 32, 44, 0.16);
  font-family: var(--font-mono);
  font-size: 0.78em; font-weight: 700;
  line-height: 1.5;
  vertical-align: middle;
}
#crest-list-quiz-btn .corner.cost.is-locked,
#mania-list-quiz-btn .corner.cost.is-locked,
#results-retry-btn .corner.cost.is-locked { background: rgba(120, 20, 15, 0.88); color: #FFF1EE; }
#crest-list-quiz-btn .corner.cost:empty,
#mania-list-quiz-btn .corner.cost:empty,
#results-retry-btn .corner.cost:empty { display: none; }

.setrun-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.setrun-row--sub > button {
  flex: 1 1 140px; min-width: 0; width: auto; margin: 0 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  
  padding-inline: 10px; font-size: 0.9rem;
}

.setrun-row--sub > button > span:not(.corner) {
  min-width: 0; white-space: normal; word-break: keep-all; line-height: 1.25;
}
.setrun-row--sub > button { padding-block: 10px; }

.setrun-row--sub .corner.cost { white-space: nowrap; flex: none; }

#crest-list-full-btn .corner.cost,
#mania-list-full-btn .corner.cost {
  position: static;
  display: inline-block;
  margin-inline-start: 8px;
  padding: 2px 8px; border-radius: 999px;
  
  background: color-mix(in srgb, currentColor 14%, transparent);
  font-family: var(--font-mono);
  font-size: 0.78em; font-weight: 700;
  line-height: 1.5;
  vertical-align: middle;
}
#crest-list-full-btn .corner.cost.is-locked,
#mania-list-full-btn .corner.cost.is-locked { background: rgba(120, 20, 15, 0.88); color: #FFF1EE; }
#crest-list-full-btn .corner.cost:empty,
#mania-list-full-btn .corner.cost:empty { display: none; }

.quiz-globe, .map-canvas { position: relative; }
.atlas-flip {
  
  position: absolute; inset-inline-end: 10px; bottom: 10px; z-index: 5;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 1.25rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.3);
  transition: transform 140ms ease;
}
.atlas-flip:active { transform: scale(0.92); }

.atlas-loading {
  position: absolute; inset: 0; z-index: 4;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  opacity: 0; animation: atlas-loading-in 200ms ease-out 200ms forwards;
}
.atlas-loading-box {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: rgba(15, 23, 42, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #F3ECDB; font-size: 0.84rem; font-weight: 700; line-height: 1.2;
}
.atlas-loading-ring {
  flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(243, 236, 219, 0.28); border-top-color: #F3ECDB;
  animation: atlas-loading-spin 0.9s linear infinite;
}
@keyframes atlas-loading-in { to { opacity: 1; } }
@keyframes atlas-loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .atlas-loading { animation-duration: 1ms; }
  .atlas-loading-ring { display: none; }
}

#quiz-flag-frame.flag-frame--hunt { max-width: 132px; min-height: 0; margin: 0 auto 6px; padding: 10px; }
.flag-frame--hunt #flag-image { max-height: 82px; max-width: 100%; }

.feedback-card { pointer-events: none; }

@media (min-height: 501px) {
  .quiz-panel--hunt .feedback-card { top: 24%; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .quiz-panel--hunt .options-grid { display: none; }
  .quiz-panel--hunt .flag-frame--quiz { grid-area: options; align-self: start; justify-self: center; min-height: 0; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .pro-card {
    max-width: min(640px, calc(100vw - 32px));
    padding: 14px 20px 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "hero  price"
      "title buy"
      "sub   restore"
      "bene  status"
      "bene  fine"
      "bene  links";
    grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
    column-gap: 20px;
    align-content: start;
    align-items: start;
  }
  .pro-card .pro-hero { grid-area: hero; font-size: 2rem; margin: 0 0 4px; }
  .pro-card .confirm-title { grid-area: title; margin: 0 0 4px; }
  .pro-card #pro-subtitle { grid-area: sub; margin: 0 0 6px; }
  .pro-card .pro-benefits { grid-area: bene; margin: 0; gap: 6px; }
  .pro-card .pro-price-row { grid-area: price; margin: 0 0 6px; }
  .pro-card .pro-buy { grid-area: buy; }
  .pro-card .pro-restore { grid-area: restore; margin-top: 6px; }
  .pro-card .pro-status { grid-area: status; }
  .pro-card .pro-fineprint { grid-area: fine; margin: 8px 0 0; }
  .pro-card .pro-links { grid-area: links; margin-top: 6px; align-self: start; }
}

.quiz-panel--map { padding: 12px 14px 14px; margin-top: -10px; }
.quiz-panel--map .top-bar { padding-bottom: 0; gap: 6px; }
.quiz-panel--map .fm-chip { padding: 4px 10px; font-size: 0.72rem; }
.quiz-panel--map .fm-chip strong { font-size: 0.76rem; }
.quiz-panel--map .progress-track { height: 5px; margin-top: 6px; }

.quiz-panel--map #quiz-globe.quiz-map,
.quiz-panel--map #quiz-map.quiz-map {
  aspect-ratio: auto;
  width: calc(100% + 28px);
  max-width: none;
  
  height: 46vh;
  height: min(46dvh, calc(100dvh - 430px));
  min-height: 170px;
  max-height: 520px;
  margin: 8px -14px 6px;
  border-radius: 16px;
}

.quiz-panel--hunt #quiz-globe.quiz-map {
  height: 60vh;
  height: min(62dvh, calc(100dvh - 225px));
  max-height: 720px;
}

@media (orientation: portrait) {
  .quiz-panel--map {
    display: flex; flex-direction: column;
    
    height: calc(100vh - var(--shell-pt) - var(--shell-pb));
    height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
    
    padding-bottom: 20px;
  }

  
  
  body.fit-screen .app-shell { height: 100dvh; display: flex; flex-direction: column; }
  body.fit-screen .screen:not([hidden]) {
    display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
  }
  body.fit-screen .quiz-panel--map { height: auto; min-height: 0; flex: 1 1 auto; }
  
  body.fit-screen #mania-map-screen .atlas-page { flex: 1 1 auto; min-height: 0; }
  
  body.fit-screen #mania-map-screen .mania-map { flex: 0 0 auto; }
  
  .quiz-panel--map > * { flex: 0 0 auto; }
  .quiz-panel--map #quiz-globe.quiz-map,
  .quiz-panel--map #quiz-map.quiz-map {
    
    flex: 1 1 0%;
    height: auto;
    min-height: 180px;
  }
  
  .quiz-panel--map .map-hint-btn {
    min-height: 44px; padding: 8px 20px; font-size: 0.9rem;
    margin: 0 auto 8px;
  }
}

.quiz-panel--map .prompt { margin: 4px 0 6px; font-size: clamp(0.92rem, 3.6vw, 1.12rem); }
.quiz-panel--map .map-hint-btn { margin: 0 auto 6px; padding: 5px 12px; font-size: 0.76rem; }
.quiz-panel--map .map-hint-card { margin: 0 0 6px; }
.quiz-panel--map .options-grid { gap: 7px !important; }
.quiz-panel--map .option-button {
  min-height: 46px !important; padding: 7px 12px !important;
  font-size: 0.86rem; gap: 10px; border-radius: 14px;
}
.quiz-panel--map .option-button .k { width: 26px; height: 26px; font-size: 0.76rem; border-radius: 9px; }
.quiz-panel--map .option-flag { width: 34px; height: 23px; }
.quiz-panel--map .footer-actions { margin-top: 8px; }

@media (orientation: portrait) {
  
  .quiz-panel--map .map-hint-card {
    position: relative; z-index: 3;
    margin-block: -68px 8px;
    margin-inline: 8px 76px;
    max-width: 460px;
  }
  .quiz-panel--map .map-hint-btn {
    position: relative; z-index: 3;
    min-height: 44px; padding: 8px 20px; font-size: 0.9rem;
    margin: -52px auto 8px;
  }
  
  .quiz-panel--hunt .atlas-flip { bottom: 62px; }
  
  .quiz-panel--map .map-hint-card:not([hidden]) ~ .map-hint-btn { margin-top: 0; }
  
  .quiz-panel--map .map-hint-inner { box-shadow: 0 12px 26px -10px rgba(0,0,0,0.55); }
  .quiz-panel--map .options-grid { gap: 6px !important; }
  .quiz-panel--map .option-button { min-height: 44px !important; padding: 6px 12px !important; }
  .quiz-panel--map .prompt { margin: 2px 0 4px; }
}

.quiz-panel--map .option-button .label-sub { font-size: 0.86em; opacity: 0.72; }
.quiz-panel--map .footer-actions .ghost-button,
.quiz-panel--map .footer-actions .secondary-button { min-height: 42px; padding: 8px 14px; font-size: 0.92rem; }

.dailyflag-card { max-width: 520px; padding: 24px 20px 18px; max-height: 94vh; max-height: 94dvh; }
.dailyflag-eyebrow { margin: 2px 0 12px; }
.dailyflag-img { width: 218px; max-height: 148px; }
.dailyflag-name { font-size: 1.46rem; }
.dailyflag-map { margin: 14px 0 4px; }

#dailyflag-map.map-canvas, #dailyflag-globe {
  aspect-ratio: 0.82;
  max-height: 44vh;
  max-height: 44dvh;
  border-radius: 18px;
  width: calc(100% + 24px);
  margin-left: -12px; margin-right: -12px;
}
#dailyflag-globe { overflow: hidden; border: 1px solid var(--line); }
.dailyflag-map { margin: 10px 0 6px; }
.dailyflag-ok { margin-top: 14px; }

.dailyflag-eyebrow { margin: 0 0 10px; }
.dailyflag-flagwrap { margin-bottom: 8px; }
.dailyflag-name { font-size: 1.18rem; line-height: 1.2; margin: 0; }
.dailyflag-sub { font-size: 0.78rem; line-height: 1.25; margin: 1px 0 0; }

.quiz-back {
  flex: 0 0 auto;
  width: 44px; height: 44px; margin-inline-end: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  
  font: 800 1.95rem/1 inherit; padding-bottom: 4px;
  color: var(--text); background: var(--soft-blue);
  border: 1.5px solid var(--line-strong, var(--line)); border-radius: 50%;
  cursor: pointer; transition: transform 120ms ease;
}
.quiz-back:active { transform: scale(0.9); }
html[data-theme="dark"] .quiz-back { background: rgba(255,255,255,0.07); color: #e6edf7; }
.quiz-panel .footer-actions[hidden] { display: none; }

.quiz-panel { position: relative; }
@media (max-width: 640px) {
  
  .quiz-back { position: absolute; inset-inline-start: 12px; top: 12px; z-index: 4; margin-inline-end: 0; }
  .quiz-panel--map .quiz-back { inset-inline-start: 8px; top: 8px; }
  
  .quiz-panel--map .top-bar { row-gap: 2px; }
  .quiz-panel--map .top-bar-left { min-height: 44px; margin-top: -4px; }
}

@media (min-width: 641px) and (min-height: 601px) {   
  .quiz-panel--map { padding: 18px 20px 20px; margin-top: 0; }
  .quiz-panel--map .fm-chip { padding: 6px 13px; font-size: 0.86rem; }
  .quiz-panel--map .fm-chip strong { font-size: 0.9rem; }
  .quiz-panel--map .quiz-back { font-size: 2.15rem; }   
  .quiz-panel--map .progress-track { height: 7px; margin-top: 10px; }
  .quiz-panel--map #quiz-globe.quiz-map,
  .quiz-panel--map #quiz-map.quiz-map {
    width: calc(100% + 40px);
    margin: 12px -20px 10px;
    height: min(56dvh, calc(100dvh - 430px));
    max-height: 900px;
    border-radius: 20px;
  }
  .quiz-panel--hunt #quiz-globe.quiz-map { height: min(70dvh, calc(100dvh - 250px)); }
  .quiz-panel--map .prompt { margin: 8px 0 10px; font-size: 1.32rem; }
  .quiz-panel--map .map-hint-btn { padding: 9px 20px; font-size: 0.98rem; margin-bottom: 10px; }
  .quiz-panel--map .options-grid { gap: 12px !important; }
  .quiz-panel--map .option-button {
    min-height: 68px !important; padding: 12px 18px !important;
    font-size: 1.1rem; gap: 14px; border-radius: 18px;
  }
  .quiz-panel--map .option-button .k { width: 38px; height: 38px; font-size: 1rem; border-radius: 12px; }
  .quiz-panel--map .option-flag { width: 56px; height: 38px; }
  .quiz-panel--map .flag-frame--hunt,
  #quiz-flag-frame.flag-frame--hunt { max-width: 210px; }
  .flag-frame--hunt #flag-image { max-height: 130px; }
}

@media (orientation: landscape) and (min-width: 700px) and (min-height: 601px) {
  .quiz-panel--map {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.85fr);
    
    height: calc(100vh - var(--shell-pt) - var(--shell-pb));
    height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
    max-height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
    grid-template-rows: auto auto auto auto auto auto minmax(0, 1fr);
    grid-template-areas:
      "top    top"
      "prog   prog"
      "media  flag"
      "media  prompt"
      "media  hint"
      "media  hintcard"
      "media  options";
    column-gap: 22px;
    align-content: start;
  }
  .quiz-panel--map .top-bar { grid-area: top; }
  .quiz-panel--map .progress-track { grid-area: prog; }
  .quiz-panel--map #quiz-flag-frame { grid-area: flag; justify-self: center; }
  .quiz-panel--map #quiz-globe.quiz-map,
  .quiz-panel--map #quiz-map.quiz-map {
    grid-area: media;
    width: 100%;
    margin: 12px 0 0;
    
    height: auto;
    min-height: 0;
    max-height: none;
    align-self: stretch;
  }
  .quiz-panel--map .prompt { grid-area: prompt; align-self: center; margin: 10px 0; }
  .quiz-panel--map .map-hint-btn { grid-area: hint; justify-self: start; }
  .quiz-panel--map .map-hint-card { grid-area: hintcard; }
  .quiz-panel--map .options-grid { grid-area: options; grid-template-columns: 1fr !important; align-content: start; }
}

.map-cat-option { min-height: 92px; align-items: flex-start; }
.map-cat-ic { flex: 0 0 34px; text-align: center; }
.map-cat-badge { flex: 0 0 auto; }
.map-cat-d { min-height: 2.4em; }

@media (max-height: 600px) {
  .dailyflag-img { width: 176px; max-height: 96px; }
  #dailyflag-map.map-canvas, #dailyflag-globe { max-height: 38vh; max-height: 38dvh; }
  .dailyflag-card { padding: 18px 18px 14px; }
  .dailyflag-eyebrow { margin: 0 0 8px; }
}

.map-modal { padding: 16px; }
.map-card { max-width: 620px; padding: 16px 16px 12px; max-height: 94vh; max-height: 94dvh; }
.map-header { margin: 0 40px 10px; }
.map-modal-title { font-size: 1.14rem; line-height: 1.2; margin: 0; }
.map-modal-sub { font-size: 0.74rem; line-height: 1.25; margin: 2px 0 0; }
#map-modal .map-canvas,
#map-modal #map-globe {
  aspect-ratio: 0.86;
  max-height: 68vh;
  max-height: 68dvh;
  width: calc(100% + 20px);
  margin-left: -10px; margin-right: -10px;
  border-radius: 18px;
}
#map-modal #map-globe { overflow: hidden; border: 1px solid var(--line); }
.map-credit { margin: 6px 4px 0; }
.map-modal-note { margin: 8px 6px 0; padding: 8px 12px; }

@media (orientation: landscape) and (min-width: 820px) and (min-height: 601px) {   
  .map-card { max-width: 760px; }
  #map-modal .map-canvas,
  #map-modal #map-globe { aspect-ratio: 1.25; max-height: 72dvh; }
}

@media (max-height: 600px) {
  #map-modal .map-canvas,
  #map-modal #map-globe { max-height: 58vh; max-height: 58dvh; }
}

.detail-meta-row { align-items: flex-start; gap: 12px; padding: 12px 0; }
.detail-meta-body { flex: 1; min-width: 0; }
.detail-meta-line {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px 12px;
}

.study-detail-meta { --meta-label-w: clamp(56px, 34%, 108px); }
.detail-meta-row strong {
  display: inline-block; flex: 0 0 auto;
  width: var(--meta-label-w); margin: 0;
  font-size: 0.76rem; color: var(--muted); letter-spacing: 0.01em;
  line-height: 1.25; hyphens: auto;   
}
.detail-meta-val {
  flex: 1 1 108px; min-width: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  font-weight: 600; line-height: 1.4;
  overflow-wrap: anywhere;   
}
.detail-meta-sub { color: var(--text); }

.detail-meta-val > .detail-map-btn { flex: 0 0 100%; max-width: fit-content; margin: 8px 0 0; }

.detail-meta-body > .detail-map-btn { margin: 8px 0 0; }
.detail-map-btn { white-space: nowrap; }

.detail-meta-row--anthem .detail-meta-body > .detail-anthem { width: 100%; }

@media (min-width: 641px) and (min-height: 601px) {   
  .detail-meta-row--anthem .detail-meta-body > .detail-anthem {
    padding-inline-start: calc(var(--meta-label-w) + 12px);
  }
}

.floating-flags { display: none !important; }

.atlas-study-cta {
  display: flex; align-items: center; gap: 14px; width: 100%;
  margin-top: 14px; padding: 16px 16px;
  text-align: start; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 20px;
  background: var(--paper-card, rgba(255,255,255,0.55));
  transition: transform 120ms ease, border-color 140ms ease;
}
.atlas-study-cta:active { transform: scale(0.985); }

.study-cta-pair { display: grid; grid-auto-rows: 1fr; gap: 10px; margin-top: 14px; }
.study-cta-pair > .atlas-study-cta { margin-top: 0; }
.atlas-cta-ic { font-size: 1.8rem; flex: 0 0 auto; }
.atlas-cta-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.atlas-cta-t { font-weight: 800; font-size: 1.02rem; }
.atlas-cta-d { font-size: 0.82rem; opacity: 0.72; line-height: 1.35; }
.atlas-cta-go { flex: 0 0 auto; font-size: 1.4rem; opacity: 0.45; }

.atlas-page { display: flex; flex-direction: column; padding: 14px 14px 16px; }
.atlas-study-map {
  position: relative;
  width: calc(100% + 28px); margin: 10px -14px 8px;
  height: 62vh; height: min(70dvh, calc(100dvh - 210px));
  min-height: 260px;
  border-radius: 18px; overflow: hidden;
  background: radial-gradient(circle at 50% 36%, #16263f 0%, #0a1626 62%, #060d18 100%);
}
.atlas-study-map canvas { display: block; width: 100%; height: 100%; }
.atlas-hint { margin: 4px 0 0; text-align: center; font-size: 0.84rem; opacity: 0.66; }
.atlas-labels-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 0.82rem; font-weight: 800;
  border: 1px solid var(--line); background: var(--paper-card, rgba(255,255,255,0.5));
  color: var(--text);
}
.atlas-labels-btn.is-on { background: var(--navy, #1f3b57); color: #F3ECDB; border-color: transparent; }

html[data-theme="dark"] .atlas-labels-btn.is-on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

html[data-theme="dark"] .atlas-labels-btn.is-on .atlas-cap-swatch { border-color: var(--on-primary); }

.atlas-topbar-tools { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.atlas-cap-swatch {
  flex: none; width: 9px; height: 9px; border-radius: 2px;
  background: #1F6FD0; border: 1.5px solid #0E3A6B; box-sizing: border-box;
}
.atlas-labels-btn.is-on .atlas-cap-swatch { border-color: #F3ECDB; }

.atlas-labels { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.atlas-label {
  position: absolute; left: 0; top: 0;
  white-space: nowrap; font-size: 0.66rem; font-weight: 800; letter-spacing: -0.01em;
  color: #12203a; text-shadow: 0 0 3px rgba(255,255,255,0.95), 0 0 6px rgba(255,255,255,0.8);
  pointer-events: none;
}
html[data-theme="dark"] .atlas-label { color: #0b1626; text-shadow: 0 0 3px rgba(226,236,250,0.95), 0 0 6px rgba(226,236,250,0.75); }

.atlas-label--ocean, .atlas-label--sea {
  
  font-style: italic; font-weight: 700; letter-spacing: 0.02em;
  color: #cfe6ff; text-shadow: 0 0 3px rgba(6,18,34,0.95), 0 0 7px rgba(6,18,34,0.85);
}
.atlas-label--ocean { font-size: 0.72rem; letter-spacing: 0.16em; color: #dcecff; }
html[data-theme="dark"] .atlas-label--ocean,
html[data-theme="dark"] .atlas-label--sea { color: #cfe6ff; text-shadow: 0 0 3px rgba(4,12,24,0.95), 0 0 7px rgba(4,12,24,0.9); }

.atlas-label--micro { font-size: 0.62rem; }
@media (min-width: 641px) and (min-height: 601px) { .atlas-label--micro { font-size: 0.72rem; } }

.atlas-label--disputed {
  font-style: italic; font-weight: 800; letter-spacing: 0.01em;
  color: #ffe0b8; text-shadow: 0 0 3px rgba(46,26,8,0.95), 0 0 7px rgba(46,26,8,0.85);
}
html[data-theme="dark"] .atlas-label--disputed { color: #ffe0b8; }

.atlas-label--capital {
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 600; font-size: 0.66rem; letter-spacing: 0.01em;
  color: #2b1d0e; text-shadow: 0 0 3px rgba(255,248,232,0.95), 0 0 6px rgba(255,248,232,0.8);
}

.atlas-label--capital i {
  flex: none; width: 7px; height: 7px; border-radius: 2px;
  background: #1F6FD0; border: 1.5px solid #0E3A6B; box-sizing: border-box;
}
html[data-theme="dark"] .atlas-label--capital {
  color: #ffe9c9; text-shadow: 0 0 3px rgba(6,18,34,0.95), 0 0 7px rgba(6,18,34,0.9);
}
html[data-theme="dark"] .atlas-label--capital i { background: #4DA3FF; border-color: #0B2C55; }

.atlas-label--capital.is-left, .atlas-label--island.is-left { flex-direction: row-reverse; }

.atlas-label--capital b, .atlas-label--island b { font: inherit; font-weight: inherit; position: relative; }

.atlas-label--capital { --lead-x: 7.5px; }
.atlas-label--island { --lead-x: 6.5px; }
.atlas-label.has-lead > b::before {
  content: ""; position: absolute; pointer-events: none;
  inset-inline-start: calc(var(--lead-x, 7.5px) * -1);
  width: var(--lead-x, 7.5px);
  height: var(--lead-h, 0px);
  border-inline-start: 1px solid currentColor;
  opacity: 0.6;
}
.atlas-label.has-lead.lead-down > b::before {
  top: calc(50% - var(--lead-h, 0px));
  border-bottom: 1px solid currentColor;
}
.atlas-label.has-lead.lead-up > b::before {
  top: 50%;
  border-top: 1px solid currentColor;
}
.atlas-label.has-lead.is-left > b::before {
  inset-inline-start: auto;
  inset-inline-end: calc(var(--lead-x, 7.5px) * -1);
  border-inline-start: 0;
  border-inline-end: 1px solid currentColor;
}
@media (min-width: 641px) and (min-height: 601px) { .atlas-label--capital { font-size: 0.76rem; } }

.atlas-label--island {
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 800; color: #fff3d0; text-shadow: 0 0 3px rgba(6,18,34,0.95), 0 0 7px rgba(6,18,34,0.85);
}
.atlas-label--island i {
  flex: none; width: 5px; height: 5px; border-radius: 50%;
  background: #ffcf5c; box-shadow: 0 0 0 1.5px rgba(6,18,34,0.85);
}
html[data-theme="dark"] .atlas-label--island { color: #fff3d0; text-shadow: 0 0 3px rgba(4,12,24,0.95), 0 0 7px rgba(4,12,24,0.9); }

.atlas-pick-modal {
  position: fixed; inset: 0; z-index: 9620; padding: 24px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,0.58);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 180ms ease-out;
}
.atlas-pick-modal.is-active { opacity: 1; }
.atlas-pick-modal[hidden] { display: none; }
.atlas-pick-card {
  position: relative; text-align: center;
  width: min(360px, 100%); padding: 22px 20px 18px;
  background: var(--panel-strong); border-radius: 24px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.3);
  transform: scale(0.96) translateY(8px);
  transition: transform 200ms cubic-bezier(0.2,0.9,0.3,1.2);
}
.atlas-pick-modal.is-active .atlas-pick-card { transform: none; }
.atlas-pick-flag {
  display: inline-block; padding: 0; margin: 4px 0 12px; line-height: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  background: var(--soft-blue); box-shadow: 0 8px 22px rgba(0,0,0,0.18);
  transition: transform 130ms ease;
}
.atlas-pick-flag:active { transform: scale(0.96); }
.atlas-pick-flag img { display: block; width: 208px; height: auto; max-height: 140px; object-fit: contain; }
.atlas-pick-name { margin: 0; font-size: 1.28rem; font-weight: 800; line-height: 1.2; }
.atlas-pick-sub { margin: 3px 0 0; font-size: 0.82rem; color: var(--muted); }
.atlas-pick-sub[hidden] { display: none; }
.atlas-pick-cta { margin: 12px 0 0; font-size: 0.8rem; color: var(--primary); font-weight: 700; }

.atlas-pick-card { padding-top: 52px; }
.atlas-pick-card .map-close { top: 12px; inset-inline-end: 12px; }

.atlas-detail-modal {
  position: fixed; inset: 0; z-index: 9640; padding: 18px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  opacity: 0; transition: opacity 200ms ease-out;
}
.atlas-detail-modal.is-active { opacity: 1; }
.atlas-detail-modal[hidden] { display: none; }
.atlas-detail-card {
  position: relative;
  width: min(560px, 100%);
  max-height: 92vh; max-height: 92dvh;
  padding: 52px 18px 18px;
  background: var(--panel-strong); border-radius: 26px;
  box-shadow: 0 26px 60px rgba(0,0,0,0.34);
  
  transform: scale(0.82); opacity: 0.4;
  transition: transform 260ms cubic-bezier(0.2,0.9,0.3,1.25), opacity 200ms ease-out;
}
.atlas-detail-modal.is-active .atlas-detail-card { transform: none; opacity: 1; }
.atlas-detail-scroll { max-height: calc(92dvh - 72px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.atlas-detail-flagwrap {
  display: block; margin: 0 auto 12px; width: fit-content;
  border-radius: 16px; overflow: hidden; line-height: 0;
  border: 1px solid var(--line); background: var(--soft-blue);
  box-shadow: 0 8px 22px rgba(0,0,0,0.18);
}
.atlas-detail-flagwrap img { display: block; width: 240px; max-width: 100%; height: auto; max-height: 158px; object-fit: contain; }
.atlas-detail-name { margin: 0; text-align: center; font-size: 1.34rem; font-weight: 800; line-height: 1.2; }
.atlas-detail-sub { margin: 3px 0 0; text-align: center; font-size: 0.84rem; color: var(--muted); }
.atlas-detail-sub[hidden] { display: none; }
.atlas-detail-card .study-detail-meta { margin-top: 14px; }
.atlas-detail-card .detail-meaning,
.atlas-detail-card .detail-highlights { margin-top: 14px; }

.atlas-back {
  width: 44px; height: 44px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font: 800 2.05rem/1 inherit; padding-bottom: 5px;
  color: var(--text); background: var(--soft-blue);
  border: 1.5px solid var(--line-strong, var(--line)); border-radius: 50%;
  cursor: pointer; transition: transform 120ms ease;
}
.atlas-back:active { transform: scale(0.9); }
html[data-theme="dark"] .atlas-back { background: rgba(255,255,255,0.07); color: #e6edf7; }

.atlas-title {
  font-size: clamp(1.15rem, 5vw, 1.9rem);
  line-height: 1.18;
  word-break: keep-all;
  overflow-wrap: break-word;
  text-wrap: balance;
}

@media (min-width: 641px) and (min-height: 601px) {   
  
  .atlas-page { padding: 20px 20px 22px; }
  .atlas-study-map {
    width: calc(100% + 40px); margin: 14px -20px 10px;
    height: min(72dvh, calc(100dvh - 250px));
    min-height: 380px; border-radius: 22px;
  }
  .atlas-back { width: 46px; height: 46px; font-size: 2.4rem; }
  .atlas-labels-btn { padding: 10px 18px; font-size: 0.96rem; }
  .atlas-hint { font-size: 0.95rem; margin-top: 8px; }
  .atlas-label { font-size: 0.78rem; }
  .atlas-label--ocean { font-size: 0.86rem; }
  
  .atlas-study-cta { padding: 20px; margin-top: 18px; border-radius: 22px; }
  
  .study-cta-pair { margin-top: 18px; }
  .atlas-cta-ic { font-size: 2.1rem; }
  .atlas-cta-t { font-size: 1.16rem; }
  .atlas-cta-d { font-size: 0.92rem; }
  
  .atlas-study-cta { min-height: 128px; }

  
  .atlas-pick-card { width: min(440px, 100%); padding: 58px 24px 22px; }
  .atlas-pick-flag img { width: 280px; max-height: 186px; }
  .atlas-pick-name { font-size: 1.5rem; }
  .atlas-pick-sub { font-size: 0.94rem; }
  .atlas-pick-cta { font-size: 0.9rem; margin-top: 14px; }

  
  .atlas-detail-card { width: min(680px, 100%); padding: 58px 26px 24px; }
  .atlas-detail-scroll { max-height: calc(92dvh - 84px); }
  .atlas-detail-flagwrap img { width: 300px; max-height: 200px; }
  .atlas-detail-name { font-size: 1.6rem; }
  .atlas-detail-sub { font-size: 0.95rem; }
}

@media (orientation: landscape) and (min-width: 900px) and (min-height: 601px) {   
  .atlas-detail-card { width: min(920px, 100%); }
  .atlas-detail-scroll {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    column-gap: 26px; align-content: start;
  }
  .atlas-detail-flagwrap { grid-column: 1; grid-row: 1; }
  .atlas-detail-name { grid-column: 1; grid-row: 2; }
  .atlas-detail-sub { grid-column: 1; grid-row: 3; }
  .atlas-detail-card .study-detail-meta { grid-column: 2; grid-row: 1 / span 3; margin-top: 0; }
  .atlas-detail-card .detail-meaning,
  .atlas-detail-card .detail-highlights { grid-column: 1 / -1; }
  
  .atlas-study-map { height: min(76dvh, calc(100dvh - 210px)); }
}

@media (orientation: landscape) and (min-width: 900px) and (min-height: 601px) {
  :where(html:not([data-fold="v"])) body:has(#atlas-study-screen:not([hidden])) {
    --shell-pt: calc(10px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  :where(html:not([data-fold="v"])) #atlas-study-screen > .atlas-page {
    height: calc(100vh - var(--shell-pt) - var(--shell-pb));
    height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
    min-height: 0;
    padding-top: 14px; padding-bottom: 12px;     
  }
  :where(html:not([data-fold="v"])) #atlas-study-screen .atlas-study-map {
    flex: 1 1 0; height: auto; min-height: 380px;
    margin-top: 10px; margin-bottom: 6px;          
  }
  :where(html:not([data-fold="v"])) #atlas-study-screen .atlas-hint { margin-top: 4px; }   
}

.atlas-detail-modal {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding-top: max(18px, env(safe-area-inset-top, 0px));
  padding-bottom: max(18px, env(safe-area-inset-bottom, 0px));
}
.atlas-detail-card { flex: none; margin-block: auto; max-height: none; padding-top: 12px; }
.atlas-detail-scroll { max-height: none; overflow: visible; }

.atlas-detail-card > .map-close {
  position: sticky; top: 10px;
  display: block; margin-block: 0 8px; margin-inline: auto -6px;   
}
@media (min-width: 641px) and (min-height: 601px) {
  .atlas-detail-card { padding-top: 12px; }
  .atlas-detail-card > .map-close { margin-block: 0 14px; margin-inline: auto -14px; }   
}

@media (orientation: landscape) and (max-height: 500px) {
  .atlas-page { padding: 4px 12px 6px; }
  .atlas-page .page-topbar { margin-bottom: 4px; gap: 10px; }
  .atlas-page .atlas-back { width: 38px; height: 38px; font-size: 1.4rem; }
  .atlas-page .atlas-title { font-size: 1.05rem; }
  .atlas-page .atlas-labels-btn { padding: 5px 11px; font-size: 0.76rem; }
  .atlas-study-map {
    width: calc(100% + 24px); margin: 4px -12px 2px;
    
    height: calc(100dvh - 84px - env(safe-area-inset-bottom, 0px));
    min-height: 0; border-radius: 14px;
  }
  .atlas-hint { font-size: 0.72rem; margin-top: 2px; }
}

.detail-map-actions { margin: 10px 0 0; }
.detail-map-actions:empty { display: none; }

#map-sub svg path { stroke-width: 1px; }
#map-sub svg .wf-map-hl path { stroke-width: 1.6px; }

.map-canvas svg .wf-map-hl2 path {
  fill: var(--orange) !important; fill-opacity: 0.45;
  stroke: var(--map-stroke); stroke-width: 1px;
}
html[data-theme="dark"] .map-canvas svg .wf-map-hl2 path { fill-opacity: 0.58; }

.home-screen .level-bar { margin-top: 8px; padding: 7px 12px; gap: 10px; }
.home-screen .level-bar .xp-track { height: 7px; }
.home-screen .level-bar .xp-label { font-size: 0.74rem; }

.atlas-pick-modal.is-disputed .atlas-pick-flag img { display: none; }
.atlas-pick-modal.is-disputed .atlas-pick-flag::before {
  content: "\26A0\FE0F";
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 96px; font-size: 2.6rem;
  border-radius: 14px;
  background: repeating-linear-gradient(45deg,
    rgba(156,111,71,0.22) 0 7px, rgba(156,111,71,0.06) 7px 14px);
  border: 1px solid rgba(156,111,71,0.45);
}
.atlas-pick-modal.is-disputed .atlas-pick-sub { color: var(--orange, #c2412d); font-weight: 800; }

.atlas-pick-modal.is-disputed .atlas-pick-cta { display: none; }
.atlas-pick-modal.is-disputed .atlas-pick-flag { cursor: default; pointer-events: none; }

.atlas-pick-era { display: none; }
.atlas-pick-modal.is-history .atlas-pick-flag img { display: none; }
.atlas-pick-modal.is-history .atlas-pick-era {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 96px; border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0)),
    color-mix(in srgb, var(--era-tint, #9c6f47) 22%, var(--paper-card, #FFFDF6));
  border: 1px solid color-mix(in srgb, var(--era-tint, #9c6f47) 55%, transparent);
}
.atlas-pick-modal.is-history .atlas-pick-era .wfi { width: 54px; height: 54px; }
.atlas-pick-modal.is-history .atlas-pick-sub { color: var(--muted); font-weight: 700; }
.atlas-pick-modal.is-history .atlas-pick-cta { display: none; }
.atlas-pick-modal.is-history .atlas-pick-flag { cursor: default; pointer-events: none; }
html[data-theme="dark"] .atlas-pick-modal.is-history .atlas-pick-era {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0)),
    color-mix(in srgb, var(--era-tint, #9c6f47) 30%, rgba(20,32,46,1));
}

.atlas-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 -4px; }
.atlas-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-strong, rgba(255,255,255,0.06));
  color: var(--muted); font: inherit; font-size: 0.78rem; font-weight: 800;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.atlas-chip.is-on { background: var(--navy, #1f3b57); color: #F3ECDB; border-color: transparent; }
.atlas-chip:active { transform: scale(0.96); }
@media (min-width: 641px) and (min-height: 601px) { .atlas-chip { padding: 9px 16px; font-size: 0.9rem; } }

.history-map {
  width: calc(100% + 40px); margin: 12px -20px 10px;
  
  height: min(38dvh, calc(100dvh - 430px)); min-height: 200px;
  border-radius: 22px; overflow: hidden; position: relative;
  background: var(--panel-strong, rgba(10,20,34,0.6));
}

.history-years {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.history-years::-webkit-scrollbar { display: none; }
.history-year {
  flex: none; scroll-snap-align: center;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent;
  color: var(--muted); font: inherit; font-size: 0.8rem; font-weight: 800;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.history-year.is-active { background: var(--navy, #1f3b57); color: #F3ECDB; border-color: transparent; }
.history-year:active { transform: scale(0.96); }

.history-legend {
  display: flex; flex-wrap: wrap; gap: 0 12px;
  
  max-height: 140px; overflow-y: auto; padding: 6px 2px 0;
}
.history-legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.74rem; font-weight: 700; color: var(--text);
}
.history-legend-item i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.history-note { margin: 8px 0 0; font-size: 0.68rem; color: var(--muted); text-align: center; }

.atlas-study-cta--history {
  margin-top: 10px;
  
  border-inline-start: 3px solid var(--gold, #b08a3e);
}
.atlas-study-cta--history .atlas-cta-ic { color: var(--gold, #b08a3e); }

.history-legend-item { border: 0; background: transparent; padding: 0 4px; min-height: 44px; cursor: pointer; font-family: inherit; }
.history-legend-item:active { transform: scale(0.96); }

.history-cats {
  display: flex; gap: 6px; overflow-x: auto; padding: 0 2px 2px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.history-cats::-webkit-scrollbar { display: none; }
.history-cat {
  flex: none; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent;
  color: var(--muted); font: inherit; font-size: 0.74rem; font-weight: 700;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.history-cat.is-active { background: var(--gold, #b08a3e); color: #1a1206; border-color: transparent; }
.history-cat:active { transform: scale(0.96); }

.history-story {
  margin-top: 10px; padding: 14px 16px 16px;
  border-radius: 18px; border: 1px solid var(--line);
  background: var(--panel, rgba(255,255,255,0.04));
  max-height: none; overflow: visible;
}
.hs-year { margin: 0; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; color: var(--gold, #b08a3e); }
.hs-era { margin: 2px 0 6px; font-size: 1.06rem; font-weight: 900; line-height: 1.3; color: var(--text); }
.hs-oneliner { margin: 0 0 10px; font-size: 0.86rem; line-height: 1.5; color: var(--text); opacity: 0.92; }
.hs-keywords { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.hs-kw {
  font-size: 0.68rem; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: rgba(176,138,62,0.14); color: var(--gold, #b08a3e);
}

.hs-beat { display: block; margin-top: 10px; }
.hs-beat-tag {
  display: inline-block; margin-bottom: 4px;
  font-size: 0.64rem; font-weight: 800; text-align: center;
  padding: 3px 8px; border-radius: 6px; color: var(--text); opacity: 0.9;
}
.hs-b1 .hs-beat-tag { background: rgba(120,150,190,0.22); }
.hs-b2 .hs-beat-tag { background: rgba(194,65,45,0.20); }
.hs-b3 .hs-beat-tag { background: rgba(90,160,120,0.20); }
.hs-beat-body { margin: 0; font-size: 0.8rem; line-height: 1.55; color: var(--text); opacity: 0.88; }

.atlas-pick-note {
  margin: 10px 0 0; font-size: 0.78rem; line-height: 1.5;
  color: var(--text); opacity: 0.8; text-align: start;
}

.atlas-pick-note.is-centered { text-align: center; }

@media (min-width: 641px) and (min-height: 601px) {   
  .history-map { height: min(60dvh, calc(100dvh - 300px)); min-height: 340px; }
  .history-year { padding: 10px 18px; font-size: 0.92rem; }
  .history-legend-item { font-size: 0.86rem; }
}

@media (orientation: landscape) and (max-height: 500px) {
  
  .history-page { padding-top: 4px; padding-bottom: 6px; }
  .history-page .page-topbar { margin-bottom: 4px; }
  .history-page .atlas-back { width: 38px; height: 38px; font-size: 1.4rem; }
  .history-page .history-title { font-size: 1.05rem; }
  .history-page .atlas-labels-btn { padding: 5px 11px; font-size: 0.76rem; }

  
  .history-page {
    display: grid;
    
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr);
    grid-template-areas:
      "topbar cats"
      "map    side";
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 12px;
    height: calc(100dvh - 24px - env(safe-area-inset-bottom, 0px));
  }
  .history-page .page-topbar { grid-area: topbar; gap: 8px; }
  
  .history-page .history-title {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .history-cats { grid-area: cats; align-self: center; padding: 0; }
  .history-map {
    grid-area: map; align-self: stretch;
    width: 100%; margin: 4px 0 0; height: auto; min-height: 0;
    border-radius: 14px;
  }
  
  .history-side {
    grid-area: side; display: grid; grid-template-rows: auto auto minmax(0, 1fr);
    min-height: 0; margin-top: 4px;
  }
  .history-years { padding: 0 0 6px; }
  .history-legend { flex-wrap: nowrap; overflow-x: auto; max-height: none; padding: 0 0 4px; }   
  
  .history-story {
    margin-top: 0; max-height: none; min-height: 0; padding: 10px 12px 12px;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  
  .hs-era { font-size: 1.02rem; }
  
  .history-note { display: none; }   
}

.nav-rank {
  position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); inset-inline-end: calc(12px + var(--sai-end)); z-index: 60; 
  width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--panel-strong, rgba(255,255,255,0.9));
  font-size: 1.25rem; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 8px 20px -10px rgba(0,0,0,0.45);
}
.nav-rank:active { transform: scale(0.94); }
.nav-rank[hidden] { display: none; }

.rankboard-modal {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(8,16,28,0.62); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  opacity: 0; transition: opacity 200ms ease;
}
.rankboard-modal.is-active { opacity: 1; }

.rankboard-modal:not(.is-active) { pointer-events: none; }
.rankboard-modal[hidden] { display: none; }
.rankboard-card {
  position: relative; display: flex; flex-direction: column;
  width: min(560px, 100%); height: min(88dvh, 900px);
  padding: 22px 18px 18px; border-radius: 26px;
  background: var(--panel-strong, #12263a); border: 1px solid var(--line);
  box-shadow: 0 30px 70px -30px rgba(0,0,0,0.7);
  transform: scale(0.96); transition: transform 220ms cubic-bezier(0.2,0.9,0.3,1);
}
.rankboard-modal.is-active .rankboard-card { transform: scale(1); }
.rankboard-title { margin: 0 0 2px; font-size: 1.15rem; font-weight: 900; text-align: center; }

.rankboard-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0 10px; }
.rankboard-tab {
  min-width: 0; min-height: 44px; padding: 8px 10px; border-radius: 999px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; text-align: center;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: inherit; font-size: 0.84rem; font-weight: 800;
  white-space: normal; line-height: 1.2; overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.rankboard-tab.is-active { background: var(--navy, #1f3b57); color: #F3ECDB; border-color: transparent; }
.rankboard-list { flex: 1 1 auto; overflow-y: auto; margin: 0; padding: 0 2px; min-height: 0; }
.rankboard-play { margin-top: 12px; width: 100%; }
@media (min-width: 641px) and (min-height: 601px) {   
  .rankboard-card { padding: 26px 22px 20px; }
  .rankboard-title { font-size: 1.35rem; }
  .rankboard-tab { font-size: 0.95rem; padding: 12px 10px; }
}

.amem-root {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg, #0b1020);
}
.amem-head { display: flex; align-items: center; gap: 10px; flex: none; }
.amem-back {
  width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  font: 800 1.95rem/1 inherit; padding-bottom: 4px; color: var(--text);
  background: var(--soft-blue); border: 1.5px solid var(--line-strong, var(--line)); border-radius: 50%; cursor: pointer;
}
.amem-title { margin: 0; font-size: 1.1rem; font-weight: 900; color: var(--text); }
.amem-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.amem-error { margin: auto; color: var(--muted); }

.amem-bar { display: flex; align-items: baseline; justify-content: space-between; flex: none; }
.amem-board { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; color: var(--muted); }
.amem-timer { font-size: 1.3rem; font-weight: 900; color: var(--gold, #b08a3e); line-height: 1; }

.amem-timer-n {
  font-size: 2.4rem; font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em; margin-inline-end: 2px;
}
.amem-score { font-size: 1.1rem; font-weight: 900; color: var(--text); }
.amem-globe { flex: 1 1 auto; min-height: 0; border-radius: 16px; overflow: hidden; position: relative; background: #0a1626; }
.amem-hint { flex: none; margin: 0; text-align: center; font-size: 0.8rem; font-weight: 800; color: var(--gold, #b08a3e); }

.amem-legend { flex: none; display: flex; flex-wrap: wrap; gap: 5px 12px; justify-content: center; }
.amem-legend-item {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel, rgba(255,255,255,0.04));
  font-size: 0.76rem; font-weight: 700; color: var(--text);
}

.amem-ask { flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.92rem; font-weight: 800; color: var(--text); }
.amem-choices { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.amem-choice {
  padding: 13px 10px; border-radius: 14px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font: inherit; font-size: 0.86rem; font-weight: 700; cursor: pointer;
}
.amem-choice:active { transform: scale(0.97); }
.amem-choice.is-correct { background: rgba(90,160,120,0.30); border-color: rgba(90,160,120,0.7); }
.amem-choice.is-wrong { background: rgba(220,38,38,0.22); border-color: rgba(220,38,38,0.6); }
.amem-feedback { flex: none; margin: 0; text-align: center; font-size: 0.88rem; font-weight: 800; }
.amem-feedback.is-correct { color: #5aa078; }
.amem-feedback.is-wrong { color: #e05a5a; }

.amem-result {
  margin: auto; width: min(400px, 100%); text-align: center;
  max-height: 100%; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.amem-result-eyebrow { margin: 0; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.06em; color: var(--muted); }
.amem-result-score { margin: 6px 0 8px; font-size: 2rem; font-weight: 900; color: var(--text); }
.amem-result-best { margin: 0 0 6px; font-size: 0.9rem; font-weight: 800; color: var(--gold, #b08a3e); }
.amem-result-xp { margin: 0 0 18px; font-size: 0.88rem; font-weight: 800; color: var(--gold, #b08a3e); }

.amem-missed { margin: 2px 0 16px; text-align: start; }
.amem-missed-title {
  margin: 0 0 8px; text-align: center;
  font-size: 0.8rem; font-weight: 800; letter-spacing: 0.04em; color: var(--muted);
}

.amem-missed-list {
  display: grid; gap: 6px; max-height: 34vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch; padding-right: 2px;
}
.amem-missed-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px;
  background: rgba(194, 65, 45, 0.07); border: 1px solid rgba(194, 65, 45, 0.16);
}
.amem-missed-flag { flex: none; display: block; }
.amem-missed-flag img {
  display: block; width: 34px; height: 23px; object-fit: contain; border-radius: 3px;
  border: 1px solid rgba(47, 63, 83, 0.12);
}
.amem-missed-col { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.amem-missed-name { font-size: 0.92rem; font-weight: 800; color: var(--text); }
.amem-missed-picked { font-size: 0.76rem; color: var(--muted); }
html[data-theme="dark"] .amem-missed-row { background: rgba(194, 65, 45, 0.14); border-color: rgba(194, 65, 45, 0.28); }

.amem-missed-row.is-openable {
  width: 100%; font: inherit; color: inherit; text-align: start; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.amem-missed-row.is-openable:active { transform: scale(0.985); }
.amem-missed-arrow { flex: none; margin-inline-start: auto; font-size: 1.1rem; font-weight: 900; color: var(--muted); line-height: 1; }
html[data-theme="dark"] .amem-missed-flag img { border-color: rgba(226, 232, 240, 0.14); }

.amem-primary {
  width: 100%; padding: 15px; border-radius: 16px; border: 0; margin-bottom: 8px;
  background: var(--stamp, #c2412d); color: #fff; font: inherit; font-size: 1rem; font-weight: 800; cursor: pointer;
}
.amem-ghost {
  width: 100%; padding: 14px; border-radius: 16px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer;
}

@media (orientation: landscape) and (max-height: 500px) {
  .amem-root { padding: 4px 12px 6px; }
  .amem-body { gap: 5px; padding-top: 4px; }
  .amem-globe { min-height: 120px; }
  .amem-choices { grid-template-columns: repeat(4, 1fr); }
  .amem-choice { padding: 9px 6px; font-size: 0.76rem; }
  .amem-legend { gap: 3px 9px; }
  .amem-legend-item { font-size: 0.7rem; }
  .amem-result-score { font-size: 1.5rem; }
}

.froute-root {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg, #0b1020);
}
.froute-head { display: flex; align-items: center; gap: 10px; flex: none; }
.froute-back {
  width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  font: 800 1.95rem/1 inherit; padding-bottom: 4px; color: var(--text);
  background: var(--soft-blue); border: 1.5px solid var(--line-strong, var(--line)); border-radius: 50%; cursor: pointer;
}
.froute-title { margin: 0; font-size: 1.1rem; font-weight: 900; color: var(--text); }
.froute-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 7px; padding-top: 8px; }
.froute-error { margin: auto; color: var(--muted); }

.froute-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.froute-end { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 33%; }
.froute-end-label { font-size: 0.64rem; font-weight: 800; letter-spacing: 0.05em; color: var(--muted); }
.froute-end-name { font-size: 0.74rem; font-weight: 800; color: var(--text); text-align: center; line-height: 1.2; }
.froute-flag { display: block; width: 52px; height: 35px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.froute-flag img { width: 100%; height: 100%; object-fit: contain; display: block; }
.froute-flag--cur { box-shadow: 0 0 0 2px var(--stamp, #c2412d); }
.froute-flag--tgt { box-shadow: 0 0 0 2px #5aa078; }
.froute-flag--big { width: 120px; height: 80px; margin: 0 auto; }
.froute-steps { display: flex; flex-direction: column; align-items: center; }
.froute-steps strong { font-size: 1.7rem; font-weight: 900; color: var(--text); line-height: 1; }
.froute-par { font-size: 0.66rem; font-weight: 700; color: var(--muted); }

.froute-globe { flex: 1 1 auto; min-height: 0; border-radius: 16px; overflow: hidden; position: relative; background: #0a1626; }
.froute-toast {
  flex: none; margin: 0; padding: 8px 12px; border-radius: 11px; text-align: center;
  font-size: 0.84rem; font-weight: 800; color: var(--text);
  background: var(--panel-strong, rgba(255,255,255,0.08)); border: 1px solid var(--line);
}
.froute-toast.is-wrong { border-color: rgba(220,38,38,0.5); }
.froute-pick { flex: none; margin: 0; text-align: center; font-size: 0.74rem; color: var(--muted); }

.froute-choices { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.froute-choice {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px;
  border-radius: 13px; border: 1px solid var(--line); background: transparent;
  color: var(--text); font: inherit; cursor: pointer; text-align: start;
}
.froute-choice .froute-flag { width: 40px; height: 27px; flex: none; }
.froute-choice-name { font-size: 0.78rem; font-weight: 700; line-height: 1.2; }

.froute-sea {
  display: inline-block; margin-top: 3px; padding: 1px 7px;
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.02em;
  color: #1d4e63; background: rgba(90, 160, 190, 0.22);
  border: 1px solid rgba(90, 160, 190, 0.45); border-radius: 999px;
  white-space: nowrap;
}
html[data-theme="dark"] .froute-sea { color: #bfe4f2; background: rgba(90, 160, 190, 0.18); }

.froute-route-arrow { font-variant-emoji: text; }
.froute-choice:active { transform: scale(0.97); }
.froute-choice.is-wrong { border-color: rgba(220,38,38,0.6); background: rgba(220,38,38,0.14); }
.froute-note { flex: none; margin: 0; text-align: center; font-size: 0.64rem; color: var(--muted); opacity: 0.8; }

.froute-giveup {
  flex: none; align-self: center; padding: 6px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: inherit; font-size: 0.72rem; font-weight: 700; cursor: pointer;
}
.froute-giveup:active { transform: scale(0.96); }

.froute-answer {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; text-align: center;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.froute-answer .froute-result-line { margin: 0; }
.froute-answer-title { margin: 0; text-align: center; font-size: 1.05rem; font-weight: 900; color: var(--gold, #b08a3e); }
.froute-route { flex: none; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 4px 5px; }

.froute-route-step { display: flex; flex-direction: row; align-items: flex-start; gap: 4px; }
.froute-route-col { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 56px; }
.froute-route-step .froute-flag { width: 40px; height: 27px; }
.froute-route-name { font-size: 0.6rem; font-weight: 700; color: var(--text); text-align: center; line-height: 1.15; }
.froute-route-arrow { flex: none; font-size: 0.95rem; font-weight: 900; color: var(--muted); line-height: 27px; }

.froute-result {
  margin: auto; width: min(400px, 100%); text-align: center;
  max-height: 100%; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.froute-result-name { margin: 12px 0 4px; font-size: 1.3rem; font-weight: 900; color: var(--text); }
.froute-result-verdict { margin: 0 0 6px; font-size: 1rem; font-weight: 800; color: var(--gold, #b08a3e); }
.froute-result-line { margin: 0 0 6px; font-size: 0.88rem; color: var(--text); }

.froute-result-best { margin: 0 0 4px; font-size: 0.9rem; font-weight: 800; color: var(--gold, #b08a3e); }
.froute-result-xp { margin: 0 0 18px; font-size: 0.88rem; font-weight: 800; color: var(--gold, #b08a3e); }
.froute-primary {
  width: 100%; padding: 15px; border-radius: 16px; border: 0; margin-bottom: 8px;
  background: var(--stamp, #c2412d); color: #fff; font: inherit; font-size: 1rem; font-weight: 800; cursor: pointer;
}
.froute-ghost {
  width: 100%; padding: 14px; border-radius: 16px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer;
}

.froute-result .froute-ghost { margin-bottom: 8px; }

@media (orientation: landscape) and (max-height: 500px) {
  .froute-root { padding: 4px 12px 6px; }
  .froute-body { gap: 5px; padding-top: 4px; }
  .froute-globe { min-height: 110px; }
  .froute-choices { grid-template-columns: repeat(4, 1fr); }
  .froute-choice { flex-direction: column; gap: 4px; padding: 7px 5px; text-align: center; }
  .froute-choice-name { font-size: 0.66rem; }
  .froute-pick, .froute-note { display: none; }
}

.wfi { width: 1em; height: 1em; display: block; flex: 0 0 auto; overflow: visible; }
.wfi-slot {
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; flex: 0 0 auto;
}

.wfi--color { text-shadow: none; }

.tabbar-ic { font-size: 23px; opacity: 1; filter: none; }
.tabbar-btn.is-active .tabbar-ic { opacity: 1; filter: none; }
.tabbar-btn.is-active .wfi--line { stroke-width: 2.15; }

.drawer-ic { font-size: 21px; color: var(--muted); }
.drawer-row:active .drawer-ic { color: var(--primary); }

.drawer-pro .wfi, #pro-btn .wfi { color: var(--gold); }

.ribbon-ic { font-size: 17px; color: var(--muted); }
.ribbon-cell--points  .ribbon-ic { color: var(--primary); }
.ribbon-cell--dailyflag .ribbon-ic { color: var(--gold); }
.ribbon-cell--conquest .ribbon-ic { color: var(--gold); }
@media (prefers-color-scheme: dark) {
}

.fm-mode .icon { font-size: 42px; margin-bottom: 8px; }
.fm-mode.featured .icon { font-size: 46px; }

.study-region-card .srg-icon { font-size: 46px; }
.study-region-card.featured .srg-icon { font-size: 44px; }
.study-region-card.region--game .srg-icon,
.study-region-card.region--reigns .srg-icon { font-size: 44px; filter: none; }

.atlas-cta-ic { font-size: 2.6rem; }
.atlas-cta-go { font-size: 1.35rem; color: var(--muted); }

.map-cat-ic { font-size: 2.4rem; flex: 0 0 auto; }
.map-cat-title .wfi { color: var(--primary); }
.map-cat-title { display: flex; align-items: center; justify-content: center; gap: 8px; }

.onboarding-icon { font-size: 4rem; filter: none; }
.result-hero { font-size: 4.4rem; display: flex; justify-content: center; }
.pro-hero { font-size: 4.4rem; filter: none; display: flex; justify-content: center; }
.lb-result-emoji { font-size: 3.4rem; display: flex; justify-content: center; }
.charge-emoji { font-size: 3.2rem; display: flex; justify-content: center; }

.pro-benefits li span:first-child { font-size: 1.9rem; width: 32px; }

.achievement-icon { font-size: 2.9rem; position: relative; }
.achievement-card--locked .achievement-icon .wfi--color { filter: grayscale(1); opacity: 0.45; }

.achievement-icon .achievement-lock {
  position: absolute; right: -3px; bottom: -3px;
  width: 0.4em; height: 0.4em; color: var(--text);
  padding: 0.08em; border-radius: 50%;
  background: var(--paper-card); box-shadow: 0 0 0 1px var(--line);
  stroke-width: 2.2;
}
.achievement-toast-icon { font-size: 2.2rem; }

.setting-icon { color: var(--muted); }
.setting-row--danger .setting-icon { color: var(--wrong); }
.setting-row-arrow { font-size: 1.15rem; }
.settings-done-btn .wfi { stroke-width: 2.6; }

.bookmark-btn { font-size: 1.5rem; display: inline-flex; align-items: center; }
.bookmark-btn.is-on { color: var(--gold); }

.fm-chip .wfi { width: 1.05em; height: 1.05em; }
.fm-chip .wfi--line { stroke-width: 2.1; }

#lives-badge { gap: 2px; padding-left: 9px; padding-right: 9px; }
#lives-badge .wfi { width: 1em; height: 1em; }

.anthem-btn-ic { font-size: 1.05rem; }
.anthem-btn.is-loading .anthem-btn-ic { display: inline-flex; }

.atlas-back, .quiz-back, .froute-back, .amem-back { font-size: 1.65rem; padding-bottom: 0; }
.atlas-back .wfi, .quiz-back .wfi, .froute-back .wfi,
.amem-back .wfi, .lb-back .wfi { stroke-width: 2.8; }
.lb-back .wfi { width: 1.15em; height: 1.15em; }

.lb-rank .wfi--color, .rb-rank .wfi--color { width: 1.55em; height: 1.55em; }

@media (orientation: landscape) and (max-height: 500px) {
  .fm-mode .icon { font-size: 30px; margin-bottom: 4px; }
  .fm-mode.featured .icon { font-size: 32px; }
  .study-region-card .srg-icon { font-size: 32px; }
  .atlas-cta-ic { font-size: 1.9rem; }
  .result-hero { font-size: 2.8rem; }
  .onboarding-icon { font-size: 2.6rem; }
}

.stage-card-icon { font-size: 2.8rem; display: flex; justify-content: center; }
@media (max-width: 374px) { .stage-card-icon { font-size: 2.2rem; } }

.detail-meta-icon { font-size: 1.25rem; color: var(--navy); }
html[data-theme="dark"] .detail-meta-icon { color: var(--gold); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .detail-meta-icon { color: var(--gold); }
}

.league-row-rank .wfi--color { width: 1.6em; height: 1.6em; }
.league-row-rank, .lb-rank, .rb-rank { display: inline-flex; align-items: center; justify-content: center; }

.map-hint-ico { display: inline-flex; align-items: center; color: var(--primary); }

.crest-detail-region { display: flex; align-items: center; gap: 6px; }
.crest-region-pin { font-size: 1rem; flex: 0 0 auto; }

.wfi-life { color: var(--wrong); }
.wfi-life--spent { opacity: 0.28; }

.atlas-flip { color: #F3ECDB; font-size: 1.35rem; }
.atlas-flip .wfi { stroke-width: 2; }

.creigns-exit { display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.creigns-meter-ico { font-size: 24px; }
.creigns-crown { font-size: 84px; display: flex; justify-content: center; filter: drop-shadow(0 8px 22px rgba(0,0,0,0.35)); }

.study-region-card.featured .srg-game-body { min-width: 0; }

@media (orientation: landscape) and (max-height: 600px) {

  
  body {
    --shell-pt: calc(6px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  
  body.has-tabbar {
    --shell-pt: calc(6px + env(safe-area-inset-top, 0px));
    --shell-pb: calc(var(--tabbar-cover, calc(56px + env(safe-area-inset-bottom, 0px))) + var(--tabbar-gap, 20px));
  }

  .creigns-root {
    gap: 4px;
    padding-top: calc(4px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
  }
  .creigns-meter { width: 44px; gap: 1px; }
  .creigns-meter-ring { width: 32px; height: 32px; }
  .creigns-meter-ico { font-size: 17px; }
  .creigns-reign { margin-top: 2px; }
  .creigns-year { font-size: 1.05rem; }
  .creigns-best { font-size: 0.6rem; }

  .creigns-stage { max-width: 680px; }
  .creigns-deck { max-height: none; }
  .creigns-card { width: min(56vw, 300px); }
  
  .creigns-card-imgwrap { min-height: 0; padding: 6px 12px 2px; }
  .creigns-card-img { max-width: 62%; max-height: min(26vh, 92px); }
  
  .creigns-card-body { padding: 4px 12px 10px; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .creigns-who { font-size: 0.9rem; }
  .creigns-role { font-size: 0.6rem; }
  .creigns-text { margin-top: 4px; font-size: 0.8rem; line-height: 1.38; }
  .creigns-pick { top: 8px; font-size: 0.74rem; padding: 4px 10px; }

  .creigns-choices { max-width: 680px; margin-top: 4px; }
  .creigns-cbtn { padding: 7px 10px; font-size: 0.76rem; }
  .creigns-hint { margin-top: 3px; font-size: 0.62rem; }

  
  .creigns-overlay { justify-content: flex-start; gap: 8px; padding: 14px 26px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  
  .creigns-crown { font-size: 40px; }
  .creigns-otitle { font-size: 1.15rem; }
  .creigns-oend-name { font-size: 1rem; }
  .creigns-overlay .creigns-odesc { font-size: 0.82rem; line-height: 1.45; max-width: 420px; }
  .creigns-fantasy-note, .creigns-tutorial-hint { margin-top: 4px; max-width: 420px; }
  .creigns-ostats { gap: 8px; }
  .creigns-ostat { padding: 6px 10px; }
  .creigns-ostat b { font-size: 1.05rem; }
}

.combo-toast strong, .combo-toast span { display: inline-flex; align-items: center; gap: 7px; }
.combo-toast-ic { font-size: 1.5rem; flex: 0 0 auto; }

.combo-toast--reward {
  
  transform: translate(-50%, 0);
  top: 34%;
  gap: 4px;
  padding: 15px 26px;
  
  width: max-content;
  max-width: min(86vw, 340px);
  border-radius: 20px;
  background: linear-gradient(165deg, #26394f, #16222f);
  border: 1px solid rgba(231, 185, 107, 0.55);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.10);
  animation: reward-pop 3200ms cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.combo-toast--reward strong {
  display: flex; align-items: center; gap: 9px; white-space: nowrap;
  font-size: 2rem; color: #F2D79B; text-shadow: none;
}
.combo-toast--reward span { font-size: 1.05rem; font-weight: 700; color: #EAE1CC; text-shadow: none; }
.combo-toast--reward .combo-toast-ic { font-size: 1.75rem; }
@keyframes reward-pop {
  0%   { opacity: 0; transform: translate(-50%, 14px) scale(0.72); }
  8%   { opacity: 1; transform: translate(-50%, -4px) scale(1.06); }
  14%  { opacity: 1; transform: translate(-50%, 0) scale(1); }
  82%  { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -18px) scale(0.98); }
}
@media (prefers-reduced-motion: reduce) {
  
  .combo-toast--reward { animation: reward-hold 3200ms linear forwards; }
  @keyframes reward-hold { 0%, 88% { opacity: 1; } 100% { opacity: 0; } }
}
.combo-toast-ic--sub { font-size: 1.15rem; color: #facc15; }

#results-best { display: inline-flex; align-items: center; gap: 7px; }
.results-best-ic { font-size: 1.5rem; flex: 0 0 auto; }

.srg-icon--flag { width: auto; height: auto; margin-bottom: 8px; }
.srg-flag {
  display: block; width: 54px; height: 36px; object-fit: contain;
  border-radius: 5px; border: 1px solid rgba(252, 248, 239, 0.55);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}
@media (max-width: 374px) { .srg-flag { width: 46px; height: 31px; } }
@media (orientation: landscape) and (max-height: 500px) {
  .srg-flag { width: 40px; height: 27px; }
  .srg-icon--flag { margin-bottom: 4px; }
}

.fm-mode .icon { margin-bottom: auto; }

.fm-mode.featured .icon { margin: 0; }

.fm-mode.worldcup,
.fm-mode--fav,
.fm-mode--favquiz { padding-inline-start: 12px; }

.home-progress-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 2px 0 10px; }
.home-progress {
  display: flex; align-items: center; gap: 11px; width: 100%;
  margin: 0; padding: 10px 13px;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--panel); font: inherit; text-align: start; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.home-progress:active { transform: scale(0.995); }
.home-rank-badge { flex: none; width: 40px; height: 40px; display: block; }
.home-rank-badge svg { width: 100%; height: 100%; display: block; }
.home-progress-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.home-progress-head { display: flex; align-items: baseline; gap: 7px; }
.home-level { font-size: 1.05rem; font-weight: 900; color: var(--text); letter-spacing: -0.01em; }
.home-rank-name {
  flex: 1; min-width: 0; font-size: 0.82rem; font-weight: 700; color: var(--gold, #b08a3e);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-progress-head .xp-label { flex: none; font-size: 0.72rem; color: var(--muted); font-weight: 700; }

.home-next-reward {
  display: block; font-size: 0.74rem; font-weight: 700; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-next-reward[hidden] { display: none; }

.level-reward-art { display: block; width: 44px; height: 44px; flex: none; }

.level-modal, .levelup-modal {
  position: fixed; inset: 0; z-index: 9600; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(15,23,42,0.58); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 200ms ease;
}
.level-modal.is-active, .levelup-modal.is-active { opacity: 1; }
.level-card, .levelup-card {
  position: relative; width: min(92vw, 420px); max-height: 86vh; overflow-y: auto;
  
  padding: 22px 20px; border-radius: 24px; background: var(--panel-strong);
  border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(0,0,0,0.28);
  transform: translateY(10px); transition: transform 240ms cubic-bezier(0.2,0.9,0.3,1.2);
}
.level-modal.is-active .level-card, .levelup-modal.is-active .levelup-card { transform: translateY(0); }
.level-close {
  position: absolute; top: 12px; inset-inline-end: 12px; width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 50%; background: var(--soft-blue);
  color: var(--text); cursor: pointer;
}

.level-hero { text-align: center; }
.level-rank-badge { display: block; width: 92px; height: 92px; margin: 4px auto 10px; }
.level-rank-name { margin: 0; font-size: 1.05rem; font-weight: 900; color: var(--primary-deep); }
.level-num { margin: 2px 0 12px; font-size: 1.9rem; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; }
.level-bar { height: 10px; border-radius: 999px; background: rgba(127,127,127,0.18); overflow: hidden; }
.level-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--wfr-gold-deep, #8F6B26); transition: width 500ms ease; }
.level-xp-text { margin: 6px 0 0; font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.level-next, .level-owned-wrap { margin-top: 18px; }
.level-next-label, .level-owned-label {
  display: block; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.05em;
  color: var(--muted); text-transform: uppercase; margin-bottom: 8px;
}
.level-next-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: 16px; }
.level-next-body { display: flex; flex-direction: column; min-width: 0; }
.level-next-name { font-weight: 800; font-size: 0.95rem; color: var(--text); word-break: keep-all; }
.level-next-at { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

.level-owned { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.level-owned-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; border: 1px solid var(--line); border-radius: 16px;
  background: transparent; color: var(--text); font: inherit; cursor: pointer;
}

.level-owned-item.is-on { border-color: var(--wfr-gold-deep, #8F6B26); border-width: 2px; background: rgba(143,107,38,0.08); }

.level-owned-name {
  font-size: 0.72rem; font-weight: 700; text-align: center; line-height: 1.25;
  word-break: keep-all;
  
  hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere;
}

.levelup-card { text-align: center; }
.levelup-art { display: block; width: 116px; height: 116px; margin: 2px auto 12px; }
.levelup-level { margin: 0; font-size: 1.15rem; font-weight: 900; color: var(--muted); font-variant-numeric: tabular-nums; }
.levelup-title { margin: 4px 0 12px; font-size: 1.35rem; font-weight: 900; color: var(--text); line-height: 1.3; word-break: keep-all; }
.levelup-reward-row { margin: 4px 0; font-size: 0.92rem; font-weight: 700; color: var(--wfr-gold-deep, #8F6B26); word-break: keep-all; }
.levelup-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.levelup-btn {
  padding: 13px 16px; border-radius: 16px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font: inherit; font-weight: 800; cursor: pointer;
}
.levelup-btn--primary { background: var(--primary-deep); border-color: transparent; color: var(--on-primary); }

@media (prefers-reduced-motion: reduce) {
  .level-card, .levelup-card { transition: none; transform: none; }
  .level-bar-fill { transition: none; }
}

.atlas-route {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; overflow: visible;
}

svg.atlas-route path.atlas-route-line {
  fill: none;
  stroke: var(--wfr-gold-deep, #8F6B26);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 5 5;
  opacity: 0.85;
  
  vector-effect: non-scaling-stroke;
  transition: stroke-dashoffset 820ms ease-out;
}
html[data-theme="dark"] svg.atlas-route path.atlas-route-line { stroke: var(--wfr-gold, #E7B96B); opacity: 0.9; }
@media (prefers-reduced-motion: reduce) {
  svg.atlas-route path.atlas-route-line { transition: none; }
}

.passport-identity {
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
}

.passport-banner { width: 40px; height: 40px; }
.passport-crown { width: 28px; height: 28px; }
.passport-rank { width: 38px; height: 38px; }

.rank-emblem { position: relative; display: inline-flex; flex: none; }
.rank-frame { position: absolute; inset: 0; display: none; pointer-events: none; }
.rank-frame svg { width: 100%; height: 100%; display: block; }

html[data-frame]:not([data-frame=""]) .rank-frame { display: block; }
html[data-frame]:not([data-frame=""]) .rank-emblem > .passport-rank,
html[data-frame]:not([data-frame=""]) .rank-emblem > .home-rank-badge {
  transform: scale(0.68);
}
.passport-seal { width: 30px; height: 30px; }
.passport-rank-label { font-size: 0.82rem; font-weight: 800; color: var(--text); margin-left: 2px; }

.passport-panel .passport-rank-label { color: #EAE1CC; }

.passport-stamps-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 10px; }
.passport-stamp-mark { width: 34px; height: 34px; opacity: 0.92; }

.level-seals { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.level-seal-item {
  display: flex; align-items: center; justify-content: center; padding: 6px;
  border: 1px solid var(--line); border-radius: 14px; background: transparent; cursor: pointer;
}
.level-seal-item .level-reward-art { width: 38px; height: 38px; }
.level-seal-item.is-on { border-color: var(--wfr-gold-deep, #8F6B26); border-width: 2px; background: rgba(143,107,38,0.08); }

.results-route { margin: 12px 0 14px; text-align: center; }  
.results-route-label {
  display: block; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.05em;
  color: var(--muted); text-transform: uppercase; margin-bottom: 4px;
}
.results-route-path {
  margin: 0; font-size: 0.86rem; font-weight: 700; line-height: 1.45;
  color: var(--wfr-gold-deep, #8F6B26); word-break: keep-all;
}
html[data-theme="dark"] .results-route-path { color: var(--wfr-gold, #E7B96B); }

.crown-stage { position: relative; width: 168px; height: 118px; margin: 0 auto 2px; }
.crown-actor { position: absolute; top: -22px; left: 0; width: 168px; height: 168px; transform-origin: 50% 62%; }
.crown-art, .crown-glint { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

.crown-glint {
  overflow: hidden; pointer-events: none;
  clip-path: polygon(
    17.2% 34.4%, 29.7% 46.5%, 40.2% 25.4%, 50% 45.3%,
    59.8% 25.4%, 70.3% 46.5%, 82.8% 34.4%, 75.8% 68.8%,
    72.7% 72%, 27.3% 72%, 24.2% 68.8%
  );
}
.crown-glint::before {
  content: ""; position: absolute; top: 18%; bottom: 18%; left: -30%; width: 18%;
  border-radius: 50%; opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.94), transparent);
  transform: skewX(-16deg);
}
.crown-actor.is-animating { animation: crown-settle 500ms cubic-bezier(0.2, 0.9, 0.3, 1.25) both; }
.crown-actor.is-animating .crown-glint::before { animation: crown-sheen 360ms 330ms ease-out both; }

@keyframes crown-settle {
  0%   { opacity: 0; transform: translateY(-10px) scale(0.94) rotate(-1.5deg); }
  62%  { opacity: 1; transform: translateY(1px) scale(1.035) rotate(0.6deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
@keyframes crown-sheen {
  0%   { opacity: 0; transform: translateX(0) skewX(-16deg); }
  18%  { opacity: 0.9; }
  78%  { opacity: 0.75; }
  100% { opacity: 0; transform: translateX(760%) skewX(-16deg); }
}

@media (prefers-reduced-motion: reduce) {
  .crown-actor.is-animating { animation: none; opacity: 1; }
  .crown-glint { display: none; }
}
@media (max-width: 420px) {
  .crown-stage { width: 148px; height: 106px; }
  .crown-actor { width: 148px; height: 148px; }
}

.mania-meta-link { color: var(--primary); text-decoration: none; word-break: break-word; }
.mania-meta-link:active { opacity: 0.6; }

.mania-quiz-ic {
  display: inline-block; flex: none; width: 30px; height: 30px;
  background: url("./mania_state_quiz_light.png") center / contain no-repeat;
}
html[data-theme="dark"] .mania-quiz-ic { background-image: url("./mania_state_quiz_dark.png"); }

.mania-viewall { width: 100%; margin: -4px 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.setrun-row--sub .mania-viewall { width: auto; margin: 0 0 12px; }

.mania-map {
  
  width: calc(100% + 28px); margin-left: -14px; margin-right: -14px;
  margin-top: 6px; border-radius: 18px; overflow: hidden;
  border: 1px solid var(--line); background: var(--map-ocean, #1b3a5b);
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.mania-map svg { display: block; width: 100%; height: 100%; }

@media (orientation: portrait) {
  #mania-map-screen .mania-map {
    
    height: calc(100vh - 200px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - 200px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    
    min-height: 200px;
    
    aspect-ratio: auto !important;
  }
}

.mania-map-flags {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  
  overflow-x: clip;
  overscroll-behavior: contain;
  margin-top: 8px; padding: 2px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px; align-content: start;
}
.mania-map-flags[hidden] { display: none; }
.mmf-item {
  
  min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 4px; border-radius: 12px;
  background: var(--paper-card); border: 1px solid var(--line);
  color: var(--text); text-align: center; cursor: pointer;
}
.mmf-item img {
  
  width: 100%; aspect-ratio: 3 / 2; object-fit: contain;
  border-radius: 5px; border: 1px solid var(--line); background: var(--panel);
}

.mmf-name { font-size: 0.64rem; font-weight: 800; line-height: 1.2; word-break: keep-all; overflow-wrap: anywhere; }
.mmf-item:active { transform: scale(0.97); }

.mmf-item.is-on { border-color: var(--orange, #E08A3C); box-shadow: 0 0 0 2px var(--orange, #E08A3C); }

@media (orientation: landscape) and (max-height: 600px) {
  body.fit-screen #mania-map-screen .atlas-page {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(230px, 1fr);
    grid-template-areas: "topbar topbar" "map flags";
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 12px;
    
    height: calc(100vh - var(--shell-pt, 0px) - var(--shell-pb, 0px));
    height: calc(100dvh - var(--shell-pt, 0px) - var(--shell-pb, 0px));
  }
  #mania-map-screen .page-topbar { grid-area: topbar; }
  
  #mania-map-screen .mania-map { grid-area: map; align-self: start; width: 100%; margin: 0; max-height: 100%; }
  #mania-map-flags {
    grid-area: flags; display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    min-height: 0; overflow-y: auto; align-content: start; margin: 0;
  }
  
  #mania-map-screen #mania-map-hint { display: none; }
}

@media (orientation: landscape) and (max-height: 600px) {
  .rankboard-card {
    width: min(94vw, 780px); max-width: none;
    max-height: calc(100dvh - 20px);
    padding: 14px 18px;
    display: grid;
    grid-template-columns: minmax(190px, 0.85fr) minmax(0, 1.3fr);
    grid-template-areas: "title list" "day list" "tabs list" "period list" "note list" "play list";
    grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
    column-gap: 16px; row-gap: 6px;
    align-content: start;
  }
  .rankboard-title { grid-area: title; margin: 0; font-size: 1.15rem; }
  #rb-day { grid-area: day; margin: 0; }
  .rankboard-tabs { grid-area: tabs; }
  
  .rankboard-period { grid-area: period; margin-top: 0; }
  .rankboard-period-note { grid-area: note; }
  .rankboard-play { grid-area: play; align-self: end; min-height: 44px; }
  
  .rankboard-list {
    grid-area: list; margin: 0; min-width: 0; min-height: 0; max-height: none;
    overflow-y: auto; padding-inline-end: 30px;
  }
  #rb-status { grid-area: list; align-self: start; min-width: 0; padding-inline-end: 30px; }
}

.mania-map svg path.mania-unit { cursor: pointer; }
.mania-map svg path.mania-unit.is-on { fill: var(--orange, #E08A3C); stroke: #fff; }

.mania-map svg path.mania-unit--empty { cursor: default; }

.mania-map svg path.mania-unit--blocked { fill: #c9c3b4; fill: color-mix(in srgb, var(--map-land) 55%, #8b8f96); }

.mania-map svg text.mania-label {
  fill: #12203a; font-weight: 800; text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: rgba(255,255,255,0.92); stroke-width: 3px;
  vector-effect: non-scaling-stroke;
}
html[data-theme="dark"] .mania-map svg text.mania-label { fill: #0b1626; stroke: rgba(226,236,250,0.92); }

.mania-map svg circle.mania-mark-ring {
  fill: none; pointer-events: none;
  stroke: var(--orange, #E08A3C); stroke-width: 3px;
  paint-order: stroke;
}
html[data-theme="dark"] .mania-map svg circle.mania-mark-ring { stroke: #FFC65C; }

.mania-pick { position: fixed; inset: 0; z-index: 9500; display: flex; align-items: center; justify-content: center; padding: 24px; }
.mania-pick[hidden] { display: none; }
.mania-pick-scrim { position: absolute; inset: 0; background: rgba(15,23,42,0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.mania-pick-card {
  position: relative; width: min(86vw, 340px); padding: 18px; border-radius: 22px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 22px 54px rgba(0,0,0,0.3);
  text-align: center;
}
.mania-pick-flag-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.mania-pick-flag-btn img {
  display: block; width: 100%; height: auto; border-radius: 12px;
  border: 1px solid var(--line); background: #fff;
  
  max-height: min(52vh, 360px); object-fit: contain;
}
.mania-pick-flag-btn:active { transform: scale(0.98); }
.mania-pick-name { margin: 12px 0 0; font-size: 1.05rem; font-weight: 900; color: var(--text); word-break: keep-all; }
.mania-pick-sub { margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); }

@media (min-width: 820px) and (min-height: 601px) {   
  .mania-quiz-ic { width: 34px; height: 34px; }
}

.mania-flag-row.is-served .mania-fr-name::after {
  content: " ✓";
  color: var(--correct);
  font-weight: 900;
}
.mania-flag-row.is-served img { opacity: 0.6; }

.setrun-reset {
  display: block;
  width: 100%;
  margin: -6px 0 12px;
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.results-setrun {
  display: inline-block;
  margin: 10px auto 0;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--muted);
  background: rgba(120, 120, 140, 0.12);
  border: 1px solid rgba(120, 120, 140, 0.2);
}

.results-noclue {
  display: block;
  margin: 10px auto 0;
  max-width: 100%;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}

.results-setrun.is-complete {
  color: var(--gold);
  background: rgba(231, 185, 107, 0.16);
  border-color: rgba(231, 185, 107, 0.42);
}

@media (orientation: landscape) and (max-height: 600px) {

  
  .app-shell {
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  .panel {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  
  .home-screen {
    padding-left: max(0px, env(safe-area-inset-left, 0px));
    padding-right: max(0px, env(safe-area-inset-right, 0px));
  }
  .tabbar {
    left: calc(16px + env(safe-area-inset-left, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
  }
  
  .nav-hamburger { inset-inline-start: max(8px, calc(4px + var(--sai-start))); }
  .drawer-panel { padding-inline-start: var(--sai-start); }
  
  .creigns-root, .amem-root, .froute-root {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  
  .tabbar { padding: 4px 8px; bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  .tabbar-btn { padding: 3px 0; gap: 1px; }
  .tabbar-ic { width: 20px; height: 20px; }
  .tabbar-lb { font-size: 9.5px; }

  
  .nav-hamburger { top: calc(6px + env(safe-area-inset-top, 0px)); width: 38px; height: 38px; }
  body.has-tabbar .panel > .page-topbar { padding-top: 0; padding-inline-start: 46px; }
  .panel { padding-top: 8px; padding-bottom: 10px; }   
  
  .page-topbar { margin-bottom: 4px; }
  .study-page > .page-topbar,
  .study-detail-page .page-topbar { padding-bottom: 4px; }
  .atlas-back { width: 34px; height: 34px; font-size: 1.5rem; padding-bottom: 3px; }
  .page-title { font-size: 1.05rem; }
  .practice-sub, .study-count { font-size: 0.76rem; }
  .study-count { margin: 0; }

  
  .study-list, .mania-flag-list, .wrong-answers-list, .achievements-list, .stage-list {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    align-content: start;
  }
  
  .stage-card { display: flex; gap: 10px; padding: 14px 12px; }
  .stage-card-icon { flex: 0 100000 44px; min-width: 24px; font-size: min(2.8rem, 44px); }
  
  .stage-card-icon .wfi { flex-shrink: 1; min-width: 0; }
  .stage-card-info { flex: 1 1 auto; width: min-content; min-width: 0; }
  .stage-card-meta { flex: 0 10000000000 auto; }
  .stage-card-arrow { flex: none; }
  .stage-card-name, .stage-card-count { overflow-wrap: break-word; }
  
  html[data-textsize="l"] .stage-card { gap: 6px; padding-inline: 10px; }
  
  .study-row { grid-template-columns: 52px 1fr auto; gap: 10px; padding: 8px 10px; }
  .study-row-flag, .study-flag { height: 38px; }
  .study-title { font-size: 0.95rem; }
  .study-row-subtitle { font-size: 0.76rem; }
  .study-search-wrap { margin-bottom: 6px; }
  .study-search { padding: 9px 14px; }

  
  .mania-list-quiz, .crest-list-screen .primary-button { min-height: 42px; padding: 8px 14px; font-size: 0.95rem; }
  
  .setrun-row--sub { margin-top: 4px; }
  .setrun-row--sub .ghost-button { min-height: 38px; padding: 6px 12px; font-size: 0.88rem; }

  
  #study-list-screen .study-page,
  #mania-list-screen .study-page,
  #crest-list-screen .study-page {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(200px, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 10px;
  }
  #study-list-screen .study-page { grid-template-areas: "topbar search" "list list"; }
  
  #mania-list-screen .study-page { grid-template-columns: minmax(0, auto) minmax(200px, 1fr) auto;
                                   grid-template-areas: "topbar quiz sub" "list list list";
                                   grid-template-rows: auto minmax(0, 1fr); }
  #crest-list-screen .study-page { grid-template-areas: "topbar quiz" "list list"; }
  #study-list-screen .page-topbar,
  #mania-list-screen .page-topbar,
  #crest-list-screen .page-topbar { grid-area: topbar; margin-bottom: 0; padding-bottom: 0; }
  #study-search-wrap { grid-area: search; margin: 0; align-self: center; }
  #mania-list-quiz-btn { grid-area: quiz; align-self: center; margin: 0; }
  #crest-list-quiz-btn { grid-area: quiz; align-self: center; margin: 0; }
  
  #mania-list-screen .setrun-row--sub { grid-area: sub; margin: 0; align-self: stretch; flex-wrap: nowrap; }
  #mania-list-screen .setrun-row--sub .mania-viewall { margin: 0; white-space: nowrap; }
  #study-list, #mania-list, #crest-list { grid-area: list; margin-top: 6px; }

  
  
  .home-screen { padding-top: 4px; gap: 6px; display: grid; grid-template-columns: minmax(auto, 1fr) minmax(calc(50% - 3px), max-content); align-content: start; }
  
  
  
  .home-screen > .stats-ribbon { grid-column: 1; margin: 0; margin-inline-start: calc(max(8px, calc(4px + var(--sai-start))) - var(--sai-start) + 44px); padding: 6px 4px; }
  
  .home-screen > .home-progress-row { grid-column: 2; margin: 0; margin-inline-end: calc(max(8px, calc(4px + var(--sai-end))) - var(--sai-end) + 44px); display: block; }
  
  .home-screen > .home-progress-row > .home-progress { padding: 7px 11px; width: 100%; height: 100%; }
  
  .home-screen > .home-progress-row .home-progress-head { flex-wrap: wrap; row-gap: 0; }
  .home-screen > .home-progress-row .home-rank-name {
    white-space: normal; overflow-wrap: break-word; min-width: min-content;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
  }
  
  .home-screen > .mode-grid { grid-template-columns: repeat(4, 1fr) !important; }
  
  .home-screen {
    
    min-height: calc(100dvh - 12px - 62px - env(safe-area-inset-bottom, 0px));
    grid-template-rows: auto minmax(0, 1fr);
  }
  .home-screen > .mode-grid { align-content: stretch; }
  .home-screen > .mode-grid .fm-mode { min-height: 0; }
  
  .home-screen > .mode-grid .fm-mode .d {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
    overflow: hidden; font-size: 0.66rem; line-height: 1.32; margin-top: 2px;
  }
  .home-screen > .mode-grid .fm-mode.featured .d { -webkit-line-clamp: 1; }
  
  #home-rank-btn {
    top: calc(6px + env(safe-area-inset-top, 0px));
    
    inset-inline-end: max(8px, calc(4px + var(--sai-end)));
    width: 38px; height: 38px;
  }
  .home-screen > .mode-grid,
  .home-screen > .section-eyebrow,
  .home-screen > #intro-copy { grid-column: 1 / -1; }
  .ribbon-v { font-size: 15px; }
  .ribbon-l { font-size: 9px; }
  .ribbon-ic { font-size: 12px; }
  
  .ribbon-flag { height: 25px; margin-bottom: 5px; }
  .home-rank-badge { width: 32px; height: 32px; }
  .home-level { font-size: 0.92rem; }
  .home-next-reward { display: none; }   

  
  @media (max-height: 500px) {
    
    :where(html:not([data-fold="v"])) .home-screen > .stats-ribbon { margin-inline-start: 48px; }
    :where(html:not([data-fold="v"])) .home-screen > .home-progress-row { margin-inline-end: 48px; }
    
    :where(html:not([data-fold="v"])) .home-screen { min-height: calc(100dvh - var(--shell-pt) - var(--shell-pb)); padding-bottom: 0; }
    
    :where(html:not([data-fold="v"])) #home-screen > .mode-grid > .fm-mode:not(.featured) { --fm-badge-row: 0px; }
    
    :where(html:not([data-fold="v"])) .home-screen > .mode-grid:has(> .fm-mode.featured:not([hidden])) {
      grid-template-rows: minmax(min-content, calc((100% - 8px) / 3)) minmax(min-content, auto);
    }
  }

  
  body.has-tabbar .app-shell { padding-bottom: var(--shell-pb) !important; }

  
  .quiz-panel--map #quiz-map.quiz-map,
  .quiz-panel--map #quiz-globe.quiz-map,
  .quiz-panel--hunt #quiz-map.quiz-map,
  .quiz-panel--hunt #quiz-globe.quiz-map {
    height: auto; min-height: 0; max-height: none;
    width: 100%; margin: 0; align-self: stretch;
  }
  
  
  .quiz-panel {
    grid-template-areas:
      "topbar   topbar"
      "progress progress"
      "media    options"
      "media    hint"
      "footer   footer";
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    
    max-height: 100dvh;
  }
  
  .quiz-panel--hunt {
    grid-template-areas:
      "topbar   topbar"
      "progress progress"
      "media    prompt"
      "media    options"
      "media    hint"
      "footer   footer";
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  }
  .quiz-panel--hunt .prompt { display: block; grid-area: prompt; margin: 0; font-size: 0.8rem; line-height: 1.25; text-align: center; }
  
  .quiz-panel #map-hint-btn {
    grid-area: hint; align-self: start; justify-self: stretch; margin: 0;
    min-height: 44px; padding: 8px 20px;
  }
  
  .quiz-panel #map-hint-card {
    grid-area: media; align-self: end; justify-self: stretch; z-index: 3;
    margin: 0 0 6px; margin-inline: 6px 76px; pointer-events: none;
  }
  .quiz-panel #map-hint-card .map-hint-inner {
    pointer-events: auto; box-shadow: 0 12px 26px -10px rgba(0, 0, 0, 0.55);
  }
  

  
  .mania-map, .atlas-study-map { max-height: calc(100dvh - 96px); }

  
  .lb-play { position: sticky; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 5; }
  .lb-list { columns: 2; column-gap: 14px; }
  .lb-row { break-inside: avoid; }

  
  .amem-choice { min-height: 44px; }

  
  .dailyflag-card { max-height: calc(100dvh - 24px); overflow-y: auto; }
}

@media (orientation: landscape) and (max-height: 600px) {
  .creigns-card { width: min(74vw, 460px); flex-direction: row; align-items: stretch; }
  .creigns-card-imgwrap { flex: 0 0 40%; min-height: 0; padding: 10px 6px 10px 12px; }
  
  .creigns-card-img { max-width: 100%; max-height: 100%; min-height: 0; align-self: stretch; }
  
  .creigns-card-body {
    flex: 1 1 auto; min-width: 0; min-height: 0;
    display: flex; flex-direction: column; justify-content: center;
    text-align: start; padding-block: 10px; padding-inline: 8px 14px;
  }
  .creigns-card.behind1 { transform: translateY(9px) scale(0.95); }
  .creigns-card.behind2 { transform: translateY(17px) scale(0.9); }

  
  .creigns-card-imgwrap {
    background: radial-gradient(75% 70% at 50% 45%, rgba(124,58,237,0.14), transparent 72%),
                linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0));
    border-inline-end: 1px solid rgba(120,80,30,0.18);
  }
  .creigns-card.void .creigns-card-imgwrap { border-inline-end-color: rgba(180,80,255,0.28); }
  .creigns-card-body { padding-inline: 16px 18px; }
  .creigns-who { font-size: 1.02rem; }
  .creigns-role { font-size: 0.64rem; margin-top: 2px; }
  .creigns-text { margin-top: 7px; font-size: 0.86rem; line-height: 1.5; }
}

@media (orientation: landscape) and (max-height: 600px) {
  .creigns-top {
    position: absolute; z-index: 4;
    top: calc(4px + env(safe-area-inset-top, 0px));
    
    left: calc(6px + env(safe-area-inset-left, 0px));
    width: 46px; max-width: none;
    flex-direction: column; align-items: center; gap: 9px;
  }
  .creigns-meters { flex: none; flex-direction: column; gap: 9px; width: 100%; }
  .creigns-meter { width: 100%; }
  .creigns-exit { width: 30px; height: 30px; }

  
  .creigns-reign {
    position: absolute; z-index: 3; margin-top: 0; text-align: end;
    top: calc(4px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: baseline;
    gap: 2px 6px; line-height: 1.15; max-width: 22vw;
  }
  .creigns-year { font-size: 1.1rem; }
  .creigns-best { font-size: 0.6rem; margin-top: 0; }
  .creigns-best-ic { margin: 0; font-size: 0.7rem; }
}

@media (orientation: landscape) and (max-height: 600px) {
  .creigns-root {
    display: grid;
    grid-template-columns: minmax(96px, 1fr) auto minmax(96px, 1fr);
    grid-template-areas: "cl stage cr" "hint hint hint";
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: center; justify-items: center; column-gap: 12px; row-gap: 2px;
    
    padding-top: calc(2px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(2px + env(safe-area-inset-bottom, 0px));
    
    padding-inline: calc(58px + env(safe-area-inset-left, 0px))
                    calc(58px + env(safe-area-inset-right, 0px));
  }
  
  .creigns-stage { grid-area: stage; height: 100%; width: auto; aspect-ratio: 0.78; max-width: none; }
  .creigns-deck { width: 100%; height: 100%; max-height: none; }
  
  .creigns-hint { grid-area: hint; margin: 0; font-size: 0.6rem; line-height: 1.1; min-height: 0; }

  
  .creigns-choices { display: contents; }
  .creigns-cbtn.left { grid-area: cl; }
  .creigns-cbtn.right { grid-area: cr; }
  .creigns-cbtn { width: 100%; max-width: 260px; padding: 12px 10px; font-size: 0.8rem; }

  
  .creigns-card {
    flex-direction: column; width: 100%; height: 100%; max-height: 100%;
  }
  
  .creigns-card-imgwrap {
    flex: 0 1 auto; min-height: 0; max-height: 44%; padding: 8px 10px 2px;
    border-inline-end: 0;
    background: radial-gradient(70% 70% at 50% 40%, rgba(124,58,237,0.16), transparent 70%);
  }
  .creigns-card-img { max-width: 92%; max-height: 100%; align-self: center; }
  
  .creigns-card-body {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    display: flex; flex-direction: column; justify-content: center;
    text-align: center; padding: 2px 11px 8px;
  }
  .creigns-who { font-size: 0.9rem; }
  .creigns-role { font-size: 0.58rem; margin-top: 1px; }
  .creigns-text { margin-top: 4px; font-size: 0.79rem; line-height: 1.4; }
}

@media (orientation: landscape) and (max-height: 600px) and (max-width: 739px) {
  .creigns-root {
    padding-inline: calc(52px + env(safe-area-inset-left, 0px))
                    calc(52px + env(safe-area-inset-right, 0px));
    column-gap: 10px;
  }
  .creigns-stage { aspect-ratio: 0.7; }
  .creigns-cbtn { font-size: 0.76rem; padding: 10px 8px; }
  .creigns-year { font-size: 1rem; }
}

@media (orientation: landscape) and (min-width: 820px) and (min-height: 601px) {
  .creigns-stage { max-width: 720px; }
  .creigns-choices { max-width: 720px; }
  .creigns-deck { max-height: none; }
  .creigns-card { width: min(64vw, 620px); flex-direction: row; align-items: stretch; }
  .creigns-card-imgwrap { flex: 0 0 42%; min-height: 0; padding: 18px 10px 18px 20px; }
  .creigns-card-img { max-width: 100%; max-height: 100%; min-height: 0; align-self: stretch; }
  .creigns-card-body {
    flex: 1 1 auto; min-width: 0; min-height: 0;
    display: flex; flex-direction: column; justify-content: center;
    text-align: start; padding-block: 18px; padding-inline: 12px 22px;
  }
  .creigns-who { font-size: 1.3rem; }
  .creigns-role { font-size: 0.76rem; }
  .creigns-text { font-size: 1.02rem; margin-top: 10px; }
}

.legal-modal {
  position: fixed; inset: 0; z-index: 9800;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(11, 22, 38, 0.62); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 200ms ease;
}
.legal-modal.is-active { opacity: 1; }
.legal-modal[hidden] { display: none; }
.legal-card {
  width: min(560px, 100%); max-height: min(80vh, 720px);
  display: flex; flex-direction: column;
  background: var(--panel-strong); border-radius: 22px;
  box-shadow: 0 26px 70px rgba(0,0,0,0.34);
  transform: scale(0.96); transition: transform 220ms cubic-bezier(0.2,0.9,0.3,1.2);
  overflow: hidden;
}
.legal-modal.is-active .legal-card { transform: scale(1); }
.legal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 12px; border-bottom: 1px solid var(--hairline, rgba(18,32,58,0.12));
}
.legal-title { flex: 1 1 auto; margin: 0; font-size: 1.05rem; font-weight: 800; color: var(--text); }

.legal-close {
  flex: 0 0 auto; width: 34px; height: 34px; border: 0; border-radius: 999px;
  background: rgba(120, 120, 140, 0.16); color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
}
.legal-close:active { transform: scale(0.94); color: var(--text); }

.legal-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 18px 24px;
  white-space: pre-wrap; word-break: break-word;
  font-size: 0.9rem; line-height: 1.62; color: var(--text);
}
.legal-body a { color: var(--primary, #C2412D); text-decoration: underline; }

.pro-links {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 8px; margin-top: 10px;
}
.pro-link {
  border: 0; background: none; padding: 4px 2px; cursor: pointer;
  font-size: 0.8rem; font-weight: 700; color: var(--muted, #5d6b83);
  text-decoration: underline; text-underline-offset: 2px;
}
.pro-link-dot { color: var(--muted, #5d6b83); font-weight: 800; opacity: 0.6; }

html[data-theme="dark"] .legal-card { background: var(--panel-strong); }

.credits-legal-links { justify-content: flex-start; margin-top: 8px; }

@media (orientation: portrait) and (max-height: 1000px) and (max-width: 700px) {
  
  body.has-tabbar .panel > .page-topbar { padding-top: 0; padding-inline-start: 46px; }

  
  .study-region-card { min-height: 96px; padding: 12px 14px; }
  .study-region-card .srg-icon { font-size: 34px; margin-bottom: 4px; }
  .study-regions-grid { gap: 10px; }
  .study-regions-sub { margin-bottom: 10px; }
  .atlas-study-cta { padding: 12px 14px; }

  
  .fm-mode { min-height: 112px; padding: 14px 14px; }
}

.drawer-pro.is-pro-owned {
  background: linear-gradient(135deg, #12603A 0%, #1C7A4B 55%, #2E9B63 100%);
  box-shadow: 0 12px 24px -10px rgba(18, 96, 58, 0.55);
}
.drawer-pro .wfi, #pro-btn .wfi {
  color: #FFD873;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.45));
}

@media (orientation: landscape) and (max-height: 500px) {
  .study-detail-card { gap: 12px; }
  
  .study-detail-visual { min-height: 0; }
  .study-detail-visual img { max-height: 132px; }
  #study-detail-flag { max-height: 132px; }
  #mania-detail-flag { max-height: 132px; }
  #crest-detail-img { max-height: 150px; }
}

#study-regions-screen .study-page {
  height: auto;
  min-height: 0;
  
  overflow: hidden;
}

.stats-modal {
  position: fixed; inset: 0; z-index: 9400;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity 200ms ease;
}
.stats-modal.is-active { opacity: 1; }
.stats-modal[hidden] { display: none; }
.stats-scrim { position: absolute; inset: 0; background: rgba(11, 22, 38, 0.55); backdrop-filter: blur(3px); }
.stats-card {
  position: relative; width: min(400px, 100%); max-height: min(84vh, 720px);
  display: flex; flex-direction: column; gap: 4px; text-align: center;
  padding: 22px 20px 18px; border-radius: 24px;
  background: var(--panel-strong); box-shadow: 0 26px 70px rgba(0,0,0,0.34);
  transform: scale(0.96); transition: transform 220ms cubic-bezier(0.2,0.9,0.3,1.2);
  overflow-y: auto; overflow-x: clip;   
}
.stats-modal.is-active .stats-card { transform: scale(1); }

.stats-close {
  position: sticky; top: 0; z-index: 2;
  align-self: flex-end; margin-block: -8px -30px; margin-inline: 0 -6px;
  flex: 0 0 auto; width: 34px; height: 34px; border: 0; border-radius: 999px;
  background: rgba(120, 120, 140, 0.16); color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
}
.stats-close:active { transform: scale(0.94); color: var(--text); }
.stats-icon { font-size: 2rem; line-height: 1; margin-bottom: 2px; color: var(--gold, #b08a3e); }
.stats-title { margin: 0; font-size: 1.25rem; font-weight: 900; color: var(--text); }
.stats-sub { margin: 0 0 8px; font-size: 0.88rem; color: var(--muted); }

.stats-body { display: grid; gap: 8px; margin: 4px 0 14px; }
.stats-row {
  display: grid; grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 5px;
  align-items: baseline; text-align: start;
}
.stats-row-name { font-size: 0.92rem; font-weight: 800; color: var(--text); min-width: 0; }
.stats-row-num { font-size: 0.82rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats-row-track {
  grid-column: 1 / -1; height: 7px; border-radius: 999px;
  background: rgba(120,120,140,0.16); overflow: hidden;
}
.stats-row-fill { display: block; height: 100%; border-radius: 999px; background: var(--gold, #b08a3e); }
.stats-row.is-done .stats-row-fill { background: var(--correct, #1C7A4B); }
.stats-row.is-done .stats-row-name { color: var(--correct, #1C7A4B); }

.stats-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats-tile {
  display: flex; flex-direction: column; gap: 2px; align-items: center;
  padding: 12px 6px; border-radius: 16px;
  background: rgba(120,120,140,0.10); border: 1px solid rgba(120,120,140,0.18);
}
.stats-tile-val { font-size: 1.15rem; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; }
.stats-tile-lab { font-size: 0.7rem; font-weight: 700; color: var(--muted); text-align: center; line-height: 1.25; }

.stats-actions { display: grid; gap: 8px; }
.stats-btn {
  width: 100%; padding: 13px; border-radius: 14px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font: inherit; font-size: 0.95rem; font-weight: 800; cursor: pointer;
}
.stats-btn--primary { border: 0; background: var(--stamp, #c2412d); color: #fff; }
.stats-btn:active { transform: scale(0.98); }

.isl-parent-flag {
  
  width: 20px; height: 14px; object-fit: contain; flex: none;
  margin-inline-end: 7px; vertical-align: -2px;
  border-radius: 2px; border: 1px solid var(--line);
}

.study-list.is-one-region .region-badge { display: none; }

@media (orientation: landscape) and (max-height: 600px) {
  
  
  .results-panel {
    display: grid;
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
    grid-template-rows: minmax(0, 1fr) auto auto auto auto auto minmax(0, 1fr) auto;
    column-gap: 16px; align-content: stretch;
    min-height: calc(100vh - var(--shell-pt, 0px) - var(--shell-pb, 0px));
    min-height: calc(100dvh - var(--shell-pt, 0px) - var(--shell-pb, 0px));
    padding: 10px 18px 8px;
  }
  .results-header { grid-column: 1; grid-row: 1 / 8; align-self: center; margin-bottom: 0; }
  .results-rank { grid-column: 2; grid-row: 2; }
  .results-route { grid-column: 2; grid-row: 3; }
  .results-stars { grid-column: 2; grid-row: 4; }
  .results-stats { grid-column: 2; grid-row: 5; }
  .wrong-answers-section { grid-column: 2; grid-row: 6; }
  .results-actions { grid-column: 1 / -1; grid-row: 8; }
  
  .result-hero { font-size: clamp(1.6rem, 8vh, 2.1rem); margin: 0 0 2px; }
  .results-eyebrow { font-size: 0.58rem; letter-spacing: 0.2em; margin: 0 0 2px; }
  .results-title { font-size: clamp(2.1rem, 10.5vh, 2.9rem); }
  .results-mode-label { font-size: 0.76rem; margin: 2px 0 0; }
  .results-best, .results-setrun { font-size: 0.72rem; margin-top: 6px; padding: 3px 10px; }
  .results-noclue { font-size: 0.72rem; margin-top: 6px; }

  
  .crown-stage { width: 104px; height: 74px; margin-bottom: 0; }
  .crown-actor { top: -14px; width: 104px; height: 104px; }

  
  .results-rank { flex-direction: row; justify-content: center; align-items: center; gap: 10px; margin: 6px 0 2px; }
  .results-rank-text { font-size: 0.88rem; }
  .results-rank-btn { font-size: 0.72rem; padding: 5px 12px; min-height: 0; }

  .results-route { margin: 6px 0 8px; }
  .results-route-label { font-size: 0.58rem; }
  
  .results-route-path { font-size: 0.74rem; line-height: 1.35; max-height: min(40vh, calc(1.35em * 7)); overflow-y: auto; overscroll-behavior: contain; }

  .results-stars { gap: 5px; margin: 6px 0; }
  .result-star { font-size: 1.25rem; }

  .results-stats {
    grid-auto-flow: column !important;
    grid-auto-columns: minmax(0, 1fr) !important;
    grid-template-columns: none !important;
    gap: 8px !important; margin-bottom: 8px;
  }
  .results-stats .fm-stat { padding: 7px 6px; }
  .results-stat-value { font-size: 1.15rem !important; }
  .results-stat-label { font-size: 0.55rem !important; letter-spacing: 0.1em !important; }

  .wrong-answers-section { margin-bottom: 6px; }
  .wrong-answers-title { font-size: 0.82rem; margin: 0 0 6px; }
  .wrong-answers-list { max-height: 118px; gap: 6px; }

  .results-actions {
    margin-top: 8px; padding: 6px; border-radius: 18px;
    bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .results-actions .primary-button,
  .results-actions .ghost-button {
    min-height: 40px; font-size: 0.86rem; border-radius: 12px; padding-inline: 10px;
  }
}

@media (orientation: landscape) and (max-height: 360px) {
  
  .creigns-card-imgwrap { max-height: 38%; }

  .quiz-panel { padding-top: 4px; padding-bottom: 6px; }
  
  .quiz-panel { row-gap: 4px; }
  .quiz-panel > .top-bar { padding-bottom: 2px; }
  .quiz-panel .atlas-back { width: 38px; height: 38px; }
  #quiz-progress-track { margin-top: 4px; }
  #options-grid { gap: 6px; }
  .option-button .k { width: 28px; height: 28px; border-radius: 9px; font-size: 0.82rem; }

  
}

@media (orientation: landscape) and (max-height: 600px) {
  .quiz-panel:not(.quiz-panel--map) {
    height: calc(100vh - var(--shell-pt) - var(--shell-pb));
    height: calc(100dvh - var(--shell-pt) - var(--shell-pb));
    min-height: 0;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  }
  .quiz-panel:not(.quiz-panel--map) #options-grid {
    grid-template-rows: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
    align-content: stretch;
  }
  .quiz-panel:not(.quiz-panel--map) .option-button { min-height: 0; padding-block: 4px; }
}

.wf-sub-capital rect { fill: #1F6FD0; stroke: #0E3A6B; stroke-width: 1.4; }
.wf-sub-capital text {
  fill: #12203a; font-weight: 800; letter-spacing: -0.01em;
  paint-order: stroke; stroke: rgba(255,255,255,0.92); stroke-width: 3px; stroke-linejoin: round;
}
html[data-theme="dark"] .wf-sub-capital rect { fill: #4DA3FF; stroke: #0B2C55; }
html[data-theme="dark"] .wf-sub-capital text { fill: #0b1626; stroke: rgba(226,236,250,0.92); }

.ost-sub {
  margin: 0 0 12px;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
}
.ost-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ost-row { margin: 0; }
.ost-btn {
  width: 100%;
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-strong, rgba(255,255,255,0.6));
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: transform 120ms ease, border-color 160ms ease;
}
.ost-btn:active { transform: scale(0.99); }
.ost-num {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 2ch;
}
.ost-ic { width: 22px; height: 22px; flex: none; color: var(--primary); }
.ost-name { font-size: 0.98rem; font-weight: 700; line-height: 1.3; word-break: keep-all; overflow-wrap: break-word; }
.ost-dur {
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 4ch;
  text-align: end;
}

.ost-row.is-playing .ost-btn { border-color: var(--primary); background: var(--soft-blue); }
.ost-row.is-playing .ost-name { color: var(--primary); }
html[data-theme="dark"] .ost-btn { background: rgba(255,255,255,0.05); }
html[data-theme="dark"] .ost-row.is-playing .ost-btn { background: rgba(255,255,255,0.10); }

@media (orientation: landscape) and (max-height: 600px) {
  .ost-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
  .ost-btn { min-height: 46px; padding: 8px 12px; gap: 8px; }
  .ost-name { font-size: 0.88rem; }
}
@media (min-width: 740px) and (min-height: 1100px) {
  .ost-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .ost-btn { min-height: 64px; }
  .ost-name { font-size: 1.05rem; }
}

.creigns-cost {
  margin-inline-start: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
  font-size: 0.82em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.creigns-sr-live {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .creigns-crown { animation: none; }
  .creigns-meter.danger .creigns-meter-ring {
    animation: none;
    box-shadow: 0 0 0 3px rgba(248,113,113,0.7);   
  }
  .creigns-meter.flash, .creigns-newbest { animation: none; }
  .creigns-flash.go { animation: creigns-flash-soft 0.4s ease-out; }
  @keyframes creigns-flash-soft { 0% { opacity: 0.16; } 100% { opacity: 0; } }
  .creigns-float { animation-duration: 0.45s; }
  .creigns-spark { display: none; }              
  .creigns-card { transition: none !important; } 
}

html[dir="rtl"] .creigns-choices { direction: ltr; }
html[dir="rtl"] .creigns-cbtn { direction: rtl; }

@media (orientation: landscape) and (max-height: 600px) {
  html[dir="rtl"] .creigns-root { direction: ltr; }
  html[dir="rtl"] .creigns-card,
  html[dir="rtl"] .creigns-hint,
  html[dir="rtl"] .creigns-overlay,
  html[dir="rtl"] .creigns-top,
  html[dir="rtl"] .creigns-reign { direction: rtl; }
}

.creigns-exit { position: relative; }
.creigns-exit::before {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 44px; height: 44px; transform: translate(-50%, -50%);
  
}

.fm-mode.is-netlocked { opacity: 0.55; filter: saturate(0.6); }
.fm-mode.is-netlocked .corner { opacity: 0.8; }

.nav-rank.is-netlocked { opacity: 0.45; filter: saturate(0.5); }

.study-pager {
  position: sticky;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  width: min(calc(100% - 32px), 420px);
  margin: 14px auto calc(10px + env(safe-area-inset-bottom, 0px));
  
  display: grid; grid-template-columns: auto minmax(max-content, 1fr) auto;
  align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 999px;
  
  background: #FFFDF6; border: 1px solid var(--line-strong, var(--line));
  
  transform: translateZ(0);
  will-change: transform;
  
  box-shadow: 0 10px 30px rgba(31,41,51,0.16);
}

.study-pager[hidden] { display: none; }

.study-pager-btn {
  width: 44px; height: 44px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.65rem; color: var(--text); background: var(--soft-blue);
  border: 1.5px solid var(--line-strong, var(--line)); border-radius: 50%;
  cursor: pointer; transition: transform 120ms ease, opacity 120ms ease;
}
.study-pager-btn .wfi { stroke-width: 2.8; }
.study-pager-btn:active { transform: scale(0.9); }

.study-pager-pos {
  text-align: center; font-weight: 800; font-size: 0.95rem;
  color: var(--muted); font-variant-numeric: tabular-nums;
  white-space: nowrap;
  
  
  transform: translateZ(0);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
html[data-theme="dark"] .study-pager {
  background: #162D42; border-color: rgba(226,232,240,0.12);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
html[data-theme="dark"] .study-pager-btn { background: rgba(255,255,255,0.07); color: #e6edf7; }

@media (orientation: landscape) and (max-height: 500px) {
  .study-pager {
    padding: 5px 10px;
    bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    margin: 10px auto calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .study-pager-btn { width: 38px; height: 38px; font-size: 1.35rem; }
}

:is(#dailyflag-modal, #charge-modal, #level-modal, #levelup-modal, #map-modal, #atlas-pick-modal,
    #map-cat-modal, .confirm-modal, #onboarding-overlay, #stats-modal) {
  flex-direction: column; align-items: center; justify-content: flex-start;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}

:is(#dailyflag-modal, #charge-modal, #level-modal, #levelup-modal, #atlas-pick-modal, #map-cat-modal, .confirm-modal) {
  padding-top: max(24px, env(safe-area-inset-top, 0px));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}
#map-modal {
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}
#stats-modal {
  padding-top: max(20px, env(safe-area-inset-top, 0px));
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
}
:is(#dailyflag-modal > .dailyflag-card, #charge-modal > .charge-card, #level-modal > .level-card,
    #levelup-modal > .levelup-card, #map-modal > .map-card, #atlas-pick-modal > .atlas-pick-card,
    #map-cat-modal > .map-cat-card, .confirm-modal > .confirm-card, #onboarding-overlay > .onboarding-card,
    #stats-modal > .stats-card) {
  flex: none; margin-block: auto; max-height: none; overflow-y: visible;
}

:is(#level-modal > .level-card, #levelup-modal > .levelup-card) { width: min(420px, 100%); }

#dailyflag-modal.is-active > .dailyflag-card,
#charge-modal.is-active > .charge-card,
#level-modal.is-active > .level-card,
#levelup-modal.is-active > .levelup-card,
#map-modal.is-active > .map-card,
.confirm-modal.is-active > .confirm-card,
#stats-modal.is-active > .stats-card { transform: none; }

#dailyflag-modal > .dailyflag-card,
#charge-modal > .charge-card,
#level-modal > .level-card,
#map-modal > .map-card,
#atlas-pick-modal > .atlas-pick-card,
#map-cat-modal > .map-cat-card { padding-top: 12px; }
.dailyflag-card > .dailyflag-close,
.charge-card > .charge-close,
.map-card > .map-close,
.atlas-pick-card > .map-close,
.map-cat-card > .map-close {
  position: sticky; top: 10px; display: block; inset-inline-end: auto; z-index: 6;
}
.level-card > .level-close { position: sticky; top: 10px; display: flex; inset-inline-end: auto; z-index: 6; }

.dailyflag-card > .dailyflag-close { margin-block: 0 -20px; margin-inline: auto -8px; }   
.charge-card > .charge-close       { margin-block: 0 -18px; margin-inline: auto -10px; }  
.level-card > .level-close         { margin-block: 0 -24px; margin-inline: auto -8px; }   
.map-card > .map-close             { margin-block: 0 -28px; margin-inline: auto -4px; }   
.atlas-pick-card > .map-close      { margin-block: 0 8px;   margin-inline: auto -8px; }   
.map-cat-card > .map-close         { margin-block: 0 -22px; margin-inline: auto -8px; }   
@media (min-width: 641px) and (min-height: 601px) {
  .atlas-pick-card > .map-close    { margin-block: 0 14px;  margin-inline: auto -12px; }  
}
@media (max-height: 600px) {
  .dailyflag-card > .dailyflag-close { margin-block: 0 -26px; margin-inline: auto -6px; } 
}

#pro-modal > .pro-card > .pro-close {
  position: sticky; top: 10px; z-index: 6; display: block; inset-inline-end: auto;
  margin-block: -14px -18px; margin-inline: auto -12px;
}

@media (orientation: landscape) and (max-height: 500px) {
  #pro-modal > .pro-card > .pro-close { position: absolute; top: 12px; inset-inline-end: 12px; margin: 0; }
}

#stats-modal { background: rgba(11, 22, 38, 0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#stats-modal > .stats-scrim { display: none; }
#stats-modal > .stats-card > .stats-close { top: 10px; margin-block: 0 -38px; z-index: 6; }

.rankboard-list, .legal-body { overscroll-behavior: contain; }

html:has(:is(#atlas-detail-modal, #dailyflag-modal, #charge-modal, #level-modal, #levelup-modal, #map-modal,
    #atlas-pick-modal, #map-cat-modal, .confirm-modal, #onboarding-overlay, #stats-modal, #rankboard-modal,
    #legal-modal, #mania-map-pick, #drawer):not([hidden])) { overflow: hidden; }

.fm-mode.pro-mode {
  grid-column: 1 / -1;
  flex-direction: row; align-items: center; justify-content: flex-start;
  gap: 14px; min-height: 0; padding: 14px 18px;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--gold) 12%, transparent), transparent 70%),
    var(--paper-card);
}

.fm-mode.pro-mode .icon { margin: 0; flex: 0 0 auto; font-size: 34px; }
.fm-mode.pro-mode .body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }

.fm-mode.pro-mode .pro-mode-price {
  flex: 0 0 auto; white-space: nowrap;
  font-family: var(--font-mono); font-weight: 700; font-size: 0.8rem;
  padding: 5px 11px; border-radius: 999px;
  color: var(--gold); background: var(--paper-card);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
}

@media (min-width: 768px) and (min-height: 601px) {
  .home-screen > .mode-grid > .fm-mode.pro-mode { grid-column: span 2; padding: 22px 26px; gap: 18px; }
  .fm-mode.pro-mode .icon { font-size: 46px; }
}

@media (orientation: landscape) and (min-width: 768px) and (min-height: 601px) {
  .home-screen > .mode-grid:has(> .fm-mode.pro-mode:not([hidden])) > .fm-mode.featured { grid-column: 1 / span 2; }
  .home-screen > .mode-grid > .fm-mode.pro-mode { grid-row: 1; grid-column: 3; padding: 14px 18px; gap: 12px; }
  .home-screen > .mode-grid > .fm-mode.pro-mode .icon { font-size: 34px; }
  .home-screen > .mode-grid > .fm-mode.pro-mode .d { display: none; }
}

@media (orientation: landscape) and (min-width: 768px) and (min-height: 601px) {
  .home-screen > .mode-grid { grid-template-columns: repeat(4, 1fr); }
  .home-screen > .mode-grid > .fm-mode.featured { grid-column: 1 / -1; }
  .home-screen > .mode-grid:has(> .fm-mode.pro-mode:not([hidden])) > .fm-mode.featured { grid-column: 1 / span 2; }
  .home-screen > .mode-grid > .fm-mode.pro-mode { grid-column: 3 / span 2; }
}

@media (orientation: landscape) and (min-width: 768px) and (max-width: 1023px) and (min-height: 601px) {
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid { column-gap: 12px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode:is(.featured, .pro-mode) { padding-inline: 16px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode.featured { gap: 12px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode:is(.featured, .pro-mode) .icon { font-size: 34px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode:is(.featured, .pro-mode) .t { font-size: 1.1rem; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode:not(.featured, .pro-mode) { padding-inline: 12px; --fm-badge-row: 0px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode.worldcup { padding-inline-start: 8px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode:not(.featured, .pro-mode) .icon { font-size: 32px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode:not(.featured, .pro-mode) .t { font-size: 1.02rem; }
}

@media (orientation: landscape) and (min-width: 768px) and (min-height: 700px) and (max-height: 760px) {
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid { row-gap: 12px; margin-top: 12px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode:not(.featured, .pro-mode) { --fm-badge-row: 0px; }
}

@media (orientation: landscape) and (min-width: 768px) and (max-width: 1023px) and (min-height: 700px) and (max-height: 760px) {
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid { margin-top: 6px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode:is(.featured, .pro-mode) { min-height: 0; padding-block: 12px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode:not(.featured, .pro-mode) { min-height: 128px; padding-block: 12px; }
}

@media (orientation: landscape) and (min-width: 768px) and (min-height: 601px) and (max-height: 699px) {
  :where(html:not([data-fold="v"])) .home-screen .home-next-reward { display: none; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid { row-gap: 10px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode:is(.featured, .pro-mode) { min-height: 0; padding-block: 12px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode:not(.featured, .pro-mode) { min-height: 0; padding-block: 12px; --fm-badge-row: 0px; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode .d { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  :where(html:not([data-fold="v"])) .home-screen > .mode-grid > .fm-mode.featured .d { -webkit-line-clamp: 1; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .home-screen > .mode-grid:has(> .fm-mode.pro-mode:not([hidden])) > .fm-mode.featured { grid-column: 1 / span 2; }
  .home-screen > .mode-grid > .fm-mode.pro-mode { grid-row: 1; grid-column: 3 / span 2; padding: 8px 14px; gap: 10px; }
  .home-screen > .mode-grid > .fm-mode.pro-mode .icon { font-size: 26px; }
  .home-screen > .mode-grid > .fm-mode.pro-mode .d { display: none; }
}

.pro-mini { display: none; }
@media (orientation: portrait) and (max-width: 767px) and (max-height: 1000px) {
  .home-screen > .mode-grid > .fm-mode.pro-mode { display: none; }
  
  .home-progress-row:has(> .pro-mini:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 12px; }
  @media (max-width: 374px) {
    
    .home-progress-row:has(> .pro-mini:not([hidden])) { column-gap: 10px; }
  }
  .pro-mini:not([hidden]) {
    display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
    min-width: 0; padding: 10px 12px; border-radius: 20px;
    font: inherit; text-align: start; color: var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent;
    border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
    background:
      linear-gradient(120deg, color-mix(in srgb, var(--gold) 12%, transparent), transparent 70%),
      var(--paper-card);
  }
  
  html[dir="rtl"] .pro-mini:not([hidden]) {
    background:
      linear-gradient(240deg, color-mix(in srgb, var(--gold) 12%, transparent), transparent 70%),
      var(--paper-card);
  }
  .pro-mini:active { transform: scale(0.995); }
  
  .pro-mini-top { order: -1; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
  .pro-mini .icon { font-size: 28px; line-height: 1; flex: 0 0 auto; }
  
  .pro-mini .pro-mode-price {
    flex: 0 0 auto; white-space: nowrap;
    font-family: var(--font-mono); font-weight: 700; font-size: 0.74rem;
    padding: 3px 9px; border-radius: 999px;
    color: var(--gold); background: var(--paper-card);
    border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  }
  
  html[data-theme="dark"] .pro-mini .pro-mode-price { background: color-mix(in srgb, #000 16%, transparent); }
  
  .pro-mini-t { font-family: var(--font-serif); font-weight: 700; font-size: 0.98rem; line-height: 1.2; text-wrap: balance; overflow-wrap: anywhere; }
  .home-progress-row:has(> .pro-mini:not([hidden])) > .home-progress { padding: 10px 11px; gap: 8px; }
  .home-progress-row:has(> .pro-mini:not([hidden])) .home-progress-head { flex-wrap: wrap; row-gap: 0; }
  .home-progress-row:has(> .pro-mini:not([hidden])) .home-progress-head .xp-label,
  .home-progress-row:has(> .pro-mini:not([hidden])) .home-next-reward { display: none; }
  
  .home-progress-row:has(> .pro-mini:not([hidden])) .home-rank-name {
    flex-basis: 100%; overflow-wrap: anywhere;
    white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  }
  
  body.has-tabbar .home-screen {
    min-height: calc(100vh - var(--shell-pt) - var(--tabbar-cover, 118px) - var(--tabbar-gap, 20px));
    min-height: calc(100dvh - var(--shell-pt) - var(--tabbar-cover, 118px) - var(--tabbar-gap, 20px));
    padding-bottom: 0;
  }
  .home-screen > .stats-ribbon { margin-bottom: 0; }
  .home-screen > .home-progress-row { margin-bottom: 0; }
  .home-screen > .mode-grid { margin-top: 2px; flex: 1 1 auto; grid-template-rows: auto; grid-auto-rows: 1fr; align-content: stretch; }
  
  .home-screen > .mode-grid > .fm-mode:not(.featured) { min-height: 0; --fm-badge-row: 0px; }
  
  .home-screen > .mode-grid > .fm-mode.featured > .corner-group { margin-inline-start: -6px; }
}

.fm-mode.pro-mode .t, #settings-pro-title, .drawer-pro [data-pro-label], .charge-option--pro .charge-option-t { text-wrap: balance; }

:root:lang(ko) :is(.pro-card .confirm-title, .fm-mode.pro-mode .t, .pro-mini-t) { font-family: "Gowun Batang", "Apple SD Gothic Neo", serif; }
:root:lang(ja) :is(.pro-card .confirm-title, .fm-mode.pro-mode .t, .pro-mini-t) { font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", serif; word-break: keep-all; }
:root:lang(zh-Hant) :is(.pro-card .confirm-title, .fm-mode.pro-mode .t, .pro-mini-t) { font-family: "PingFang TC", serif; }
.setting-row--pro { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); }
.setting-row-value {
  flex: 0 0 auto; white-space: nowrap;
  font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem; color: var(--gold);
}
#settings-restore-status.is-ok { color: var(--correct); font-weight: 700; }

#settings-restore-status.is-warn, .pro-status.is-warn { color: var(--gold); font-weight: 700; }
