:root {
  --bg: #faf9f6;
  --card: #ffffff;
  --text: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --lavender: #c7d2fe;
  --mint: #a7f3d0;
  --coral: #fecdd3;
  --sun: #fde68a;
  --blue: #bae6fd;
  --hot: #f9a8d4;
  --ink: #1e293b;
  --shadow: 0 22px 0 rgba(51, 65, 85, 0.08), 0 24px 55px rgba(51, 65, 85, 0.16);
  font-family: Inter, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 13%, rgba(254, 205, 211, 0.68) 0 72px, transparent 74px),
    radial-gradient(circle at 88% 18%, rgba(167, 243, 208, 0.7) 0 88px, transparent 90px),
    radial-gradient(circle at 72% 88%, rgba(199, 210, 254, 0.7) 0 104px, transparent 106px),
    linear-gradient(135deg, rgba(249, 168, 212, 0.24), transparent 31%),
    linear-gradient(225deg, rgba(253, 230, 138, 0.34), transparent 30%),
    var(--bg);
  background-attachment: fixed;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--sun), var(--coral) 48%, var(--lavender));
  box-shadow: 0 8px 0 rgba(51, 65, 85, 0.15), var(--shadow);
  overflow: hidden;
  transform: rotate(-4deg);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: 0;
  font-family: "Arial Rounded MT Bold", "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic UI", sans-serif;
  font-weight: 950;
  color: #7c3aed;
  text-shadow: 2px 2px 0 #fff, 4px 4px 0 var(--coral);
  transform: rotate(-1deg);
}

.brand p {
  color: var(--muted);
  font-size: 0.92rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid rgba(51, 65, 85, 0.12);
  border-radius: 999px;
  background: linear-gradient(90deg, #fff, #fff7ed);
  color: var(--ink);
  box-shadow: 0 7px 0 rgba(199, 210, 254, 0.35);
  white-space: nowrap;
  font-weight: 900;
}

.hero-grid {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 22px;
  align-items: start;
}

.panel,
.quiz-card,
.modal-card,
.result-card,
.dashboard-panel {
  border: 1px solid rgba(51, 65, 85, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
  border-top: 8px solid var(--coral);
}

.panel h2,
.quiz-card h2,
.dashboard-panel h2 {
  margin: 0 0 14px;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field label {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: linear-gradient(180deg, #fff, #f8fafc);
  color: var(--text);
  outline: 0;
}

.field input:focus,
.field select:focus {
  border-color: var(--hot);
  box-shadow: 0 0 0 4px rgba(249, 168, 212, 0.22);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.segmented button,
.option-button,
.primary,
.secondary,
.icon-btn {
  border: 0;
  border-radius: 8px;
  color: var(--text);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.segmented button {
  min-height: 44px;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 900;
}

.segmented button.active {
  background: linear-gradient(135deg, var(--lavender), var(--coral));
  box-shadow: 0 8px 0 rgba(129, 140, 248, 0.2);
}

.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 16px;
  font-weight: 800;
}

.primary {
  background: linear-gradient(135deg, var(--ink), #475569);
  color: #fff;
  box-shadow: 0 7px 0 rgba(15, 23, 42, 0.24);
}

.secondary {
  background: linear-gradient(135deg, #fff, #fef3c7);
  border: 1px solid var(--line);
  box-shadow: 0 6px 0 rgba(51, 65, 85, 0.09);
}

.wide {
  width: 100%;
}

.primary:hover,
.secondary:hover,
.option-button:hover,
.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(51, 65, 85, 0.12);
}

.quiz-card {
  position: relative;
  min-height: 560px;
  padding: 24px;
  overflow: hidden;
  border-top: 8px solid var(--lavender);
}

.quiz-card::before,
.result-card::before {
  content: "";
  position: absolute;
  inset: 10px 10px auto auto;
  width: 72px;
  height: 72px;
  background:
    linear-gradient(90deg, transparent 42%, rgba(51, 65, 85, 0.15) 43% 57%, transparent 58%),
    linear-gradient(transparent 42%, rgba(51, 65, 85, 0.15) 43% 57%, transparent 58%);
  opacity: 0.7;
  transform: rotate(12deg);
  pointer-events: none;
}

.quiz-visual {
  height: 220px;
  margin: -8px -8px 18px;
  border-radius: 8px;
  background: url("/assets/hero-mascot.png") center/cover;
  box-shadow: inset 0 -12px 0 rgba(255, 255, 255, 0.35);
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--hot), var(--lavender), var(--mint), var(--sun), var(--coral));
  transition: width 0.28s ease;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.question {
  margin: 12px 0 18px;
  font-size: clamp(1.42rem, 4vw, 2.2rem);
  line-height: 1.25;
  letter-spacing: 0;
  color: var(--ink);
  text-shadow: 2px 2px 0 rgba(254, 205, 211, 0.55);
}

.options {
  display: grid;
  gap: 12px;
}

.option-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 62px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #fff, #f8fafc);
  text-align: left;
  overflow: hidden;
  box-shadow: 0 7px 0 rgba(51, 65, 85, 0.06);
}

.option-button::after {
  content: "";
  position: absolute;
  inset: auto auto -24px -24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(249, 168, 212, 0.32);
  transform: scale(0);
  transition: transform 0.2s ease;
}

.option-button:active::after {
  transform: scale(5.5);
}

.option-button.selected {
  animation: bounce 0.28s ease;
}

.option-button.correct {
  background: #ecfdf5;
  border-color: #86efac;
  box-shadow: 0 0 0 4px rgba(167, 243, 208, 0.5), 0 10px 0 rgba(16, 185, 129, 0.12);
}

.option-button.wrong {
  background: #fff1f2;
  border-color: #fda4af;
  animation: shake 0.28s ease;
  box-shadow: 0 0 0 4px rgba(254, 205, 211, 0.42), 0 10px 0 rgba(244, 63, 94, 0.1);
}

.option-label {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--sun), #fff);
  font-weight: 900;
  box-shadow: inset 0 -3px 0 rgba(51, 65, 85, 0.08);
}

.choice-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.status-chip {
  flex: 0 0 auto;
  font-weight: 900;
}

.share-grid,
.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.copy-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff7ed, #fdf2f8);
  color: var(--text);
  border: 1px solid rgba(249, 168, 212, 0.28);
  overflow-wrap: anywhere;
}

.fixed-quiz-header {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 12px 0 18px;
  background: linear-gradient(180deg, var(--bg) 76%, rgba(250, 249, 246, 0));
}

.quiz-header-inner {
  padding: 14px 16px 8px;
  border: 1px solid rgba(51, 65, 85, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 0 rgba(199, 210, 254, 0.2), 0 12px 28px rgba(51, 65, 85, 0.08);
  backdrop-filter: blur(6px);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(51, 65, 85, 0.34);
  backdrop-filter: blur(5px);
}

.modal-card {
  width: min(420px, 100%);
  padding: 22px;
}

.feedback-pop {
  margin: 16px 0 0;
  padding: 13px 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fdf2f8, #ecfeff);
  color: var(--text);
  border: 1px solid rgba(249, 168, 212, 0.28);
}

.ad-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 728px);
  min-height: 150px;
  margin: 22px auto;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  color: #64748b;
  background:
    repeating-linear-gradient(-45deg, rgba(199, 210, 254, 0.18) 0 10px, rgba(254, 205, 211, 0.18) 10px 20px),
    rgba(255, 255, 255, 0.74);
  font-size: 0.88rem;
  font-weight: 900;
  text-align: center;
  overflow: hidden;
}

.ad-slot picture,
.ad-slot img {
  display: block;
  width: 100%;
  height: 100%;
}

.ad-slot img {
  object-fit: cover;
}

.ad-label {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #64748b;
  font-size: 0.72rem;
  line-height: 1;
  backdrop-filter: blur(4px);
}

.break-screen {
  display: grid;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.result-card {
  position: relative;
  padding: 28px;
  text-align: center;
  border-top: 8px solid var(--mint);
}

.score {
  margin: 10px 0 4px;
  font-size: clamp(4rem, 16vw, 8rem);
  line-height: 0.95;
  font-weight: 950;
  letter-spacing: 0;
  color: var(--ink);
  text-shadow: 5px 5px 0 var(--coral), 9px 9px 0 var(--lavender);
}

.title-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--sun), var(--coral));
  font-weight: 900;
  box-shadow: 0 7px 0 rgba(51, 65, 85, 0.12);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 22px;
}

.list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list li {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #fff, #f8fafc);
  box-shadow: 0 6px 0 rgba(51, 65, 85, 0.05);
}

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

.metric {
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff, #fef3c7);
  border: 1px solid var(--line);
  box-shadow: 0 8px 0 rgba(51, 65, 85, 0.07);
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 1.8rem;
}

.dashboard-panel {
  padding: 22px;
  margin-top: 18px;
}

.leaderboard {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard th,
.leaderboard td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(360px, calc(100% - 36px));
  padding: 13px 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--ink), #be185d);
  color: #fff;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.confetti {
  position: fixed;
  top: -12px;
  width: 9px;
  height: 14px;
  z-index: 45;
  border-radius: 3px;
  animation: fall 1s linear forwards;
}

.empty {
  padding: 42px 20px;
  text-align: center;
}

@keyframes bounce {
  45% {
    transform: scale(1.04) rotate(-0.7deg);
  }
}

@keyframes shake {
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}

@keyframes fall {
  to {
    transform: translateY(105vh) rotate(560deg);
    opacity: 0;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 22px, 680px);
    padding-top: 18px;
  }

  .topbar,
  .hero-grid,
  .two-col,
  .dashboard-grid,
  .share-grid,
  .actions {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .pill {
    justify-self: start;
  }

  .quiz-card {
    min-height: auto;
    padding: 18px;
  }

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

  .question {
    font-size: 1.45rem;
  }
}

@media (max-width: 799px) and (min-width: 500px) {
  .ad-slot {
    width: min(100%, 468px);
    min-height: 110px;
  }
}

@media (max-width: 499px) {
  .ad-slot {
    width: min(100%, 320px);
    min-height: 140px;
  }
}
