:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --ink: #1f2528;
  --muted: #6b7175;
  --line: #dad4cb;
  --surface: #fffdf8;
  --accent: #d94862;
  --accent-dark: #a92e45;
  --ok: #258c64;
  --bad: #c43f46;
  --shadow: 0 18px 52px rgba(61, 49, 39, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(217, 72, 98, 0.08), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(720px, calc(100% - 32px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  gap: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-self: start;
}

.kicker,
.meter,
.status {
  color: var(--muted);
}

.kicker,
.meter {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.meter {
  justify-self: end;
  align-self: end;
}

.quiz {
  display: grid;
  justify-items: center;
  gap: 16px;
}

.imageStage {
  position: relative;
  width: min(500px, 100%);
  height: clamp(360px, 58svh, 580px);
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 160ms ease, transform 160ms ease;
}

.imageStage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  padding: clamp(20px, 3vw, 30px);
  opacity: 1;
  transform: scale(1);
  transition: opacity 160ms ease, transform 180ms ease;
}

.shell[data-state="loading"] .imageStage img,
.shell[data-state="revealing"] .imageStage img {
  opacity: 0.1;
  transform: scale(0.985);
}

.shell[data-result="correct"] .imageStage {
  border-color: color-mix(in srgb, var(--ok), white 24%);
}

.shell[data-result="wrong"] .imageStage {
  border-color: color-mix(in srgb, var(--bad), white 18%);
}

.feedback {
  width: min(500px, 100%);
  min-height: 38px;
  padding: 10px 14px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink);
  font-weight: 700;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.shell[data-result] .feedback {
  opacity: 1;
  transform: translateY(0);
}

.answerRow {
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.answerRow input {
  min-width: 0;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255, 253, 248, 0.86);
  color: var(--ink);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.answerRow input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(217, 72, 98, 0.14);
}

.answerRow button,
.result button {
  height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--ink);
  color: #fffdf8;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.answerRow button:hover,
.result button:hover {
  background: var(--accent-dark);
}

.answerRow button:active,
.result button:active {
  transform: translateY(1px);
}

.answerRow button:disabled,
.answerRow input:disabled {
  cursor: wait;
  opacity: 0.62;
}

.status {
  min-height: 22px;
  margin: 0;
  text-align: center;
}

.result {
  width: min(520px, 100%);
  justify-self: center;
  padding: 28px 0 6px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.result h2 {
  margin: 6px 0 8px;
  font-size: clamp(2.6rem, 9vw, 5rem);
  line-height: 1;
  letter-spacing: 0;
}

.result p {
  margin: 0 0 18px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 720px);
    padding: 18px 0;
    gap: 12px;
  }

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

  .meter {
    justify-self: start;
  }

  .imageStage img {
    padding: 18px;
  }

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

  .answerRow button,
  .result button {
    width: 100%;
  }
}
