:root {
  color-scheme: light;
  --ink: #253047;
  --muted: #617084;
  --paper: #fffdf7;
  --panel: #ffffff;
  --sky: #cfe9ff;
  --leaf: #6ec28f;
  --sun: #ffd166;
  --rose: #ff8c94;
  --blue: #4f8cff;
  --shadow: 0 22px 60px rgba(40, 60, 90, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 16%, rgba(255, 209, 102, 0.55) 0 9rem, transparent 9.1rem),
    radial-gradient(circle at 86% 18%, rgba(110, 194, 143, 0.45) 0 7rem, transparent 7.1rem),
    linear-gradient(135deg, #e7f5ff 0%, #fff8d9 54%, #ffe5df 100%);
}

button {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.quiz-panel {
  width: min(920px, 100%);
  background: rgba(255, 255, 255, 0.86);
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 36px);
}

.top-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: clamp(0.95rem, 2.4vw, 1.2rem);
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4.8rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.score-card {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  min-width: 92px;
  min-height: 92px;
  padding: 10px;
  border-radius: 24px;
  background: var(--sun);
  border: 3px solid #fff2b6;
  box-shadow: inset 0 -8px 0 rgba(175, 119, 0, 0.12);
}

.score-label {
  font-size: 0.95rem;
  font-weight: 900;
}

.score-card strong {
  font-size: 2.2rem;
  line-height: 1;
}

.stage {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 20px 0;
  padding: clamp(18px, 4vw, 32px);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(207, 233, 255, 0.92), rgba(255, 253, 247, 0.92));
  overflow: hidden;
}

.stage::before,
.stage::after {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255, 140, 148, 0.28);
}

.stage::before {
  left: -34px;
  bottom: -42px;
}

.stage::after {
  right: -30px;
  top: -36px;
  background: rgba(110, 194, 143, 0.28);
}

.sparkle {
  position: absolute;
  top: 20px;
  left: 24px;
  color: #f2a900;
  font-size: 2.2rem;
  transform: rotate(-16deg);
}

.flag {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(62vw, 330px);
  aspect-ratio: 1.35;
  border-radius: 22px;
  background: var(--paper);
  border: 5px solid #ffffff;
  box-shadow: 0 18px 30px rgba(29, 59, 99, 0.18);
  font-size: clamp(6.2rem, 25vw, 13rem);
  line-height: 1;
}

.prompt {
  position: relative;
  z-index: 1;
  margin: 8px 0 0;
  font-size: clamp(1.25rem, 4.5vw, 2rem);
  font-weight: 900;
}

.level-panel {
  margin: 0 0 16px;
}

.level-panel h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: clamp(1rem, 3vw, 1.25rem);
  letter-spacing: 0;
}

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

.level-button {
  display: grid;
  gap: 3px;
  min-height: 66px;
  border: 0;
  border-radius: 18px;
  padding: 10px 8px;
  color: var(--ink);
  background: #f4f8ff;
  box-shadow: 0 6px 0 #c9d6e5;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.level-button:hover,
.level-button:focus-visible {
  transform: translateY(-2px);
  outline: 4px solid rgba(79, 140, 255, 0.24);
}

.level-button[aria-pressed="true"] {
  background: #dff8e8;
  box-shadow: 0 6px 0 #93cfa9;
}

.level-name {
  font-size: clamp(1rem, 3vw, 1.35rem);
  font-weight: 900;
}

.level-count {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 900;
}

.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.choice {
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: center;
  justify-items: center;
  gap: 8px;
  min-height: 124px;
  border: 0;
  border-radius: 22px;
  padding: 12px 10px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 8px 0 rgba(37, 48, 71, 0.12), 0 16px 26px rgba(37, 48, 71, 0.11);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.choice:hover,
.choice:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 11px 0 rgba(37, 48, 71, 0.12), 0 20px 28px rgba(37, 48, 71, 0.14);
  outline: 4px solid rgba(79, 140, 255, 0.28);
}

.choice:disabled {
  cursor: default;
  opacity: 0.88;
}

.choice.correct {
  background: #dff8e8;
  outline: 4px solid rgba(110, 194, 143, 0.55);
}

.choice.wrong {
  background: #ffe1df;
  outline: 4px solid rgba(255, 140, 148, 0.5);
}

.choice-number {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--sun);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 900;
  box-shadow: inset 0 -5px 0 rgba(175, 119, 0, 0.14);
}

.choice-flag {
  display: none;
  font-size: clamp(2.5rem, 9vw, 4.2rem);
  line-height: 1;
}

.choices.answered .choice-number {
  display: none;
}

.choices.answered .choice-flag {
  display: block;
}

.choice-name {
  display: block;
  font-size: clamp(1rem, 3vw, 1.45rem);
  font-weight: 900;
  line-height: 1.25;
}

.result {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 62px;
  margin-top: 18px;
  padding: 10px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
}

.result span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  font-size: 1.5rem;
}

.result p {
  margin: 0;
  font-size: clamp(1rem, 3.5vw, 1.5rem);
  font-weight: 900;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.next-button,
.quiet-button {
  min-width: 130px;
  min-height: 54px;
  border: 0;
  border-radius: 18px;
  padding: 10px 18px;
  font-weight: 900;
  cursor: pointer;
}

.next-button {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 7px 0 #2f62bd;
}

.quiet-button {
  background: #eef4fa;
  color: var(--ink);
  box-shadow: 0 7px 0 #c9d6e5;
}

.next-button:active,
.quiet-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 rgba(37, 48, 71, 0.28);
}

@media (max-width: 680px) {
  .quiz-panel {
    border-radius: 22px;
  }

  .top-row {
    align-items: center;
  }

  .score-card {
    min-width: 76px;
    min-height: 76px;
    border-radius: 20px;
  }

  .choices {
    grid-template-columns: 1fr;
  }

  .choice {
    display: grid;
    grid-template-columns: 54px 1fr;
    grid-template-rows: 1fr;
    align-items: center;
    justify-items: start;
    text-align: left;
    min-height: 82px;
    padding: 10px 16px;
  }

  .choice-number {
    justify-self: center;
  }

  .choice-flag {
    justify-self: center;
    font-size: 2.8rem;
  }

  .controls {
    flex-direction: column;
  }

  .next-button,
  .quiet-button {
    width: 100%;
  }
}
