:root {
  --ink: #172c35;
  --muted: #728188;
  --cream: #f6f1e7;
  --card: #fffdf8;
  --green: #a7d930;
  --green-dark: #88bb16;
  --coral: #ff735b;
  --line: rgba(23, 44, 53, 0.13);
  --shadow: 0 26px 70px rgba(35, 46, 43, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 20%, rgba(255, 115, 91, 0.08), transparent 24%),
    radial-gradient(circle at 84% 62%, rgba(167, 217, 48, 0.12), transparent 27%),
    var(--cream);
  font-family: "Noto Sans JP", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(23, 44, 53, 0.1) 0.7px, transparent 0.7px);
  background-size: 21px 21px;
  opacity: 0.22;
  content: "";
  pointer-events: none;
}

button,
a {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.site-header {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.brand-mark {
  width: 29px;
  height: 29px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 4px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  transform: rotate(-9deg);
}

.brand-mark span {
  border-radius: 50% 50% 45% 55%;
  background: var(--coral);
}

.brand-mark span:nth-child(2),
.brand-mark span:nth-child(3) {
  background: var(--green);
}

.header-meta {
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(167, 217, 48, 0.17);
}

main {
  flex: 1;
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: clamp(64px, 9vw, 135px);
  align-items: center;
  padding: 54px 0 60px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  color: var(--coral);
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.eyebrow::before {
  width: 33px;
  height: 2px;
  background: var(--coral);
  content: "";
}

h1 {
  margin: 0;
  font-size: clamp(42px, 4.2vw, 64px);
  line-height: 1.34;
  letter-spacing: -0.055em;
}

h1 em {
  position: relative;
  z-index: 0;
  color: var(--ink);
  font-style: normal;
}

h1 em::after {
  position: absolute;
  right: -4px;
  bottom: 4px;
  left: -3px;
  z-index: -1;
  height: 16px;
  border-radius: 2px 7px 3px 5px;
  background: var(--green);
  content: "";
  transform: rotate(-1deg);
}

.intro-copy {
  margin: 30px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 2;
}

.quiz-wrap {
  position: relative;
}

.quiz-card {
  position: relative;
  z-index: 1;
  padding: 28px;
  overflow: hidden;
  border: 1px solid rgba(23, 44, 53, 0.08);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.quiz-card::before {
  position: absolute;
  top: -26px;
  right: -20px;
  width: 110px;
  height: 80px;
  border: 14px solid rgba(167, 217, 48, 0.12);
  border-radius: 50%;
  content: "";
  transform: rotate(-28deg);
}

.card-topline {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  color: var(--muted);
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.difficulty {
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: #f0f5e5;
  color: #677453;
  letter-spacing: 0.09em;
}

.difficulty i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-dark);
}

.flag-stage {
  position: relative;
  min-height: 226px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 17px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.28)),
    repeating-linear-gradient(135deg, #eff0e6 0, #eff0e6 1px, transparent 1px, transparent 12px),
    #f7f5ee;
}

.flag-stage::before,
.flag-stage::after {
  position: absolute;
  border: 1px solid rgba(23, 44, 53, 0.12);
  border-radius: 50%;
  content: "";
}

.flag-stage::before {
  width: 210px;
  height: 210px;
}

.flag-stage::after {
  width: 285px;
  height: 285px;
}

.flag-frame {
  position: relative;
  z-index: 2;
  width: min(282px, 73%);
  aspect-ratio: 3 / 2;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 14px 28px rgba(24, 40, 44, 0.17), 0 0 0 1px rgba(23, 44, 53, 0.1);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s;
}

.flag-frame.is-changing {
  opacity: 0;
  transform: translateY(8px) scale(0.96);
}

#flagImage {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.flag-fallback {
  display: none;
  font-size: 108px;
  line-height: 1;
}

.flag-fallback.is-visible {
  display: block;
}

.decor {
  position: absolute;
  z-index: 1;
  color: var(--coral);
  font-family: "DM Sans", sans-serif;
}

.decor-one {
  top: 28px;
  left: 32px;
  font-size: 20px;
  transform: rotate(12deg);
}

.decor-two {
  right: 29px;
  bottom: 26px;
  font-size: 34px;
}

.answer-area {
  min-height: 90px;
  display: grid;
  place-items: center;
  padding: 15px 0 13px;
  text-align: center;
}

.answer-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.answer-name {
  display: none;
  opacity: 0;
  transform: translateY(6px);
}

.answer-name.is-visible {
  display: flex;
  flex-direction: column;
  animation: reveal 0.35s ease forwards;
}

.answer-name span {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.answer-name small {
  margin-top: 1px;
  color: var(--coral);
  font-family: "DM Sans", sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.button-row {
  display: grid;
  grid-template-columns: minmax(116px, 0.44fr) 1fr;
  gap: 10px;
}

.back-button {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(23, 44, 53, 0.15);
  border-radius: 13px;
  background: #f3f0e8;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.back-button:not(:disabled):hover {
  border-color: rgba(23, 44, 53, 0.3);
  background: #ebe6db;
  transform: translateY(-2px);
}

.back-button:disabled {
  color: #a5adaf;
  cursor: not-allowed;
  opacity: 0.55;
}

.back-button:focus-visible {
  outline: 3px solid rgba(255, 115, 91, 0.45);
  outline-offset: 3px;
}

.back-icon {
  font-family: "DM Sans", sans-serif;
  font-size: 18px;
  line-height: 1;
  transition: transform 0.2s;
}

.back-button:not(:disabled):hover .back-icon {
  transform: translateX(-3px);
}

.primary-button {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border: 0;
  border-radius: 13px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 9px 18px rgba(23, 44, 53, 0.18);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.primary-button:hover {
  background: #23444f;
  box-shadow: 0 12px 23px rgba(23, 44, 53, 0.22);
  transform: translateY(-2px);
}

.primary-button:active {
  transform: translateY(0);
}

.primary-button:focus-visible {
  outline: 3px solid rgba(255, 115, 91, 0.45);
  outline-offset: 3px;
}

.button-icon {
  font-family: "DM Sans", sans-serif;
  font-size: 20px;
  line-height: 1;
  transition: transform 0.2s;
}

.primary-button:hover .button-icon {
  transform: translateX(4px);
}

.side-note {
  position: absolute;
  right: -42px;
  bottom: -56px;
  z-index: 0;
  width: 245px;
  display: flex;
  gap: 16px;
  padding: 20px 25px 19px 30px;
  border-radius: 0 0 18px 18px;
  background: var(--coral);
  color: #fff;
  transform: rotate(-2deg);
}

.note-number {
  color: rgba(255, 255, 255, 0.55);
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  font-weight: 700;
}

.side-note strong {
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
}

.side-note p {
  margin: 6px 0 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.65;
}

footer {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 20px;
  border-top: 1px solid var(--line);
  color: #839096;
  font-family: "DM Sans", sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

footer p {
  margin: 0;
  white-space: nowrap;
}

.footer-line {
  width: 100%;
  height: 1px;
  background: var(--line);
}

@media (max-width: 900px) {
  .page-shell {
    width: min(680px, calc(100% - 38px));
  }

  main {
    grid-template-columns: 1fr;
    gap: 42px;
    padding: 46px 0 98px;
  }

  .intro {
    text-align: center;
  }

  .eyebrow {
    justify-content: center;
  }

  h1 {
    font-size: clamp(40px, 10vw, 58px);
  }

  .side-note {
    right: 18px;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 24px, 480px);
  }

  .site-header {
    height: 74px;
  }

  .header-meta span:last-child {
    display: none;
  }

  main {
    padding-top: 36px;
  }

  .eyebrow {
    margin-bottom: 15px;
  }

  h1 {
    font-size: 40px;
  }

  .intro-copy {
    margin-top: 22px;
    font-size: 13px;
  }

  .desktop-only {
    display: none;
  }

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

  .flag-stage {
    min-height: 190px;
  }

  .flag-frame {
    width: 76%;
  }

  .answer-name span {
    font-size: 22px;
  }

  .side-note {
    right: 10px;
    bottom: -61px;
    width: 225px;
  }

  footer {
    gap: 12px;
  }

  footer p:last-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
