.game-main { padding-block: 23px 48px; }
.home-link { display: inline-flex; align-items: center; gap: 6px; min-height: 33px; color: var(--muted); font-size: .9rem; font-weight: 750; }
.home-link:hover { color: var(--purple); }
.home-link .icon { width: 16px; height: 16px; }
.game-main h1 { margin: 4px 0 19px; font-size: clamp(2rem, 5vw, 3rem); font-weight: 900; line-height: 1.13; letter-spacing: -.075em; }

.mode-tabs { display: flex; gap: 8px; }
.mode-tab { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 12px; background: white; color: #5c506f; font-weight: 750; }
.mode-tab:hover { background: #f0ebfe; }
.mode-tab[aria-current="page"] { background: var(--purple); border-color: var(--purple); color: #fff; box-shadow: 0 4px 0 #3c218f; }
.mode-tab .icon { width: 18px; height: 18px; }

.dan-section { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 17px; margin-block: 22px 16px; border: 1px solid var(--line); background: white; border-radius: 16px; }
.dan-section h2 {font-size: 1.02rem; letter-spacing: -.035em; }
.dan-list { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.dan-button { position: relative; min-width: 50px; min-height: 44px; padding: 4px 9px; border: 1px solid #ebe6f6; border-radius: 10px; color: #493968; background: #f9f6ff; font-weight: 800; white-space: nowrap; }
.dan-button:hover { background: #eee6ff; }
.dan-button[aria-pressed="true"] { background: #eae0ff; border-color: #aa93ed; color: #4e2ac0; box-shadow: inset 0 0 0 1px #aa93ed; }
.dan-button .icon { display: none; position: absolute; z-index: 1; top: -5px; right: -2px; width: 14px; height: 14px; fill: #ffce59; color: #9b5528; }
.dan-button[data-earned="true"] .icon { display: block; }

.workspace { display: grid; grid-template-columns: 1.4fr 1fr; gap: 15px; align-items: stretch; }
.board-panel, .activity-panel { min-width: 0; display: flex; flex-direction: column; padding: 23px; border: 1px solid var(--line); border-radius: 21px; }
.board-panel { background: white; }
.activity-panel { background: #f0eafd; border-color: #e7dcfa; }
.workspace h2 { font-size: 1.42rem; line-height: 1.25; font-weight: 850; letter-spacing: -.055em; }
.panel-description { color: var(--muted); margin-top: 6px; line-height: 1.5; word-break: keep-all; }
.board-area { flex: 1; display: grid; place-items: center; margin-top: 17px; min-height: 268px; border: 1px solid #eee8f9; border-radius: 16px; background-color: #faf8ff; background-image: radial-gradient(#ded2f5 1px, transparent 1px); background-size: 16px 16px; }
.star-board { display: grid; width: min(100%, 453px); padding: 13px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.star-tile { display: grid; grid-template-rows: 1fr auto; align-items: center; justify-items: center; min-height: 81px; padding: 7px 5px; background: #eee6ff; border: 1px solid #dfd0fc; border-radius: 12px; box-shadow: 0 2px 0 #dfd0fc; }
.tile-stars { min-height: 38px; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 1px; width: min(100%, 68px); }
.tile-star { width: clamp(12px, 2.1vw, 21px); height: clamp(12px, 2.1vw, 21px); fill: #ffcf57; color: #a35d21; }
.tile-label { font-size: .75rem; color: #625182; font-weight: 700; white-space: nowrap; }

.workspace[data-mode="guide"] { margin-top: 22px; }
.workspace[data-mode="guide"] .board-area { align-content: center; gap: 8px; background-color: #f2ecff; background-image: radial-gradient(#c8b5ee 1px, transparent 1px); }
.station-total { display: flex; align-items: center; gap: 5px; margin-bottom: 12px; padding: 7px 12px; border-radius: 999px; border: 1px solid #dccbf5; background: #fff; color: #4e3b6b; font-weight: 750; }
.station-total .icon { width: 17px; height: 17px; margin-right: 2px; color: #a35d21; fill: #ffcf57; }
.guide-page { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: #573b9c; font-size: .9rem; font-weight: 760; }
.guide-page .icon { width: 16px; height: 16px; }
.guide-page span { margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.guide-story { margin-top: 11px; color: #4c3f64; font-size: 1.05rem; line-height: 1.75; word-break: keep-all; }
.guide-story strong { color: var(--purple-dark); }
.guide-example { display: grid; align-content: center; gap: 3px; min-height: 89px; margin-block: 14px 15px; padding: 12px 10px; border: 1px solid #e8ddf9; border-radius: 13px; background: white; color: #56446f; text-align: center; line-height: 1.5; word-break: keep-all; }
.guide-example p { font-size: .96rem; }
.guide-example .guide-expression { color: var(--purple-dark); font-size: clamp(1.65rem, 4vw, 2rem); font-weight: 900; letter-spacing: -.035em; }
.guide-key { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 4px; }
.guide-key span { display: grid; align-self: stretch; align-content: center; border-radius: 9px; padding: 4px; background: #ece5ff; color: #492c95; }
.guide-key span:nth-of-type(2) { background: #fff2cf; color: #745018; }
.guide-key span:nth-of-type(3) { background: #e4f5eb; color: #275743; }
.guide-key strong { font-size: 1.82rem; line-height: 1.12; }
.guide-key small { font-size: .875rem; font-weight: 750; }
.guide-actions .button-primary { margin-inline-start: auto; }

.stepper { display: grid; grid-template-columns: 46px 1fr 46px; gap: 10px; align-items: center; text-align: center; margin-top: 18px; }
.stepper > button { display: grid; place-items: center; min-height: 45px; border: 1px solid #d8c9f0; border-radius: 11px; background: white; color: var(--purple); }
.stepper > button:hover { background: #faf6ff; }
.stepper > button[aria-disabled="true"] { color: #74689a; background: #eae3f8; cursor: default; }
.stepper span { color: #634d82; font-weight: 800; }
.stepper span strong { color: var(--ink); font-size: 1.42rem; margin-right: 4px; }
.readout { margin-block: 14px; padding: 14px; border-radius: 14px; background: white; text-align: center; }
.big-expression { color: var(--purple-dark); font-size: clamp(2rem, 5vw, 2.75rem); font-weight: 900; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.big-expression > span { color: #34225d; }
.addition-expression { color: #574470; margin-top: 2px; font-size: 1rem; font-weight: 750; overflow-wrap: anywhere; }
.plain-expression { margin-top: 6px; color: var(--muted); line-height: 1.5; font-size: .9rem; word-break: keep-all; }
.plain-expression strong { color: var(--ink); }
.group-change { display: inline-block; margin-top: 9px; padding: 4px 10px; border-radius: 999px; color: #5b437e; background: #f1ebfc; font-size: .875rem; font-weight: 750; }
.group-change[data-change="plus"] { background: #e1f5eb; color: #215b40; }
.group-change[data-change="minus"] { background: #fff1d6; color: #80511b; }
.answer-reveal { display: inline-block; }
.wide-button { width: 100%; margin-top: auto; }

.question { min-height: 63px; display: grid; place-items: center; margin-block: 14px 10px; padding: 7px; border-radius: 13px; background: white; text-align: center; white-space: pre-wrap; color: var(--purple-dark); font-size: clamp(1.9rem, 4vw, 2.7rem); font-weight: 900; line-height: 1.2; letter-spacing: -.045em; }
.question:has(span) { display: block; padding: 13px 8px; }
.question span { color: #7153d6; }
.question-addition { font-size: clamp(1.13rem, 2.7vw, 1.55rem); letter-spacing: -.016em; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(55px, 1fr)); gap: 7px; }
.choice { min-height: 52px; padding: 7px 4px; border: 1px solid #d8c9f0; border-radius: 11px; background: white; color: var(--ink); font-size: 1.16rem; font-weight: 850; white-space: nowrap; }
.choice:hover:not([aria-disabled="true"]) { background: #f9f5ff; border-color: #9e86e0; }
.choice[aria-disabled="true"] { cursor: default; }
.choice[data-result="wrong"] { background: #fbebe9; border-color: #d49891; color: #8c3830; text-decoration: line-through; }
.choice[data-result="correct"] { background: #daf3e5; border-color: #71a68a; color: #215b40; }
.feedback { min-height: 48px; margin-block: 10px 4px; font-size: .95rem; font-weight: 750; line-height: 1.45; word-break: keep-all; }
.feedback[data-result="wrong"] { color: #873d37; }
.feedback[data-result="correct"] { color: #215b40; }
.panel-actions { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.panel-actions .button { padding-inline: 10px; }
.quiz-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.quiz-heading span { color: #5c4881; font-size: .9rem; font-weight: 750; }
progress { width: 100%; height: 9px; margin-top: 9px; border: 0; border-radius: 8px; overflow: hidden; background: #dfd3f7; accent-color: var(--purple); }
progress::-webkit-progress-bar { background: #dfd3f7; }
progress::-webkit-progress-value { background: var(--purple); }

.quiz-art { position: relative; width: 203px; height: 170px; display: grid; place-items: center; }
.quiz-orb { width: 111px; height: 111px; display: grid; place-items: center; border: 4px solid #e7dbff; border-radius: 50%; background: radial-gradient(circle at 36% 29%, #c5a8ff, #7b53e9 71%, #5b33c5); box-shadow: 0 9px 0 #d2bdf5, 0 15px 24px #5027b22a; color: white; font-size: 4rem; font-weight: 900; }
.quiz-art-solved .quiz-orb { border-color: #dbf1e5; background: radial-gradient(circle at 36% 29%, #4d9e78, #287052 80%); box-shadow: 0 9px 0 #b7e1cd, 0 15px 24px #295d432a; }
.quiz-art-solved .quiz-orb .icon { width: 52%; height: 52%; stroke-width: 2.25; }
.quiz-spark { position: absolute; }
.quiz-spark .icon { fill: #ffd16a; color: #a46337; }
.spark-one { top: 33px; left: 14px; transform: rotate(-15deg); }
.spark-two { bottom: 27px; right: 19px; transform: rotate(12deg); }
.spark-two .icon { width: 25px; height: 25px; }

.result-panel { grid-column: 1 / -1; display: grid; justify-items: center; padding: 35px 20px; border: 1px solid #dfd1f9; border-radius: 22px; background: radial-gradient(ellipse at center top, #f5ecff 2%, #fff 64%); text-align: center; }
.result-star { position: relative; display: grid; place-items: center; width: 105px; height: 105px; border-radius: 50%; background: #fff0c0; box-shadow: 0 0 0 9px #fff7e1; margin: 8px 0 23px; }
.result-star-icon { width: 63px; height: 63px; fill: #ffd259; color: #9d5b20; transform: rotate(9deg); }
.result-sparks { position: absolute; inset: 0; pointer-events: none; }
.result-sparks span { position: absolute; left: calc(50% - 4px); top: calc(50% - 4px); width: 8px; height: 8px; border-radius: 2px; opacity: 0; background: #eea630; --angle: 0deg; --distance: 80px; }
.result-sparks span:nth-child(2n) { background: #9b73f5; --distance: 69px; }
.result-sparks span:nth-child(3n) { background: #459b7c; width: 6px; height: 6px; }
.result-sparks span:nth-child(2) { --angle: 45deg; }
.result-sparks span:nth-child(3) { --angle: 90deg; }
.result-sparks span:nth-child(4) { --angle: 135deg; }
.result-sparks span:nth-child(5) { --angle: 180deg; }
.result-sparks span:nth-child(6) { --angle: 225deg; }
.result-sparks span:nth-child(7) { --angle: 270deg; }
.result-sparks span:nth-child(8) { --angle: 315deg; }
.result-panel h2 { font-size: clamp(1.9rem, 4vw, 2.65rem); }
.result-panel p { color: var(--muted); margin-top: 8px; line-height: 1.55; word-break: keep-all; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-block: 19px 2px; }
.result-panel .save-status { min-height: 1.5em; font-size: .88rem; }

@media (max-width: 760px) {
  .game-main { padding-top: 14px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 11px; }
  .board-panel, .activity-panel { padding: 16px; border-radius: 16px; }
  .board-area { min-height: 180px; margin-top: 12px; }
  .star-tile { min-height: 61px; }
  .quiz-art { height: 124px; }
  .quiz-orb { width: 78px; height: 78px; font-size: 2.8rem; }
}

@media (max-width: 545px) {
  .game-main h1 { margin-bottom: 13px; }
  .mode-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .mode-tab { gap: 5px; min-width: 0; min-height: 44px; padding: 6px 3px; font-size: .92rem; white-space: nowrap; }
  .mode-tab .icon { width: 16px; height: 16px; }
  .dan-section { display: block; padding: 10px; margin-block: 14px 10px; }
  .dan-list { margin-top: 7px; gap: 4px; }
  .dan-button { min-width: 0; padding-inline: 0; border-radius: 8px; font-size: .84rem; }
  .board-area { min-height: 139px; }
  .star-board { padding: 9px; gap: 5px; }
  .star-tile { min-height: 54px; padding: 3px; }
  .tile-star { width: 15px; height: 15px; }
  .tile-stars { min-height: 29px; width: min(100%, 48px); }
  .tile-label { font-size: .72rem; }
  .workspace h2 { font-size: 1.25rem; }
  .result-panel h2 { font-size: 1.85rem; }
  .panel-description { font-size: .92rem; }
  .workspace[data-mode="guide"] { margin-top: 14px; }
}

@media (prefers-reduced-motion: no-preference) {
  .star-tile-arriving { animation: tile-drop .35s cubic-bezier(.21, .76, .43, 1); }
  .star-tile-arriving .tile-star { animation: star-glow .48s ease-out; }
  .star-tile-leaving { animation: tile-leave .2s ease-in both; }
  .star-board-arriving, .guide-example-arriving, .question { animation: reveal-up .24s ease-out; }
  .answer-reveal, .choice[data-result="correct"], .quiz-art-solved .quiz-orb { animation: answer-pop .28s ease-out; }
  .choice[data-result="wrong"] { animation: nudge .22s ease-in-out; }
  .result-star { animation: star-reward .62s cubic-bezier(.2, .8, .3, 1) both; }
  .result-sparks span { animation: spark-out .75s .15s ease-out both; }
  progress::-webkit-progress-value { transition: width .22s ease-out; }
}

@keyframes tile-drop {
  0% { opacity: 0; transform: translateY(-18px) scale(.88); }
  70% { opacity: 1; transform: translateY(2px) scale(1.04); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes star-glow {
  45% { fill: #ffe68e; filter: drop-shadow(0 0 4px #ffc447); }
}

@keyframes tile-leave {
  100% { opacity: 0; transform: translateY(-9px) scale(.87); }
}

@keyframes reveal-up {
  from { opacity: .35; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes answer-pop {
  40% { transform: scale(1.09); }
}

@keyframes nudge {
  25% { transform: translateX(-3px); }
  65% { transform: translateX(3px); }
}

@keyframes star-reward {
  0% { opacity: 0; transform: translateY(13px) scale(.54) rotate(-16deg); }
  60% { opacity: 1; transform: translateY(-3px) scale(1.12) rotate(6deg); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes spark-out {
  0% { opacity: 0; transform: rotate(var(--angle)) translateX(40px) rotate(0deg) scale(.45); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--angle)) translateX(var(--distance)) rotate(175deg) scale(.85); }
}
