:root {
  color-scheme: light;
  --ink: #1f2a44;
  --muted: #52627a;
  --paper: #fff3cf;
  --panel: #ffffff;
  --line: #b9c7dc;
  --accent: #1f7af5;
  --accent-strong: #1452b8;
  --mint: #18b97d;
  --sun: #ff9f1c;
  --rose: #f25f7a;
  --gold: #ffd43b;
  --violet: #8b5cf6;
  --aqua: #22d3ee;
  --shadow: 0 18px 50px rgba(31, 42, 68, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    "Yu Gothic", "Hiragino Kaku Gothic ProN", "Meiryo", system-ui, sans-serif;
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 212, 59, 0.28), transparent 22%),
    radial-gradient(circle at 90% 12%, rgba(34, 211, 238, 0.18), transparent 22%),
    linear-gradient(90deg, rgba(31, 122, 245, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(31, 122, 245, 0.12) 1px, transparent 1px),
    var(--paper);
  background-size: 36px 36px;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-nav {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: blur(10px);
}

.home-button {
  min-height: 40px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  padding: 0 16px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(37, 48, 68, 0.08);
}

.home-button {
  color: var(--accent-strong);
}

.home-button:hover,
.home-card:hover,
.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.hero-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(220px, 360px);
  align-items: center;
  min-height: min(680px, calc(100vh - 96px));
  gap: 30px;
  padding: clamp(24px, 5vw, 56px);
  border: 2px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 212, 59, 0.38), transparent 32%),
    radial-gradient(circle at 84% 18%, rgba(34, 211, 238, 0.22), transparent 26%),
    linear-gradient(135deg, #eaf6ff, #fff0ba 58%, #e9fff4);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-panel.has-quest-bg {
  border-color: rgba(255, 255, 255, 0.82);
  background:
    linear-gradient(90deg, rgba(255, 250, 241, 0.94), rgba(255, 250, 241, 0.78) 48%, rgba(255, 250, 241, 0.42)),
    var(--home-bg),
    linear-gradient(135deg, #eaf6ff, #fff0ba 58%, #e9fff4);
  background-position: center;
  background-size: cover;
}

.hero-panel.has-quest-bg.frame-sparkle {
  box-shadow:
    var(--shadow),
    0 0 0 5px rgba(255, 255, 255, 0.7),
    0 0 34px rgba(105, 185, 255, 0.36);
}

.hero-panel.has-quest-bg.frame-gold {
  border-color: #ffd43b;
  box-shadow:
    var(--shadow),
    0 0 0 5px rgba(255, 244, 190, 0.84),
    0 0 42px rgba(255, 184, 77, 0.44);
}

.hero-panel::after {
  content: "★";
  position: absolute;
  right: 26px;
  top: 20px;
  color: rgba(255, 159, 28, 0.5);
  font-size: 2.5rem;
  text-shadow:
    -80px 38px 0 rgba(34, 211, 238, 0.32),
    -170px -8px 0 rgba(139, 92, 246, 0.24),
    -250px 72px 0 rgba(255, 212, 59, 0.34);
  pointer-events: none;
}

.hero-copy h1 {
  max-width: 620px;
  margin-bottom: 16px;
  font-size: clamp(2.4rem, 5vw, 4.8rem);
}

.hero-copy h1 span {
  display: block;
}

.hero-copy p:not(.eyebrow) {
  max-width: 540px;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.7;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.home-dashboard {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.home-dashboard-simple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.daily-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  align-content: stretch;
  gap: 12px;
  min-height: 190px;
  border: 2px solid #ffb020;
  border-radius: 8px;
  background:
    radial-gradient(circle at 90% 10%, rgba(255, 212, 59, 0.28), transparent 32%),
    linear-gradient(180deg, rgba(255, 239, 180, 0.98), rgba(255, 255, 255, 0.96));
  padding: 18px;
  box-shadow: 0 10px 26px rgba(37, 48, 68, 0.08);
}

.daily-card .ghost-button {
  align-self: end;
}

.daily-card.soft {
  border-color: #34c38f;
  background:
    radial-gradient(circle at 90% 10%, rgba(52, 195, 143, 0.22), transparent 32%),
    linear-gradient(180deg, rgba(213, 255, 235, 0.98), rgba(255, 255, 255, 0.96));
}

.daily-card.reward-preview {
  border-color: #6ba8ff;
  background:
    radial-gradient(circle at 90% 10%, rgba(139, 92, 246, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(222, 237, 255, 0.98), rgba(255, 255, 255, 0.96));
}

.daily-card.journey-card {
  border-color: #f79009;
  background:
    radial-gradient(circle at 88% 12%, rgba(255, 212, 59, 0.34), transparent 34%),
    linear-gradient(180deg, rgba(255, 244, 214, 0.98), rgba(255, 255, 255, 0.96));
}

.journey-progress span {
  background: linear-gradient(90deg, #f79009, #ffd43b, #34c38f);
}

.daily-card h2 {
  margin: 0;
  font-size: 1.35rem;
}

.daily-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.5;
}

.home-progress {
  height: 16px;
  overflow: hidden;
  border: 2px solid #ffd88f;
  border-radius: 999px;
  background: #fffaf1;
}

.home-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffb84d, #34c38f);
  transition: width 240ms ease;
}

.hero-teacher {
  display: grid;
  place-items: center;
  min-height: 300px;
}

.character-avatar {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition:
    transform 180ms ease,
    filter 180ms ease;
}

.character-avatar-main {
  width: min(320px, 78vw);
  filter: drop-shadow(0 22px 34px rgba(37, 48, 68, 0.18));
  transform: rotate(-2deg);
}

.character-avatar-main[data-mood="happy"] {
  transform: translateY(-6px) rotate(1deg) scale(1.03);
}

.character-avatar-main[data-mood="thinking"] {
  transform: translateY(2px) rotate(-5deg) scale(0.98);
}

.character-avatar-main[data-mood="cheer"] {
  transform: translateY(-2px) rotate(-1deg) scale(1.01);
}

.pencil-pal {
  position: relative;
  width: 190px;
  height: 292px;
  border: 5px solid var(--ink);
  border-radius: 86px 86px 22px 22px;
  background:
    linear-gradient(#fff 0 0) 50% 68% / 82px 8px no-repeat,
    linear-gradient(90deg, rgba(255, 255, 255, 0.4) 18%, transparent 19% 78%, rgba(255, 255, 255, 0.28) 79%),
    linear-gradient(180deg, #ffdf7e 0 62%, #ff9f1c 62% 100%);
  box-shadow:
    0 24px 46px rgba(37, 48, 68, 0.18),
    inset 0 -14px 0 rgba(181, 71, 8, 0.12);
  transform: rotate(-3deg);
}

.pencil-pal::before {
  content: "";
  position: absolute;
  left: 48px;
  top: -82px;
  border-left: 45px solid transparent;
  border-right: 45px solid transparent;
  border-bottom: 86px solid #f6b68a;
  filter: drop-shadow(0 -2px 0 var(--ink));
}

.pencil-pal::after {
  content: "";
  position: absolute;
  left: 80px;
  top: -82px;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-bottom: 30px solid var(--ink);
}

.pencil-band {
  position: absolute;
  left: -5px;
  right: -5px;
  top: 32px;
  height: 34px;
  border: 5px solid var(--ink);
  border-left: 0;
  border-right: 0;
  background: #8bd3ff;
}

.pencil-eye {
  position: absolute;
  top: 114px;
  width: 15px;
  height: 28px;
  border-radius: 999px;
  background: var(--ink);
}

.pencil-eye::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 5px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #fff;
}

.pencil-eye.left {
  left: 58px;
}

.pencil-eye.right {
  right: 58px;
}

.pencil-cheek {
  position: absolute;
  top: 154px;
  width: 24px;
  height: 13px;
  border-radius: 999px;
  background: rgba(244, 111, 123, 0.42);
}

.pencil-cheek.left {
  left: 36px;
}

.pencil-cheek.right {
  right: 36px;
}

.pencil-smile {
  position: absolute;
  left: 75px;
  top: 150px;
  width: 40px;
  height: 22px;
  border-bottom: 5px solid var(--ink);
  border-radius: 0 0 999px 999px;
}

.pencil-arm {
  position: absolute;
  top: 176px;
  width: 58px;
  height: 13px;
  border-radius: 999px;
  background: var(--ink);
}

.pencil-arm.left {
  left: -50px;
  transform: rotate(24deg);
}

.pencil-arm.right {
  right: -48px;
  transform: rotate(-28deg);
}

.pencil-foot {
  position: absolute;
  bottom: -18px;
  width: 50px;
  height: 20px;
  border: 5px solid var(--ink);
  border-radius: 999px;
  background: #fff;
}

.pencil-foot.left {
  left: 32px;
}

.pencil-foot.right {
  right: 32px;
}

.pencil-note {
  position: absolute;
  right: -70px;
  top: 182px;
  display: grid;
  place-items: center;
  width: 78px;
  height: 64px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 18px, rgba(47, 128, 237, 0.18) 19px),
    repeating-linear-gradient(#fff 0 14px, #edf2fb 15px 16px);
  color: var(--accent-strong);
  font-size: 1rem;
  font-weight: 900;
  transform: rotate(7deg);
}

.large-copy {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.55;
}

.home-secondary-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.seo-content {
  margin-top: 28px;
  padding: 0 0 20px;
}

.seo-content-inner {
  border: 2px solid rgba(205, 217, 232, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: clamp(18px, 3vw, 28px);
  box-shadow: 0 10px 26px rgba(37, 48, 68, 0.06);
}

.seo-content h2 {
  max-width: 760px;
  margin: 0 0 12px;
  font-size: clamp(1.35rem, 2.3vw, 2rem);
}

.seo-content p {
  max-width: 900px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.8;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.seo-grid article {
  border: 1px solid rgba(187, 201, 221, 0.86);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.72);
  padding: 14px;
}

.seo-grid h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.seo-grid p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
}

.seo-content details {
  border-top: 1px solid rgba(187, 201, 221, 0.86);
  padding-top: 14px;
}

.seo-content summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 900;
}

.seo-content dl {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
}

.seo-content dt {
  color: var(--ink);
  font-weight: 900;
}

.seo-content dd {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.6;
}

.ad-slot {
  display: grid;
  place-items: center;
  gap: 4px;
  width: min(728px, 100%);
  min-height: 90px;
  margin: 22px auto 0;
  border: 2px dashed rgba(82, 98, 122, 0.34);
  border-radius: 8px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.72) 0 12px, rgba(255, 248, 236, 0.72) 12px 24px),
    rgba(255, 255, 255, 0.86);
  color: rgba(82, 98, 122, 0.84);
  text-align: center;
}

.ad-slot span {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
}

.ad-slot strong {
  font-size: 0.95rem;
  font-weight: 900;
}

.home-ad-slot {
  margin-top: 18px;
}

.challenge-ad-slot {
  width: min(640px, 100%);
  min-height: 74px;
  margin-top: 14px;
}

.parent-link {
  display: inline-block;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  text-decoration: underline;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.map-view,
.gacha-view,
.rewards-view,
.review-view,
.parent-view {
  min-height: calc(100vh - 56px);
  padding: 28px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.gacha-view {
  background:
    radial-gradient(circle at 85% 18%, rgba(255, 207, 117, 0.42), transparent 24%),
    radial-gradient(circle at 12% 88%, rgba(52, 195, 143, 0.2), transparent 24%),
    linear-gradient(135deg, rgba(239, 246, 255, 0.98), rgba(255, 250, 241, 0.98));
}

.map-view {
  position: relative;
  overflow: visible;
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.96), rgba(255, 255, 255, 0.96));
}

.map-view.has-stage-art {
  border-color: rgba(255, 207, 117, 0.92);
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.96), rgba(255, 255, 255, 0.98));
}

.map-view > * {
  position: relative;
  z-index: 1;
}

.map-view.has-stage-art .section-head {
  position: relative;
  z-index: 3;
  width: min(620px, calc(100% - 36px));
  margin: 0 0 -104px 18px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 16px 18px;
  box-shadow: 0 14px 32px rgba(37, 48, 68, 0.12);
  backdrop-filter: blur(7px);
}

.stage-art-frame {
  display: none;
}

.map-view.has-stage-art .stage-art-frame {
  display: block;
  position: relative;
  z-index: 1;
  aspect-ratio: 16 / 9;
  width: 100%;
  margin: 0;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 250, 241, 0.1)),
    var(--stage-art);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  box-shadow: 0 18px 42px rgba(37, 48, 68, 0.16);
}

.map-view.has-stage-art .map-status-grid {
  position: relative;
  z-index: 3;
  margin: -132px 16px 18px;
  padding: 0;
}

.map-status-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 12px;
  margin: 16px 0 18px;
}

.map-status-card {
  display: grid;
  gap: 6px;
  min-height: 126px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 16px;
  box-shadow: 0 8px 20px rgba(37, 48, 68, 0.06);
  backdrop-filter: blur(6px);
}

.map-status-card.current {
  border-color: #ffcf75;
  background:
    linear-gradient(135deg, rgba(255, 244, 215, 0.96), rgba(255, 255, 255, 0.96));
}

.map-status-card.reward {
  border-color: #bfd7ff;
  background:
    linear-gradient(135deg, rgba(239, 246, 255, 0.96), rgba(255, 255, 255, 0.96));
}

.map-status-card strong {
  font-size: 1.2rem;
}

.map-status-card span {
  color: var(--muted);
  font-weight: 900;
  line-height: 1.45;
}

.map-journey-meter {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) 1.4fr;
  gap: 16px;
  align-items: center;
  margin: 12px 0 20px;
  border: 2px solid #c7d2e5;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(239, 246, 255, 0.92), rgba(255, 255, 255, 0.92));
  padding: 14px 16px;
  backdrop-filter: blur(6px);
}

.map-journey-meter strong {
  display: block;
  font-size: 1rem;
}

.journey-track {
  height: 18px;
  border: 3px solid #bfd7ff;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, #fff 0 28px, #f4f8ff 28px 34px);
  overflow: hidden;
}

.journey-track span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #34c38f, #ffcf75, #f79009);
  transition: width 260ms ease;
}

.big-map-trail {
  display: grid;
  grid-template-columns: repeat(5, minmax(74px, 1fr));
  gap: 18px;
  margin: 28px 0;
  padding: 14px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(4px);
}

.stage-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 20px 0 8px;
}

.stage-card {
  min-height: 96px;
  border: 2px solid rgba(214, 222, 235, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 14px;
  color: var(--muted);
  font-weight: 900;
  backdrop-filter: blur(5px);
}

.stage-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 1rem;
}

.stage-card .stage-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(37, 48, 68, 0.12);
}

.stage-card.current {
  border-color: #ffb84d;
  background: rgba(255, 244, 215, 0.92);
  color: #92400e;
  box-shadow: 0 10px 24px rgba(255, 184, 77, 0.2);
}

.stage-card.cleared {
  border-color: #9ee6bd;
  background: rgba(239, 253, 245, 0.9);
  color: #027a48;
}

.stage-card.locked {
  background: rgba(248, 250, 252, 0.72);
}

.big-map-trail span,
.reward-treasure {
  display: grid;
  place-items: center;
  min-height: 86px;
  border: 3px solid #d6deeb;
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.9);
  color: #b54708;
  font-size: 1.5rem;
  font-weight: 900;
}

.big-map-trail span {
  position: relative;
}

.big-map-trail span b {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  color: #f79009;
  box-shadow: 0 10px 22px rgba(247, 144, 9, 0.2);
}

.big-map-trail span .map-tile-icon {
  font-size: 1.25rem;
}

.map-runner {
  position: absolute;
  right: -18px;
  bottom: -18px;
  width: 42px;
  height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgba(37, 48, 68, 0.18));
  animation: runnerHop 900ms ease-in-out infinite;
}

.big-map-trail span small {
  position: absolute;
  right: 8px;
  bottom: 6px;
  color: var(--muted);
  font-size: 0.7rem;
}

.big-map-trail span.passed {
  border-color: #ffcf75;
  background: #fff2cf;
}

.big-map-trail span.current {
  border-color: #f79009;
  background: #fff4d7;
  animation: mapPulse 1200ms ease-in-out infinite;
}

.big-map-trail span.next {
  border-style: dashed;
}

@keyframes mapPulse {
  50% {
    transform: translateY(-4px);
    box-shadow: 0 14px 28px rgba(247, 144, 9, 0.2);
  }
}

@keyframes runnerHop {
  50% {
    transform: translateY(-6px) rotate(4deg);
  }
}

.gacha-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(300px, 410px);
  gap: 24px;
  align-items: center;
  min-height: 380px;
  border: 4px solid #ffb020;
  border-radius: 8px;
  background:
    radial-gradient(circle at 78% 22%, rgba(255, 255, 255, 0.98), transparent 18%),
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.95), transparent 30%),
    radial-gradient(circle at 48% 78%, rgba(255, 212, 59, 0.42), transparent 22%),
    linear-gradient(135deg, #ffe58a, #dff1ff 48%, #dcffe9);
  padding: clamp(18px, 4vw, 34px);
  box-shadow:
    inset 0 0 0 6px rgba(255, 255, 255, 0.38),
    0 22px 50px rgba(37, 48, 68, 0.16),
    0 0 0 6px rgba(255, 212, 59, 0.14);
  overflow: hidden;
}

.gacha-hero::before,
.gacha-hero::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.gacha-hero::before {
  inset: -42% -12% auto;
  height: 240px;
  background:
    repeating-conic-gradient(from 0deg, rgba(255, 212, 59, 0.5) 0 8deg, rgba(255, 255, 255, 0.12) 8deg 16deg, transparent 16deg 24deg);
  opacity: 0.9;
  animation: prizeLights 7200ms linear infinite;
}

.gacha-hero::after {
  inset: auto -10% -32%;
  height: 220px;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.82), transparent 13%),
    radial-gradient(circle at 48% 18%, rgba(255, 212, 59, 0.7), transparent 10%),
    radial-gradient(circle at 72% 34%, rgba(34, 211, 238, 0.44), transparent 12%);
}

.gacha-copy,
.gacha-machine {
  z-index: 1;
}

.gacha-copy h2 {
  max-width: 680px;
  margin: 0 0 12px;
  font-size: clamp(1.9rem, 4vw, 3.4rem);
}

.gacha-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.gacha-stat {
  display: grid;
  gap: 4px;
  min-height: 92px;
  border: 2px solid rgba(255, 207, 117, 0.66);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  padding: 14px;
  box-shadow: 0 8px 20px rgba(37, 48, 68, 0.08);
}

.gacha-stat span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.gacha-stat strong {
  font-size: clamp(1.35rem, 3vw, 2.3rem);
}

.gacha-machine {
  position: relative;
  justify-self: center;
  width: min(350px, 100%);
  filter: drop-shadow(0 24px 30px rgba(37, 48, 68, 0.2));
}

.gacha-glow {
  position: absolute;
  inset: -24px -30px auto;
  height: 260px;
  border-radius: 999px;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.96), rgba(255, 212, 59, 0.58) 36%, rgba(139, 92, 246, 0.2) 54%, transparent 72%);
  animation: gachaGlow 2400ms ease-in-out infinite;
}

.gacha-machine::before,
.gacha-machine::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.gacha-machine::before {
  inset: -18px -18px auto;
  height: 72px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 18% 50%, #fff, transparent 8%),
    radial-gradient(circle at 38% 50%, #ffd43b, transparent 9%),
    radial-gradient(circle at 58% 50%, #22d3ee, transparent 8%),
    radial-gradient(circle at 78% 50%, #8b5cf6, transparent 8%);
  animation: marqueeTwinkle 900ms ease-in-out infinite;
}

.gacha-machine::after {
  inset: auto 20px -18px;
  height: 20px;
  border-radius: 999px;
  background: rgba(37, 48, 68, 0.16);
  filter: blur(8px);
}

.gacha-dome {
  position: relative;
  display: block;
  height: 196px;
  border: 5px solid #253044;
  border-bottom: 0;
  border-radius: 180px 180px 28px 28px;
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.96), transparent 18%),
    radial-gradient(circle at 74% 64%, rgba(255, 212, 59, 0.76), transparent 16%),
    linear-gradient(135deg, rgba(97, 178, 255, 0.88), rgba(255, 255, 255, 0.76));
  overflow: hidden;
}

.gacha-dome::after {
  content: "";
  position: absolute;
  inset: 18px 34px auto auto;
  width: 74px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  transform: rotate(-22deg);
}

.capsule {
  position: absolute;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 3px solid #253044;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0 48%, rgba(255, 159, 28, 0.98) 48% 100%);
  color: #92400e;
  font-weight: 900;
  box-shadow: 0 10px 16px rgba(37, 48, 68, 0.12);
  animation: capsuleFloat 2600ms ease-in-out infinite;
}

.capsule.c1 {
  left: 42px;
  top: 90px;
}

.capsule.c2 {
  left: 120px;
  top: 58px;
  animation-delay: 160ms;
}

.capsule.c3 {
  right: 42px;
  top: 94px;
  animation-delay: 260ms;
}

.capsule.c4 {
  left: 78px;
  top: 132px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0 48%, rgba(24, 185, 125, 0.96) 48% 100%);
  animation-delay: 420ms;
}

.capsule.c5 {
  right: 92px;
  top: 128px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0 48%, rgba(139, 92, 246, 0.88) 48% 100%);
  animation-delay: 540ms;
}

.gacha-body {
  position: relative;
  display: grid;
  place-items: center;
  gap: 4px;
  height: 156px;
  border: 5px solid #253044;
  border-radius: 26px 26px 10px 10px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.2), transparent 18% 82%, rgba(146, 64, 14, 0.18)),
    linear-gradient(180deg, #ffd43b, #ff8a00);
  color: #fff;
  overflow: visible;
}

.gacha-window {
  display: grid;
  place-items: center;
  min-width: 112px;
  min-height: 32px;
  border: 3px solid rgba(37, 48, 68, 0.86);
  border-radius: 999px;
  background: #fffaf1;
  color: #92400e;
  font-size: 0.8rem;
  font-weight: 900;
}

.gacha-body strong {
  font-size: 2.8rem;
  line-height: 1;
}

.gacha-body span {
  font-weight: 900;
  letter-spacing: 0;
}

.gacha-handle {
  position: absolute;
  right: -26px;
  top: 52px;
  width: 54px;
  height: 54px;
  border: 5px solid #253044;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 12px #bfd7ff;
}

.gacha-handle::after {
  content: "";
  position: absolute;
  left: 20px;
  top: 42px;
  width: 13px;
  height: 48px;
  border: 4px solid #253044;
  border-radius: 999px;
  background: #ffcf75;
}

.gacha-view.has-ticket .gacha-machine {
  animation: machineReady 1200ms ease-in-out infinite;
}

.gacha-view.has-ticket .gacha-button {
  animation: readyButton 1200ms ease-in-out infinite;
}

.gacha-view.rolling .gacha-machine {
  animation: machineRoll 700ms ease both;
}

.gacha-view.rolling .capsule {
  animation: capsuleSpin 700ms ease both;
}

.gacha-view.rolling .gacha-glow {
  animation: gachaGlow 240ms ease-in-out infinite;
}

.gacha-view.rolling.rarity-SR .gacha-hero {
  box-shadow:
    inset 0 0 0 6px rgba(255, 255, 255, 0.52),
    0 0 0 7px rgba(255, 212, 59, 0.36),
    0 26px 80px rgba(247, 144, 9, 0.38);
}

.gacha-view.rolling.rarity-UR .gacha-hero {
  box-shadow:
    inset 0 0 0 7px rgba(255, 255, 255, 0.6),
    0 0 0 8px rgba(139, 92, 246, 0.3),
    0 0 34px rgba(255, 212, 59, 0.46),
    0 30px 92px rgba(139, 92, 246, 0.38);
}

.gacha-action-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin: 18px 0;
  border: 3px solid #ffcf75;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 244, 215, 0.98), rgba(255, 255, 255, 0.96));
  padding: 18px;
  box-shadow: 0 12px 28px rgba(247, 144, 9, 0.1);
}

.gacha-action-panel strong {
  display: block;
  margin-bottom: 10px;
  font-size: 1.25rem;
}

.gacha-coin-track {
  height: 18px;
  border: 3px solid #ffcf75;
  border-radius: 999px;
  background: #fffaf1;
  overflow: hidden;
}

.gacha-coin-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f79009, #ffcf75, #34c38f);
  transition: width 240ms ease;
}

.gacha-button {
  min-width: 190px;
  min-height: 58px;
  font-size: 1.08rem;
}

.gacha-button:disabled {
  cursor: not-allowed;
  border-color: #d8deea;
  background: #e4e7ec;
  box-shadow: none;
  color: #667085;
  transform: none;
}

.gacha-result {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  border: 3px solid #bfd7ff;
  border-radius: 8px;
  background:
    radial-gradient(circle at 10% 50%, rgba(255, 255, 255, 0.9), transparent 24%),
    linear-gradient(135deg, rgba(239, 246, 255, 0.98), rgba(255, 255, 255, 0.96));
  padding: 18px;
  box-shadow: 0 12px 30px rgba(37, 48, 68, 0.1);
  overflow: hidden;
}

.gacha-result::after {
  content: "";
  position: absolute;
  inset: -40% auto -40% -16%;
  width: 28%;
  background: rgba(255, 255, 255, 0.6);
  transform: rotate(18deg);
  animation: resultShine 2800ms ease-in-out infinite;
}

.gacha-result h3 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

.gacha-result p {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
}

.gacha-result-prize {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border: 4px solid #ffcf75;
  border-radius: 999px;
  background: #fff;
  color: #92400e;
  font-size: 1.25rem;
  font-weight: 900;
  overflow: hidden;
  isolation: isolate;
}

.gacha-result.has-prize .gacha-result-prize {
  animation: prizeReveal 760ms ease both;
}

.gacha-result-prize img,
.prize-portrait img,
.treasure-icon img,
.party-prize img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gacha-result-prize img {
  width: 78px;
  height: 78px;
}

.prize-mark {
  display: grid;
  place-items: center;
  font-weight: 900;
}

.gacha-result-prize img + .prize-mark,
.prize-portrait img + .prize-mark,
.treasure-icon img + .prize-mark,
.party-prize img + .prize-mark {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 26px;
  height: 26px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #ffcf75;
  color: #92400e;
  font-size: 0.72rem;
  box-shadow: 0 5px 12px rgba(37, 48, 68, 0.18);
}

.rarity-badge {
  display: inline-grid;
  place-items: center;
  min-width: 64px;
  min-height: 28px;
  margin-bottom: 6px;
  border: 2px solid #ffcf75;
  border-radius: 999px;
  background: #fff4d7;
  color: #92400e;
  font-size: 0.76rem;
  font-weight: 900;
}

.rarity-badge.rarity-SR {
  border-color: #f79009;
  background: linear-gradient(135deg, #fff4d7, #ffe0f0, #eff6ff);
  color: #7a2e0e;
}

.rarity-badge.rarity-UR {
  border-color: #7c3aed;
  background: linear-gradient(135deg, #fff4d7, #f3e8ff, #dbeafe, #ffe0f0);
  color: #4c1d95;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12);
}

.rarity-badge.rarity-R {
  border-color: #bfd7ff;
  background: #eff6ff;
  color: #1b5fbe;
}

.gacha-prize-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.gacha-focus-panel,
.gacha-exchange-teaser,
.gacha-prize-list {
  grid-column: 1 / -1;
}

.gacha-focus-panel,
.gacha-exchange-teaser {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) 1.3fr;
  gap: 14px;
  align-items: center;
  border: 2px solid #d8deea;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  padding: 14px;
}

.gacha-focus-panel h3,
.gacha-exchange-teaser h3 {
  margin: 0;
  font-size: 1.35rem;
}

.rarity-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rarity-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 2px solid #d8deea;
  border-radius: 999px;
  background: #fff;
  padding: 5px 10px;
  color: var(--muted);
  font-weight: 900;
}

.rarity-chip b {
  color: var(--ink);
}

.rarity-chip.rarity-R {
  border-color: #bfd7ff;
  background: #eff6ff;
}

.rarity-chip.rarity-SR {
  border-color: #f79009;
  background: #fff4d7;
}

.rarity-chip.rarity-UR {
  border-color: #7c3aed;
  background: linear-gradient(135deg, #fff4d7, #f3e8ff, #dbeafe);
}

.gacha-target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.gacha-target-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 9px;
  align-items: center;
  border: 2px dashed #d8deea;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  color: var(--muted);
  font-weight: 900;
}

.gacha-target-card span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid currentColor;
  border-radius: 999px;
  background: #fff;
}

.gacha-target-card strong,
.gacha-target-card small {
  display: block;
}

.gacha-target-card[data-rarity="SR"],
.gacha-target-card[data-rarity="UR"] {
  border-style: solid;
}

.gacha-prize-list {
  border: 2px solid #d8deea;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 14px;
}

.gacha-list-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.gacha-list-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.compact-button {
  min-height: 38px;
  padding: 7px 14px;
}

.gacha-prize-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.gacha-prize-card {
  position: relative;
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 128px;
  border: 2px dashed #d8deea;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  padding: 12px;
  text-align: center;
  color: #98a2b3;
  font-weight: 900;
  overflow: hidden;
}

.gacha-prize-card.owned::after,
.reward-treasure.unlocked::after,
.sticker-card.owned::after,
.title-card.owned::after {
  content: "\2605";
  position: absolute;
  right: 8px;
  top: 6px;
  color: rgba(255, 159, 28, 0.72);
  font-size: 1rem;
  text-shadow:
    -18px 18px 0 rgba(34, 211, 238, 0.34),
    -34px 2px 0 rgba(255, 212, 59, 0.38);
  pointer-events: none;
}

.gacha-prize-card.owned {
  border-style: solid;
  border-color: #ffb020;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.92), transparent 28%),
    linear-gradient(135deg, #ffe58a, #fff9dc);
  color: #92400e;
  box-shadow:
    0 12px 28px rgba(255, 159, 28, 0.18),
    0 0 0 4px rgba(255, 212, 59, 0.12);
}

.gacha-prize-card.owned strong {
  color: #7a2e0e;
}

.gacha-prize-card[data-rarity="SR"] {
  border-color: rgba(247, 144, 9, 0.8);
}

.gacha-prize-card[data-rarity="UR"] {
  border-color: rgba(124, 58, 237, 0.86);
}

.gacha-prize-card[data-rarity="SR"].owned {
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.94), transparent 28%),
    linear-gradient(135deg, #ffd43b, #ffe0f0, #dff1ff);
}

.gacha-prize-card[data-rarity="UR"].owned {
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.96), transparent 28%),
    linear-gradient(135deg, #ffd43b, #e9d5ff, #bae6fd, #ffe0f0);
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.14);
}

.prize-portrait {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 3px solid currentColor;
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
}

.gacha-prize-card.owned .prize-portrait {
  border-color: #ffcf75;
  box-shadow: 0 8px 18px rgba(247, 144, 9, 0.16);
}

.gacha-prize-card small {
  color: inherit;
  font-size: 0.76rem;
}

.gacha-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

.gacha-party-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  pointer-events: none;
  overflow: hidden;
}

.gacha-party-overlay.show {
  display: block;
  animation: partyFlash 1850ms ease both;
}

.party-burst {
  position: absolute;
  left: 50%;
  top: 45%;
  width: min(76vmin, 560px);
  height: min(76vmin, 560px);
  border-radius: 999px;
  background:
    repeating-conic-gradient(from 0deg, rgba(255, 207, 117, 0.86) 0 9deg, rgba(255, 255, 255, 0.2) 9deg 18deg),
    radial-gradient(circle, rgba(255, 255, 255, 0.94), rgba(255, 244, 215, 0.82) 38%, transparent 68%);
  transform: translate(-50%, -50%) scale(0);
  animation: partyBurst 1200ms ease-out both;
}

.gacha-party-overlay.rarity-SR .party-burst {
  background:
    repeating-conic-gradient(from 0deg, rgba(255, 207, 117, 0.96) 0 8deg, rgba(255, 224, 240, 0.82) 8deg 16deg, rgba(191, 215, 255, 0.82) 16deg 24deg),
    radial-gradient(circle, rgba(255, 255, 255, 0.98), rgba(255, 244, 215, 0.88) 38%, transparent 70%);
}

.gacha-party-overlay.rarity-UR .party-burst {
  background:
    repeating-conic-gradient(from 0deg, rgba(255, 207, 117, 0.98) 0 6deg, rgba(243, 232, 255, 0.92) 6deg 12deg, rgba(219, 234, 254, 0.92) 12deg 18deg, rgba(255, 224, 240, 0.92) 18deg 24deg),
    radial-gradient(circle, rgba(255, 255, 255, 0.98), rgba(243, 232, 255, 0.9) 36%, transparent 72%);
}

.party-prize {
  position: absolute;
  left: 50%;
  top: 45%;
  display: grid;
  place-items: center;
  gap: 6px;
  width: min(260px, 58vw);
  min-height: 250px;
  border: 5px solid #ffcf75;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.96), transparent 28%),
    linear-gradient(135deg, #fff4d7, #ffffff);
  color: #92400e;
  padding: 18px;
  text-align: center;
  box-shadow:
    0 24px 80px rgba(37, 48, 68, 0.25),
    0 0 0 8px rgba(255, 255, 255, 0.55);
  transform: translate(-50%, -50%) scale(0.2) rotate(-8deg);
  animation: partyPrize 1200ms cubic-bezier(0.2, 1.35, 0.3, 1) 180ms both;
}

.party-prize[data-rarity="SR"] {
  border-color: #f79009;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.98), transparent 28%),
    linear-gradient(135deg, #fff4d7, #ffe0f0 52%, #eff6ff);
}

.party-prize[data-rarity="UR"] {
  border-color: #7c3aed;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.98), transparent 28%),
    linear-gradient(135deg, #fff4d7, #f3e8ff 42%, #dbeafe 72%, #ffe0f0);
  color: #4c1d95;
  box-shadow:
    0 28px 90px rgba(124, 58, 237, 0.28),
    0 0 0 10px rgba(255, 255, 255, 0.62);
}

.party-prize img {
  width: 138px;
  height: 138px;
}

.party-prize strong {
  font-size: clamp(1.15rem, 3vw, 1.5rem);
}

.party-prize small {
  color: var(--muted);
  font-weight: 900;
}

.party-spark {
  position: absolute;
  left: var(--x);
  top: -48px;
  display: grid;
  place-items: center;
  min-width: 26px;
  min-height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: #ffcf75;
  color: #92400e;
  padding: 3px 6px;
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(37, 48, 68, 0.12);
  animation: partySpark 1500ms ease-in var(--delay) both;
  transform: rotate(var(--rot));
}

.party-spark:nth-child(3n) {
  background: #bfd7ff;
  color: #1b5fbe;
}

.party-spark:nth-child(4n) {
  background: #baf7da;
  color: #027a48;
}

@keyframes gachaGlow {
  50% {
    transform: scale(1.08);
    opacity: 0.72;
  }
}

@keyframes prizeLights {
  to {
    transform: rotate(360deg);
  }
}

@keyframes marqueeTwinkle {
  50% {
    opacity: 0.55;
    transform: translateY(-2px);
  }
}

@keyframes capsuleFloat {
  50% {
    transform: translateY(-8px) rotate(5deg);
  }
}

@keyframes capsuleSpin {
  40% {
    transform: translateY(-18px) rotate(26deg) scale(1.08);
  }
  100% {
    transform: translateY(0) rotate(0) scale(1);
  }
}

@keyframes machineReady {
  50% {
    transform: translateY(-5px);
  }
}

@keyframes machineRoll {
  20% {
    transform: translateX(-14px) rotate(-4deg) scale(1.03);
  }
  45% {
    transform: translateX(14px) rotate(4deg) scale(1.05);
  }
  70% {
    transform: translateX(-8px) rotate(-2deg) scale(1.02);
  }
}

@keyframes readyButton {
  50% {
    box-shadow: 0 14px 30px rgba(47, 128, 237, 0.24);
  }
}

@keyframes resultShine {
  0%,
  45% {
    transform: translateX(0) rotate(18deg);
    opacity: 0;
  }
  68% {
    opacity: 0.85;
  }
  100% {
    transform: translateX(520%) rotate(18deg);
    opacity: 0;
  }
}

@keyframes prizeReveal {
  0% {
    transform: scale(0.4) rotate(-14deg);
    opacity: 0;
  }
  62% {
    transform: scale(1.14) rotate(4deg);
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

@keyframes partyFlash {
  0% {
    background: rgba(255, 250, 241, 0);
  }
  14% {
    background: rgba(255, 250, 241, 0.88);
  }
  72% {
    background: rgba(255, 250, 241, 0.5);
  }
  100% {
    background: rgba(255, 250, 241, 0);
  }
}

@keyframes partyBurst {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(0);
    opacity: 0;
  }
  28% {
    opacity: 0.95;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.25) rotate(55deg);
    opacity: 0;
  }
}

@keyframes partyPrize {
  0% {
    transform: translate(-50%, -50%) scale(0.2) rotate(-8deg);
    opacity: 0;
  }
  58% {
    transform: translate(-50%, -50%) scale(1.12) rotate(3deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1) rotate(0);
    opacity: 1;
  }
}

@keyframes partySpark {
  0% {
    transform: translateY(0) rotate(var(--rot)) scale(0.7);
    opacity: 0;
  }
  14% {
    opacity: 1;
  }
  100% {
    transform: translateY(108vh) rotate(calc(var(--rot) + 300deg)) scale(1);
    opacity: 0;
  }
}

.reward-room {
  display: grid;
  gap: 18px;
}

.reward-section {
  display: grid;
  gap: 12px;
}

.reward-section h3 {
  margin: 0;
  font-size: 1.15rem;
}

.reward-section h3 span {
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.reward-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.reward-summary-grid > div {
  border: 2px solid #d8deea;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 14px;
}

.reward-summary-grid strong {
  display: block;
  font-size: 1.55rem;
}

.reward-summary-grid span {
  color: var(--muted);
  font-weight: 900;
}

.exchange-station {
  border: 2px solid #ffcf75;
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.92), transparent 28%),
    linear-gradient(135deg, #fff8df, #ffffff);
  padding: 14px;
}

.background-book {
  border: 2px solid #b8d7ff;
  border-radius: 8px;
  background:
    radial-gradient(circle at 90% 8%, rgba(255, 212, 59, 0.22), transparent 30%),
    linear-gradient(135deg, rgba(239, 246, 255, 0.96), rgba(255, 255, 255, 0.96));
  padding: 14px;
}

.background-book-note {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
}

.background-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.background-card {
  display: grid;
  gap: 8px;
  border: 2px dashed #d8deea;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  color: var(--muted);
  font-weight: 900;
}

.background-card.owned {
  border-style: solid;
  border-color: #8ec5ff;
  color: var(--ink);
  box-shadow: 0 12px 26px rgba(47, 128, 237, 0.12);
}

.background-card.selected {
  border-color: #34c38f;
  background: #edfff6;
  box-shadow:
    0 12px 30px rgba(52, 195, 143, 0.2),
    0 0 0 4px rgba(52, 195, 143, 0.12);
}

.background-card.frame-sparkle.owned {
  border-color: #7dd3fc;
  background: linear-gradient(135deg, #ffffff, #eff6ff, #f5f3ff);
}

.background-card.frame-gold.owned {
  border-color: #ffd43b;
  background: linear-gradient(135deg, #fff8d7, #ffffff);
}

.background-thumb {
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background-color: #eef2f7;
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.background-card.locked .background-thumb {
  filter: grayscale(1);
  opacity: 0.45;
}

.exchange-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.exchange-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 2px dashed #d8deea;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  color: var(--muted);
}

.exchange-card.ready {
  border-style: solid;
  border-color: #f79009;
  background: #fff4d7;
  color: #92400e;
  box-shadow: 0 10px 24px rgba(255, 184, 77, 0.14);
}

.exchange-card[data-rarity="UR"].ready {
  border-color: #7c3aed;
  background: linear-gradient(135deg, #fff4d7, #f3e8ff, #dbeafe);
  color: #4c1d95;
}

.exchange-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 3px solid currentColor;
  border-radius: 999px;
  background: #fff;
  font-weight: 900;
}

.exchange-card strong,
.exchange-card small {
  display: block;
}

.reward-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reward-filter-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  border: 2px solid #d8deea;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 6px 12px;
  font-weight: 900;
  cursor: pointer;
}

.reward-filter-button span {
  color: var(--muted);
  font-size: 0.8rem;
}

.reward-filter-button.active {
  border-color: #2f80ed;
  background: #eff6ff;
  color: #1b5fbe;
}

.treasure-grid,
.sticker-grid,
.title-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}

.reward-treasure {
  min-height: 132px;
  align-content: center;
  gap: 8px;
  padding: 14px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.treasure-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border: 3px solid currentColor;
  border-radius: 999px;
  background: #fff;
  font-size: 1.15rem;
  font-weight: 900;
  overflow: hidden;
}

.reward-treasure small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.reward-treasure.locked {
  border-style: dashed;
  background: #f8fafc;
  color: #98a2b3;
}

.reward-treasure.unlocked {
  border-color: #ffb020;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.94), transparent 28%),
    linear-gradient(135deg, #ffe58a, #fff8d7);
  color: #92400e;
  box-shadow:
    0 12px 30px rgba(255, 159, 28, 0.2),
    0 0 0 4px rgba(255, 212, 59, 0.12);
}

.reward-treasure.selected {
  border: 3px solid #34c38f;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.94), transparent 28%),
    linear-gradient(135deg, #c7ffd9, #e8fff2);
  color: #046c4e;
  box-shadow:
    0 12px 30px rgba(52, 195, 143, 0.24),
    0 0 0 4px rgba(52, 195, 143, 0.14);
}

.reward-treasure[data-rarity="UR"].unlocked {
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.96), transparent 30%),
    linear-gradient(135deg, #ffd43b, #e9d5ff 42%, #bae6fd 72%, #ffe0f0);
}

.mini-action-button {
  min-height: 34px;
  border: 2px solid #d8deea;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  padding: 5px 12px;
}

.mini-action-button:not(:disabled) {
  cursor: pointer;
}

.mini-action-button:not(:disabled):hover {
  border-color: #2f80ed;
  background: #eff6ff;
}

.mini-action-button.exchange-button:not(:disabled) {
  border-color: #f79009;
  background: #fff4d7;
  color: #92400e;
}

.mini-action-button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.sticker-card {
  position: relative;
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 142px;
  border: 2px dashed #d8deea;
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
  text-align: center;
  color: #98a2b3;
  font-weight: 900;
  overflow: hidden;
}

.sticker-card span,
.title-card span {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 3px solid currentColor;
  border-radius: 999px;
  background: #fff;
  font-size: 1.5rem;
}

.sticker-card span img,
.title-card span img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sticker-card small,
.title-card small {
  color: var(--muted);
}

.sticker-card.owned {
  border-style: solid;
  border-color: #ffb020;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.94), transparent 28%),
    linear-gradient(135deg, #ffe58a, #ffffff);
  color: #b54708;
  box-shadow:
    0 12px 28px rgba(255, 159, 28, 0.18),
    0 0 0 4px rgba(255, 212, 59, 0.12);
}

.sticker-card.owned span {
  color: #f79009;
}

.title-card {
  position: relative;
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 152px;
  border: 2px dashed #d8deea;
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
  text-align: center;
  color: #98a2b3;
  font-weight: 900;
  overflow: hidden;
}

.title-card span {
  width: 64px;
  height: 64px;
  border-color: currentColor;
  border-radius: 8px;
}

.title-card.owned {
  border-style: solid;
  border-color: #6ba8ff;
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 255, 255, 0.96), transparent 34%),
    linear-gradient(135deg, #dbeafe, #fff1a8, #e9d5ff);
  color: #1452b8;
  box-shadow:
    0 12px 30px rgba(47, 128, 237, 0.18),
    0 0 0 4px rgba(107, 168, 255, 0.14);
}

.title-card.owned span {
  border-color: #6ba8ff;
  background: #fff;
  box-shadow:
    0 8px 18px rgba(47, 128, 237, 0.16),
    0 0 14px rgba(255, 212, 59, 0.22);
}

.top-bar,
.controls,
.workspace {
  display: grid;
  gap: 18px;
}

.top-bar {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

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

h1 {
  max-width: 740px;
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 3.2rem);
  line-height: 1.12;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.25rem;
}

.score-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 10px;
}

.score-board > div {
  min-width: 92px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(37, 48, 68, 0.08);
}

.score-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.score-board strong {
  display: block;
  font-size: 1.7rem;
}

.controls {
  grid-template-columns: 1fr minmax(190px, 260px) auto;
  align-items: center;
  margin: 22px 0;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
}

.course-controls {
  grid-template-columns: 1fr;
}

.course-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.course-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.course-head h2 {
  margin: 0;
  font-size: 1.35rem;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.course-card {
  display: grid;
  gap: 6px;
  min-height: 92px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(37, 48, 68, 0.06);
}

.course-card strong {
  font-size: 0.96rem;
}

.course-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.35;
}

.course-card.active {
  border-color: #f79009;
  background: #fff4d7;
  box-shadow: 0 12px 28px rgba(247, 144, 9, 0.18);
}

.course-card.featured {
  grid-column: span 2;
  border-color: #2f80ed;
  background:
    radial-gradient(circle at 88% 22%, rgba(255, 207, 117, 0.42), transparent 28%),
    linear-gradient(135deg, #eff6ff, #fffaf1);
}

.course-card.featured strong {
  font-size: 1.06rem;
}

.course-select-view {
  display: none;
  gap: 12px;
}

.course-select-view.active {
  display: grid;
}

.course-select-hero,
.course-category {
  border: 2px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 34px rgba(37, 48, 68, 0.08);
}

.course-select-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
}

.course-select-hero h1 {
  margin: 0 0 4px;
  font-size: clamp(1.55rem, 3.2vw, 2.15rem);
}

.course-select-hero p:last-child {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
  line-height: 1.45;
}

.course-category-grid {
  display: grid;
  gap: 10px;
}

.course-category {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.course-category.featured {
  grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.2fr);
  align-items: stretch;
  border-color: #8bc6ff;
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 207, 117, 0.42), transparent 24%),
    linear-gradient(135deg, #eff6ff, #fffaf1);
}

.course-category-head h2 {
  margin: 0 0 3px;
  font-size: 1.08rem;
}

.course-category-head p:last-child {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
  line-height: 1.35;
}

.course-category .course-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.course-category.featured .course-card {
  min-height: 96px;
}

.course-category:not(.featured) .course-card.featured {
  grid-column: auto;
}

.course-controls.compact {
  gap: 10px;
}

.course-controls.compact .course-grid {
  grid-template-columns: 1fr;
}

.course-controls.compact .course-card:not(.active) {
  display: none;
}

.course-controls.compact .course-card {
  min-height: auto;
  grid-template-columns: minmax(150px, max-content) 1fr;
  align-items: center;
}

.course-controls.compact .course-card.featured {
  grid-column: auto;
}

.feature-strip,
.tool-panel {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
}

.feature-strip {
  grid-template-columns: 1.4fr 1fr 1.1fr;
}

.tool-panel {
  grid-template-columns: 1.4fr 1fr 1fr;
}

.parent-dashboard,
.parent-insight-grid,
.parent-tool-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.parent-dashboard {
  grid-template-columns: 1.4fr repeat(3, 1fr);
}

.parent-insight-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

.parent-tool-grid {
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
  align-items: start;
}

.adventure-panel,
.collection-panel,
.coach-panel,
.custom-form,
.review-box,
.parent-box,
.parent-summary-card,
.parent-report-card {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 14px;
  box-shadow: 0 8px 24px rgba(37, 48, 68, 0.08);
}

.parent-summary-card {
  display: grid;
  align-content: center;
  gap: 5px;
  min-height: 122px;
}

.parent-summary-card.main {
  border-color: #ffcf75;
  background: #fff4d7;
}

.parent-summary-card strong {
  display: block;
  font-size: 1.65rem;
  line-height: 1;
}

.parent-summary-card span,
.parent-advice {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.5;
}

.parent-report-card {
  display: grid;
  gap: 12px;
}

.parent-report-card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.report-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.weak-list,
.history-list {
  display: grid;
  gap: 8px;
}

.weak-item,
.weak-empty,
.history-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 2px solid #e8edf5;
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 900;
}

.weak-empty,
.history-item.empty {
  justify-content: start;
  color: var(--muted);
}

.history-item span {
  color: var(--muted);
  font-size: 0.82rem;
}

.parent-custom-form {
  grid-template-columns: 1fr minmax(180px, 240px) auto;
}

.parent-reset-box {
  grid-column: 1 / -1;
  border-color: #ffd0d0;
  background: #fffafa;
}

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

.all-reset-button {
  grid-column: 1 / -1;
}

.danger-button {
  border-color: #fecaca;
  color: #b42318;
  background: #fff7f7;
}

.danger-button:hover {
  border-color: #f87171;
  background: #fff1f1;
}

.danger-button.strong {
  border-color: #fb7185;
  background: #fff1f2;
}

.parent-reset-message {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: #b42318;
  font-size: 0.9rem;
  font-weight: 900;
}

.adventure-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
}

.adventure-panel h2 {
  margin: 0;
}

.map-trail {
  display: grid;
  grid-template-columns: repeat(10, minmax(18px, 1fr));
  gap: 5px;
}

.map-trail span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px solid #d6deeb;
  border-radius: 999px;
  background: #f8fafc;
  color: #b54708;
  font-size: 0.8rem;
  font-weight: 900;
}

.map-trail span.passed {
  border-color: #ffcf75;
  background: #fff2cf;
}

.reward-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.reward-shelf span {
  border: 2px solid #bee3f8;
  border-radius: 999px;
  background: #ecf8ff;
  padding: 5px 9px;
  font-size: 0.82rem;
  font-weight: 900;
}

.coach-panel p:last-child,
.mini-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.custom-form,
.review-box {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 220px) auto;
  gap: 10px;
  align-items: end;
}

.custom-form label,
.parent-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.custom-form input,
.parent-grid input,
.parent-grid select {
  min-height: 40px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
}

.review-box {
  grid-template-columns: 1fr auto;
}

.parent-box summary {
  cursor: pointer;
  font-weight: 900;
}

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

.toggle-row {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.toggle-row input {
  min-height: auto;
}

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

.mode-button,
.primary-button,
.ghost-button,
select {
  min-height: 44px;
  border-radius: 8px;
}

.mode-button,
.ghost-button {
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.mode-button.active {
  border-color: var(--accent);
  background: #dbeafe;
  color: var(--accent-strong);
}

.primary-button {
  border: 0;
  background: linear-gradient(135deg, #1f7af5, #1452b8);
  color: white;
  padding: 0 18px;
  font-weight: 900;
  box-shadow:
    0 12px 28px rgba(31, 122, 245, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.26);
}

.ghost-button {
  padding: 0 14px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(31, 42, 68, 0.08);
}

.select-wrap {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

select {
  width: 100%;
  border: 2px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

.workspace {
  grid-template-columns: 300px 1fr;
  align-items: start;
}

.challenge-view.fill-challenge .workspace {
  grid-template-columns: 1fr;
}

.challenge-view.fill-challenge .mission-panel {
  display: none;
}

.mission-panel,
.problem-card {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.mission-panel {
  padding: 22px;
}

.mascot {
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  margin-bottom: 18px;
  border: 2px solid #ffcf75;
  border-radius: 999px;
  background: #fff4d7;
  box-shadow: 0 14px 28px rgba(37, 48, 68, 0.12);
}

.character-avatar-small {
  width: 108px;
  filter: drop-shadow(0 8px 12px rgba(37, 48, 68, 0.14));
}

.character-avatar-small[data-mood="happy"] {
  transform: translateY(-3px) scale(1.04);
}

.character-avatar-small[data-mood="thinking"] {
  transform: rotate(-5deg) scale(0.98);
}

.character-avatar-small[data-mood="cheer"] {
  transform: translateY(-2px) scale(1.02);
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #f3f6fb;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--mint), var(--sun));
  transition: width 250ms ease;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.badge {
  border: 2px solid #ffd27a;
  border-radius: 999px;
  background: #fff5d8;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 900;
}

.combo-panel {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  border: 2px solid #ffd08a;
  border-radius: 8px;
  background: #fff8ec;
  padding: 12px;
}

.combo-panel strong {
  font-size: 0.98rem;
}

.combo-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #ffe8bf;
}

.combo-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffb84d, #f46f7b, #2f80ed);
  transition: width 220ms ease;
}

.combo-panel.fever {
  border-color: #f46f7b;
  background: #fff0f2;
  animation: comboPop 900ms ease-in-out infinite;
}

@keyframes comboPop {
  50% {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(244, 111, 123, 0.16);
  }
}

.history-card {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 2px dashed var(--line);
}

.history-list {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.problem-card {
  min-height: 560px;
  padding: 24px;
}

.problem-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.stage-status-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1.35fr) repeat(2, minmax(120px, 0.8fr));
  gap: 10px;
  margin: 12px 0;
}

.stage-status-main,
.stage-status-item {
  display: grid;
  gap: 4px;
  min-height: 62px;
  border: 2px solid #d8deea;
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px 12px;
}

.stage-status-main {
  border-color: #ffcf75;
  background:
    radial-gradient(circle at 90% 12%, rgba(255, 207, 117, 0.35), transparent 28%),
    #fff4d7;
}

.stage-status-item:nth-child(2) {
  border-color: #f6b84d;
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 207, 117, 0.34), transparent 30%),
    #fffaf0;
}

.stage-status-panel span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.stage-status-panel strong {
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.15;
}

.play-reward-panel {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin: 14px 0 4px;
  padding: 12px 14px;
  border: 2px solid #ffcf75;
  border-radius: 8px;
  background: #fff4d7;
  box-shadow: 0 8px 20px rgba(247, 144, 9, 0.1);
}

.play-reward-panel .eyebrow {
  margin-bottom: 2px;
}

.play-reward-panel strong {
  display: block;
  font-size: 1.05rem;
}

.play-reward-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.treasure-path {
  flex: 0 0 min(180px, 38%);
  height: 14px;
  border: 2px solid #f6b84d;
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
}

.treasure-path span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffb84d, #34c38f);
  transition: width 220ms ease;
}

.problem-area {
  display: grid;
  place-items: center;
  min-height: 320px;
  margin: 16px 0;
  border: 2px dashed #c7d2e5;
  border-radius: 8px;
  background: #fbfdff;
  overflow-x: auto;
}

.problem-area:focus-within {
  border-color: #ffcf75;
}

.guided-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(220px, 300px);
  gap: 18px;
  align-items: stretch;
  width: 100%;
}

.paper-board {
  width: min(100%, 520px);
  padding: 24px;
  color: #1f2937;
  font-family: "Consolas", "Courier New", monospace;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 800;
  --cell-size: 1.28em;
}

.calc-row {
  display: grid;
  justify-items: end;
  min-height: 1.35em;
}

.digit-line {
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  justify-content: end;
  align-items: center;
}

.digit-cell {
  display: grid;
  place-items: center;
  width: var(--cell-size);
  height: 1.34em;
  line-height: 1;
  text-align: center;
}

.carry-line {
  min-height: 0.78em;
  margin-bottom: -0.08em;
}

.carry-line .digit-cell {
  height: 0.78em;
  align-items: end;
}

.calc-line {
  height: 3px;
  margin: 8px 0;
  background: var(--ink);
}

.operator-row {
  display: grid;
  grid-template-columns: var(--cell-size) 1fr;
  gap: 8px;
  align-items: center;
}

.operator {
  color: var(--rose);
  display: grid;
  place-items: center;
  width: var(--cell-size);
}

.digit-input {
  width: 1.05em;
  height: 1.16em;
  margin: 0;
  border: 3px solid var(--accent);
  border-radius: 8px;
  background: #eef6ff;
  color: var(--ink);
  text-align: center;
  font: inherit;
  font-weight: 900;
  line-height: 1;
  vertical-align: baseline;
}

.digit-input.carry-input {
  width: 0.9em;
  height: 0.9em;
  border-width: 2px;
  border-radius: 6px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.58em;
  transform: translateY(0.12em);
}

.digit-input.locked,
.digit-input:disabled {
  border-color: #ccd5e2;
  background: #f3f6fa;
  color: #98a2b3;
  cursor: default;
}

.digit-input.active {
  border-color: #f79009;
  background: #fff4df;
  color: var(--ink);
  box-shadow:
    0 0 0 5px rgba(247, 144, 9, 0.18),
    0 8px 18px rgba(247, 144, 9, 0.2);
  cursor: text;
}

.digit-input.carry-input.active {
  border-color: #f97316;
  background: #ffedd5;
  color: #7c2d12;
  box-shadow:
    0 0 0 4px rgba(249, 115, 22, 0.18),
    0 6px 14px rgba(249, 115, 22, 0.18);
}

.digit-input:focus {
  outline: 4px solid rgba(47, 128, 237, 0.2);
}

.digit-input.correct {
  border-color: var(--mint);
  background: #eaffe9;
  color: var(--ink);
}

.digit-input.carry-input.correct {
  color: #087443;
}

.digit-input.wrong {
  border-color: var(--rose);
  background: #fff0f2;
}

.digit-input.mistake-shake {
  animation: mistakeShake 320ms ease both;
}

.assist-focus {
  position: relative;
  z-index: 1;
  border-radius: 8px;
  box-shadow:
    0 0 0 4px rgba(247, 144, 9, 0.18),
    0 0 22px rgba(247, 144, 9, 0.26);
}

.assist-source {
  border-radius: 8px;
  background: rgba(255, 244, 215, 0.75);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.12);
}

.hint-pulse {
  border-color: #f79009 !important;
  background: #fff4d7 !important;
  animation: hintPulse 900ms ease-in-out infinite;
}

.input-group {
  display: inline-grid;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  justify-content: end;
  align-items: center;
}

.fill-layout {
  grid-template-columns: minmax(280px, 1fr) minmax(220px, 300px);
}

.fill-board {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  width: min(100%, 560px);
  min-height: 260px;
  border: 3px solid #ffd166;
  border-radius: 18px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.92), transparent 30%),
    linear-gradient(135deg, #fff4c2, #ffe0f1 48%, #d9f7ff);
  box-shadow:
    0 18px 38px rgba(247, 144, 9, 0.18),
    inset 0 0 0 5px rgba(255, 255, 255, 0.55);
  font-family: var(--font-family, inherit);
}

.fill-badge {
  padding: 7px 14px;
  border-radius: 999px;
  background: #ff8a00;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 8px 16px rgba(255, 138, 0, 0.28);
}

.fill-equation {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(10px, 2vw, 18px);
  color: #172033;
  font-size: clamp(2.35rem, 7vw, 4.9rem);
  font-weight: 950;
  line-height: 1;
}

.fill-equation .input-group {
  --cell-size: 1.08em;
}

.fill-equation .digit-cell {
  width: var(--cell-size);
  height: 1.18em;
}

.fill-equation .digit-input {
  width: 1.06em;
  height: 1.06em;
  border-width: 4px;
  border-radius: 16px;
  background: #fff7df;
}

.fill-equation .digit-input.active {
  background: #ffedc2;
  box-shadow:
    0 0 0 7px rgba(247, 144, 9, 0.22),
    0 14px 28px rgba(247, 144, 9, 0.28);
}

.fill-number,
.fill-product {
  min-width: 1.15em;
  text-align: center;
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.7);
}

.fill-product {
  color: #2364d2;
}

.fill-operator {
  color: #ff5a7a;
}

.fill-reward-hint {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  color: #344054;
  font-size: 0.95rem;
  font-weight: 800;
}

.fill-reward-hint strong {
  color: #0f8a5f;
}

.problem-area:has(.fill-layout) {
  overflow: visible;
}

.division-board {
  width: min(100%, 620px);
  --division-label-width: 4.2em;
  --division-label-gap: 8px;
  --division-bracket-offset: 18px;
  --division-step-offset: 14px;
}

.wide-division-layout {
  grid-template-columns: minmax(0, 1fr);
}

.wide-division-layout .step-guide {
  width: min(100%, 620px);
  justify-self: center;
}

.wide-division {
  width: max-content;
  max-width: 100%;
  padding: 18px;
  font-size: clamp(1.25rem, 2.4vw, 1.9rem);
  --cell-size: 1.08em;
  --division-label-width: 3.8em;
  --division-label-gap: 6px;
  --division-bracket-offset: 16px;
  --division-step-offset: 12px;
}

.division-top {
  display: grid;
  grid-template-columns: var(--division-label-width) auto auto;
  align-items: end;
  justify-content: center;
  column-gap: var(--division-label-gap);
}

.division-work {
  width: calc((var(--cols) * var(--cell-size)) + 18px);
}

.division-work > .digit-line {
  justify-content: start;
  padding-left: 18px;
}

.division-symbol {
  border-left: 4px solid var(--ink);
  border-top: 4px solid var(--ink);
  padding: 10px 0 0 14px;
}

.division-symbol .digit-line {
  justify-content: start;
}

.division-checks {
  display: grid;
  gap: 12px;
  margin-top: 24px;
  font-family: inherit;
  font-size: clamp(1.1rem, 3vw, 1.45rem);
}

.division-steps {
  display: grid;
  gap: 2px;
  margin-top: 10px;
  width: calc(var(--division-label-width) + var(--division-label-gap) + var(--cols) * var(--cell-size) + var(--division-bracket-offset));
  margin-left: auto;
  margin-right: auto;
}

.division-steps .digit-line {
  justify-content: start;
  padding-left: var(--division-step-offset);
}

.division-work-row {
  display: grid;
  grid-template-columns: var(--division-label-width) 1fr;
  align-items: center;
  gap: var(--division-label-gap);
}

.division-work-row::before {
  content: attr(data-label);
  justify-self: end;
  color: #667085;
  font-family:
    "Yu Gothic", "Hiragino Kaku Gothic ProN", "Meiryo", system-ui, sans-serif;
  font-size: 0.32em;
  font-weight: 900;
}

.division-subtract-line {
  width: calc(100% - var(--division-label-width) - var(--division-label-gap) - var(--division-step-offset));
  height: 3px;
  margin: 2px 0 4px auto;
  background: #253044;
}

.division-product-row .digit-input {
  background: #eef6ff;
}

.division-carry-work-row .carry-line {
  opacity: 1;
}

.division-carry-work-row .digit-input.carry-input {
  width: 0.9em;
  height: 0.9em;
  min-height: 0;
  border-width: 2px;
  border-radius: 6px;
  font-size: 0.58em;
  transform: translateY(0.12em);
}

.division-remainder-row .digit-input,
.division-final-row .digit-input {
  background: #f8fafc;
}

.step-guide {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px;
  border: 2px solid #ffd08a;
  border-radius: 8px;
  background: #fff8ec;
  box-shadow: 0 10px 26px rgba(247, 144, 9, 0.12);
}

.step-guide h3 {
  margin: 0;
  font-size: 1.05rem;
}

.step-guide p {
  margin: 0;
}

#stepText {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.55;
}

.carry-board {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 2px solid #f6c56f;
  border-radius: 8px;
  background: #fff;
}

.carry-board span {
  color: #b54708;
  font-size: 0.78rem;
  font-weight: 900;
}

.carry-board strong {
  font-size: 0.95rem;
  line-height: 1.45;
}

.division-multiply-assist {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 2px solid #9ed7ff;
  border-radius: 8px;
  background: #f0f9ff;
  color: var(--ink);
}

.division-multiply-assist[hidden] {
  display: none;
}

.division-multiply-memo {
  display: grid;
  gap: 5px;
}

.division-multiply-memo span {
  color: #1b5fbe;
  font-size: 0.78rem;
  font-weight: 900;
}

.division-multiply-memo strong {
  font-size: 1rem;
}

.division-multiply-memo p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1.4;
}

.step-meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #ffe3b8;
}

.step-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f79009, var(--mint));
  transition: width 220ms ease;
}

.check-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.feedback {
  min-height: 34px;
  margin: 18px 0 0;
  color: var(--ink);
  font-weight: 900;
  text-align: center;
}

.feedback.good {
  color: #087443;
}

.feedback.try {
  color: #b54708;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.numpad button {
  min-height: 46px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.numpad button:active {
  border-color: #f79009;
  background: #fff4df;
}

.celebration {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.stage-up-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 207, 117, 0.42), transparent 34%),
    rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: scale(0.98);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.stage-up-overlay.show {
  opacity: 1;
  transform: scale(1);
}

.stage-up-card {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(520px, 100%);
  border: 4px solid #ffcf75;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.95), transparent 34%),
    linear-gradient(135deg, #fff8df, #e8fff2);
  padding: 22px;
  text-align: center;
  overflow: hidden;
  box-shadow:
    0 28px 80px rgba(37, 48, 68, 0.24),
    0 0 0 10px rgba(255, 207, 117, 0.18);
}

.stage-up-card::before,
.stage-up-card::after {
  content: "★";
  position: absolute;
  color: #f79009;
  font-size: 2rem;
  animation: stageStarFloat 1400ms ease-in-out infinite;
}

.stage-up-card::before {
  left: 32px;
  top: 28px;
}

.stage-up-card::after {
  right: 38px;
  bottom: 34px;
  animation-delay: 220ms;
}

.stage-up-glow {
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 0deg, transparent, rgba(255, 207, 117, 0.45), transparent, rgba(52, 195, 143, 0.3), transparent);
  animation: stageSpin 3600ms linear infinite;
}

.stage-up-character {
  position: relative;
  width: 118px;
  height: 118px;
  margin-bottom: 6px;
  filter: drop-shadow(0 16px 22px rgba(37, 48, 68, 0.16));
  animation: stagePop 700ms ease both;
}

.stage-up-card .eyebrow,
.stage-up-card h2,
.stage-up-card p,
.stage-up-card strong {
  position: relative;
}

.stage-up-card h2 {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
}

.stage-up-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
}

.stage-up-card strong {
  margin-top: 14px;
  padding: 8px 18px;
  border-radius: 999px;
  background: #f79009;
  color: #fff;
  box-shadow: 0 12px 24px rgba(247, 144, 9, 0.22);
}

.reward-toast {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: start end;
  padding: 18px;
  opacity: 0;
  transform: translateY(-12px) scale(0.98);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

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

.reward-toast-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  width: min(380px, calc(100vw - 28px));
  border: 4px solid #ffb020;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.96), transparent 30%),
    linear-gradient(135deg, rgba(255, 229, 138, 0.98), rgba(255, 255, 255, 0.98));
  padding: 12px 14px;
  box-shadow:
    0 24px 70px rgba(255, 159, 28, 0.22),
    0 0 0 8px rgba(255, 212, 59, 0.12);
  text-align: left;
  overflow: hidden;
}

.reward-toast-card .eyebrow {
  margin: 0 0 2px;
  font-size: 0.72rem;
}

.reward-toast.treasure .reward-toast-card {
  border-color: #f79009;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 207, 117, 0.62), transparent 35%),
    linear-gradient(135deg, rgba(255, 250, 240, 0.98), rgba(255, 244, 215, 0.98));
  box-shadow:
    0 24px 70px rgba(247, 144, 9, 0.26),
    0 0 0 8px rgba(255, 207, 117, 0.18);
}

.reward-toast.stage .reward-toast-card {
  border-color: #34c38f;
  background:
    radial-gradient(circle at 50% 0%, rgba(52, 195, 143, 0.34), transparent 38%),
    linear-gradient(135deg, rgba(232, 255, 242, 0.98), rgba(255, 248, 223, 0.98));
  box-shadow:
    0 24px 70px rgba(52, 195, 143, 0.22),
    0 0 0 8px rgba(255, 207, 117, 0.16);
}

.reward-toast.gacha-ready .reward-toast-card {
  border-color: #f79009;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.98), transparent 28%),
    linear-gradient(135deg, #fff4d7, #ffe0f0, #eff6ff);
  box-shadow:
    0 24px 70px rgba(247, 144, 9, 0.24),
    0 0 0 8px rgba(255, 255, 255, 0.5);
}

.reward-prize {
  display: grid;
  place-items: center;
  grid-row: 1 / span 4;
  width: 58px;
  height: 50px;
  margin: 0;
  border: 3px solid #92400e;
  border-radius: 8px 8px 12px 12px;
  background:
    linear-gradient(#ffd43b 0 42%, #ff8a00 42% 100%);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 900;
  box-shadow:
    0 14px 30px rgba(247, 144, 9, 0.28),
    0 0 18px rgba(255, 212, 59, 0.28);
}

.reward-toast.treasure .reward-prize {
  width: 64px;
  height: 54px;
  border-color: #78350f;
  background:
    linear-gradient(#ffe7a3 0 38%, #f79009 38% 100%);
  box-shadow:
    0 18px 34px rgba(247, 144, 9, 0.28),
    inset 0 0 0 3px rgba(255, 255, 255, 0.28);
}

.reward-toast.stage .reward-prize {
  border-color: #087443;
  background:
    radial-gradient(circle, #fff6b8 0 34%, transparent 35%),
    linear-gradient(135deg, #34c38f, #f79009);
}

.reward-toast.gacha-ready .reward-prize {
  border-color: #92400e;
  background: #fff4d7;
  color: #92400e;
  animation:
    treasurePop 520ms ease both,
    readyButton 900ms ease-in-out infinite;
}

.reward-prize span {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: rgba(146, 64, 14, 0.24);
}

.reward-toast.show .reward-prize {
  animation: treasurePop 520ms ease both;
}

.reward-toast-card h2 {
  margin: 0 0 4px;
  font-size: 1.12rem;
  line-height: 1.2;
}

.reward-toast-card p:last-child {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
  font-size: 0.86rem;
  line-height: 1.35;
}

.toast-road {
  grid-column: 2;
  height: 12px;
  margin-top: 8px;
  border: 2px solid #d6deeb;
  border-radius: 999px;
  background: #f8fafc;
  overflow: hidden;
}

.toast-road span {
  display: block;
  width: 12%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #18b97d, #ffd43b, #ff8a00, #8b5cf6);
  transition: width 260ms ease;
}

.spark {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  background: var(--gold);
  animation: fall 900ms ease-out forwards;
}

.spark:nth-child(3n) {
  background: var(--aqua);
}

.spark:nth-child(3n + 1) {
  background: var(--violet);
}

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

@keyframes mistakeShake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  55% {
    transform: translateX(5px);
  }

  78% {
    transform: translateX(-2px);
  }
}

@keyframes hintPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(247, 144, 9, 0.28);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(247, 144, 9, 0);
  }
}

@keyframes stageSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes stagePop {
  0% {
    transform: translateY(12px) scale(0.84);
    opacity: 0;
  }

  60% {
    transform: translateY(-6px) scale(1.08);
    opacity: 1;
  }

  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes stageStarFloat {
  0%,
  100% {
    transform: translateY(0) rotate(-8deg);
  }

  50% {
    transform: translateY(-10px) rotate(8deg);
  }
}

@keyframes treasurePop {
  0% {
    transform: translateY(12px) scale(0.88) rotate(-4deg);
    opacity: 0;
  }

  55% {
    transform: translateY(-8px) scale(1.08) rotate(3deg);
    opacity: 1;
  }

  100% {
    transform: translateY(0) scale(1) rotate(0);
    opacity: 1;
  }
}

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

  .top-bar,
  .controls,
  .workspace,
  .feature-strip,
  .tool-panel,
  .parent-dashboard,
  .parent-insight-grid,
  .parent-tool-grid,
  .hero-panel,
  .gacha-hero,
  .gacha-action-panel,
  .gacha-result,
  .home-dashboard,
  .stage-strip,
  .map-status-grid,
  .map-journey-meter,
  .course-grid {
    grid-template-columns: 1fr;
  }

  .course-category.featured {
    grid-template-columns: 1fr;
  }

  .course-category .course-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .gacha-focus-panel,
  .gacha-exchange-teaser,
  .reward-summary-grid {
    grid-template-columns: 1fr;
  }

  .course-head {
    align-items: stretch;
    flex-direction: column;
  }

  .gacha-status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .gacha-machine {
    width: min(290px, 82%);
  }

  .gacha-hero {
    min-height: auto;
  }

  .gacha-dome {
    height: 172px;
  }

  .gacha-body {
    height: 136px;
  }

  .gacha-action-panel {
    align-items: stretch;
  }

  .gacha-button {
    width: 100%;
  }

  .score-board,
  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }

  .parent-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .problem-card,
  .mission-panel {
    padding: 18px;
  }

  .problem-head {
    align-items: stretch;
  }

  .paper-board {
    padding: 12px;
  }

  .guided-layout {
    grid-template-columns: 1fr;
  }

  .custom-form,
  .review-box {
    grid-template-columns: 1fr;
  }

  .reset-action-grid {
    grid-template-columns: 1fr;
  }

  .numpad {
    grid-template-columns: repeat(3, 1fr);
  }

  .hero-panel {
    min-height: auto;
  }

  .hero-teacher {
    min-height: 220px;
  }

  .pencil-pal {
    width: 136px;
    height: 214px;
  }

  .pencil-pal::before {
    left: 32px;
    top: -68px;
    border-left-width: 34px;
    border-right-width: 34px;
    border-bottom-width: 72px;
  }

  .pencil-pal::after {
    left: 56px;
    top: -68px;
  }

  .pencil-band {
    top: 24px;
  }

  .pencil-eye {
    top: 82px;
  }

  .pencil-eye.left {
    left: 40px;
  }

  .pencil-eye.right {
    right: 40px;
  }

  .pencil-cheek,
  .pencil-smile,
  .pencil-note {
    transform: scale(0.82);
  }

  .pencil-cheek {
    top: 118px;
  }

  .pencil-smile {
    left: 48px;
    top: 116px;
  }

  .pencil-arm.left {
    left: -36px;
  }

  .pencil-arm.right {
    right: -34px;
  }

  .pencil-note {
    right: -54px;
    top: 142px;
  }

  .pencil-foot {
    width: 40px;
  }

  .big-map-trail {
    grid-template-columns: repeat(2, 1fr);
  }

  .map-view.has-stage-art .section-head {
    width: calc(100% - 24px);
    margin: 0 0 -78px 12px;
    padding: 12px;
  }

  .map-view.has-stage-art .section-head h2 {
    margin-bottom: 4px;
    font-size: 1.1rem;
  }

  .map-view.has-stage-art .section-head .large-copy {
    font-size: 0.86rem;
    line-height: 1.35;
  }

  .map-view.has-stage-art .map-status-grid {
    margin: -68px 8px 14px;
    padding: 0;
  }
}

@media (orientation: landscape) and (min-width: 821px) and (max-height: 820px) {
  .app-shell {
    width: min(1160px, calc(100% - 24px));
    padding: 10px 0 8px;
  }

  .hero-panel {
    grid-template-columns: minmax(420px, 1fr) 220px;
    min-height: 250px;
    gap: 18px;
    padding: 22px 28px;
  }

  .hero-copy h1 {
    margin: 0 0 8px;
    max-width: 560px;
    font-size: clamp(2rem, 3.5vw, 2.75rem);
  }

  .hero-copy p:not(.eyebrow) {
    max-width: 620px;
    font-size: 0.98rem;
    line-height: 1.45;
  }

  .home-actions {
    margin-top: 14px;
  }

  .hero-teacher {
    min-height: 176px;
  }

  .character-avatar-main {
    width: min(210px, 22vw);
  }

  .home-dashboard {
    gap: 10px;
    margin-top: 10px;
  }

  .home-dashboard-simple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .daily-card {
    min-height: 132px;
    gap: 8px;
    padding: 12px;
  }

  .daily-card h2 {
    font-size: 1.08rem;
  }

  .daily-card p {
    font-size: 0.86rem;
    line-height: 1.35;
  }

  .home-secondary-actions {
    margin-top: 10px;
  }

  .home-secondary-actions .ghost-button,
  .parent-link {
    font-size: 0.82rem;
  }

  .gacha-view {
    min-height: auto;
    padding: 12px 16px 4px;
  }

  .gacha-view .page-nav {
    margin-bottom: 10px;
  }

  .gacha-hero {
    grid-template-columns: minmax(420px, 1fr) 250px;
    min-height: 280px;
    padding: 14px 18px;
  }

  .gacha-copy h2 {
    margin-bottom: 8px;
    font-size: clamp(1.7rem, 3.2vw, 2.35rem);
  }

  .gacha-copy .large-copy {
    font-size: 0.92rem;
    line-height: 1.4;
  }

  .gacha-status-grid {
    margin-top: 12px;
  }

  .gacha-stat {
    min-height: 76px;
    padding: 10px;
  }

  .gacha-machine {
    width: 250px;
  }

  .gacha-dome {
    height: 132px;
  }

  .gacha-body {
    height: 106px;
  }

  .capsule {
    width: 46px;
    height: 46px;
  }

  .capsule.c1 {
    left: 34px;
    top: 62px;
  }

  .capsule.c2 {
    left: 92px;
    top: 40px;
  }

  .capsule.c3 {
    right: 34px;
    top: 64px;
  }

  .capsule.c4 {
    left: 62px;
    top: 96px;
  }

  .capsule.c5 {
    right: 72px;
    top: 94px;
  }

  .gacha-body strong {
    font-size: 2.1rem;
  }

  .gacha-window {
    min-width: 96px;
    min-height: 26px;
    font-size: 0.72rem;
  }

  .gacha-handle {
    right: -20px;
    top: 36px;
    width: 44px;
    height: 44px;
    box-shadow: inset 0 0 0 10px #bfd7ff;
  }

  .gacha-handle::after {
    left: 16px;
    top: 34px;
    height: 36px;
  }

  .gacha-action-panel {
    min-height: 92px;
    margin: 8px 0;
    padding: 12px;
  }

  .gacha-result {
    min-height: 96px;
    padding: 10px 12px;
  }

  .gacha-result-prize {
    width: 58px;
    height: 58px;
  }

  .gacha-result h3 {
    font-size: 1.08rem;
  }

  .gacha-result p {
    font-size: 0.82rem;
    line-height: 1.35;
  }

  .gacha-prize-preview {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 6px;
  }

  .gacha-focus-panel,
  .gacha-exchange-teaser,
  .gacha-prize-list {
    padding: 10px;
  }

  .gacha-prize-grid {
    grid-template-columns: repeat(6, minmax(86px, 1fr));
    gap: 8px;
  }

  .gacha-prize-card {
    min-height: 72px;
    gap: 4px;
    padding: 8px;
  }

  .gacha-prize-card strong {
    font-size: 0.72rem;
  }

  .gacha-prize-card small {
    font-size: 0.66rem;
  }

  .prize-portrait {
    width: 34px;
    height: 34px;
  }

  .gacha-result-prize img {
    width: 52px;
    height: 52px;
  }

  .prize-portrait img + .prize-mark,
  .gacha-result-prize img + .prize-mark {
    width: 18px;
    height: 18px;
    font-size: 0.56rem;
  }

  .gacha-footer-actions {
    display: none;
  }
}

@media (max-width: 520px) {
  .ad-slot {
    min-height: 72px;
    margin-top: 14px;
  }

  .home-dashboard-simple {
    grid-template-columns: 1fr;
  }

  .reward-toast {
    place-items: start center;
    padding: 10px;
  }

  .reward-toast-card {
    width: min(100%, 340px);
    column-gap: 10px;
    padding: 10px 12px;
  }

  .reward-prize {
    width: 50px;
    height: 44px;
    font-size: 0.95rem;
  }

  .reward-toast-card h2 {
    font-size: 1rem;
  }

  .course-select-hero {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .course-select-hero .character-avatar {
    display: none;
  }

  .course-category {
    padding: 12px;
  }

  .course-category .course-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.65rem;
  }

  .gacha-status-grid {
    grid-template-columns: 1fr;
  }

  .controls {
    padding: 10px;
  }

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

  .parent-dashboard {
    grid-template-columns: 1fr;
  }

  .exchange-card {
    grid-template-columns: 44px 1fr;
  }

  .exchange-card .mini-action-button {
    grid-column: 1 / -1;
  }

  .problem-head {
    flex-direction: column;
  }

  .division-top {
    gap: 10px;
  }

  .digit-input {
    border-width: 2px;
    border-radius: 6px;
  }
}

@media (max-width: 699px) {
  .app-shell {
    width: min(100% - 12px, 680px);
    padding-top: 6px;
    padding-bottom: 0;
  }

  .page-nav {
    top: 4px;
    margin-bottom: 8px;
    padding: 4px;
  }

  .challenge-view .top-bar {
    grid-template-columns: minmax(150px, 1fr) minmax(270px, auto);
    align-items: center;
    gap: 8px;
  }

  .challenge-view .top-bar h1 {
    font-size: 1.24rem;
  }

  .challenge-view .score-board {
    gap: 6px;
  }

  .challenge-view .score-board > div {
    min-width: 0;
    padding: 5px 6px;
  }

  .challenge-view .score-label {
    font-size: 0.68rem;
  }

  .challenge-view .score-board strong {
    font-size: 1rem;
  }

  .challenge-view .controls {
    margin: 8px 0;
    padding: 6px;
  }

  .course-controls.compact {
    gap: 8px;
    padding: 8px;
  }

  .course-controls.compact .course-head {
    align-items: center;
    flex-direction: row;
  }

  .course-controls.compact .course-head h2 {
    font-size: 1rem;
  }

  .challenge-view .course-controls.compact .course-head h2,
  .challenge-view .course-controls.compact .course-head p {
    display: none;
  }

  .course-controls.compact .course-actions {
    flex-wrap: nowrap;
  }

  .course-controls.compact .course-actions button {
    min-height: 32px;
    padding: 0 8px;
    font-size: 0.82rem;
  }

  .course-controls.compact .course-card {
    min-height: 40px;
    grid-template-columns: 1fr;
    padding: 6px 8px;
  }

  .course-controls.compact .course-card strong {
    font-size: 0.88rem;
  }

  .course-controls.compact .course-card span {
    display: none;
  }

  .challenge-view .workspace {
    gap: 8px;
  }

  .challenge-view .mission-panel {
    display: none;
  }

  .challenge-view.fill-challenge .workspace {
    grid-template-columns: 1fr;
  }

  .challenge-view.fill-challenge .mission-panel,
  .challenge-view.fill-challenge .play-reward-panel {
    display: none;
  }

  .challenge-view .problem-card {
    min-height: 0;
    padding: 10px;
  }

  .challenge-view .problem-head {
    gap: 8px;
    align-items: center;
  }

  .challenge-view .problem-head .eyebrow {
    display: none;
  }

  .challenge-view .problem-head h2 {
    margin: 0;
    font-size: 1rem;
  }

  .challenge-view .stage-status-panel {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 6px 0;
  }

  .challenge-view .stage-status-main {
    grid-column: 1 / -1;
  }

  .challenge-view .stage-status-main,
  .challenge-view .stage-status-item {
    min-height: 42px;
    padding: 6px 8px;
  }

  .challenge-view .stage-status-panel span {
    font-size: 0.66rem;
  }

  .challenge-view .stage-status-panel strong {
    font-size: 0.82rem;
  }

  .challenge-view .play-reward-panel {
    gap: 8px;
    margin: 6px 0 4px;
    padding: 6px 8px;
  }

  .challenge-view .play-reward-panel .eyebrow {
    display: none;
  }

  .challenge-view .play-reward-panel > div:first-child {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    align-items: baseline;
    min-width: 0;
  }

  .challenge-view .play-reward-panel strong {
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .challenge-view .play-reward-panel span {
    font-size: 0.74rem;
    white-space: nowrap;
  }

  .challenge-view .treasure-path {
    flex-basis: 112px;
    height: 11px;
  }

  .challenge-view .problem-area {
    min-height: 164px;
    max-height: 164px;
    margin: 8px 0;
    padding: 10px;
    overflow: auto;
  }

  .challenge-view .guided-layout {
    gap: 8px;
  }

  .challenge-view .paper-board {
    padding: 10px;
    font-size: clamp(1.05rem, 4.7vw, 1.62rem);
  }

  .challenge-view .step-guide {
    gap: 7px;
    padding: 10px;
  }

  .challenge-view .step-guide h3 {
    font-size: 1rem;
  }

  .challenge-view .step-guide p,
  .challenge-view .carry-board {
    font-size: 0.86rem;
  }
}

@media (min-width: 521px) and (max-width: 699px) {
  .challenge-view .course-controls.compact {
    display: flex;
    align-items: center;
  }

  .challenge-view .course-controls.compact .course-head {
    flex: 0 0 auto;
  }

  .challenge-view .course-controls.compact .course-grid {
    flex: 1 1 auto;
    min-width: 0;
  }

  .challenge-view .guided-layout {
    grid-template-columns: minmax(250px, 1fr) minmax(190px, 220px);
    align-items: start;
  }

  .challenge-view .step-guide {
    max-height: 164px;
    overflow: auto;
  }

  .challenge-view .numpad {
    grid-template-columns: repeat(6, minmax(42px, 1fr));
    gap: 6px;
    margin-top: 8px;
  }

  .challenge-view .numpad button {
    min-height: 38px;
    padding: 0 8px;
  }
}

@media (min-width: 700px) and (max-width: 1100px) {
  .app-shell {
    width: min(100% - 16px, 1040px);
    padding-top: 10px;
  }

  .page-nav {
    top: 4px;
    margin-bottom: 10px;
    padding: 4px;
  }

  .top-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .top-bar h1 {
    font-size: 1.45rem;
  }

  .score-board {
    grid-template-columns: repeat(3, minmax(78px, 1fr));
    gap: 6px;
  }

  .score-board > div {
    min-width: 0;
    padding: 8px 10px;
  }

  .score-board strong {
    font-size: 1.2rem;
  }

  .controls {
    margin: 10px 0;
    padding: 10px;
    gap: 10px;
  }

  .course-head {
    align-items: center;
    flex-direction: row;
  }

  .course-head h2 {
    font-size: 1.1rem;
  }

  .course-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .course-card {
    min-height: 72px;
    padding: 10px;
  }

  .course-card strong {
    font-size: 0.9rem;
  }

  .course-card span {
    font-size: 0.72rem;
    line-height: 1.25;
  }

  .workspace {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 10px;
  }

  .challenge-view.fill-challenge .workspace {
    grid-template-columns: 1fr;
  }

  .challenge-view.fill-challenge .mission-panel,
  .challenge-view.fill-challenge .play-reward-panel {
    display: none;
  }

  .mission-panel,
  .problem-card {
    padding: 12px;
  }

  .mission-panel h2 {
    font-size: 1rem;
  }

  .mission-panel .mascot {
    display: none;
  }

  .coach-panel.in-sidebar {
    padding: 10px;
  }

  .problem-card {
    min-height: 0;
  }

  .problem-head {
    align-items: center;
  }

  .problem-head h2 {
    font-size: 1.15rem;
  }

  .problem-area {
    min-height: 260px;
    max-height: calc(100vh - 360px);
    margin: 10px 0;
    overflow: auto;
    align-items: start;
  }

  .challenge-view .problem-area:has(.fill-layout) {
    min-height: 250px;
    max-height: none;
    overflow: visible;
  }

  .guided-layout {
    grid-template-columns: minmax(240px, 1fr) minmax(180px, 240px);
    gap: 10px;
  }

  .challenge-view .fill-layout {
    grid-template-columns: minmax(430px, 1fr) minmax(190px, 260px);
    gap: 8px;
  }

  .challenge-view .fill-board {
    min-height: 198px;
    gap: 10px;
    padding: 14px;
  }

  .challenge-view .fill-equation {
    gap: 10px;
    font-size: clamp(2.2rem, 5vw, 3.8rem);
  }

  .challenge-view .fill-layout .step-guide {
    max-height: none;
    overflow: visible;
  }

  .paper-board {
    padding: 12px;
    font-size: clamp(1.25rem, 2.4vw, 1.9rem);
  }

  .step-guide {
    padding: 12px;
    gap: 8px;
  }

  .step-guide h3 {
    font-size: 1rem;
  }

  .step-guide p,
  .carry-board {
    font-size: 0.86rem;
  }

  .actions {
    gap: 8px;
  }

  .numpad {
    gap: 7px;
  }

  .numpad button,
  .primary-button,
  .ghost-button {
    min-height: 40px;
  }
}

@media (orientation: landscape) and (min-width: 700px) and (max-width: 1100px) and (max-height: 820px) {
  .challenge-view {
    max-height: calc(100vh - 12px);
    overflow: hidden;
  }

  .challenge-ad-slot {
    display: none;
  }

  .challenge-view .page-nav {
    display: none;
  }

  .challenge-view .top-bar {
    grid-template-columns: auto 1fr;
    align-items: center;
    margin-bottom: 0;
  }

  .challenge-view .top-bar .eyebrow,
  .challenge-view .top-bar h1 {
    display: none;
  }

  .challenge-view .score-board {
    justify-content: end;
  }

  .challenge-view .score-board > div {
    min-height: 30px;
    padding: 4px 7px;
  }

  .challenge-view .course-controls.compact {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    padding: 4px;
  }

  .challenge-view .course-controls.compact .course-head {
    flex: 0 0 auto;
  }

  .challenge-view .course-controls.compact .course-head h2,
  .challenge-view .course-controls.compact .course-head p {
    display: none;
  }

  .challenge-view .course-controls.compact .course-actions {
    flex-wrap: nowrap;
  }

  .challenge-view .course-controls.compact .course-actions button {
    min-height: 28px;
    padding: 0 8px;
    font-size: 0.78rem;
  }

  .challenge-view .course-controls.compact .course-grid {
    flex: 1 1 auto;
    min-width: 0;
  }

  .challenge-view .course-controls.compact .course-card {
    min-height: 36px;
    grid-template-columns: 1fr;
    padding: 6px 8px;
  }

  .challenge-view .course-controls.compact .course-card span {
    display: none;
  }

  .challenge-view .workspace {
    grid-template-columns: 1fr;
  }

  .challenge-view .mission-panel {
    display: none;
  }

  .challenge-view .problem-card {
    padding: 7px;
  }

  .challenge-view .problem-head {
    align-items: center;
    margin-bottom: 4px;
  }

  .challenge-view .problem-head h2 {
    font-size: 0.92rem;
  }

  .challenge-view .problem-head .eyebrow {
    display: none;
  }

  .challenge-view .problem-head .ghost-button {
    min-height: 28px;
    padding: 0 8px;
    font-size: 0.78rem;
  }

  .challenge-view .stage-status-panel {
    grid-template-columns: minmax(150px, 1fr) repeat(2, minmax(92px, auto));
    gap: 6px;
    margin: 3px 0;
  }

  .challenge-view .stage-status-main,
  .challenge-view .stage-status-item {
    min-height: 28px;
    padding: 3px 7px;
  }

  .challenge-view .stage-status-panel span {
    font-size: 0.62rem;
  }

  .challenge-view .stage-status-panel strong {
    font-size: 0.78rem;
  }

  .challenge-view .play-reward-panel {
    display: none;
  }

  .challenge-view .problem-area {
    min-height: 168px;
    max-height: 210px;
    margin: 4px 0;
    overflow: auto;
  }

  .challenge-view .problem-area:has(.fill-layout) {
    min-height: 238px;
    max-height: none;
    overflow: visible;
  }

  .challenge-view .guided-layout {
    grid-template-columns: minmax(280px, 1fr) minmax(200px, 260px);
  }

  .challenge-view .fill-layout {
    grid-template-columns: minmax(470px, 1fr) minmax(200px, 270px);
    align-items: stretch;
    gap: 8px;
  }

  .challenge-view .fill-board {
    min-height: 190px;
    gap: 10px;
    padding: 14px;
    border-radius: 14px;
  }

  .challenge-view .fill-badge {
    padding: 5px 12px;
    font-size: 0.82rem;
  }

  .challenge-view .fill-equation {
    gap: 10px;
    font-size: clamp(2.15rem, 5.2vw, 3.9rem);
  }

  .challenge-view .fill-equation .digit-input {
    border-width: 3px;
    border-radius: 12px;
  }

  .challenge-view .fill-reward-hint {
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .challenge-view .fill-layout .step-guide {
    max-height: none;
    overflow: visible;
  }

  .challenge-view .wide-division-layout {
    grid-template-columns: minmax(0, 1fr) minmax(190px, 240px);
    gap: 8px;
    align-items: stretch;
  }

  .challenge-view .wide-division-layout .step-guide {
    width: auto;
    max-height: 200px;
    padding: 8px;
    gap: 5px;
    overflow: hidden;
  }

  .challenge-view .wide-division {
    padding: 6px;
    font-size: clamp(0.78rem, 1.42vw, 1.05rem);
    --cell-size: 0.9em;
    --division-label-width: 3.2em;
    --division-label-gap: 4px;
    --division-bracket-offset: 12px;
    --division-step-offset: 8px;
  }

  .challenge-view .wide-division .division-symbol {
    border-left-width: 3px;
    border-top-width: 3px;
    padding: 5px 0 0 8px;
  }

  .challenge-view .wide-division .division-work {
    width: calc((var(--cols) * var(--cell-size)) + 10px);
  }

  .challenge-view .wide-division .division-work > .digit-line {
    padding-left: 10px;
  }

  .challenge-view .wide-division .division-steps {
    gap: 0;
    margin-top: 3px;
  }

  .challenge-view .wide-division .division-subtract-line {
    height: 2px;
    margin: 0 0 1px auto;
  }

  .challenge-view .wide-division .digit-cell {
    height: 1.12em;
  }

  .challenge-view .wide-division .digit-input {
    border-width: 2px;
    border-radius: 5px;
  }

  .challenge-view .wide-division .digit-input.carry-input {
    width: 0.9em;
    height: 0.9em;
    font-size: 0.58em;
  }

  .challenge-view .wide-division-layout .step-guide h3 {
    font-size: 0.92rem;
  }

  .challenge-view .wide-division-layout .step-guide p,
  .challenge-view .wide-division-layout .carry-board {
    font-size: 0.76rem;
    line-height: 1.3;
  }

  .challenge-view .wide-division-layout .carry-board {
    padding: 7px;
    gap: 3px;
  }

  .challenge-view .actions {
    gap: 6px;
  }

  .challenge-view .actions button {
    min-height: 30px;
    padding: 0 10px;
    font-size: 0.82rem;
  }

  .challenge-view .feedback {
    min-height: 22px;
    margin: 4px 0 0;
    font-size: 0.82rem;
    line-height: 1.25;
  }

  .challenge-view .numpad {
    grid-template-columns: repeat(6, minmax(42px, 1fr));
    gap: 4px;
    margin-top: 4px;
  }

  .challenge-view .numpad button {
    min-height: 28px;
    font-size: 0.9rem;
  }
}
