:root {
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color: #414450;
  background: #f9eff7;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #414450;
  --muted: #858493;
  --pink: #ff7cae;
  --pink-light: #fff0f5;
  --green: #14bd62;
  --green-dark: #088e4b;
  --blue: #3586f5;
  --blue-dark: #1f67cf;
  --card: rgba(255, 255, 255, .94);
  --shadow: 0 12px 30px rgba(93, 76, 113, .12), 0 2px 7px rgba(93, 76, 113, .08);
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: max(14px, env(safe-area-inset-top)) 18px max(92px, calc(env(safe-area-inset-bottom) + 80px));
  overflow-x: hidden;
  background:
    radial-gradient(circle at 5% 12%, rgba(255, 222, 170, .72) 0 7%, transparent 7.2%),
    radial-gradient(circle at 99% 42%, rgba(205, 241, 235, .75) 0 8%, transparent 8.2%),
    linear-gradient(115deg, #fff1ea 0%, #f9eafa 52%, #e9f4ff 100%);
}

button { font: inherit; }
button:focus-visible, input:focus-visible + span { outline: 4px solid #ffc84a; outline-offset: 3px; }
[hidden] { display: none !important; }

.ambient { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.sparkle, .floaty { position: absolute; display: block; user-select: none; }
.sparkle { color: #e8a63c; opacity: .62; font-size: clamp(18px, 3vw, 32px); animation: twinkle 3.6s ease-in-out infinite; }
.sparkle-one { left: 7%; top: 19%; color: #ffd15e; animation-delay: -.5s; }
.sparkle-two { left: 15%; top: 68%; color: #ef83ad; animation-delay: -2s; }
.sparkle-three { right: 11%; top: 15%; color: #f3ba49; animation-delay: -1s; }
.sparkle-four { right: 7%; top: 72%; color: #8d94ee; animation-delay: -2.4s; }
.sparkle-five { left: 4%; top: 86%; color: #76c8c2; animation-delay: -.9s; }
.sparkle-six { right: 18%; top: 88%; color: #ffa0be; animation-delay: -1.7s; }
.animal { font-size: clamp(23px, 3vw, 35px); opacity: .76; filter: drop-shadow(0 3px 2px rgba(76, 74, 91, .08)); animation: bob 4s ease-in-out infinite; }
.animal-one { left: 4%; top: 7%; animation-delay: -1.1s; }
.animal-two { left: 3%; top: 43%; animation-delay: -.3s; }
.animal-three { right: 4%; top: 9%; animation-delay: -2.5s; }
.animal-four { right: 6%; top: 34%; animation-delay: -.9s; }
.animal-five { left: 7%; top: 76%; animation-delay: -1.7s; }
.animal-six { right: 2%; top: 82%; animation-delay: -.4s; }
.animal-seven { right: 12%; top: 59%; animation-delay: -2.1s; }
.animal-eight { left: 13%; top: 30%; animation-delay: -.8s; }
.animal-nine { right: 15%; top: 26%; animation-delay: -2.7s; }
.animal-ten { left: 12%; top: 56%; animation-delay: -1.4s; }
.animal-eleven { left: 17%; top: 90%; animation-delay: -.6s; }
.animal-twelve { right: 17%; top: 91%; animation-delay: -1.8s; }

.app-shell { position: relative; z-index: 1; width: min(100%, 600px); margin: 0 auto; }
.brand-header { position: relative; text-align: center; padding: 4px 12px 10px; }
.brand-header h1 { margin: 1px 0 3px; color: #323442; font-size: clamp(1.65rem, 6vw, 2.2rem); font-weight: 1000; line-height: 1.2; letter-spacing: .025em; text-shadow: 0 2px #fff; }
.brand-header h1 .title-add { color: #318057; }
.brand-header h1 .title-sub { color: #3586f5; }
.brand-caption { margin: 4px 0 0; color: #747282; font-size: .83rem; font-weight: 700; }

.screen { animation: screen-in .38s cubic-bezier(.2,.8,.3,1) both; }
.intro-card, .mode-card, .problem-card, .records-card {
  border: 2px solid rgba(229, 227, 240, .86);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.intro-card { display: flex; align-items: center; justify-content: space-between; min-height: 92px; margin: 0 0 10px; padding: 5px 14px 5px 18px; overflow: hidden; background: linear-gradient(118deg, #fff 0 58%, #fff8e7 100%); }
.intro-copy { position: relative; z-index: 1; min-width: 0; padding: 2px 0; }
.tiny-label { display: inline-flex; align-items: center; gap: 5px; color: #aa6587; font-size: .73rem; font-weight: 900; letter-spacing: .08em; }
.tiny-label::before { content: "✦"; color: #ffb44b; }
.intro-copy h2 { margin: 3px 0 2px; color: #39404e; font-size: clamp(1.2rem, 3.9vw, 1.55rem); line-height: 1.18; letter-spacing: .01em; }
.intro-copy p { margin: 0; color: #737382; font-size: .83rem; font-weight: 650; line-height: 1.5; }
.encouragement { display: inline-block; margin-top: 8px; padding: 4px 10px; border-radius: 999px; color: #a75078; background: #ffe9f1; font-size: .72rem; font-weight: 850; }
.mascot-home { flex: 0 0 auto; width: clamp(74px, 19vw, 100px); height: auto; object-fit: contain; margin: -2px -4px -2px 2px; filter: drop-shadow(0 4px 3px rgba(102, 76, 42, .1)); }

.mode-card { min-inline-size: 0; margin: 0; padding: 9px 13px; }
.mode-list { display: grid; gap: 5px; }
.mode-option { position: relative; display: flex; align-items: center; gap: 10px; min-height: 53px; padding: 5px 10px; border: 1px solid #eeebf2; border-radius: 13px; background: #fff; cursor: pointer; transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.mode-option:hover { transform: translateY(-1px); border-color: #d7ebdf; box-shadow: 0 3px 9px rgba(47, 107, 73, .09); }
.mode-option.selected { border-color: #74c895; background: #f2fff6; box-shadow: inset 0 0 0 1px rgba(116, 200, 149, .27); }
.mode-option.is-disabled, .mode-option.is-disabled:hover { cursor: not-allowed; transform: none; border-color: #f0eef2; background: #faf9fb; box-shadow: none; }
.mode-option.is-disabled .mode-icon { color: #bdb9c3; background: #f1eff3; }
.mode-option.is-disabled .mode-text strong { color: #aaa7b0; }
.mode-option.is-disabled .mode-text small { color: #bbb8c1; }
.mode-option.is-disabled .radio-indicator { border-color: #e7e4ea; background: #faf9fb; }
.mode-option input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.mode-option:focus-within { outline: 3px solid #ffd34e; outline-offset: 2px; }
.mode-icon { display: grid; flex: 0 0 31px; width: 31px; height: 31px; place-items: center; border-radius: 11px; font-weight: 1000; font-size: 1.5rem; }
.add-icon { color: #198b4c; background: #dff8e8; }
.sub-icon { color: #3476dc; background: #e5f1ff; }
.mix-icon { color: #a65fbd; background: #f7e8ff; font-size: 1.2rem; }
.challenge-icon { color: #d59123; background: #fff3ce; font-size: 1.2rem; }
.weak-icon { color: #b85576; background: #ffe8ef; font-size: 1.2rem; }
.mode-text { display: grid; gap: 0; min-width: 0; line-height: 1.13; }
.mode-text strong { color: #454653; font-size: .9rem; }
.mode-text small { color: #94919f; font-size: .67rem; font-weight: 650; }
.badge-new { display: inline-flex; align-items: center; margin-left: .28rem; padding: .12rem .38rem; border-radius: 999px; color: #fff; background: #ef6d8c; font-size: .58rem; font-weight: 1000; line-height: 1.25; vertical-align: middle; }
.radio-indicator { display: grid; flex: 0 0 20px; width: 20px; height: 20px; place-items: center; margin-left: auto; border: 2px solid #d4d2dc; border-radius: 50%; background: #fff; }
.selected .radio-indicator { border-color: #21af5e; }
.selected .radio-indicator::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #20ae5d; }
.menu-actions { display: flex; gap: 9px; margin-top: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 13px; border: 0; border-radius: 13px; color: #fff; font-weight: 900; font-size: .98rem; letter-spacing: .015em; cursor: pointer; box-shadow: 0 4px 0 rgba(48, 60, 77, .14), 0 7px 13px rgba(58, 61, 80, .1); transition: transform .14s ease, filter .14s ease, box-shadow .14s ease; }
.button:hover { filter: brightness(1.035); transform: translateY(-1px); box-shadow: 0 5px 0 rgba(48, 60, 77, .13), 0 9px 16px rgba(58, 61, 80, .12); }
.button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(48, 60, 77, .14); }
.button-start { flex: 1.06; background: linear-gradient(180deg, #24cd70, #0daf59); font-size: 1.08rem; }
.button-start:hover { background: linear-gradient(180deg, #31d77a, #0bae58); }
.button-records { flex: .94; background: linear-gradient(180deg, #438ef9, #2f79e9); font-size: .9rem; }
.button-records:hover { background: linear-gradient(180deg, #559cff, #3077e2); }

.game-toolbar, .records-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 42px; margin: 0 0 11px; }
.button-home { min-height: 37px; padding: 6px 11px; border-radius: 11px; color: #725b4b; background: #fff2bd; box-shadow: 0 3px 0 #ebcf73; font-size: .84rem; }
.current-mode { color: #636271; font-size: .82rem; font-weight: 900; }
.timer-chip { display: inline-flex; align-items: center; gap: 5px; min-width: 78px; justify-content: center; padding: 6px 11px; border: 1px solid #d7e7ff; border-radius: 999px; color: #256ec4; background: #edf5ff; font-weight: 900; font-size: .9rem; }
.progress-wrap { margin: 0 6px 10px; }
.progress-copy { display: flex; justify-content: space-between; margin: 0 2px 5px; color: #858493; font-size: .75rem; font-weight: 850; }
#countDisplay { color: #5b5a6b; font-size: .95rem; font-weight: 1000; line-height: 1; }
#progressLabel { color: #5b5a6b; font-size: .95rem; font-weight: 1000; line-height: 1; }
.progress-track { width: 100%; height: 8px; overflow: hidden; border-radius: 99px; background: rgba(255, 255, 255, .85); box-shadow: inset 0 1px 3px rgba(80, 71, 100, .12); }
.progress-track span { display: block; width: 10%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7cd99c, #38ba70); transition: width .45s cubic-bezier(.2,.7,.2,1); }
.problem-card { position: relative; min-height: 385px; padding: 17px 20px 17px; text-align: center; overflow: hidden; }
.problem-card.answer-correct { border-color: #89d6a2; }
.problem-card.answer-correct .problem { animation: correct-pop .4s ease; }
.problem-card.answer-wrong { animation: gentle-shake .35s ease; border-color: #ffb0c2; }
.weak-empty-card { padding: 26px 18px 22px; border: 1px solid rgba(255, 255, 255, .9); border-radius: 22px; background: rgba(255, 255, 255, .94); box-shadow: 0 8px 22px rgba(74, 79, 105, .09); text-align: center; animation: screen-in .35s ease both; }
.weak-empty-icon { display: block; color: #f1b84c; font-size: 2rem; }
.weak-empty-card h2 { margin: 7px 0; color: #42465a; font-size: 1.28rem; font-weight: 1000; }
.weak-empty-card p { margin: 0 0 16px; color: #858493; font-size: .9rem; font-weight: 750; line-height: 1.6; }
.problem-hint { margin: 0 0 5px; color: #9b96a4; font-size: .78rem; font-weight: 850; letter-spacing: .04em; }
.problem { min-height: 128px; display: grid; place-items: center; color: #38465a; font-size: clamp(6.5rem, 9vw, 7.5rem); font-weight: 1000; line-height: 1.08; letter-spacing: .025em; font-variant-numeric: tabular-nums; }
.answer-line { display: flex; align-items: center; justify-content: center; gap: 12px; width: fit-content; min-width: 140px; height: 50px; min-height: 50px; margin: 7px auto 5px; padding: 4px 18px; border: 2px dashed #ded9e7; border-radius: 14px; background: #fdfbff; }
.answer-label { color: #9692a2; font-size: .81rem; font-weight: 850; }
.answer-value { min-width: 36px; color: #39865a; font-size: 1.6rem; font-weight: 1000; font-variant-numeric: tabular-nums; }
.feedback-slot { display: flex; align-items: center; justify-content: center; min-height: 52px; margin: 0 auto 4px; }
.feedback { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px; margin: 0 auto; color: #3b8958; font-weight: 900; animation: feedback-in .22s ease both; }
.feedback-mark { display: grid; width: 35px; height: 35px; place-items: center; border-radius: 50%; color: #fff; background: #37c470; font-size: 1.3rem; font-weight: 1000; box-shadow: 0 3px 0 #15974e; }
.feedback.incorrect { color: #bd5673; }
.feedback.incorrect .feedback-mark { background: #f57798; box-shadow: 0 3px 0 #d45073; }
.keypad { display: none; grid-template-columns: repeat(3, 1fr); gap: 0; width: 100%; max-width: 420px; margin: 14px auto 0; }
.key-button { height: 64px; min-height: 0; margin: 0; border: 3px solid #3a7a4a; border-radius: 12px; color: #263c2d; background: #b2f2bb; box-shadow: none; font-size: 2rem; font-weight: 950; cursor: pointer; touch-action: manipulation; transition: filter .1s ease, transform .1s ease; }
.key-button:hover { filter: brightness(.97); }
.key-button:active { transform: scale(.97); filter: brightness(.94); }
.key-utility { border-color: #2b5c99; color: #264b78; background: #bde0fe; font-size: 1.4rem; }
.key-submit { border-color: #c4476b; color: #8c3450; background: #ffb3c6; font-size: 1.4rem; }
.key-utility:hover, .key-submit:hover { filter: brightness(.97); }
.keyboard-hint { margin: 9px 0 0; color: #aba7b2; font-size: .68rem; }
.result-view { padding: 8px 5px 2px; animation: screen-in .45s ease both; }
.result-kicker { margin: 0 0 7px; color: #9a91a0; font-size: .9rem; font-weight: 850; }
.result-title { margin: 0; color: #41455a; font-size: clamp(1.45rem, 5vw, 2rem); font-weight: 1000; }
.result-score { margin: 7px 0 0; color: #555364; font-size: 1.22rem; font-weight: 900; }
.result-score strong { color: #ec5b84; font-size: 2.2rem; font-variant-numeric: tabular-nums; }
.result-time { margin: 5px 0 0; color: #4c7fc0; font-weight: 900; font-size: 1.05rem; }
.result-mascot { display: block; width: 175px; height: 175px; object-fit: contain; margin: 4px auto -3px; animation: mascot-bounce 1.2s ease-in-out infinite alternate; }
.result-cheer { margin: 7px 0 12px; color: #a46281; font-size: .9rem; font-weight: 850; }
.result-actions { display: flex; justify-content: center; gap: 9px; margin: 13px 0 4px; }
.result-actions .button { min-width: 135px; }
.button-again { background: linear-gradient(180deg, #25ca6c, #0cad56); }
.button-result-home { color: #655953; background: #fff1bd; box-shadow: 0 4px 0 #ead284; }

.records-toolbar { margin-bottom: 9px; }
.records-stamp { color: #f5bd48; font-size: 1.9rem; animation: twinkle 2.4s ease-in-out infinite; }
.records-card { padding: 19px 18px 15px; }
.records-heading-row { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 12px; border-bottom: 1px solid #eeeaf1; }
.records-heading-row h2 { margin: 2px 0 0; color: #424451; font-size: 1.55rem; }
.records-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 16px; background: #fff5d7; font-size: 1.6rem; }
.records-list { display: grid; gap: 8px; max-height: min(55vh, 480px); padding: 12px 0 4px; overflow-y: auto; }
.record-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; padding: 11px 12px; border: 1px solid #efedf2; border-radius: 12px; background: #fff; }
.record-date { color: #92909b; font-size: .7rem; font-weight: 750; }
.record-mode { grid-column: 1 / -1; color: #666574; font-size: .75rem; font-weight: 850; }
.record-score { grid-row: 1 / span 2; grid-column: 2; color: #ed678b; font-size: 1.05rem; font-weight: 950; white-space: nowrap; }
.record-time { display: inline-block; margin-left: 7px; color: #427bb7; font-size: .74rem; }
.empty-records { padding: 27px 12px; color: #8c8996; text-align: center; font-size: .9rem; font-weight: 800; }
.empty-records span { display: block; margin-bottom: 8px; color: #f1b84a; font-size: 2.2rem; }
.records-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.button-reset { min-height: 37px; padding: 7px 12px; border: 1px solid #ffd2d6; border-radius: 10px; color: #a85463; background: #fff0f0; box-shadow: none; font-size: .78rem; }
.records-note { margin: 10px 0 0; color: #96919f; text-align: center; font-size: .7rem; font-weight: 700; }


.sound-toggle { position: fixed; z-index: 5; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 12px; border: 1px solid #d8e4d9; border-radius: 999px; color: #287849; background: rgba(255, 255, 255, .95); box-shadow: 0 3px 12px rgba(70, 74, 90, .13); font-size: .81rem; font-weight: 900; cursor: pointer; }
.sound-toggle[aria-pressed="false"] { color: #777481; background: rgba(255, 255, 255, .86); }
.sound-icon { font-size: 1.05rem; }
.noscript-message { position: fixed; z-index: 9; inset: auto 10px 60px; padding: 12px; border: 2px solid #f3b4c1; border-radius: 12px; background: #fff; text-align: center; }
.confetti-layer { position: fixed; z-index: 4; inset: 0; overflow: hidden; pointer-events: none; }
.confetti-piece { position: absolute; top: -18px; left: var(--x); width: var(--size); height: calc(var(--size) * 1.5); border-radius: 3px; background: var(--color); opacity: .94; transform: rotate(var(--rotate)); animation: confetti-fall var(--duration) cubic-bezier(.2,.6,.3,1) var(--delay) forwards; }

@keyframes screen-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes twinkle { 0%, 100% { opacity: .43; transform: scale(.88) rotate(-7deg); } 50% { opacity: .88; transform: scale(1.1) rotate(8deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-9px) rotate(4deg); } }
@keyframes feedback-in { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: scale(1); } }
@keyframes correct-pop { 0% { transform: scale(1); } 45% { transform: scale(1.012); } 100% { transform: scale(1); } }
@keyframes gentle-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes mascot-bounce { from { transform: translateY(0) rotate(-2deg); } to { transform: translateY(-8px) rotate(2deg); } }
@keyframes confetti-fall { 0% { transform: translate3d(0, -5vh, 0) rotate(0); } 100% { transform: translate3d(var(--drift), 112vh, 0) rotate(var(--spin)); } }

@media (min-width: 900px) {
  body { padding-top: 18px; }
  .app-shell { width: min(100%, 530px); }
  .brand-header { padding-bottom: 8px; }
  .intro-card { min-height: 88px; padding: 4px 12px 4px 16px; }
  .mascot-home { width: 96px; }
  .problem-card { min-height: 410px; }
  .problem { min-height: 140px; font-size: clamp(6.5rem, 9vw, 7.5rem); }
}

@media (max-width: 520px) {
  body { padding-right: 12px; padding-left: 12px; }
  .animal-five, .animal-seven, .animal-ten, .animal-eleven, .animal-twelve { display: none; }
  .app-shell { width: min(100%, 460px); }
  .intro-card { min-height: 86px; padding: 4px 11px 4px 15px; }
  .mascot-home { width: clamp(72px, 19vw, 94px); margin-right: -6px; }
  .mode-card { padding: 8px 10px; }
  .mode-list { gap: 4px; }
  .mode-option { min-height: 49px; gap: 7px; padding: 4px 8px; }
  .mode-text strong { font-size: .84rem; }
  .mode-text small { font-size: .66rem; }
  .menu-actions { gap: 7px; }
  .button-start, .button-records { font-size: .87rem; }
  .problem-card { min-height: 378px; padding: 15px 13px 14px; }
  .problem { min-height: 112px; font-size: clamp(4rem, 19vw, 5rem); }
  .key-button { height: 56px; font-size: 1.8rem; }
  .key-utility, .key-submit { font-size: 1.3rem; }
  .records-card { padding: 16px 12px 13px; }
}

@media (max-width: 360px) {
  .intro-card { min-height: 82px; }
  .intro-copy h2 { font-size: 1.08rem; }
  .mascot-home { width: 72px; }
  .mode-option { gap: 6px; min-height: 48px; padding-right: 7px; }
  .mode-icon { flex-basis: 29px; width: 29px; height: 29px; }
  .mode-text small { font-size: .61rem; }
  .button { padding-right: 8px; padding-left: 8px; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .problem { min-height: 128px; font-size: clamp(6rem, 13vw, 7.5rem); }
  .key-button { height: 64px; }
  .key-utility, .key-submit { font-size: 1.4rem; }
}

@media (pointer: coarse) and (min-width: 521px) {
  .problem { min-height: 128px; font-size: clamp(5rem, 13vw, 7.5rem); }
}

@media (pointer: coarse) {
  .keypad { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
