:root {
  --bg-a: #ff7f50;
  --bg-b: #ffd166;
  --bg-c: #4cc9f0;
  --ink: #1b1b2f;
  --white: #ffffff;
  --good: #1ea95c;
  --bad: #d7263d;
  --info: #5d5fef;
  --card-shadow: 0 10px 24px rgba(27, 27, 47, 0.18);
  --round: 22px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, Verdana, sans-serif;
  color: var(--ink);
  background: linear-gradient(120deg, var(--bg-a), var(--bg-b) 46%, var(--bg-c));
  overflow: hidden;
}

.app {
  position: relative;
  width: min(960px, 96vw);
  margin: 0 auto;
  min-height: 100%;
  max-height: 100dvh;
  max-height: 100svh;
  padding: 16px 0 24px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.bg-shapes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.22;
}

.shape {
  position: absolute;
  border-radius: 50%;
  animation: floaty 6s ease-in-out infinite;
}

.potion {
  width: 90px;
  height: 120px;
  left: 6%;
  top: 14%;
  background: radial-gradient(circle at 30% 30%, #ffffff66, #5d5fef);
  border-radius: 38% 38% 28% 28%;
}

.sparkle {
  width: 110px;
  height: 110px;
  right: 8%;
  top: 20%;
  background: conic-gradient(from 40deg, #fff4, #ffd166, #fff4);
  clip-path: polygon(50% 0%, 61% 38%, 100% 50%, 62% 61%, 50% 100%, 38% 62%, 0% 50%, 39% 38%);
}

.island {
  width: 140px;
  height: 80px;
  left: 16%;
  bottom: 14%;
  border-radius: 48% 52% 58% 42% / 64% 56% 44% 36%;
  background: linear-gradient(145deg, #28c76f, #20a366);
}

.bubble {
  width: 170px;
  height: 170px;
  right: 13%;
  bottom: 10%;
  background: radial-gradient(circle at 35% 35%, #ffffff77, #00b4d866);
}

.screen {
  display: none;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: block;
}

.start-screen {
  position: relative;
  overflow: hidden;
}

.card {
  background: #ffffffed;
  border-radius: var(--round);
  padding: 18px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(3px);
}

.start-card,
.end-card,
.pause-card {
  max-width: 760px;
  margin: 24px auto;
}

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

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

.end-card .controls-row {
  justify-content: center;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  line-height: 1.15;
}

.subtitle {
  font-size: 1.05rem;
  margin-bottom: 18px;
}

.controls-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.start-card .controls-row {
  justify-content: center;
}

.tools-row {
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
  font-size: 0.98rem;
  cursor: pointer;
  min-height: 46px;
  min-width: 120px;
  transition: transform 120ms ease, filter 120ms ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.04);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: var(--white);
}

.btn-secondary {
  background: #fff;
  color: #14304b;
  border: 2px solid #73d2de;
}

.btn-danger {
  background: #ffe8ec;
  border: 2px solid #f7768e;
  color: #8f1532;
}

.btn.big {
  font-size: 1.2rem;
  min-height: 56px;
  padding-inline: 26px;
}

.editor-panel {
  margin-top: 16px;
  border-top: 2px dashed #7fcde2;
  padding-top: 14px;
  text-align: left;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.editor-help {
  margin: 8px 0 14px;
}

.hero-editor {
  background: #ffffff;
  border: 2px solid #c2f2ff;
  border-radius: 16px;
  padding: 10px;
  margin-bottom: 12px;
}

.hero-editor h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.editor-panel .controls-row {
  justify-content: flex-start;
}

.editor-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.editor-item {
  background: #ffffff;
  border: 2px solid #c2f2ff;
  border-radius: 16px;
  padding: 10px;
}

.editor-item h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

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

.upload-tile {
  display: grid;
  gap: 6px;
  justify-items: start;
  background: #f6fbff;
  border: 2px dashed #9ddcf0;
  border-radius: 12px;
  padding: 8px;
}

.upload-preview {
  width: 72px;
  aspect-ratio: 3 / 4;
  height: auto;
  border-radius: 12px;
  object-fit: contain;
  object-position: center;
  background: #ffffff;
  border: 2px solid #8dd7f0;
}

.image-path-input {
  width: 100%;
  min-height: 40px;
  border: 2px solid #9ddcf0;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}

.hud {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.hud-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-self: end;
}

.hud-center-link {
  position: static;
  transform: none;
  justify-self: center;
}

.pill {
  background: #ffffffd9;
  border: 2px solid #6ac8db;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
}

.question-card {
  margin-top: 8px;
}

.question-card.question-advance {
  animation: questionAdvance 240ms ease;
}

.cards-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.option-card {
  position: relative;
  border: 3px solid #a7deef;
  border-radius: 18px;
  background: #ffffff;
  padding: 12px;
  text-align: center;
  min-height: 180px;
  transition: transform 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.option-card:hover,
.option-card:focus-visible {
  transform: scale(1.02);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12);
}

.option-card:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.option-image {
  width: 100%;
  max-width: 132px;
  aspect-ratio: 4 / 5;
  border-radius: 16px;
  object-fit: contain;
  object-position: center;
  background: #ffffff;
  display: block;
  margin: 0 auto 8px;
  border: 3px solid #d7f4ff;
}

.option-name {
  font-size: 1rem;
  font-weight: 900;
}

.option-label {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #ffffff;
  border: 2px solid #8cd4e8;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 900;
  padding: 2px 8px;
}

.badge {
  position: absolute;
  right: 8px;
  top: 8px;
  font-size: 0.74rem;
  font-weight: 900;
  color: #fff;
  border-radius: 999px;
  padding: 3px 8px;
}

.badge.correct {
  background: var(--good);
}

.badge.wrong {
  background: var(--bad);
}

.option-card.state-correct {
  border-color: var(--good);
}

.option-card.state-wrong {
  border-color: var(--bad);
}

.option-card.flash-good {
  animation: pulseGood 460ms ease-in-out 3;
}

.option-card.flash-bad {
  animation: pulseBad 460ms ease-in-out 3;
}

.result-banner {
  margin: 12px 0;
  text-align: center;
  font-size: 1.24rem;
  font-weight: 900;
  color: #fff;
  padding: 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff4d6d, #ff758f);
  box-shadow: var(--card-shadow);
}

.explanation {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.final-score {
  font-size: 1.2rem;
  font-weight: 900;
}

.final-mood-image {
  width: min(78vw, 300px);
  aspect-ratio: 4 / 5;
  display: block;
  margin: 8px auto 10px;
  border-radius: 16px;
  border: 3px solid #9ddcf0;
  object-fit: contain;
  object-position: center;
  background: #ffffffd9;
}

.final-message {
  font-size: 1.05rem;
}

.hero-slot-section {
  max-width: 760px;
  margin: 10px auto 0;
}

.hero-image {
  width: 100%;
  aspect-ratio: 3 / 2;
  display: block;
  border-radius: var(--round);
  border: 3px solid #9ddcf0;
  object-fit: contain;
  object-position: center;
  background: #ffffffd9;
  box-shadow: var(--card-shadow);
}

.start-credit {
  text-align: center;
  margin: 12px auto 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: #11445f;
  max-width: 760px;
  opacity: 0.92;
}

.start-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.mini {
  position: absolute;
  display: block;
  opacity: 0.35;
  animation: driftSoft 9s ease-in-out infinite;
}

.mini.bubble-a,
.mini.bubble-b,
.mini.bubble-c {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffffb8, #8bd8f05e);
}

.mini.bubble-a {
  width: 18px;
  height: 18px;
  left: 11%;
  top: 26%;
}

.mini.bubble-b {
  width: 13px;
  height: 13px;
  right: 14%;
  top: 18%;
  animation-delay: 1.1s;
}

.mini.bubble-c {
  width: 16px;
  height: 16px;
  right: 20%;
  bottom: 20%;
  animation-delay: 2.4s;
}

.mini.star-a,
.mini.star-b {
  width: 15px;
  height: 15px;
  background: #fff7a2cc;
  clip-path: polygon(50% 0%, 61% 38%, 100% 50%, 62% 61%, 50% 100%, 38% 62%, 0% 50%, 39% 38%);
}

.mini.star-a {
  left: 20%;
  top: 14%;
  animation-delay: 1.7s;
}

.mini.star-b {
  right: 27%;
  bottom: 28%;
  animation-delay: 3s;
}

.mini.drop-a,
.mini.drop-b {
  width: 12px;
  height: 16px;
  background: linear-gradient(180deg, #9fe8ffcc, #57b5ef88);
  border-radius: 55% 55% 70% 70%;
  clip-path: polygon(50% 0%, 100% 38%, 84% 100%, 16% 100%, 0% 38%);
}

.mini.drop-a {
  left: 29%;
  bottom: 24%;
  animation-delay: 2.1s;
}

.mini.drop-b {
  right: 10%;
  top: 34%;
  animation-delay: 0.8s;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 34, 0.45);
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 20px;
}

.pause-card {
  max-width: 420px;
  text-align: center;
}

@keyframes pulseGood {
  0% {
    box-shadow: 0 0 0 0 rgba(30, 169, 92, 0.6);
  }
  60% {
    box-shadow: 0 0 0 10px rgba(30, 169, 92, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(30, 169, 92, 0);
  }
}

@keyframes pulseBad {
  0% {
    box-shadow: 0 0 0 0 rgba(215, 38, 61, 0.65);
  }
  60% {
    box-shadow: 0 0 0 10px rgba(215, 38, 61, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(215, 38, 61, 0);
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

@keyframes driftSoft {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes questionAdvance {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@media (max-width: 700px) {
  .app {
    width: min(96vw, 760px);
  }

  .hud {
    display: flex;
    flex-wrap: wrap;
  }

  .cards-grid {
    gap: 10px;
  }

  .option-card {
    min-height: 160px;
    padding: 10px;
  }

  .btn {
    width: 100%;
  }

  .tools-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .tools-row .btn {
    width: 100%;
  }

  .hud-actions {
    width: 100%;
    margin-left: 0;
  }

  .hud-actions .btn {
    width: auto;
    flex: 1;
  }

  .hud-center-link {
    position: static;
    transform: none;
    width: 100%;
    order: 3;
  }

  .editor-options {
    grid-template-columns: 1fr;
  }
}
