:root {
  --game-mint: #159f96;
  --game-mint-bright: #2acfc0;
  --game-mint-soft: #dff7f1;
  --game-ink: #1e2841;
  --game-muted: #60708c;
  --game-line: rgba(21, 159, 150, 0.16);
  --game-card: rgba(255, 255, 255, 0.82);
  --game-shadow: 0 18px 44px rgba(66, 101, 115, 0.16);
}

html {
  background: #e8f7f2;
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(circle at 16% 8%, rgba(42, 207, 192, 0.18), transparent 28%),
    linear-gradient(180deg, #eefaf6 0%, #dff2ed 100%);
  color: var(--game-ink);
  overscroll-behavior: none;
}

button,
[role='button'],
input,
textarea {
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:disabled,
[aria-disabled='true'] {
  opacity: 0.48;
  pointer-events: none;
}

.app,
.phone {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  color: var(--game-ink);
  background:
    radial-gradient(circle at 88% 10%, rgba(42, 207, 192, 0.14), transparent 28%),
    linear-gradient(180deg, rgba(238, 250, 246, 0.98), rgba(220, 241, 235, 0.98));
}

.phone .top {
  position: sticky;
  top: 0;
  z-index: 12;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(238, 250, 246, 0.96), rgba(238, 250, 246, 0.72), transparent);
  backdrop-filter: blur(16px);
}

.phone .bar {
  background: rgba(21, 159, 150, 0.12);
}

.phone .fill {
  background: linear-gradient(90deg, var(--game-mint), var(--game-mint-bright));
}

.phone .progress-text,
.phone .progress-text span {
  color: var(--game-muted);
}

.phone .screen {
  align-items: flex-start;
  padding: 18px 18px calc(28px + env(safe-area-inset-bottom));
}

.phone .card,
.phone .task-panel,
.phone .onboarding-card,
.phone .result-card,
.phone .assessment-result-hero,
.phone .assessment-radar-card,
.phone .assessment-suggest {
  color: var(--game-ink);
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(235, 249, 245, 0.74));
  box-shadow: var(--game-shadow);
  backdrop-filter: blur(20px) saturate(145%);
}

.phone h1,
.phone h2,
.phone .task-title,
.phone .question-text,
.phone .coordination-stats strong,
.phone .summary strong {
  color: var(--game-ink);
}

.phone .desc,
.phone .task-sub,
.phone .coordination-hint,
.phone .question-text span {
  color: var(--game-muted);
}

.phone .tag,
.phone .question-label {
  color: var(--game-mint);
}

.phone .choice,
.phone .age-btn,
.phone .number-memory-cell,
.phone .cell,
.phone .chip,
.phone .secondary {
  color: var(--game-ink);
  border-color: rgba(21, 159, 150, 0.14);
  background: rgba(255, 255, 255, 0.72);
}

.phone .question-card,
.phone .visual,
.phone .target-cue,
.phone .dynamic-memory-arena,
.phone .coordination-arena,
.phone .number-chase-arena {
  border-color: var(--game-line);
  background: radial-gradient(circle at 50% 35%, rgba(42, 207, 192, 0.16), rgba(255, 255, 255, 0.56));
}

.phone .primary,
.game-shell-primary {
  color: #fff;
  border: 0;
  background: linear-gradient(135deg, var(--game-mint), var(--game-mint-bright));
  box-shadow: 0 12px 26px rgba(21, 159, 150, 0.32);
}

.game-shell-guide-trigger {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  top: max(58px, calc(env(safe-area-inset-top) + 10px));
  z-index: 34;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  color: var(--game-mint);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 10px 28px rgba(66, 101, 115, 0.18);
  backdrop-filter: blur(16px);
  font-size: 13px;
  font-weight: 800;
}

.game-shell-guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 45, 54, 0.48);
  backdrop-filter: blur(8px);
}

.game-shell-guide-card {
  position: relative;
  width: min(372px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 26px;
  color: var(--game-ink);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.97), rgba(226, 248, 241, 0.94));
  box-shadow: 0 28px 72px rgba(20, 52, 60, 0.28);
}

.game-shell-guide-kicker {
  color: var(--game-mint);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
}

.game-shell-guide-card h2 {
  margin: 7px 0 6px;
  color: var(--game-ink);
  font-size: 23px;
}

.game-shell-guide-objective {
  margin: 0 0 16px;
  color: var(--game-muted);
  font-size: 14px;
  line-height: 1.65;
}

.game-shell-guide-section {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--game-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
}

.game-shell-guide-section strong {
  display: block;
  margin-bottom: 7px;
  color: var(--game-ink);
  font-size: 13px;
}

.game-shell-guide-section p,
.game-shell-guide-section li {
  color: var(--game-muted);
  font-size: 13px;
  line-height: 1.55;
}

.game-shell-guide-section ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
}

.game-shell-guide-confirm {
  width: 100%;
  margin-top: 18px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--game-mint), var(--game-mint-bright));
  box-shadow: 0 12px 28px rgba(21, 159, 150, 0.32);
  font-size: 15px;
  font-weight: 900;
}

@media (prefers-reduced-motion: reduce) {
  .game-shell-guide-card { animation: none !important; }
}

.matchstick-stage {
  overflow: hidden;
}

.matchstick-loading {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 330px;
  padding-top: 80px;
  color: var(--game-muted);
  text-align: center;
}

.matchstick-spark {
  color: #f4a84e;
  font-size: 46px;
  animation: matchstick-pulse 1.2s ease-in-out infinite;
}

.matchstick-rule {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  padding: 14px 16px;
  border: 1px solid var(--game-line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
}

.matchstick-rule strong { font-size: 17px; }
.matchstick-rule span { color: var(--game-muted); font-size: 13px; line-height: 1.5; }

.matchstick-board {
  min-height: 300px;
  padding: 20px 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  background: radial-gradient(circle at 50% 35%, rgba(42, 207, 192, 0.14), rgba(255, 255, 255, 0.76));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 18px 38px rgba(66, 101, 115, 0.12);
  touch-action: none;
  user-select: none;
}

.matchstick-equation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 230px;
}

.matchstick-glyph {
  position: relative;
  flex: 0 0 43px;
  width: 43px;
  height: 88px;
}

.matchstick-glyph.kind-operator,
.matchstick-glyph.kind-equals { flex-basis: 36px; width: 36px; }

.matchstick-slot {
  position: absolute;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.matchstick-slot i,
.matchstick-reserve i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 8px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: linear-gradient(90deg, #f2bd66 0 82%, #d74c3f 82% 100%);
  box-shadow: 0 2px 5px rgba(87, 50, 18, 0.22);
  transition: transform 160ms ease, opacity 160ms ease, filter 160ms ease;
}

.matchstick-slot.empty i {
  opacity: 0.18;
  filter: grayscale(1);
  box-shadow: none;
}

.matchstick-slot.selected-source i { filter: drop-shadow(0 0 7px #2acfc0); transform: translate(-50%, -50%) scale(1.12); }
.matchstick-slot.selected-target i { opacity: 0.7; filter: none; outline: 2px dashed var(--game-mint); outline-offset: 3px; }
.matchstick-slot.seg-b i,
.matchstick-slot.seg-c i,
.matchstick-slot.seg-e i,
.matchstick-slot.seg-f i,
.matchstick-slot.seg-v i { transform: translate(-50%, -50%) rotate(90deg); }
.matchstick-slot.seg-b.selected-source i,
.matchstick-slot.seg-c.selected-source i,
.matchstick-slot.seg-e.selected-source i,
.matchstick-slot.seg-f.selected-source i,
.matchstick-slot.seg-v.selected-source i { transform: translate(-50%, -50%) rotate(90deg) scale(1.12); }

.matchstick-glyph .seg-a { left: 0; top: -18px; }
.matchstick-glyph .seg-b { right: -18px; top: 3px; }
.matchstick-glyph .seg-c { right: -18px; bottom: 3px; }
.matchstick-glyph .seg-d { left: 0; bottom: -18px; }
.matchstick-glyph .seg-e { left: -18px; bottom: 3px; }
.matchstick-glyph .seg-f { left: -18px; top: 3px; }
.matchstick-glyph .seg-g,
.matchstick-glyph .seg-h { left: 0; top: 22px; }
.matchstick-glyph .seg-v { left: -4px; top: 22px; }
.matchstick-glyph .seg-u { left: -4px; top: 6px; }
.matchstick-glyph .seg-l { left: -4px; bottom: 6px; }

.matchstick-reserve {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 42px;
  height: 52px;
  margin: -4px auto 14px;
  color: var(--game-mint);
  font-size: 12px;
  font-weight: 800;
}

.matchstick-reserve i { left: calc(50% - 48px); }

.matchstick-shape-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.matchstick-shape-pair > div > span {
  display: block;
  margin-bottom: 7px;
  color: var(--game-muted);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.matchstick-shape-canvas {
  position: relative;
  width: 100%;
  height: min(230px, calc(var(--shape-rows) * 48px));
  overflow: hidden;
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.48);
  transform-origin: top left;
}

.matchstick-shape-position { position: absolute; width: 44px; height: 44px; }
.matchstick-shape-position .matchstick-slot { left: 0; top: 0; }
.matchstick-feedback {
  min-height: 46px;
  padding: 12px 8px 6px;
  color: var(--game-muted);
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
}

.matchstick-actions { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 10px; }
.matchstick-actions button { border-radius: 999px; font-weight: 900; }
.matchstick-hint { border: 1px solid var(--game-line); color: var(--game-mint); background: rgba(255, 255, 255, 0.76); }

@keyframes matchstick-pulse { 50% { transform: scale(1.16) rotate(8deg); opacity: 0.72; } }

@media (max-width: 430px) {
  .matchstick-board { min-height: 286px; padding-inline: 4px; }
  .matchstick-equation { transform: scale(0.92); transform-origin: center; }
  .matchstick-glyph { flex-basis: 40px; }
}
