:root {
  color-scheme: dark;
  --ink: #10101f;
  --panel: #171529ef;
  --gold: #ebd5a7;
  --muted: #b4abc5;
  --line: #ead9af30;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --ease-out: cubic-bezier(.2, .72, .25, 1);
  --serif: "Noto Serif TC", "PMingLiU", Georgia, serif;
  font-family: "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  color: #f4edf8;
  background: var(--ink);
}
.scene-transition { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; background: radial-gradient(ellipse at center, color-mix(in srgb, var(--travel-color, #c6a2ff) 19%, #151226), #080914 72%); color: #f8eddb; }
.scene-transition > strong { font: 30px var(--serif); letter-spacing: .15em; margin: 10px 0; }
.scene-transition > p:last-child { font-size: 12px; color: #bfb0cf; letter-spacing: .25em; }
.travel-gate { position: relative; width: 160px; height: 160px; display: grid; place-items: center; margin-bottom: 30px; }
.travel-gate i { position: absolute; inset: 0; border: 1px solid var(--travel-color, #c6a2ff); border-radius: 50%; box-shadow: 0 0 30px #bb9dff26, inset 0 0 24px #bb9dff16; }
.travel-gate i:nth-child(2) { inset: 19px; border-style: dashed; transform: rotate(25deg); }
.travel-gate span { font-size: 58px; color: var(--travel-color, #c6a2ff); text-shadow: 0 0 36px currentColor; }
.passive-summary { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.passive-token { border: 1px solid #d5a8ff3b; border-radius: 4px; padding: 3px 5px; font-size: 9px; color: #d9c4ed; background: #b184d60d; }
.passive-token b { color: #f5d69a; font-weight: 400; }
.passive-toast { position: fixed; z-index: 6; top: 39%; left: 50%; transform: translateX(-50%); padding: 7px 15px; border: 1px solid #e6c9ff59; border-radius: 20px; background: #20152edd; color: #ffe4b5; font-size: 12px; letter-spacing: .08em; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .travel-gate { animation: gate-arrive .65s ease-out both; }
  .travel-gate i:nth-child(2) { animation: gate-turn 2.5s linear infinite; }
  .passive-awaken { animation: passive-awaken .35s ease-out; }
  @keyframes gate-arrive { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
  @keyframes gate-turn { to { transform: rotate(205deg); } }
  @keyframes passive-awaken { from { opacity: 0; translate: 0 9px; } to { opacity: 1; translate: 0 0; } }
}
* { box-sizing: border-box; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { margin: 0; height: 100vh; height: 100dvh; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button, img { -webkit-user-drag: none; -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
input, textarea, select { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:is(button, select):focus-visible { outline: 2px solid #e9ceff; outline-offset: 4px; }
@media (prefers-reduced-motion: no-preference) {
  :where(button:not(.primary-button, .utility, .spirit-card, .skill-card, .reward-card, .action-skill, .touchpad button)):active:not(:disabled) {
    translate: 0 1px;
  }
}
[hidden] { display: none !important; }
#world, .world-shade, #hit-flash { position: fixed; inset: 0; }
#world { height: 100vh; height: 100dvh; touch-action: none; }
#world canvas { display: block; width: 100%; height: 100%; }
.world-shade { pointer-events: none; background: radial-gradient(ellipse at center, transparent 20%, #080714ab 100%), linear-gradient(0deg, #090713cf, transparent 30%, transparent 60%, #0a0819b3); transition: background .5s; }
body[data-phase=menu] .world-shade { background: linear-gradient(180deg, #0d0c20e0 0%, #131026c2 44%, #0d0a1cf0 100%); backdrop-filter: blur(4px); }
#hit-flash { pointer-events: none; box-shadow: inset 0 0 110px #d1475e; opacity: 0; }
#hit-flash.hurt { animation: hurt .5s ease-out; }
@keyframes hurt { from { opacity: .65; } to { opacity: 0; } }
.masthead { position: fixed; z-index: 4; top: 23px; left: 34px; right: 34px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.brand, .header-tools { pointer-events: auto; display: flex; align-items: center; }
.brand { gap: 13px; }
.brand-seal { font-size: 32px; color: var(--gold); text-shadow: 0 0 25px #f2c59166; }
.wordmark { display: block; color: var(--gold); font: 19px Georgia, serif; letter-spacing: .26em; }
.brand-name { display: block; color: #b7aec6; font-size: 10px; letter-spacing: .14em; margin-top: 5px; }
.brand-name i { font-style: normal; opacity: .4; margin: 0 4px; }
.header-tools { gap: 8px; }
.utility { border: 1px solid #ddc7fc25; background: #171425a3; border-radius: 7px; padding: 9px 11px; font-size: 11px; color: #b8adc8; backdrop-filter: blur(10px); }
.utility span { color: #f2dfb9; padding-left: 7px; }
.utility:hover { background: #342740; border-color: #ddc7fc75; }
.utility[aria-pressed=true] { color: var(--gold); border-color: #d6b28765; }
.icon-button { width: 35px; height: 35px; padding: 0; font-size: 17px; }
.fullscreen-button { display: inline-flex; align-items: center; gap: 6px; }
.fullscreen-button .fullscreen-icon { padding: 0; color: #e5d2ef; font-size: 18px; line-height: 1; }
.fullscreen-button .fullscreen-label { padding: 0; color: #c6b5d2; }
.menu-screen { position: fixed; inset: 0; overflow-y: auto; overscroll-behavior: contain; padding: 106px 34px 22px; }
.menu-intro { text-align: center; margin-bottom: 30px; }
.eyebrow { color: var(--gold); font: 10px Georgia, serif; letter-spacing: .28em; margin: 0 0 13px; }
.menu-intro h1 { font: 500 clamp(29px, 3.1vw, 43px)/1.4 var(--serif); margin: 0 0 13px; letter-spacing: .1em; }
.menu-intro > p:last-child { color: #bdb2cd; font-size: 12px; letter-spacing: .1em; margin: 0; }
.card-gallery { max-width: 1240px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 15px; margin: 0 auto; }
.spirit-card { --element: #d5a8ff; position: relative; display: block; padding: 5px; text-align: left; min-width: 0; border: 1px solid #b7a08255; border-radius: 13px; background: linear-gradient(150deg, #64526863, #1b182b 35%, #292036); box-shadow: 0 14px 40px #0003; isolation: isolate; transition: transform .25s, box-shadow .25s, border-color .25s; }
.spirit-card::before { content: ""; position: absolute; inset: 3px; border: 1px solid #efddb824; border-radius: 10px; pointer-events: none; z-index: 1; }
.spirit-card:hover { transform: translateY(-8px); border-color: var(--element); box-shadow: 0 16px 40px color-mix(in srgb, var(--element) 16%, transparent); }
.spirit-card[aria-pressed=true] { border-color: var(--element); box-shadow: 0 0 0 1px color-mix(in srgb, var(--element) 26%, transparent), 0 0 28px color-mix(in srgb, var(--element) 12%, transparent); }
.card-art { position: relative; overflow: hidden; display: block; aspect-ratio: 0.88; border-radius: 8px 8px 5px 5px; background: radial-gradient(ellipse at 50% 38%, color-mix(in srgb, var(--element) 36%, #211631), #181425 70%); }
.card-art img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .6s; }
.spirit-card:hover .card-art img { transform: scale(1.07); }
.card-art::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(0deg, #20182c9e, transparent 45%); }
.element-tag { position: absolute; top: 13px; left: 13px; z-index: 2; color: #fff2dd; background: #1311249c; border: 1px solid #eee0ba44; border-radius: 20px; font-size: 9px; padding: 4px 8px; letter-spacing: .1em; backdrop-filter: blur(6px); }
.selection-mark { position: absolute; top: 13px; right: 13px; z-index: 2; border: 1px solid #ead4b88c; border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; color: transparent; background: #1a142b9e; font-size: 12px; }
.spirit-card[aria-pressed=true] .selection-mark { color: #171323; border-color: var(--element); background: var(--element); box-shadow: 0 0 17px color-mix(in srgb, var(--element) 70%, transparent); }
.card-copy { display: block; padding: 13px 9px 9px; }
.card-name { display: block; font: 600 clamp(15px, 1.5vw, 19px) var(--serif); letter-spacing: .08em; color: #f2e6d1; }
.card-spell { display: block; font-size: 10px; color: var(--element); letter-spacing: .1em; margin: 7px 0; }
.card-description { display: block; font-size: 10px; line-height: 1.7; color: #baafc7; min-height: 3.4em; }
.card-numbers { display: flex; justify-content: space-between; font-size: 9px; margin-top: 11px; padding-top: 9px; color: #b5a9c5; border-top: 1px solid #d5c1e71a; }
.card-numbers b { color: #e8d9f0; font-weight: 400; }
.departure { display: flex; justify-content: space-between; align-items: center; gap: 25px; max-width: 1240px; margin: 27px auto 0; padding: 20px 0 0; border-top: 1px solid var(--line); }
.selection-label { font-size: 12px; color: #eee1c6; letter-spacing: .09em; }
.selection-label strong { color: var(--gold); font: 15px Georgia, serif; margin-left: 17px; }
.deck-summary p { font-size: 11px; color: #a99dbc; margin: 9px 0 0; line-height: 1.7; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 33px; min-width: 213px; padding: 16px 24px; border: 1px solid #f2daac; border-radius: 7px; background: linear-gradient(120deg, #f2deb3, #d2af7b); color: #38283a; font-size: 14px; font-weight: 600; letter-spacing: .08em; box-shadow: 0 5px 25px #cca2631f; transition: filter .2s, box-shadow .2s; }
.primary-button > span:last-child { font-size: 19px; }
.primary-button:hover:not(:disabled) { filter: brightness(1.12); box-shadow: 0 0 35px #d5ac6f3d; }
.primary-button:disabled { opacity: .48; }
.menu-bottom { max-width: 1240px; margin: 22px auto 0; display: flex; justify-content: space-between; gap: 15px; color: #80758f; font-size: 10px; letter-spacing: .08em; }
.player-status { position: fixed; left: 34px; top: 100px; width: 273px; padding: 16px 18px; border: 1px solid #d9bdd82b; border-radius: 10px; background: #131124d6; backdrop-filter: blur(12px); }
.player-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 12px; color: #eee1d5; }
.shield-value { color: #bddbf9; font-size: 10px; }
.vital { position: relative; display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.vital-name { font-size: 9px; color: #ada1be; }
.meter { height: 6px; border-radius: 6px; overflow: hidden; background: #e0c9f512; }
.vital .meter { flex: 1; }
.meter i { height: 100%; width: 100%; display: block; border-radius: inherit; transition: width .12s linear; }
.health i { background: linear-gradient(90deg, #a3557c, #f5aeb0); box-shadow: 0 0 9px #f29dab66; }
.mana i { background: linear-gradient(90deg, #6970c8, #bdb5ff); }
.vital strong { width: 53px; color: #d6cddd; text-align: right; font-size: 9px; font-weight: 400; font-variant-numeric: tabular-nums; }
.blessing-summary { display: flex; gap: 5px; flex-wrap: wrap; }
.blessing-summary:empty { display: none; }
.blessing-token { display: inline-block; color: #dcc49f; font-size: 9px; border: 1px solid #e5cda731; border-radius: 4px; padding: 3px 5px; margin-top: 12px; }
.wave-status { position: fixed; top: 32px; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; }
.wave-status .eyebrow { font: 9px system-ui; letter-spacing: .2em; margin-bottom: 7px; display: block; }
.wave-status h2 { font: 500 17px var(--serif); letter-spacing: .08em; margin: 0; }
.wave-status p { color: #b5a6c4; font-size: 10px; margin: 8px 0 0; }
.small-dot { margin: 0 8px; color: #8f7a9f; }
.run-status { position: fixed; right: 34px; top: 102px; display: flex; gap: 17px; padding: 10px 13px; border: 1px solid #d9bdd825; background: #131124a6; border-radius: 6px; font-size: 10px; color: #bcaacc; }
.run-status strong { font: 17px Georgia, serif; color: #f0d3a7; margin-left: 7px; }
.boss-status { position: fixed; left: 50%; top: 112px; transform: translateX(-50%); width: min(360px, 35vw); }
.boss-status > div:first-child { display: flex; justify-content: space-between; font-size: 11px; color: #f6bfd5; margin-bottom: 7px; }
.boss i { background: linear-gradient(90deg, #9f4c9f, #f7a7b9); }
.control-hint { position: fixed; bottom: 28px; left: 34px; display: flex; flex-direction: column; gap: 10px; font-size: 10px; color: #c5b5d1; }
.control-hint span:last-child { color: #877a9c; font-size: 9px; }
kbd { display: inline-grid; place-items: center; min-width: 19px; padding: 2px 4px; margin-right: 2px; border: 1px solid #d7bce43b; border-radius: 4px; background: #1b1426a3; color: #decee9; font: 9px system-ui; }
.combat-dock { position: fixed; bottom: 23px; left: 50%; transform: translateX(-50%); display: flex; align-items: end; gap: 14px; }
.equipped-cards { display: flex; align-items: end; gap: 9px; }
.skill-card { --element: #d2b7f3; position: relative; width: 108px; height: 139px; overflow: hidden; padding: 0; border: 1px solid color-mix(in srgb, var(--element) 60%, transparent); border-radius: 10px; background: #1c162a; text-align: left; box-shadow: 0 8px 25px #0004; transition: transform .2s; }
.skill-card:hover:not(:disabled) { transform: translateY(-5px); border-color: #fff1de; }
.skill-card img { width: 100%; height: 100%; object-fit: cover; }
.skill-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, #151022 0%, #151022da 20%, transparent 73%); pointer-events: none; }
.skill-key { position: absolute; z-index: 2; top: 7px; left: 7px; background: #181121c9; border-color: #e8d2b783; font-size: 11px; min-width: 23px; }
.skill-cost { position: absolute; top: 9px; right: 8px; z-index: 2; color: #eee1ff; font-size: 9px; text-shadow: 0 1px 5px #000; }
.skill-label { position: absolute; left: 9px; bottom: 11px; right: 5px; z-index: 2; }
.skill-label b { display: block; color: #f8e8ce; font: 600 12px var(--serif); letter-spacing: .06em; }
.skill-label small { display: block; font-size: 9px; color: var(--element); margin-top: 5px; }
.skill-shade { position: absolute; z-index: 3; inset: 0; height: 0; background: #0c091bb5; pointer-events: none; }
.skill-cooldown { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; color: #fff3f9; text-shadow: 0 2px 15px #09050c; font: 30px Georgia, serif; pointer-events: none; }
.skill-card.no-mana img { filter: saturate(.4) brightness(.55); }
.action-skill { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1px solid #c2a7df42; background: #171324d9; border-radius: 10px; width: 88px; min-height: 110px; padding: 8px 5px; color: #e8d8ed; font-size: 10px; backdrop-filter: blur(10px); }
.action-skill small { font-size: 8px; color: #b8a5c9; }
.action-skill kbd { margin-top: 2px; }
.action-skill:disabled { border-color: #aa92bf25; color: #8d7d9d; }
.action-symbol { font: 28px Georgia, serif; color: #b7dcf9; text-shadow: 0 0 15px #a0b8f76b; }
.nova-orbit { display: grid; place-items: center; height: 35px; width: 35px; border: 1px solid #c5a47153; border-radius: 50%; color: #e6c58a; font-size: 20px; }
.nova-action.ready { border-color: #ecc88b; box-shadow: 0 0 25px #e8b66445; }
.nova-action.ready .nova-orbit { color: #ffe6a4; text-shadow: 0 0 12px #ffcf58; animation: breathe 2s ease-in-out infinite alternate; }
@keyframes breathe { to { box-shadow: 0 0 18px #e8b6648a; } }
.touchpad { display: none; position: fixed; touch-action: none; }
.stage-selection { max-width: 1180px; margin: 0 auto 25px; }
.stage-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.stage-heading > span:last-child { font-size: 10px; color: #b3a4c2; }
.stage-heading .eyebrow { margin: 0; color: #e4cba6; font-size: 10px; }
.stage-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stage-card { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 14px; border: 1px solid #ccb3df29; border-radius: 12px; background: linear-gradient(135deg, #22182de8, #14101edb); text-align: left; transition: border-color .2s, background .2s, translate .16s; }
.stage-card::before { content: ''; pointer-events: none; position: absolute; inset: 0; opacity: .16; background: radial-gradient(ellipse at 15% 120%, var(--stage), transparent 70%); }
.stage-card[aria-pressed=true] { border-color: var(--stage); box-shadow: inset 0 0 22px color-mix(in srgb, var(--stage) 9%, transparent), 0 5px 14px #0003; }
.stage-card:active { translate: 0 1px; }
.stage-symbol { position: relative; display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border: 1px solid color-mix(in srgb, var(--stage) 40%, transparent); color: var(--stage); border-radius: 50%; font-size: 23px; text-shadow: 0 0 14px var(--stage); }
.stage-copy { position: relative; min-width: 0; display: grid; gap: 6px; }
.stage-copy b { font: 600 15px var(--serif); color: #f0dfc8; letter-spacing: .06em; }
.stage-copy small { font-size: 9px; color: #c1adca; }
.stage-check { margin-left: auto; color: var(--stage); opacity: 0; font-size: 12px; }
.stage-card[aria-pressed=true] .stage-check { opacity: 1; }
.stage-description { margin: 9px 2px 0; min-height: 1.8em; font-size: 10px; line-height: 1.8; color: #b7a6c5; }
@media (max-width: 700px) {
  .stage-selection { margin-bottom: 20px; }
  .stage-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .stage-card { min-height: 66px; padding: 10px; gap: 8px; }
  .stage-symbol { width: 30px; height: 30px; flex-basis: 30px; font-size: 19px; }
  .stage-copy b { font-size: 12px; }
  .stage-copy small { font-size: 8px; }
  .stage-heading > span:last-child { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) { .stage-card { transition: none; } }
.joystick-ring, .joystick-knob, .joystick-hint { display: none; }
.notice { position: fixed; z-index: 30; bottom: 186px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); padding: 11px 20px; border: 1px solid #ebcdae55; border-radius: 7px; background: #20152eef; color: #f3dfc4; text-align: center; font-size: 12px; box-shadow: 0 8px 24px #0004; pointer-events: none; }
body[data-phase=menu] .notice { bottom: 24px; }
.overlay-screen { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; overflow-y: auto; padding: 34px 20px; background: #090716b0; backdrop-filter: blur(9px); }
.reward-panel, .pause-panel, .result-panel { position: relative; width: min(900px, 100%); text-align: center; border: 1px solid #e3cba738; border-radius: 18px; background: radial-gradient(ellipse at top, #35223d, #171327 70%); padding: 39px; box-shadow: 0 24px 100px #04020a80; }
.overlay-screen h2 { font: 500 32px var(--serif); letter-spacing: .12em; color: #f4e3cb; margin: 12px 0; outline: none; }
.panel-description { color: #bfb0cd; font-size: 12px; line-height: 1.8; margin: 0; }
.reward-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 17px; margin-top: 30px; }
.reward-card { text-align: center; border: 1px solid #c2a4d047; border-radius: 10px; padding: 26px 18px; background: linear-gradient(150deg, #4b305659, #20182d); transition: border-color .2s, transform .2s; }
.reward-card:hover { border-color: #e1c296; transform: translateY(-6px); }
.reward-icon { width: 65px; height: 65px; display: grid; place-items: center; margin: 0 auto 20px; border: 1px solid #d1ad7370; border-radius: 50%; color: #e6c795; font-size: 30px; background: radial-gradient(circle, #9b6ba434, transparent); box-shadow: 0 0 0 6px #c3a3c507, 0 0 0 7px #c3a3c519; }
.reward-card b { display: block; color: #eed9b8; font: 600 18px var(--serif); letter-spacing: .07em; }
.reward-card p { color: #bfb0cc; font-size: 12px; line-height: 1.8; min-height: 3.6em; }
.reward-card small { color: #9f8aad; font-size: 10px; }
.reward-note { margin: 26px 0 0; color: #9c8ba9; font-size: 11px; }
.pause-panel { width: min(480px, 100%); padding: 31px; }
.pause-panel h2 { font-size: 27px; }
.controls-list { margin: 24px 0 0; padding: 17px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.controls-list > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; color: #d0c0da; text-align: left; }
.help-tips { text-align: left; color: #a494b6; font-size: 11px; line-height: 1.9; }
.help-tips b { color: #d9bce8; font-weight: 400; }
.panel-actions { margin-top: 23px; display: flex; flex-direction: column; align-items: center; gap: 15px; }
.text-button { padding: 4px; background: none; border: none; font-size: 10px; color: #a28caf; text-decoration: underline; text-underline-offset: 4px; }
.result-panel { width: min(610px, 100%); }
.result-symbol { display: block; color: #e6c991; font-size: 44px; text-shadow: 0 0 30px #e8c57968; margin-bottom: 15px; }
.result-panel .primary-button { margin: 25px auto 0; }
.result-deck { display: flex; justify-content: center; gap: 11px; margin: 25px 0; }
.result-card { width: 70px; height: 88px; object-fit: cover; border-radius: 6px; border: 1px solid #dec79a69; }
.result-card:nth-child(1) { transform: rotate(-9deg) translateY(5px); }
.result-card:nth-child(3) { transform: rotate(9deg) translateY(5px); }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 20px 0; gap: 10px; }
.result-stats strong { display: block; font: 28px Georgia, serif; color: #f1d7aa; }
.result-stats span { display: block; font-size: 10px; color: #af9abd; margin-top: 8px; }
.record-line { color: #a995b7; font-size: 10px; margin-top: 20px; }
.load-error { position: fixed; z-index: 100; inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: min(380px, 90vw); border: 1px solid #cba8d5; background: #21162e; padding: 25px; border-radius: 12px; }
.load-error p { color: #cdbad6; font-size: 13px; line-height: 1.7; }
.load-error button { background: #e6c795; color: #2d1d33; border: none; border-radius: 5px; padding: 8px 16px; }
@media (min-width: 1101px) and (min-height: 880px) {
  .menu-screen { padding-top: 14vh; }
  .menu-intro { margin-bottom: 42px; }
  .card-art { aspect-ratio: .78; }
  .departure { margin-top: 36px; }
}
@media (max-width: 1100px) {
  .menu-screen { padding-top: 100px; }
  .card-gallery { max-width: 780px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-art { aspect-ratio: 1.35; }
  .card-copy { padding: 10px; }
  .card-description { min-height: 0; }
  .card-name { font-size: 18px; }
  .departure, .menu-bottom { max-width: 780px; }
  .menu-bottom { padding-bottom: 10px; }
  .control-hint { display: none; }
  .player-status { width: 235px; }
}
@media (max-width: 700px) {
  .masthead { top: 16px; left: 17px; right: 17px; }
  .brand { gap: 9px; }
  .brand-seal { font-size: 25px; }
  .wordmark { font-size: 15px; }
  .brand-name { font-size: 8px; }
  .utility { padding: 8px; font-size: 9px; }
  .icon-button { width: 30px; height: 30px; font-size: 16px; padding: 0; }
  .header-tools { gap: 5px; }
  .menu-screen { padding: 92px 17px 22px; }
  .menu-intro { margin-bottom: 25px; }
  .menu-intro h1 { font-size: 26px; }
  .menu-intro > p:last-child { font-size: 10px; }
  .card-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
  .card-art { aspect-ratio: 1.04; }
  .card-description { font-size: 10px; min-height: 3.4em; }
  .card-name { font-size: 17px; }
  .card-copy { padding: 11px 8px 7px; }
  .card-spell { font-size: 10px; }
  .departure { margin-top: 22px; padding-top: 18px; flex-direction: column; align-items: stretch; gap: 16px; }
  .departure .primary-button { width: 100%; }
  .menu-bottom { flex-direction: column; align-items: center; font-size: 9px; gap: 8px; }
  .player-status { top: 83px; left: 14px; width: 195px; padding: 12px; }
  .player-heading { font-size: 10px; margin-bottom: 8px; }
  .vital { gap: 5px; margin-top: 7px; }
  .vital strong { width: 45px; font-size: 8px; }
  .wave-status { left: auto; right: 15px; top: 85px; transform: none; text-align: right; }
  .wave-status h2 { font-size: 13px; letter-spacing: 0; }
  .wave-status .eyebrow { font-size: 8px; margin-bottom: 5px; }
  .wave-status p { font-size: 9px; margin-top: 6px; }
  .run-status { top: 150px; right: 15px; gap: 10px; padding: 6px 8px; font-size: 8px; }
  .run-status strong { font-size: 13px; margin-left: 4px; }
  .boss-status { top: 195px; width: min(300px, calc(100% - 45px)); }
  .combat-dock { bottom: 15px; gap: 7px; }
  .equipped-cards { gap: 6px; }
  .skill-card { width: 67px; height: 102px; border-radius: 7px; }
  .skill-label { left: 6px; bottom: 8px; }
  .skill-label b { font-size: 10px; letter-spacing: 0; }
  .skill-label small { font-size: 8px; margin-top: 4px; }
  .skill-key { min-width: 18px; font-size: 9px; top: 5px; left: 5px; }
  .skill-cost { right: 5px; top: 7px; font-size: 8px; }
  .skill-cooldown { font-size: 24px; }
  .action-skill { width: 57px; min-height: 90px; font-size: 9px; gap: 4px; }
  .action-skill small { font-size: 7px; }
  .action-symbol { font-size: 23px; }
  .nova-orbit { width: 28px; height: 28px; font-size: 16px; }
  .notice { bottom: 137px; font-size: 11px; }
  .overlay-screen { padding: 20px 14px; }
  .reward-panel, .result-panel { padding: 27px 18px; }
  .overlay-screen h2 { font-size: 25px; }
  .reward-options { gap: 10px; margin-top: 24px; }
  .reward-card { padding: 20px 10px; }
  .reward-icon { width: 44px; height: 44px; font-size: 22px; margin-bottom: 18px; }
  .reward-card b { font-size: 14px; letter-spacing: 0; }
  .reward-card p { font-size: 10px; line-height: 1.8; min-height: 5.4em; }
  .reward-card small { font-size: 8px; }
  .result-stats strong { font-size: 23px; }
  .result-stats span { font-size: 9px; }
  .pause-panel { padding: 27px 20px; }
}
@media (pointer: coarse) {
  .touchpad { display: grid; position: fixed; bottom: 150px; left: 20px; grid-template-columns: repeat(3, 39px); gap: 4px; touch-action: none; }
  .touchpad button { height: 39px; border: 1px solid #d0b5e34d; border-radius: 8px; background: #251b35c9; color: #e4d4f3; font-size: 17px; user-select: none; }
  .touchpad button[data-move="KeyW"] { grid-column: 2; }
  .touchpad button:nth-child(2) { grid-column: 1; }
  .touchpad button:active { background: #72558a; }
  .control-hint { display: none; }
  .skill-card, .action-skill { touch-action: manipulation; }
}
@media (max-height: 620px) and (min-width: 701px) {
  .menu-screen { padding-top: 88px; }
  .menu-intro h1 { font-size: 27px; }
  .menu-intro { margin-bottom: 20px; }
  .card-gallery { grid-template-columns: repeat(6, minmax(0, 1fr)); max-width: 1240px; }
  .card-art { aspect-ratio: 1.15; }
  .card-name { font-size: 14px; }
  .card-description { display: none; }
  .departure { margin-top: 17px; padding-top: 15px; }
  .menu-bottom { margin-top: 13px; }
  .skill-card { height: 102px; width: 82px; }
  .combat-dock { bottom: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Keep the game and controls inside the visible viewport, including device cutouts. */
.masthead { top: calc(23px + var(--safe-top)); left: calc(34px + var(--safe-left)); right: calc(34px + var(--safe-right)); }
.menu-screen {
  height: 100vh; height: 100dvh; overflow-x: hidden;
  padding-top: calc(106px + var(--safe-top));
  padding-right: calc(34px + var(--safe-right));
  padding-bottom: calc(22px + var(--safe-bottom));
  padding-left: calc(34px + var(--safe-left));
  touch-action: pan-y;
}
.overlay-screen {
  height: 100vh; height: 100dvh; overflow-x: hidden; overscroll-behavior: contain;
  padding-top: calc(34px + var(--safe-top)); padding-bottom: calc(34px + var(--safe-bottom));
  padding-left: calc(20px + var(--safe-left)); padding-right: calc(20px + var(--safe-right));
  touch-action: pan-y;
}
.combat-dock { bottom: calc(23px + var(--safe-bottom)); }
@media (pointer: coarse), (max-width: 700px) {
  body[data-phase=menu] .world-shade, .overlay-screen { backdrop-filter: none; }
  .overlay-screen { background-color: #090716df; }
  .utility, .icon-button { min-width: 44px; min-height: 44px; }
  .icon-button { width: 44px; height: 44px; }
  .text-button { min-height: 44px; padding: 10px 5px; }
  .primary-button { min-height: 48px; }
  .touchpad { grid-template-columns: repeat(3, 44px); gap: 4px; bottom: calc(148px + var(--safe-bottom)); left: calc(16px + var(--safe-left)); }
  .touchpad button { min-width: 44px; min-height: 44px; height: 44px; }
  .skill-card, .action-skill { min-width: 44px; min-height: 44px; user-select: none; }
}
@media (max-width: 700px) {
  .masthead { top: calc(10px + var(--safe-top)); left: calc(12px + var(--safe-left)); right: calc(12px + var(--safe-right)); }
  .touchpad { display: grid; }
  .brand { gap: 6px; }
  .brand-name { display: none; }
  .brand-seal { font-size: 23px; }
  .wordmark { font-size: 13px; letter-spacing: .14em; }
  .header-tools { gap: 3px; }
  .fullscreen-button { justify-content: center; width: 44px; padding: 0; }
  .fullscreen-button .fullscreen-icon { font-size: 23px; }
  .fullscreen-label { display: none; }
  #quality { width: 44px; padding: 4px; font-size: 0; }
  #quality span { padding: 0; font-size: 10px; }
  .menu-screen {
    padding: calc(89px + var(--safe-top)) calc(15px + var(--safe-right)) calc(22px + var(--safe-bottom)) calc(15px + var(--safe-left));
  }
  .player-status { top: calc(78px + var(--safe-top)); left: calc(12px + var(--safe-left)); width: clamp(165px, 45vw, 195px); padding: 10px; }
  .wave-status { top: calc(81px + var(--safe-top)); right: calc(12px + var(--safe-right)); max-width: 43vw; }
  .wave-status h2 { font-size: 11px; white-space: nowrap; }
  .wave-status .eyebrow { font-size: 8px; letter-spacing: .1em; }
  .run-status { top: calc(141px + var(--safe-top)); right: calc(12px + var(--safe-right)); }
  .boss-status { top: calc(185px + var(--safe-top)); }
  .combat-dock {
    bottom: calc(12px + var(--safe-bottom));
    left: calc(12px + var(--safe-left)); right: calc(12px + var(--safe-right));
    transform: none; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 6px;
  }
  .equipped-cards { gap: 6px; min-width: 0; }
  .skill-card { flex: 1; width: 0; height: 106px; }
  .action-skill { width: 44px; height: 92px; padding: 7px 2px; font-size: 8px; }
  .action-skill kbd { font-size: 8px; padding: 2px; }
  .action-skill small { font-size: 7px; }
  .skill-label b { font-size: 10px; }
  .skill-label small { font-size: 8px; }
  .notice { bottom: calc(258px + var(--safe-bottom)); }
  body[data-phase=menu] .notice { bottom: calc(24px + var(--safe-bottom)); }
  .overlay-screen { padding: calc(22px + var(--safe-top)) calc(14px + var(--safe-right)) calc(22px + var(--safe-bottom)) calc(14px + var(--safe-left)); }
}
@media (max-width: 380px) {
  .masthead .wordmark { font-size: 11px; letter-spacing: .08em; }
  .masthead .brand-seal { display: none; }
  .header-tools { gap: 2px; }
  .card-gallery { gap: 10px; }
  .card-copy { padding-inline: 6px; }
  .card-name { font-size: 15px; }
  .card-description { font-size: 9px; }
  .result-stats { grid-template-columns: repeat(2, 1fr); gap: 20px 10px; }
  .controls-list > div { font-size: 10px; }
  .controls-list kbd { font-size: 8px; min-width: 16px; padding-inline: 2px; }
}
@media (max-width: 480px) and (orientation: portrait) {
  .reward-options { grid-template-columns: 1fr; gap: 10px; }
  .reward-card { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 5px 15px; padding: 15px 17px; text-align: left; align-items: center; }
  .reward-icon { grid-row: 1 / 4; margin: 0; }
  .reward-card p { grid-column: 2; margin: 0; min-height: 0; font-size: 11px; }
  .reward-card small { grid-column: 2; }
}
/* Landscape places movement and spells under the player's left and right thumbs. */
@media (orientation: landscape) and (max-height: 600px) {
  .masthead { top: calc(7px + var(--safe-top)); left: calc(15px + var(--safe-left)); right: calc(15px + var(--safe-right)); }
  .brand-name { display: none; }
  .brand-seal { font-size: 24px; }
  .wordmark { font-size: 14px; }
  .utility { min-width: 44px; min-height: 44px; }
  .icon-button { width: 44px; height: 44px; }
  .fullscreen-button { width: 44px; justify-content: center; padding: 0; }
  .fullscreen-label { display: none; }
  #quality { width: 44px; padding: 4px; font-size: 0; }
  #quality span { padding: 0; font-size: 10px; }
  .menu-screen { padding-top: calc(78px + var(--safe-top)); }
  .menu-intro { margin-bottom: 20px; }
  .menu-intro h1 { font-size: 24px; }
  .card-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 760px; }
  .card-art { aspect-ratio: 1.6; }
  .card-description { display: block; min-height: 3.4em; }
  .player-status { top: calc(64px + var(--safe-top)); left: calc(15px + var(--safe-left)); width: 198px; padding: 9px 12px; }
  .player-heading { margin-bottom: 7px; font-size: 10px; }
  .vital { margin-top: 6px; }
  .blessing-summary { max-height: 36px; overflow: auto; }
  .blessing-token { margin-top: 7px; font-size: 8px; }
  .wave-status { top: calc(13px + var(--safe-top)); left: 50%; right: auto; transform: translateX(-50%); text-align: center; }
  .wave-status h2 { font-size: 13px; }
  .wave-status .eyebrow { font-size: 8px; margin-bottom: 5px; }
  .wave-status p { font-size: 9px; margin-top: 5px; }
  .run-status { top: calc(66px + var(--safe-top)); right: calc(15px + var(--safe-right)); padding: 7px 10px; font-size: 9px; }
  .boss-status { top: calc(82px + var(--safe-top)); width: min(260px, 32vw); }
  .control-hint { display: none; }
  .touchpad { bottom: calc(15px + var(--safe-bottom)); left: calc(18px + var(--safe-left)); }
  .combat-dock {
    left: auto; right: calc(15px + var(--safe-right)); bottom: calc(15px + var(--safe-bottom)); transform: none;
    display: flex; gap: 7px;
  }
  .equipped-cards { gap: 6px; }
  .skill-card { flex: none; width: 66px; height: 95px; }
  .skill-label { left: 5px; bottom: 7px; }
  .skill-label b { font-size: 9px; letter-spacing: 0; }
  .skill-label small { font-size: 8px; }
  .skill-cost { top: 7px; right: 5px; font-size: 8px; }
  .skill-key { top: 5px; left: 5px; min-width: 18px; font-size: 9px; }
  .action-skill { width: 49px; min-height: 86px; height: 86px; font-size: 9px; padding: 5px 2px; gap: 3px; }
  .action-skill small { font-size: 7px; }
  .action-symbol { font-size: 23px; }
  .nova-orbit { width: 28px; height: 28px; font-size: 16px; }
  .notice { bottom: calc(124px + var(--safe-bottom)); font-size: 11px; }
  .overlay-screen { align-items: start; padding-top: calc(18px + var(--safe-top)); padding-bottom: calc(18px + var(--safe-bottom)); }
  .reward-panel, .result-panel, .pause-panel { margin-block: auto; }
  .reward-panel { padding: 22px 28px; }
  .reward-options { margin-top: 20px; }
  .reward-card { padding: 17px 12px; }
  .reward-icon { width: 44px; height: 44px; font-size: 23px; margin-bottom: 13px; }
  .reward-card p { min-height: 3.6em; }
  .reward-note { margin-top: 18px; }
}

/* Pointer press, card selection, and confirmed spell release each have a distinct response. */
@media (pointer: coarse), (max-width: 700px) {
  .touchpad.joystick-ready {
    display: block; width: 126px; height: 126px; border-radius: 50%;
    border: 1px solid #d8c0f52e; background: radial-gradient(circle, #5e416331 15%, #17112685 64%, #33224040);
    box-shadow: inset 0 0 22px #bb8dff12, 0 8px 22px #0003;
    touch-action: none; -webkit-tap-highlight-color: transparent;
  }
  .joystick-ready .joystick-ring {
    display: block; position: absolute; inset: 14%; border: 1px solid #d6baf03d;
    border-radius: 50%; pointer-events: none; transition: border-color .16s, box-shadow .16s;
  }
  .joystick-ring::before, .joystick-ring::after {
    content: ''; position: absolute; inset: -4px 50%; width: 1px;
    background: linear-gradient(#dbc1f39c 7%, transparent 7% 93%, #dbc1f39c 93%);
  }
  .joystick-ring::after { transform: rotate(90deg); }
  .joystick-ready .joystick-knob {
    display: grid; place-items: center; position: absolute; top: calc(50% - 25px); left: calc(50% - 25px);
    width: 50px; height: 50px; border-radius: 50%; color: #f7e7c9; font-size: 24px;
    border: 1px solid #ead2ad8a; background: radial-gradient(circle at 35% 25%, #65506be8, #251d39ef 74%);
    box-shadow: 0 5px 12px #0006, inset 0 1px 6px #f0d5ff33;
    pointer-events: none; transition: transform .15s var(--ease-out), box-shadow .15s;
  }
  .joystick-ready .joystick-hint {
    display: block; position: absolute; width: 100%; top: calc(100% + 7px); text-align: center;
    color: #d2c3df; font-size: 9px; letter-spacing: .2em; opacity: .8; pointer-events: none;
  }
  .joystick-ready.steering .joystick-knob { transition: box-shadow .15s; box-shadow: 0 5px 12px #0006, 0 0 14px #c8a1ff40, inset 0 1px 6px #f0d5ff55; }
  .joystick-ready.steering .joystick-ring { border-color: #e4c7ff8a; box-shadow: 0 0 18px #c59cff1a; }
  .joystick-ready [data-move] { position: absolute; width: 1px; height: 1px; min-width: 0; min-height: 0; padding: 0; overflow: hidden; clip-path: inset(50%); }
  .joystick-ready [data-move]:focus-visible { clip-path: none; width: 44px; height: 44px; z-index: 2; }
  .joystick-ready [data-move="KeyW"] { left: 41px; top: -5px; }
  .joystick-ready [data-move="KeyA"] { left: -5px; top: 41px; }
  .joystick-ready [data-move="KeyS"] { left: 41px; bottom: -5px; }
  .joystick-ready [data-move="KeyD"] { right: -5px; top: 41px; }
}
@media (orientation: landscape) and (max-height: 600px) {
  .touchpad.joystick-ready { bottom: calc(24px + var(--safe-bottom)); }
}
@media (max-width: 700px) and (orientation: portrait) {
  .touchpad.joystick-ready { bottom: calc(176px + var(--safe-bottom)); }
}
@media (pointer: coarse) {
  .combat-card-hint kbd, .action-skill kbd { display: none; }
  .combat-card-hint { justify-content: flex-end; }
  .action-skill { font-size: 9px; }
  .action-skill small { font-size: 9px; line-height: 1.3; }
}
@media (prefers-reduced-motion: reduce) {
  .joystick-ready .joystick-knob, .joystick-ready .joystick-ring { transition: none; }
}

/* Pointer press, card selection, and confirmed spell release each have a distinct response. */
.primary-button, .utility, .reward-card, .action-skill, .touchpad button {
  transition: transform 120ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out, filter 180ms ease-out;
}
.spirit-card:active:not(:disabled) {
  transform: translateY(1px) scale(.965);
  filter: brightness(1.12);
  transition-duration: 80ms;
}
.skill-card:active:not(:disabled), .reward-card:active:not(:disabled) {
  transform: translateY(2px) scale(.95);
  transition-duration: 70ms;
}
.primary-button:active:not(:disabled), .action-skill:active:not(:disabled), .utility:active:not(:disabled) {
  transform: translateY(2px) scale(.96);
  filter: brightness(1.18);
}
.touchpad button:active { transform: scale(.92); box-shadow: inset 0 0 16px #e5c4ff3d; }
.spirit-card.card-selected { animation: card-contract 520ms cubic-bezier(.2,.7,.3,1); }
.spirit-card.card-selected .selection-mark { animation: seal-contract 460ms ease-out; }
@keyframes card-contract {
  0% { transform: translateY(2px) scale(.96); }
  38% { transform: translateY(-9px) scale(1.02); box-shadow: 0 0 0 2px var(--element), 0 0 46px color-mix(in srgb, var(--element) 39%, transparent); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes seal-contract {
  0% { transform: scale(.55); }
  50% { transform: scale(1.22); }
  100% { transform: scale(1); }
}
.skill-card.cast-flash, .action-skill.cast-flash {
  position: relative;
  border-color: #fff1cf;
  box-shadow: 0 0 0 1px #fff0c177, 0 0 28px color-mix(in srgb, var(--element, #c7adff) 65%, transparent);
  animation: spell-release 520ms cubic-bezier(.18,.7,.3,1);
}
.skill-card.cast-flash::before, .action-skill.cast-flash::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 8;
  background: linear-gradient(115deg, transparent 20%, #fffceba6 47%, transparent 72%);
  opacity: 0;
  animation: spell-sheen 430ms ease-out;
}
@keyframes spell-release {
  0% { transform: translateY(1px) scale(.95); filter: brightness(1.45); }
  24% { transform: translateY(-10px) scale(1.045); filter: brightness(1.23); }
  100% { transform: translateY(0) scale(1); filter: brightness(1); }
}
@keyframes spell-sheen {
  0% { opacity: .8; transform: translateX(-35%); }
  100% { opacity: 0; transform: translateX(35%); }
}
.notice.notice-enter { animation: notice-arrive 240ms ease-out; }
@keyframes notice-arrive {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@media (prefers-reduced-motion: no-preference) {
  .overlay-screen:not([hidden]) > :is(.reward-panel, .pause-panel, .result-panel) {
    animation: overlay-arrive 230ms var(--ease-out);
  }
}
@keyframes overlay-arrive { from { opacity: 0; translate: 0 8px; } }
@media (prefers-reduced-motion: reduce) {
  .spirit-card:active:not(:disabled), .skill-card:active:not(:disabled),
  .reward-card:active:not(:disabled), .primary-button:active:not(:disabled),
  .action-skill:active:not(:disabled), .utility:active:not(:disabled), .touchpad button:active {
    transform: none;
  }
}



