:root {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #edf5ff;
  background: #070b14;
  color-scheme: dark;
  --bg: #070b14;
  --bg-soft: #0c1220;
  --panel: rgba(18, 27, 46, 0.92);
  --panel-strong: #121b2e;
  --panel-raised: #17243b;
  --line: #2b3c58;
  --line-bright: #3d5478;
  --text: #edf5ff;
  --muted: #9eb0c8;
  --cyan: #3dd9e8;
  --cyan-strong: #18b9cc;
  --violet: #8b7cf6;
  --green: #35d18a;
  --red: #ff6d7a;
  --amber: #f6c45c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% -10%, rgba(61, 217, 232, 0.16), transparent 32rem),
    radial-gradient(circle at 95% 5%, rgba(139, 124, 246, 0.15), transparent 28rem),
    linear-gradient(180deg, #080d18 0%, #070b14 65%, #050810 100%);
  color: var(--text);
}

button,
select,
input {
  font: inherit;
}

button,
.file-button {
  border: 1px solid var(--line-bright);
  background: linear-gradient(180deg, #17243a, #111a2b);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 15px;
  font-weight: 750;
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}

button:hover,
.file-button:hover {
  border-color: var(--cyan);
  background: linear-gradient(180deg, #1b2c47, #142238);
}

button:active,
.file-button:active {
  transform: translateY(1px);
}

button:focus-visible,
select:focus-visible,
.file-button:focus-within {
  outline: 3px solid rgba(61, 217, 232, 0.32);
  outline-offset: 2px;
}

button:disabled {
  cursor: default;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px max(14px, env(safe-area-inset-left));
  background: rgba(7, 11, 20, 0.88);
  border-bottom: 1px solid rgba(61, 217, 232, 0.18);
  backdrop-filter: blur(18px);
}

.app-header h1 {
  font-size: 1.08rem;
  margin: 0;
  letter-spacing: 0.01em;
}

.app-header p {
  font-size: 0.77rem;
  margin: 3px 0 0;
  color: var(--muted);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  padding: 0;
  font-size: 1.35rem;
  color: var(--cyan);
  border-color: rgba(61, 217, 232, 0.42);
}

main {
  max-width: 920px;
  margin: auto;
  padding: 18px 14px calc(42px + env(safe-area-inset-bottom));
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.hero-panel,
.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.hero-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(61, 217, 232, 0.12), rgba(139, 124, 246, 0.08)),
    var(--panel-strong);
}

.hero-panel::after {
  content: "";
  position: absolute;
  right: -70px;
  bottom: -110px;
  width: 260px;
  height: 260px;
  border: 1px solid rgba(61, 217, 232, 0.15);
  border-radius: 50%;
}

.hero-panel h2 {
  max-width: 600px;
  margin: 7px 0 8px;
  font-size: clamp(1.45rem, 4vw, 2.35rem);
  line-height: 1.08;
}

.hero-panel p {
  max-width: 660px;
  margin: 0;
  color: var(--muted);
}

.globe-mark {
  position: relative;
  z-index: 1;
  color: var(--cyan);
  font-size: 5rem;
  line-height: 1;
  text-shadow: 0 0 30px rgba(61, 217, 232, 0.35);
}

.eyebrow {
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
}

.card {
  padding: 17px;
  margin-bottom: 14px;
  background: var(--panel);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 1.12rem;
}

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

.section-heading h2 {
  margin: 5px 0 0;
}

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

.form-grid label {
  color: #c7d6e8;
  font-size: 0.8rem;
  font-weight: 750;
}

.form-grid select {
  width: 100%;
  margin-top: 6px;
  padding: 11px;
  border: 1px solid var(--line-bright);
  border-radius: 11px;
  background: #0c1424;
  color: var(--text);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 13px 0;
}

.button-row.compact {
  margin-bottom: 0;
}

.primary {
  color: #041117;
  border-color: var(--cyan);
  background: linear-gradient(135deg, #61eff5, #30c7df);
  box-shadow: 0 8px 26px rgba(61, 217, 232, 0.18);
}

.primary:hover {
  color: #031014;
  border-color: #8af6fb;
  background: linear-gradient(135deg, #85f7fb, #43d5ea);
}

.danger-subtle {
  color: #ff9ca5;
  border-color: rgba(255, 109, 122, 0.45);
}

.file-button input {
  display: none;
}

.notice {
  margin: 12px 0;
  padding: 13px 15px;
  border: 1px solid rgba(246, 196, 92, 0.28);
  border-left: 4px solid var(--amber);
  border-radius: 10px;
  background: rgba(76, 58, 19, 0.28);
  color: #f2dfb4;
  font-size: 0.88rem;
}

.hidden {
  display: none !important;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}

.stat {
  padding: 12px 8px;
  text-align: center;
  border: 1px solid rgba(61, 217, 232, 0.14);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(61, 217, 232, 0.08), rgba(12, 20, 36, 0.55));
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-bottom: 2px;
  color: var(--cyan);
  font-size: 1.3rem;
}

.quiz-top {
  display: flex;
  justify-content: space-between;
  margin: 3px 3px 10px;
  color: #bed0e5;
  font-weight: 750;
}

.question-card {
  text-align: center;
}

.prompt {
  max-width: 760px;
  margin: 3px auto 16px;
  line-height: 1.35;
}

.question-en,
.question-ja,
.question-entity {
  display: block;
}

.question-en {
  font-size: 1.32rem;
  font-weight: 850;
}

.question-ja {
  margin-top: 4px;
  color: #c8d8ea;
  font-size: 1rem;
  font-weight: 650;
}

.question-entity {
  margin-top: 13px;
  padding: 11px 14px;
  border: 1px solid rgba(61, 217, 232, 0.26);
  border-radius: 12px;
  background: rgba(61, 217, 232, 0.07);
}

.visual {
  min-height: 20px;
}

.bilingual {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
}

.bilingual .en {
  color: inherit;
}

.bilingual .ja {
  color: #aebfd3;
  font-size: 0.88em;
  font-weight: 620;
}

.question-entity .bilingual .en {
  font-size: 1.18rem;
  font-weight: 850;
}

.question-entity .bilingual .ja {
  font-size: 0.98rem;
}

.flag-frame {
  display: grid;
  place-items: center;
  min-height: 270px;
  margin: 8px auto 12px;
}

.flag-svg,
.flag-img {
  display: block;
  width: min(500px, 90vw);
  max-width: 100%;
  max-height: 310px;
  object-fit: contain;
  border: 1px solid var(--line-bright);
  border-radius: 9px;
  background: white;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.36);
  shape-rendering: geometricPrecision;
  text-rendering: geometricPrecision;
}

.flag-loading,
.flag-error {
  display: grid;
  place-items: center;
  width: min(500px, 90vw);
  min-height: 240px;
  border: 1px dashed var(--line-bright);
  border-radius: 9px;
  color: var(--muted);
  background: #0b1423;
  font-weight: 750;
}

.answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 760px;
  margin: 16px auto;
}

.answer {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  min-height: 70px;
  text-align: left;
  background: #111b2d;
}

.choice-letter {
  align-self: start;
  padding-top: 2px;
  color: var(--cyan);
  font-weight: 900;
}

.answer-label {
  align-items: flex-start;
}

.answer-label .en {
  font-weight: 800;
}

.answer-label .ja {
  margin-top: 2px;
  line-height: 1.35;
}

.answer.correct {
  color: #dfffee;
  border-color: var(--green);
  background: rgba(53, 209, 138, 0.18);
}

.answer.wrong {
  color: #ffe5e8;
  border-color: var(--red);
  background: rgba(255, 109, 122, 0.18);
}

.answer:disabled {
  color: inherit;
  opacity: 1;
}

.feedback {
  max-width: 760px;
  margin: 14px auto;
  padding: 15px;
  border-radius: 11px;
  text-align: left;
  background: #0e1728;
}

.feedback.good {
  border: 1px solid rgba(53, 209, 138, 0.38);
  border-left: 5px solid var(--green);
}

.feedback.bad {
  border: 1px solid rgba(255, 109, 122, 0.38);
  border-left: 5px solid var(--red);
}

.feedback h3 {
  margin: 0 0 9px;
}

.feedback p {
  margin: 6px 0;
  color: #c9d8e8;
}

.your-answer {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.fact-grid {
  display: grid;
  gap: 9px;
}

.answer-fact {
  display: grid;
  grid-template-columns: minmax(110px, 150px) 1fr;
  gap: 12px;
  align-items: start;
  padding: 8px 0;
}

.fact-label {
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.language-note {
  color: var(--muted) !important;
  font-size: 0.82rem;
}

.map-wrap {
  max-width: 840px;
  margin: auto;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  margin-bottom: 8px;
}

.map-control,
.map-reset {
  min-width: 43px;
  padding: 8px 11px;
}

.map-control {
  font-size: 1.25rem;
  line-height: 1;
}

.zoom-label {
  min-width: 66px;
  color: var(--cyan);
  font-size: 0.82rem;
  font-weight: 800;
}

.map-wrap svg {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 35%, rgba(61, 217, 232, 0.06), transparent 55%),
    #08111d;
  box-shadow: inset 0 0 45px rgba(0, 0, 0, 0.3);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.map-wrap svg.is-panning {
  cursor: grabbing;
}

.map-region {
  fill: #17243a;
  stroke: #5a7190;
  stroke-width: 0.72;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 100ms ease;
}

.map-region:hover,
.map-region.hovered {
  fill: #223858;
}

.map-region.target {
  fill: var(--amber);
  stroke: #fff0bd;
  stroke-width: 1.15;
}

.map-region.selected {
  fill: var(--red);
}

.map-region.correct {
  fill: var(--green);
  stroke: #dfffee;
  stroke-width: 1.1;
}

.map-region-hit {
  fill: transparent;
  stroke: transparent;
  stroke-width: 14;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
  cursor: pointer;
}

.map-wrap #mapCaption {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.77rem;
}

.big-score {
  margin: 15px;
  color: var(--cyan);
  font-size: 3rem;
  font-weight: 900;
}

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

@media (max-width: 620px) {
  .form-grid,
  .answers {
    grid-template-columns: 1fr;
  }

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

  .hero-panel {
    padding: 18px;
  }

  .globe-mark {
    display: none;
  }

  .question-en {
    font-size: 1.16rem;
  }

  .question-ja {
    font-size: 0.94rem;
  }

  .answer-fact {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .map-wrap svg {
    aspect-ratio: 4 / 3;
  }

  .map-toolbar {
    justify-content: center;
  }

  .button-row > * {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
