:root {
  color-scheme: light;
  --ink: #23323a;
  --muted: #60727c;
  --paper: #ffffff;
  --page: #f4fbff;
  --mint: #d8f3dc;
  --aqua: #bde0fe;
  --sun: #ffd166;
  --coral: #ef6f6c;
  --leaf: #2a9d8f;
  --plum: #6d597a;
  --line: #d6e3e8;
  --shadow: 0 18px 48px rgba(35, 50, 58, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  background:
    linear-gradient(90deg, rgba(189, 224, 254, 0.34) 0 12px, transparent 12px 32px),
    var(--page);
  color: var(--ink);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
  touch-action: manipulation;
}

.page-shell {
  width: min(1040px, calc(100% - 28px));
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 0 max(32px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 132px;
  padding: 16px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.photo-frame {
  width: 112px;
  height: 112px;
  border: 4px solid var(--sun);
  border-radius: 8px;
  overflow: hidden;
  background: var(--mint);
}

.photo-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.title-block {
  min-width: 0;
}

.title-block p {
  margin: 0 0 8px;
  color: var(--leaf);
  font-size: 1rem;
  font-weight: 800;
}

.title-block h1 {
  margin: 0;
  color: var(--ink);
  font-size: 2.35rem;
  line-height: 1.04;
}

.next-button,
.tool-button,
.choice-button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.next-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 178px;
  min-height: 58px;
  padding: 0 20px;
  border-radius: 8px;
  background: var(--coral);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 900;
  box-shadow: 0 8px 0 #bf4f4d;
}

.next-button span:first-child {
  font-size: 1.5rem;
  line-height: 1;
}

.next-button:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #bf4f4d;
}

.game {
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(300px, 0.95fr);
  gap: 18px;
  margin-top: 18px;
}

.animal-stage {
  min-height: 560px;
  padding: 18px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.game-counts {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
}

.animal-image {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin: 18px auto 16px;
  border: 3px solid #263238;
  border-radius: 8px;
  background: var(--aqua);
  object-fit: contain;
}

.feedback {
  min-height: 64px;
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  background: #f0f7f2;
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1.18;
  font-weight: 900;
  text-align: center;
}

.feedback.correct {
  background: var(--mint);
  color: #176f58;
}

.feedback.miss {
  background: #ffe8e6;
  color: #a63b38;
}

.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-content: start;
}

.choice-button {
  min-height: 112px;
  padding: 14px 12px;
  border-radius: 8px;
  background: var(--paper);
  border: 3px solid var(--line);
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 950;
  line-height: 1.1;
  overflow-wrap: anywhere;
  box-shadow: 0 7px 0 #c8d8de;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.choice-button:nth-child(1) {
  border-color: var(--leaf);
}

.choice-button:nth-child(2) {
  border-color: var(--sun);
}

.choice-button:nth-child(3) {
  border-color: var(--plum);
}

.choice-button:nth-child(4) {
  border-color: var(--coral);
}

.choice-button:hover,
.choice-button:focus-visible {
  transform: translateY(-2px);
  outline: 3px solid rgba(17, 138, 178, 0.25);
}

.choice-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #c8d8de;
}

.choice-button.correct-choice {
  background: var(--mint);
  border-color: var(--leaf);
}

.choice-button.wrong-choice {
  background: #ffe8e6;
  border-color: var(--coral);
}

.choice-button:disabled {
  cursor: default;
}

.toolbar {
  grid-column: 2;
  display: flex;
  gap: 14px;
  align-items: stretch;
}

.tool-button {
  min-height: 64px;
  padding: 0 20px;
  border-radius: 8px;
  background: var(--plum);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 900;
  box-shadow: 0 7px 0 #4e3f58;
}

.tool-button:first-child {
  width: 74px;
  padding: 0;
  font-size: 1.6rem;
  background: var(--leaf);
  box-shadow: 0 7px 0 #1d7068;
}

.reveal-button {
  flex: 1;
}

.tool-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 rgba(35, 50, 58, 0.35);
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .photo-frame {
    width: 94px;
    height: 94px;
  }

  .title-block h1 {
    font-size: 1.75rem;
  }

  .next-button {
    grid-column: 1 / -1;
    width: 100%;
  }

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

  .animal-stage {
    min-height: 0;
  }

  .toolbar {
    grid-column: 1;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: min(100% - 18px, 1040px);
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .topbar {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    min-height: 0;
  }

  .photo-frame {
    width: 82px;
    height: 82px;
  }

  .title-block p {
    margin-bottom: 5px;
    font-size: 0.86rem;
  }

  .title-block h1 {
    font-size: 1.45rem;
  }

  .animal-stage {
    padding: 12px;
  }

  .animal-image {
    margin: 12px auto;
  }

  .answer-grid {
    gap: 10px;
  }

  .choice-button {
    min-height: 86px;
    padding: 10px 8px;
    font-size: 1.02rem;
  }

  .feedback {
    min-height: 56px;
    padding: 12px;
    font-size: 1.2rem;
  }

  .tool-button {
    min-height: 58px;
  }
}

@media (max-width: 380px) {
  .title-block h1 {
    font-size: 1.28rem;
  }

  .choice-button {
    min-height: 78px;
    font-size: 0.95rem;
  }
}
