:root {
  --ink: #172048;
  --muted: #6d759e;
  --purple: #6859dc;
  --purple-dark: #4937ae;
  --yellow: #ffd95b;
  --mint: #5ee0bd;
  --danger: #ed6e7d;
  --glass: rgba(17, 28, 72, .63);
  --glass-light: rgba(255, 255, 255, .88);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #fff;
  background: #101936;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #101936; }
body { -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 4px solid rgba(255, 224, 106, .9); outline-offset: 3px; }
[hidden] { display: none !important; }

.game-root { position: fixed; inset: 0; overflow: hidden; isolation: isolate; background: #18224f; }
.scene-backdrop { position: absolute; inset: 0; z-index: -3; background-color: #18224f; background-position: center; background-repeat: no-repeat; background-size: cover; transition: background-image .65s ease, filter .65s ease; }
.scene-vignette { position: absolute; inset: 0; z-index: -2; pointer-events: none; background: linear-gradient(180deg, rgba(5, 10, 32, .48) 0%, rgba(7, 14, 42, .03) 28%, rgba(8, 14, 39, .15) 62%, rgba(5, 10, 28, .68) 100%); }
.game-root::after { position: absolute; inset: 0; z-index: -1; content: ""; pointer-events: none; background: radial-gradient(circle at 50% 42%, transparent 25%, rgba(7, 10, 34, .17) 100%); }

.game-topbar { position: absolute; z-index: 20; top: 0; left: 0; right: 0; display: flex; min-height: 65px; align-items: center; justify-content: space-between; padding: max(12px, env(safe-area-inset-top)) clamp(16px, 4vw, 52px) 10px; background: linear-gradient(180deg, rgba(7, 13, 42, .64), rgba(7, 13, 42, 0)); }
.game-title { color: #fff; font-size: clamp(16px, 2.2vw, 23px); font-weight: 950; letter-spacing: .02em; text-shadow: 0 2px 12px rgba(5, 8, 27, .45); }
.exit-button, .text-button, .icon-button { border: 0; color: rgba(255,255,255,.9); background: rgba(13, 22, 58, .45); cursor: pointer; text-decoration: none; }
.exit-button { min-height: 42px; padding: 10px 15px; border-radius: 14px; font-size: 14px; font-weight: 900; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.stage-pill { min-height: 36px; padding: 9px 13px; border: 1px solid rgba(255,255,255,.25); border-radius: 13px; color: #fff6b8; background: rgba(24, 29, 78, .6); font-size: 12px; font-weight: 900; white-space: nowrap; }
.icon-button { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; font-size: 19px; }
.text-button { min-height: 42px; padding: 9px 11px; border-radius: 13px; font-size: 12px; font-weight: 900; }
.exit-button:hover, .text-button:hover, .icon-button:hover { background: rgba(255,255,255,.18); }

.story-screen { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 78px 20px 26px; }
.story-card { position: relative; width: min(600px, 100%); padding: clamp(29px, 6vw, 57px) clamp(22px, 6vw, 64px) clamp(24px, 5vw, 44px); overflow: hidden; border: 1px solid rgba(255,255,255,.34); border-radius: 34px; background: linear-gradient(145deg, rgba(26, 38, 103, .88), rgba(35, 46, 120, .67)); box-shadow: 0 24px 80px rgba(4, 8, 30, .4), inset 0 1px 0 rgba(255,255,255,.22); backdrop-filter: blur(16px); text-align: center; }
.story-card::before { position: absolute; width: 220px; height: 220px; top: -145px; right: -50px; border-radius: 50%; content: ""; background: rgba(255,255,255,.1); }
.story-orbit { position: absolute; top: 18px; right: 31px; color: #ffeb92; font-size: 17px; letter-spacing: 13px; opacity: .85; }
.story-symbol { display: grid; width: 82px; height: 82px; place-items: center; margin: 0 auto 13px; border: 6px solid rgba(255,255,255,.32); border-radius: 28px; background: linear-gradient(145deg, #ffdf68, #ffaf55); box-shadow: 0 10px 24px rgba(255, 184, 67, .35); font-size: 43px; animation: symbol-float 2.8s ease-in-out infinite; }
@keyframes symbol-float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-7px) rotate(2deg); } }
.story-kicker, .modal-kicker, .scene-kicker { margin: 0 0 8px; color: #ffed9a; font-size: 12px; font-weight: 950; letter-spacing: .15em; }
.story-card h1 { margin: 0; color: #fff; font-size: clamp(34px, 7vw, 62px); line-height: 1; letter-spacing: -.06em; text-shadow: 0 5px 18px rgba(0,0,0,.25); }
.story-copy { max-width: 470px; margin: 18px auto 23px; color: rgba(255,255,255,.91); font-size: clamp(16px, 2.5vw, 20px); font-weight: 750; line-height: 1.75; }
.story-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.story-note { margin: 18px 0 0; color: rgba(255,255,255,.63); font-size: 12px; font-weight: 700; line-height: 1.55; }

.battle-screen { position: absolute; inset: 0; z-index: 3; display: flex; min-height: 100%; flex-direction: column; padding: 75px clamp(12px, 4vw, 50px) max(13px, env(safe-area-inset-bottom)); }
.scene-heading { position: relative; z-index: 2; flex: 0 0 auto; width: fit-content; max-width: 80%; margin: 0 auto; padding: 9px 22px 8px; border: 1px solid rgba(255,255,255,.24); border-radius: 17px; background: rgba(13, 23, 61, .46); box-shadow: 0 8px 22px rgba(5, 11, 35, .16); text-align: center; backdrop-filter: blur(10px); }
.scene-kicker { margin-bottom: 4px; font-size: 11px; }
.scene-heading h2 { margin: 0; color: #fff; font-size: clamp(16px, 2.7vw, 25px); letter-spacing: -.03em; }
.battle-stage { display: grid; grid-template-columns: minmax(0, 1fr) clamp(45px, 9vw, 120px) minmax(0, 1fr); flex: 1 1 auto; min-height: 0; align-items: center; gap: clamp(4px, 2vw, 22px); padding: clamp(8px, 1.5vh, 22px) 0 clamp(7px, 1.4vh, 18px); }
.character { display: flex; align-items: center; flex-direction: column; min-width: 0; text-align: center; filter: drop-shadow(0 18px 17px rgba(3, 9, 34, .23)); }
.enemy-character { animation: character-bob 3s ease-in-out infinite; }
.player-character { animation: character-bob 3.4s ease-in-out infinite reverse; }
@keyframes character-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.speech-bubble { position: relative; max-width: min(230px, 100%); min-height: 35px; margin-bottom: 5px; padding: 9px 13px; border-radius: 15px; color: var(--ink); background: rgba(255,255,255,.93); font-size: clamp(11px, 1.5vw, 14px); font-weight: 950; line-height: 1.25; box-shadow: 0 7px 15px rgba(5, 12, 40, .16); }
.speech-bubble::after { position: absolute; bottom: -7px; left: 50%; width: 14px; height: 14px; content: ""; background: inherit; transform: translateX(-50%) rotate(45deg); }
.enemy-speech { color: #704b08; background: #fff0a9; }
.player-speech { color: #276e62; background: #d6fff0; }
.character-art { position: relative; display: grid; width: clamp(130px, 19vw, 220px); height: clamp(130px, 19vw, 220px); place-items: center; overflow: hidden; border: clamp(4px, .65vw, 7px) solid rgba(255,255,255,.87); box-shadow: 0 12px 26px rgba(4, 11, 37, .28), inset 0 0 0 2px rgba(255,255,255,.24); }
.enemy-art { border-radius: 45% 55% 48% 52%; background: radial-gradient(circle at 34% 24%, #a9b0ff, #645bd3 59%, #403496); }
.player-art { border-radius: 30px; background: #e3f4ff; transform: rotate(2deg); }
.character-art img { display: block; width: 100%; height: 100%; }
.enemy-art img { object-fit: cover; border-radius: inherit; }
.player-art img { object-fit: cover; border-radius: 22px; }
.character-fallback { color: #fff1a8; font-size: clamp(50px, 8vw, 88px); text-shadow: 0 4px 12px rgba(35, 24, 104, .3); }
.player-art .character-fallback { color: var(--purple); }
.character-name { display: flex; align-items: center; gap: 7px; margin-top: 9px; color: #fff; text-shadow: 0 2px 7px rgba(4, 8, 30, .4); }
.character-name strong { max-width: 160px; overflow: hidden; font-size: clamp(15px, 2.2vw, 22px); text-overflow: ellipsis; white-space: nowrap; }
.character-name span { padding: 4px 7px; border-radius: 8px; color: #7d4c55; background: #ffe2e5; font-size: 10px; font-weight: 950; text-shadow: none; }
.player-character .character-name span { color: #277b67; background: #d9ffef; }
.boss-health { width: min(250px, 90%); margin-top: 7px; }
.health-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; color: rgba(255,255,255,.83); font-size: 10px; font-weight: 900; text-shadow: 0 2px 5px rgba(5, 9, 35, .5); }
.health-label strong { color: #fff; }
.health-track { height: 13px; overflow: hidden; border: 2px solid rgba(255,255,255,.72); border-radius: 12px; background: rgba(8, 16, 52, .5); box-shadow: inset 0 2px 4px rgba(0,0,0,.25); }
.health-fill { width: 100%; height: 100%; border-radius: inherit; transition: width .32s ease; }
.boss-health-fill { background: linear-gradient(90deg, #ff6f7e, #ffb16d); }
.courage-row { display: flex; align-items: center; gap: 8px; margin-top: 9px; color: rgba(255,255,255,.87); font-size: 11px; font-weight: 900; text-shadow: 0 2px 6px rgba(5, 9, 35, .55); }
.courage-row strong { color: #ffdf6a; font-size: 21px; letter-spacing: 2px; line-height: 1; }
.battle-center { position: relative; display: grid; place-items: center; align-self: center; }
.versus-mark { position: relative; z-index: 1; display: grid; width: clamp(46px, 6vw, 74px); height: clamp(46px, 6vw, 74px); place-items: center; border: 5px solid rgba(255,255,255,.76); border-radius: 50%; color: #fff7bf; background: linear-gradient(145deg, #f47e8e, #bc4ea1); box-shadow: 0 8px 21px rgba(30, 16, 74, .28); font-size: clamp(13px, 2vw, 22px); font-weight: 950; font-style: italic; }
.battle-light { position: absolute; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle, rgba(255,239,145,.65), rgba(255,239,145,0) 67%); opacity: .65; }
.bottom-hud { flex: 0 0 auto; padding: 10px 13px 12px; border: 1px solid rgba(255,255,255,.24); border-radius: 22px; background: linear-gradient(135deg, rgba(17, 27, 72, .84), rgba(31, 42, 105, .65)); box-shadow: 0 15px 33px rgba(5, 10, 35, .29), inset 0 1px 0 rgba(255,255,255,.16); backdrop-filter: blur(14px); }
.hud-message { min-height: 25px; margin-bottom: 8px; color: #fff3b0; font-size: clamp(13px, 1.7vw, 16px); font-weight: 950; text-align: center; text-shadow: 0 2px 6px rgba(2, 7, 26, .4); }
.team-hud { display: flex; align-items: center; gap: 10px; }
.team-label { display: flex; flex: 0 0 auto; flex-direction: column; gap: 3px; min-width: 76px; color: rgba(255,255,255,.71); font-size: 11px; font-weight: 800; }
.team-label strong { color: #fff; font-size: 16px; }
.team-list { display: flex; flex: 1 1 auto; min-width: 0; align-items: center; gap: 7px; overflow: hidden; }
.team-empty { flex: 1; color: rgba(255,255,255,.65); font-size: 12px; font-weight: 800; }
.team-card { position: relative; display: flex; flex: 0 0 clamp(48px, 6.2vw, 73px); width: clamp(48px, 6.2vw, 73px); height: clamp(57px, 7.5vw, 86px); align-items: center; flex-direction: column; padding: 3px; border: 3px solid transparent; border-radius: 12px; color: #fff; background: rgba(255,255,255,.13); cursor: pointer; }
.team-card img { display: block; width: 100%; height: 100%; min-height: 0; border-radius: 8px; object-fit: cover; }
.team-card.active { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 221, 102, .22), 0 6px 13px rgba(255, 208, 68, .25); transform: translateY(-3px); }
.team-card.fainted { filter: grayscale(1); opacity: .5; }
.team-card-label { position: absolute; right: 3px; bottom: 3px; left: 3px; overflow: hidden; padding: 2px 3px; border-radius: 5px; color: #fff; background: rgba(10, 14, 43, .7); font-size: 9px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.team-card-badge { position: absolute; top: -8px; right: -5px; z-index: 2; padding: 3px 5px; border-radius: 7px; color: #6b4d00; background: #ffe47b; font-size: 8px; font-weight: 950; }
.summon-button { flex: 0 0 auto; min-height: 47px; padding: 9px 15px; border: 0; border-radius: 14px; color: #493700; background: linear-gradient(135deg, #ffe680, #ffc957); box-shadow: 0 7px 13px rgba(9, 13, 45, .2); cursor: pointer; font-size: 14px; font-weight: 950; }
.summon-button:active, .big-button:active, .small-button:active, .answer-button:active { transform: translateY(2px) scale(.99); }

.primary-button, .secondary-button, .big-button, .small-button { border: 0; cursor: pointer; font-weight: 950; }
.primary-button { color: #fff; background: linear-gradient(135deg, #7869ef, #4b39b4); box-shadow: 0 10px 18px rgba(30, 20, 105, .24); }
.secondary-button { color: var(--purple-dark); background: #f2efff; }
.big-button { min-height: 59px; padding: 12px 19px; border-radius: 17px; font-size: 17px; }
.small-button { min-height: 45px; padding: 9px 14px; border-radius: 13px; font-size: 14px; }
.big-button:hover, .small-button:hover, .summon-button:hover { filter: brightness(1.05); }

.modal-layer { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); background: rgba(5, 8, 30, .65); backdrop-filter: blur(9px); }
.modal-card { position: relative; width: min(570px, 100%); max-height: 96vh; overflow: auto; padding: clamp(23px, 4vw, 35px); border: 1px solid rgba(255,255,255,.54); border-radius: 28px; color: var(--ink); background: var(--glass-light); box-shadow: 0 25px 70px rgba(2, 5, 25, .4); text-align: center; }
.modal-close { position: absolute; top: 12px; right: 13px; display: grid; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 12px; color: var(--muted); background: #eef0fc; cursor: pointer; font-size: 27px; line-height: 1; }
.modal-close:hover { color: var(--danger); background: #ffe9ed; }
.modal-kicker { color: var(--purple); }
.modal-card h2 { margin: 0; color: var(--ink); font-size: clamp(24px, 4vw, 34px); letter-spacing: -.045em; }
.modal-copy { margin: 10px auto 16px; color: var(--muted); font-size: 14px; font-weight: 750; line-height: 1.55; }
.camera-frame { position: relative; width: 100%; aspect-ratio: 16 / 10; overflow: hidden; border: 3px solid #d5d7f1; border-radius: 20px; background: #172044; }
#camera { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
#camera.active { opacity: 1; }
#camera.front-camera { transform: scaleX(-1); }
.camera-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px; color: #dbe1ff; background: radial-gradient(circle at 50% 35%, #4c548f, #172044 72%); }
.camera-empty > span { color: #ffe174; font-size: 48px; line-height: 1; }
.camera-empty strong { color: #fff; font-size: 18px; }
.camera-empty small { font-size: 12px; }
.scan-guide { position: absolute; inset: 18% 25%; pointer-events: none; opacity: 0; transition: opacity .2s; }
.scan-guide.visible { opacity: 1; }
.scan-guide i { position: absolute; width: 28px; height: 28px; border-color: #ffe26f; border-style: solid; }
.scan-guide i:nth-child(1) { top: 0; left: 0; border-width: 4px 0 0 4px; border-radius: 8px 0 0; }
.scan-guide i:nth-child(2) { top: 0; right: 0; border-width: 4px 4px 0 0; border-radius: 0 8px 0 0; }
.scan-guide i:nth-child(3) { bottom: 0; left: 0; border-width: 0 0 4px 4px; border-radius: 0 0 0 8px; }
.scan-guide i:nth-child(4) { right: 0; bottom: 0; border-width: 0 4px 4px 0; border-radius: 0 0 8px; }
.scan-guide > div { position: absolute; top: 50%; left: 0; right: 0; height: 3px; background: #ffe26f; box-shadow: 0 0 13px #ffe26f; animation: scan-line 2.1s ease-in-out infinite; }
@keyframes scan-line { 0%, 100% { transform: translateY(-52px); opacity: .35; } 50% { transform: translateY(52px); opacity: 1; } }
.camera-status { min-height: 20px; margin: 9px 0 7px; color: var(--muted); font-size: 12px; font-weight: 850; }
.camera-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.camera-actions button:disabled { cursor: not-allowed; opacity: .48; }
.adult-tools { margin-top: 17px; padding-top: 13px; border-top: 1px dashed #dde0f0; text-align: left; }
.adult-tools label { display: block; margin-bottom: 6px; color: #8b91ad; font-size: 11px; font-weight: 850; }
.adult-tools > div { display: flex; gap: 8px; }
.adult-tools input { width: 93px; min-height: 45px; padding: 8px 11px; border: 2px solid #e3e5f2; border-radius: 13px; color: var(--ink); outline: none; font-weight: 900; }
.adult-tools input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(104, 89, 220, .13); }
.scan-feedback { min-height: 20px; margin: 10px 0 0; color: var(--muted); font-size: 12px; font-weight: 800; }
.scan-feedback.success { color: #138262; }
.scan-feedback.error { color: #b94d5d; }

.math-card { width: min(505px, 100%); padding-top: 30px; }
.math-badge { display: inline-flex; min-height: 31px; align-items: center; padding: 7px 12px; border-radius: 11px; color: #785300; background: #ffe99b; font-size: 12px; font-weight: 950; }
.math-card h2 { margin-top: 11px; }
.math-problem { margin: 13px auto 20px; color: var(--purple-dark); font-size: clamp(42px, 9vw, 68px); font-weight: 950; letter-spacing: .04em; line-height: 1.1; }
.answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.answer-button { min-height: 75px; border: 3px solid #e0def8; border-radius: 17px; color: var(--purple-dark); background: #faf9ff; cursor: pointer; font-size: clamp(25px, 5vw, 36px); font-weight: 950; box-shadow: 0 6px 12px rgba(58, 47, 150, .07); }
.answer-button:hover { border-color: var(--purple); background: #f0eeff; transform: translateY(-2px); }
.answer-button:disabled { cursor: default; opacity: .6; transform: none; }
.answer-feedback { min-height: 23px; margin: 14px 0 0; color: var(--muted); font-size: 13px; font-weight: 850; }
.answer-feedback.good { color: #168565; }
.answer-feedback.bad { color: #b94d5d; }
.question-summon-button { min-height: 40px; margin-top: 8px; padding: 8px 14px; border: 2px solid #ddd9fa; border-radius: 12px; color: var(--purple-dark); background: #f6f4ff; cursor: pointer; font-size: 12px; font-weight: 900; }
.question-summon-button:hover { border-color: var(--purple); background: #efecff; }

/* 答题是战斗的一部分：保留场景、角色和血条，只浮出一张轻量答题卡。 */
#mathModal { display: block; padding: 0; background: linear-gradient(180deg, transparent 42%, rgba(5, 9, 31, .12) 100%); backdrop-filter: none; pointer-events: none; }
#mathModal .math-card { position: absolute; bottom: calc(152px + env(safe-area-inset-bottom)); left: 50%; width: min(430px, calc(100% - 32px)); max-height: none; padding: 17px 20px 14px; border-color: rgba(255,255,255,.78); border-radius: 22px; box-shadow: 0 17px 38px rgba(3, 7, 29, .32), 0 0 0 5px rgba(255,255,255,.11); pointer-events: auto; transform: translateX(-50%); }
#mathModal .math-badge { min-height: 27px; padding: 5px 10px; }
#mathModal .math-card h2 { margin-top: 7px; font-size: clamp(21px, 3vw, 27px); }
#mathModal .modal-copy { margin: 5px auto 7px; font-size: 12px; }
#mathModal .math-problem { margin: 6px auto 11px; font-size: clamp(37px, 6vw, 54px); }
#mathModal .answer-grid { gap: 8px; }
#mathModal .answer-button { min-height: 53px; border-width: 2px; border-radius: 13px; font-size: clamp(23px, 4vw, 31px); }
#mathModal .answer-feedback { min-height: 19px; margin: 8px 0 0; font-size: 11px; }
#mathModal .question-summon-button { min-height: 34px; margin-top: 5px; padding: 6px 11px; font-size: 11px; }

.result-card { width: min(500px, 100%); padding-top: 34px; }
.result-symbol { display: grid; width: 92px; height: 92px; place-items: center; margin: 0 auto 14px; border-radius: 31px; background: #fff4bf; box-shadow: 0 9px 22px rgba(241, 190, 56, .22); font-size: 55px; }
.result-card h2 { margin-top: 4px; }
.result-card .modal-copy { max-width: 390px; margin-bottom: 23px; font-size: 16px; }
.result-card .big-button { min-width: 210px; }
.toast { position: absolute; z-index: 90; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; max-width: min(90%, 490px); padding: 12px 17px; border: 1px solid rgba(255,255,255,.25); border-radius: 14px; color: #fff; background: rgba(15, 23, 62, .9); box-shadow: 0 13px 28px rgba(1, 4, 22, .25); opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: opacity .2s, transform .2s; text-align: center; font-size: 13px; font-weight: 850; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

.shake { animation: battle-shake .3s ease-in-out; }
@keyframes battle-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-9px); } 75% { transform: translateX(9px); } }

@media (max-width: 720px) {
  .game-topbar { padding-right: 12px; padding-left: 12px; }
  .game-title { display: none; }
  .text-button { display: none; }
  .stage-pill { font-size: 11px; }
  .battle-screen { padding-right: 8px; padding-left: 8px; }
  .battle-stage { grid-template-columns: minmax(0, 1fr) 43px minmax(0, 1fr); gap: 3px; }
  .speech-bubble { max-width: 145px; padding: 8px 9px; font-size: 10px; }
  .character-art { width: clamp(112px, 28vw, 170px); height: clamp(112px, 28vw, 170px); }
  .character-name { flex-direction: column; gap: 3px; }
  .character-name strong { max-width: 120px; font-size: 15px; }
  .boss-health { width: min(170px, 90%); }
  .health-label { font-size: 9px; }
  .team-label { min-width: 61px; }
  .team-label span { font-size: 10px; }
  .team-label strong { font-size: 14px; }
  .summon-button { padding: 8px 10px; font-size: 12px; }
  .team-card { flex-basis: 49px; width: 49px; height: 62px; }
  .team-card-label { font-size: 8px; }
  #mathModal .math-card { bottom: calc(101px + env(safe-area-inset-bottom)); width: min(390px, calc(100% - 22px)); padding-right: 14px; padding-left: 14px; }
}

@media (max-height: 660px) {
  .game-topbar { min-height: 54px; padding-top: 7px; }
  .battle-screen { padding-top: 59px; }
  .scene-heading { padding-top: 5px; padding-bottom: 5px; }
  .battle-stage { padding-top: 3px; padding-bottom: 3px; }
  .character-art { width: clamp(100px, 17vw, 170px); height: clamp(100px, 17vw, 170px); }
  .speech-bubble { min-height: 29px; margin-bottom: 2px; padding: 6px 9px; }
  .character-name { margin-top: 4px; }
  .boss-health { margin-top: 4px; }
  .courage-row { margin-top: 4px; }
  .bottom-hud { padding-top: 6px; padding-bottom: 7px; }
  .hud-message { min-height: 19px; margin-bottom: 4px; font-size: 12px; }
  .team-card { height: 52px; }
}

@media (max-width: 430px) {
  .story-screen { padding-right: 10px; padding-left: 10px; }
  .story-card { border-radius: 26px; }
  .story-actions { flex-direction: column-reverse; }
  .story-actions .big-button { width: 100%; }
  .modal-card { border-radius: 23px; padding-right: 17px; padding-left: 17px; }
  .team-hud { gap: 5px; }
  .team-label { min-width: 53px; }
  .summon-button { padding-right: 7px; padding-left: 7px; }
  #mathModal .math-card { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
