:root {
  color-scheme: light;
  --bg: #fff7ed;
  --surface: #ffffff;
  --surface-strong: #fffaf3;
  --text: #27212b;
  --muted: #746b7a;
  --line: #eaded4;
  --primary: #ff6f61;
  --primary-dark: #df4f43;
  --accent: #20a39e;
  --gold: #ffc857;
  --good: #22a06b;
  --bad: #df4f43;
  --shadow: 0 14px 34px rgba(68, 46, 28, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 200, 87, 0.28), transparent 34rem),
    linear-gradient(180deg, #fffaf3 0%, #fff2e1 100%);
  color: var(--text);
}

body {
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
select,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: 100%;
  max-width: 520px;
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background: rgba(255, 250, 243, 0.72);
}

.app-header {
  padding: calc(12px + env(safe-area-inset-top)) 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary-dark);
  font-size: 0.74rem;
  font-weight: 800;
}

.eyebrow.dark {
  color: var(--muted);
}

.app-header h1 {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.level-pill {
  min-width: 86px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 111, 97, 0.18);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(68, 46, 28, 0.08);
  text-align: right;
}

.level-pill span,
.level-pill strong {
  display: block;
}

.level-pill span {
  color: var(--muted);
  font-size: 0.72rem;
}

.level-pill strong {
  font-size: 0.88rem;
}

.screen {
  min-height: 0;
  overflow: hidden;
  padding: 6px 16px 12px;
  scrollbar-width: none;
}

.screen-settings {
  overflow: auto;
}

.screen-home,
.screen-progress,
.screen-daily,
.screen-quiz {
  display: grid;
  align-content: start;
}

.screen-home {
  grid-template-rows: auto auto auto auto;
  gap: 8px;
}

.screen-home .hero-card,
.screen-home .stats-grid,
.screen-home .panel,
.screen-home .ad-slot {
  margin: 0;
}

.screen-home .ad-slot {
  display: none;
}

.screen-progress {
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
}

.screen-progress .stats-grid,
.screen-progress .panel {
  margin: 0;
}

.screen-daily .hero-card,
.screen-daily .panel,
.screen-daily .reward-slot,
.screen-quiz .panel,
.screen-quiz .premium-panel,
.screen-quiz .quiz-card {
  margin: 0 0 8px;
}

.screen-learn {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  overflow: hidden;
}

.screen-learn .toolbar,
.screen-learn .answer-bar {
  margin: 0;
}

.screen-learn .learn-stage {
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-self: stretch;
}

.screen-learn .flag-card {
  width: 100%;
  height: 100%;
  min-height: 0;
  justify-self: stretch;
}

.screen::-webkit-scrollbar {
  display: none;
}

.app-loading,
.offline-state {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 28px;
  text-align: center;
}

.loading-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 2.4rem;
}

.hero-card,
.panel,
.quiz-card,
.premium-panel {
  border: 1px solid rgba(234, 222, 212, 0.9);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 18px;
  display: grid;
  gap: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(255, 247, 237, 0.98)),
    var(--surface);
}

.hero-card.compact {
  gap: 14px;
}

.hero-card h2,
.panel h2,
.result-panel h2 {
  margin: 0 0 8px;
  font-size: clamp(1.22rem, 4.8vw, 1.56rem);
  line-height: 1.18;
  letter-spacing: 0;
}

.hero-card p,
.panel p,
.premium-panel p,
.result-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

.primary-action,
.secondary-action,
.ghost-button,
.danger-button {
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.primary-action {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #ff8a4c);
  box-shadow: 0 10px 20px rgba(255, 111, 97, 0.25);
}

.secondary-action {
  color: var(--primary-dark);
  background: #fff0eb;
}

.ghost-button {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
}

.danger-button {
  color: #fff;
  background: #b94337;
}

.primary-action:active,
.secondary-action:active,
.ghost-button:active,
.danger-button:active,
.tab-button:active,
.mode-button:active,
.choice:active {
  transform: scale(0.98);
}

.primary-action:disabled,
.secondary-action:disabled {
  opacity: 0.55;
  cursor: default;
}

.full {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 10px 0;
}

.stat-card {
  min-width: 0;
  padding: 11px 9px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.84);
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
}

.stat-card strong {
  display: block;
  margin: 5px 0 2px;
  font-size: 1.2rem;
  line-height: 1.1;
}

.panel,
.premium-panel,
.quiz-card {
  margin: 10px 0;
  padding: 14px;
}

.tap-panel {
  width: 100%;
  display: block;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.goal-card {
  box-shadow: 0 10px 24px rgba(68, 46, 28, 0.1);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h2,
.section-title h3 {
  margin: 0;
  font-size: 1.08rem;
}

.section-title span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.goal-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  align-items: center;
}

.goal-row h4 {
  margin: 0 0 5px;
}

.progress-ring {
  width: 72px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) calc(var(--value) * 1%), #efe3d9 0);
}

.progress-ring span {
  width: 52px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  font-weight: 900;
}

.ad-slot,
.reward-slot {
  min-height: 42px;
  display: grid;
  place-items: center;
  margin: 10px 0;
  border: 1px dashed #d9c8bd;
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.44);
  font-size: 0.82rem;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 8px;
}

.toolbar select,
.settings-list select {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  font-weight: 700;
}

.learn-stage {
  display: grid;
  gap: 8px;
  width: 100%;
}

.mini-progress {
  position: relative;
  height: 20px;
  border-radius: 999px;
  overflow: hidden;
  background: #efe3d9;
}

.mini-progress span {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: #594a40;
  font-size: 0.78rem;
  font-weight: 900;
}

.mini-progress i,
.mastery-strip i,
.continent-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
  background: #efe3d9;
}

.mini-progress i {
  background: linear-gradient(90deg, var(--gold), var(--primary));
}

.flag-card {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: min(56dvh, 500px);
  border: 0;
  padding: 0;
  background: transparent;
  perspective: 1400px;
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  transform-style: preserve-3d;
  transition: transform 0.58s cubic-bezier(0.22, 0.8, 0.24, 1);
}

.card-front {
  transform: rotateY(0);
}

.card-back {
  transform: rotateY(180deg);
  text-align: center;
}

.flag-card.flipped .card-front {
  transform: rotateY(-180deg);
}

.flag-card.flipped .card-back {
  transform: rotateY(0);
}

.card-front img {
  width: 100%;
  max-height: 68%;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 12px 26px rgba(28, 24, 20, 0.2);
}

.card-front p,
.sub-name {
  color: var(--muted);
  margin: 0;
}

.card-cue {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff0eb;
  color: var(--primary-dark);
  font-size: 1.5rem;
  font-weight: 900;
}

.mini-flag {
  width: 88px;
  max-height: 54px;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(28, 24, 20, 0.14);
}

.card-back h2 {
  margin: 0;
  font-size: clamp(1.05rem, 5vw, 1.42rem);
  line-height: 1.25;
}

.back-copy {
  width: 100%;
  min-height: 0;
  display: grid;
  justify-items: center;
  gap: 7px;
}

.fact-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.fact-row {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 8px 9px;
  border-radius: 12px;
  background: var(--surface-strong);
}

.fact-row span {
  color: var(--muted);
}

.trivia {
  margin: 0;
  color: #51464f;
  line-height: 1.35;
  font-size: 0.78rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.map-stack {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 8px;
}

.map-card {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbf7;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.map-card > span {
  padding: 5px 8px 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.regional-map,
.world-map-mini {
  min-height: 0;
  display: grid;
  place-items: center;
}

.regional-map svg,
.world-map-mini svg {
  width: 100%;
  height: 100%;
}

.map-error {
  color: var(--muted);
  font-size: 0.72rem;
}

.card-zone {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 34px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: rgba(39, 33, 43, 0.48);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 8px 18px rgba(68, 46, 28, 0.1);
  font-size: 2rem;
  font-weight: 900;
  transform: translateY(-50%);
  pointer-events: none;
}

.zone-left {
  left: 10px;
}

.zone-right {
  right: 10px;
}

.wm-country {
  fill: #e8efe2;
  stroke: #8aa97c;
  stroke-width: 0.4;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.wm-highlight {
  fill: #ffd54f;
  stroke: #f57c00;
  stroke-width: 1.2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 4px rgba(255, 152, 0, 0.65));
}

.wm-graticule line {
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 0.6;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}

.wm-pin {
  fill: #e53935;
  stroke: #fff;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.wm-pin-core {
  fill: #fff;
  pointer-events: none;
}

.wm-tiny-ring-outer,
.wm-tiny-ring-inner {
  stroke: #f57c00;
  vector-effect: non-scaling-stroke;
}

.mastery-strip {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.mastery-strip i {
  height: 8px;
}

.mastery-strip b,
.continent-row b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.answer-bar {
  display: grid;
  grid-template-columns: 1fr 0.8fr 1.2fr;
  gap: 8px;
  margin-top: 8px;
}

.answer-icon {
  min-width: 0;
  padding: 8px;
  font-size: 1.55rem;
  line-height: 1;
}

.answer-miss {
  color: #9d2e25;
}

.answer-got {
  font-size: 1.35rem;
}

.mode-grid {
  display: grid;
  gap: 10px;
}

.mode-button {
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: var(--surface-strong);
  text-align: left;
}

.mode-button strong,
.mode-button span {
  display: block;
}

.mode-button strong {
  margin-bottom: 4px;
  font-size: 1rem;
}

.mode-button span {
  color: var(--muted);
  font-size: 0.84rem;
}

.premium-panel {
  background: #fff8ec;
}

.premium-panel ul {
  margin: 12px 0 0;
  padding-left: 1.2em;
  color: var(--muted);
  line-height: 1.75;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 900;
  margin-bottom: 10px;
}

.quiz-prompt {
  display: grid;
  place-items: center;
  min-height: 142px;
  gap: 10px;
  text-align: center;
}

.quiz-prompt h2 {
  margin: 0;
  font-size: 1.8rem;
}

.quiz-prompt p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.quiz-flag {
  width: min(100%, 320px);
  max-height: 168px;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 12px 26px rgba(28, 24, 20, 0.18);
}

.choice-grid {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}

.choice {
  min-height: 49px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text);
  font-weight: 900;
}

.choice.correct {
  border-color: rgba(34, 160, 107, 0.4);
  background: #e9f8ef;
  color: #176945;
}

.choice.wrong {
  border-color: rgba(223, 79, 67, 0.42);
  background: #fff0ee;
  color: #9d2e25;
}

.flag-options {
  grid-template-columns: repeat(2, 1fr);
}

.flag-options .choice {
  min-height: 92px;
  display: grid;
  place-items: center;
  gap: 6px;
  font-size: 0.78rem;
}

.flag-options img {
  width: 100%;
  max-height: 52px;
  object-fit: contain;
  border-radius: 8px;
}

.result-panel {
  text-align: center;
}

.share-text,
.result-share p {
  margin: 12px 0;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-strong);
}

.continent-row {
  display: grid;
  grid-template-columns: 96px 1fr 44px;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  font-size: 0.8rem;
  font-weight: 800;
}

.continent-row i {
  height: 9px;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.badge {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 15px;
  background: #f2ece6;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.badge.earned {
  background: #fff1c4;
  color: #6c4c00;
}

.settings-list {
  display: grid;
  gap: 14px;
}

.settings-list label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
}

.settings-list label span {
  font-weight: 900;
}

.settings-list input[type="checkbox"] {
  width: 26px;
  height: 26px;
  accent-color: var(--primary);
}

.setting-note,
.version-panel {
  color: var(--muted);
  font-size: 0.85rem;
}

.bottom-tabs {
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  border-top: 1px solid rgba(234, 222, 212, 0.92);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.tab-button {
  min-width: 0;
  min-height: 50px;
  border: 0;
  border-radius: 15px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.tab-button span {
  font-size: 1.05rem;
  line-height: 1;
}

.tab-button small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.62rem;
}

.tab-button.active {
  color: var(--primary-dark);
  background: #fff0eb;
}

.feedback-correct .screen {
  animation: correctPulse 0.34s ease;
}

.feedback-wrong .screen {
  animation: wrongShake 0.28s ease;
}

@keyframes correctPulse {
  0% { filter: saturate(1); }
  45% { filter: saturate(1.35) brightness(1.04); }
  100% { filter: saturate(1); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@media (min-width: 760px) {
  .app-shell {
    max-width: 820px;
    border-left: 1px solid rgba(234, 222, 212, 0.9);
    border-right: 1px solid rgba(234, 222, 212, 0.9);
  }

  .screen {
    padding-inline: 28px;
  }

  .app-header {
    padding-inline: 30px;
  }

  .app-header h1 {
    font-size: 1.48rem;
  }

  .hero-card,
  .panel,
  .quiz-card,
  .premium-panel {
    border-radius: 26px;
  }

  .hero-card {
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 28px;
  }

  .flag-card {
    min-height: min(60dvh, 620px);
  }

  .screen-learn .flag-card {
    min-height: 0;
  }

  .card-face {
    padding: 24px;
  }

  .card-front img {
    max-height: 68%;
  }

  .card-back h2 {
    font-size: 2rem;
  }

  .trivia {
    max-width: 620px;
    font-size: 1rem;
  }

  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choice {
    min-height: 68px;
    font-size: 1.02rem;
  }

  .quiz-prompt {
    min-height: 230px;
  }

  .quiz-flag {
    max-height: 250px;
  }

  .bottom-tabs {
    padding-inline: 14px;
    gap: 8px;
  }

  .tab-button {
    min-height: 62px;
  }

  .tab-button small {
    font-size: 0.7rem;
  }
}

@media (min-width: 900px) and (min-height: 680px) {
  .app-shell {
    max-width: 1040px;
  }

  .screen {
    padding: 10px 40px 24px;
  }

  .stats-grid {
    gap: 16px;
  }

  .stat-card {
    padding: 20px 18px;
    border-radius: 22px;
  }

  .stat-card strong {
    font-size: 1.55rem;
  }

  .learn-stage {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
  }

  .answer-bar {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
  }

  .flag-card {
    min-height: min(62dvh, 680px);
  }

  .screen-learn .flag-card {
    min-height: 0;
  }

  .card-front img {
    max-height: 72%;
  }

  .quiz-card {
    max-width: 880px;
    margin-inline: auto;
  }

  .premium-panel,
  .panel {
    max-width: 880px;
    margin-inline: auto;
  }
}

@media (orientation: landscape) and (max-height: 640px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    max-width: none;
    grid-template-columns: 76px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-header {
    grid-column: 2;
    grid-row: 1;
    padding: calc(8px + env(safe-area-inset-top)) 18px 8px;
  }

  .app-header .eyebrow {
    display: none;
  }

  .app-header h1 {
    font-size: 1.05rem;
  }

  .level-pill {
    min-width: 78px;
    padding: 7px 9px;
  }

  .screen {
    grid-column: 2;
    grid-row: 2;
    padding: 6px 16px 12px;
  }

  .bottom-tabs {
    grid-column: 1;
    grid-row: 1 / 3;
    grid-template-columns: 1fr;
    align-content: center;
    gap: 6px;
    padding: calc(8px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 0;
    border-right: 1px solid rgba(234, 222, 212, 0.92);
  }

  .tab-button {
    min-height: 48px;
    border-radius: 14px;
  }

  .tab-button span {
    font-size: 0.95rem;
  }

  .tab-button small {
    font-size: 0.52rem;
  }

  .toolbar {
    grid-template-columns: minmax(160px, 260px) auto;
    max-width: 720px;
    margin: 0 auto 8px;
  }

  .learn-stage {
    max-width: 900px;
    margin: 0 auto;
    grid-template-columns: minmax(360px, 1.4fr) minmax(230px, 0.8fr);
    grid-template-rows: 20px minmax(0, 1fr) auto;
    gap: 8px 14px;
    align-items: stretch;
  }

  .mini-progress {
    grid-column: 1 / -1;
    height: 20px;
  }

  .flag-card {
    grid-column: 1;
    grid-row: 2 / 4;
    min-height: calc(100dvh - 126px);
  }

  .screen-learn .flag-card {
    min-height: 0;
  }

  .mastery-strip {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.82);
  }

  .answer-bar {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: min(32vw, 260px);
    grid-template-columns: 1fr;
    margin: 0;
    z-index: 5;
  }

  .answer-bar .primary-action,
  .answer-bar .secondary-action,
  .answer-bar .ghost-button {
    min-height: 46px;
  }

  .card-face {
    gap: 10px;
    padding: 16px;
    border-radius: 22px;
  }

  .card-front img {
    max-height: 76%;
  }

  .card-back {
    display: grid;
    grid-template-columns: minmax(230px, 0.85fr) minmax(300px, 1.15fr);
    grid-template-rows: 1fr;
    gap: 12px;
    align-content: center;
    text-align: left;
  }

  .card-back .mini-flag {
    width: 72px;
    max-height: 46px;
  }

  .back-copy,
  .map-stack {
    min-height: 0;
    align-self: stretch;
  }

  .back-copy {
    justify-items: start;
    align-content: center;
  }

  .map-stack {
    grid-template-columns: 1fr;
    grid-template-rows: 1.15fr 0.85fr;
  }

  .card-back h2 {
    font-size: clamp(1.25rem, 4vw, 1.8rem);
  }

  .sub-name,
  .trivia {
    font-size: 0.82rem;
  }

  .fact-row {
    padding: 8px 10px;
  }

  .map-card {
    min-height: 0;
  }

  .quiz-card {
    max-width: 900px;
    margin: 0 auto;
    padding: 14px;
  }

  .quiz-card {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(330px, 1.1fr);
    grid-template-rows: auto 1fr auto;
    gap: 8px 16px;
  }

  .quiz-meta {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .quiz-prompt {
    min-height: 0;
    align-content: center;
  }

  .quiz-flag {
    max-height: 210px;
  }

  .choice-grid {
    align-self: center;
    margin: 0;
  }

  .quiz-card > .primary-action.full {
    grid-column: 2;
  }

  .hero-card,
  .panel,
  .premium-panel {
    max-width: 900px;
    margin-inline: auto;
  }
}

@media (orientation: landscape) and (max-height: 430px) {
  .app-header {
    padding-top: 6px;
    padding-bottom: 5px;
  }

  .level-pill {
    display: none;
  }

  .flag-card {
    min-height: calc(100dvh - 94px);
  }

  .screen-learn .flag-card {
    min-height: 0;
  }

  .card-front p,
  .trivia {
    display: none;
  }

  .map-stack {
    grid-template-rows: 1fr;
  }

  .map-stack .map-card + .map-card {
    display: none;
  }

  .mastery-strip {
    padding: 10px;
  }
}

@media (max-width: 390px) {
  .app-header {
    padding-left: 14px;
    padding-right: 14px;
  }

  .screen {
    padding-left: 12px;
    padding-right: 12px;
  }

  .stats-grid {
    gap: 7px;
  }

  .stat-card {
    padding: 12px 8px;
  }

  .stat-card strong {
    font-size: 1rem;
  }

  .tab-button small {
    font-size: 0.56rem;
  }
}
