@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700;900&family=Noto+Sans+TC:wght@400;700;900&display=swap");

:root { --bg: #0d0d24; --bg2: #14142e; --bg3: #1e1e3e; --panel: #1b2750; --border: #2a2a4a; --accent: #4fc3f7; --accent2: #7c4dff; --gold: #ffd54f; --danger: #ef5350; --success: #66bb6a; --curse: #7c4dff; --txt: #e8eaf6; --txt2: #9fa8da; --txt3: #5c6bc0; --shadow-blue: 0 0 20px rgba(79,195,247,0.4); --shadow-purple: 0 0 20px rgba(124,77,255,0.5); --shadow-gold: 0 0 20px rgba(255,213,79,0.5); }

* { box-sizing: border-box; margin: 0px; padding: 0px; }

html { touch-action: manipulation; }

body { background: var(--bg); color: var(--txt); font-family: "Noto Sans TC", "Noto Sans JP", sans-serif; min-height: 100vh; overflow-x: hidden; user-select: none; touch-action: manipulation; }

body.battle-mode { overflow: hidden; }

#particles { position: fixed; inset: 0px; pointer-events: none; z-index: 0; overflow: hidden; }

.particle { position: absolute; border-radius: 50%; animation: auto linear 0s infinite normal none running float-up; opacity: 0; }

@keyframes float-up { 
  0% { opacity: 0; transform: translateY(0px) scale(1); }
  10% { opacity: 0.6; }
  90% { opacity: 0.2; }
  100% { opacity: 0; transform: translateY(-100vh) scale(0.3); }
}

.screen { display: none; position: relative; z-index: 1; }

.screen:not(.active) { display: none !important; }

.screen.active { display: flex; flex-direction: column; min-height: 100vh; }

#screen-title { align-items: center; justify-content: center; text-align: center; padding: 2rem; background: radial-gradient(ellipse at center, #1a1a3e 0%, var(--bg) 70%); }

.title-logo { position: relative; margin-bottom: 2rem; }

.title-logo .kanji-bg { font-size: clamp(80px, 20vw, 160px); font-weight: 900; color: transparent; -webkit-text-stroke: 1px rgba(124, 77, 255, 0.3); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); white-space: nowrap; animation: 3s ease-in-out 0s infinite normal none running pulse-stroke; }

@keyframes pulse-stroke { 
  0%, 100% { -webkit-text-stroke: 1px rgba(124, 77, 255, 0.2); }
  50% { -webkit-text-stroke: 1px rgba(79, 195, 247, 0.5); }
}

.title-main { font-size: clamp(36px, 10vw, 72px); font-weight: 900; letter-spacing: 0.1em; position: relative; z-index: 1; background-image: ; background-position-x: ; background-position-y: ; background-size: ; background-repeat: ; background-attachment: ; background-origin: ; background-color: ; background-clip: text; -webkit-text-fill-color: transparent; text-shadow: none; animation: 2s ease-in-out 0s infinite normal none running title-glow; padding: 1rem 0px; }

@keyframes title-glow { 
  0%, 100% { filter: drop-shadow(rgba(79, 195, 247, 0.5) 0px 0px 10px); }
  50% { filter: drop-shadow(rgba(124, 77, 255, 0.8) 0px 0px 25px); }
}

.title-sub { font-size: clamp(13px, 3vw, 18px); color: var(--txt2); letter-spacing: 0.2em; margin-bottom: 3rem; }

.title-char-row { display: flex; gap: 1.5rem; justify-content: center; margin-bottom: 3rem; flex-wrap: wrap; }

.title-char { width: 80px; height: 80px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 40px; position: relative; animation: 3s ease-in-out 0s infinite normal none running char-bob; cursor: pointer; transition: transform 0.2s; }

.title-char:hover { transform: scale(1.15); }

.title-char:nth-child(1) { animation-delay: 0s; background: radial-gradient(circle, rgb(26, 26, 62), rgb(10, 10, 26)); border-color: var(--accent2); box-shadow: var(--shadow-purple); }

.title-char:nth-child(2) { animation-delay: 0.3s; background: radial-gradient(circle, rgb(26, 42, 26), rgb(10, 20, 10)); border-color: var(--success); box-shadow: rgba(102, 187, 106, 0.4) 0px 0px 20px; }

.title-char:nth-child(3) { animation-delay: 0.6s; background: radial-gradient(circle, rgb(42, 26, 26), rgb(20, 10, 10)); border-color: var(--danger); box-shadow: rgba(239, 83, 80, 0.4) 0px 0px 20px; }

@keyframes char-bob { 
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

.btn-start { background: linear-gradient(135deg, var(--accent2), #5e35b1); border-width: medium; border-style: none; border-color: currentcolor; border-image: initial; border-radius: 50px; color: rgb(255, 255, 255); font-size: 20px; font-weight: 700; padding: 16px 48px; cursor: pointer; letter-spacing: 0.1em; box-shadow: var(--shadow-purple), 0 4px 15px rgba(0,0,0,0.5); transition: 0.2s; position: relative; overflow: hidden; }

.btn-start::before { content: ""; position: absolute; inset: 0px; background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent); }

.btn-start:hover { transform: translateY(-3px) scale(1.05); box-shadow: rgba(124, 77, 255, 0.7) 0px 0px 40px, rgba(0, 0, 0, 0.5) 0px 8px 20px; }

.btn-start:active { transform: scale(0.97); }

.title-kana-strip { display: flex; gap: 12px; justify-content: center; margin-top: 2.5rem; flex-wrap: wrap; opacity: 0.4; }

.title-kana-strip span { font-size: 18px; color: var(--accent); animation: 4s ease-in-out 0s infinite normal none running kana-fade; }

.title-kana-strip span:nth-child(2n+1) { animation-delay: 0.5s; color: var(--accent2); }

@keyframes kana-fade { 
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

#screen-stage { padding: 1.5rem; }

.screen-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }

.screen-header .back-btn { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--txt2); padding: 8px 14px; cursor: pointer; font-size: 14px; transition: 0.2s; }

.screen-header .back-btn:hover { border-color: var(--accent); color: var(--accent); }

.screen-header h2 { font-size: 20px; font-weight: 700; color: var(--txt); }

.stage-summary {
  display: flex;
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  color: var(--txt2);
  font-size: 12px;
}

.stage-summary span {
  white-space: nowrap;
}

.stage-summary strong {
  color: #fff;
}

.theme-toggle-btn {
  border: 1px solid rgba(255, 213, 79, 0.45);
  border-radius: 8px;
  background: rgba(255, 213, 79, 0.1);
  color: var(--gold);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}

.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

.stage-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 1.2rem 1rem; text-align: center; cursor: pointer; transition: 0.25s; position: relative; overflow: hidden; scroll-margin-block: 20vh; }

.stage-card.unlocked:hover { border-color: var(--accent2); box-shadow: var(--shadow-purple); transform: translateY(-4px); }

.stage-card.locked { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.5); }

.stage-card.boss-card { border-color: var(--danger); background: linear-gradient(135deg, #2a0a0a, var(--panel)); }

.stage-card.boss-card:hover { box-shadow: rgba(239, 83, 80, 0.5) 0px 0px 25px; transform: translateY(-4px); }

.stage-card .stage-emoji { font-size: 36px; margin-bottom: 8px; }

.stage-card .stage-name { font-size: 15px; font-weight: 700; color: var(--txt); }

.stage-card .stage-desc { font-size: 12px; color: var(--txt2); margin-top: 4px; }

.stage-card .stage-row-label { display: inline-block; margin-top: 8px; font-size: 11px; padding: 2px 10px; border-radius: 20px; background: var(--bg3); color: var(--txt3); }

.stage-card.boss-card .stage-row-label { background: rgba(239, 83, 80, 0.2); color: rgb(239, 154, 154); }

.stage-card .lock-icon { font-size: 24px; margin-top: 6px; opacity: 0.5; }

.star-row { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }

.star { font-size: 14px; }

.star.lit { filter: none; }

.star.dim { opacity: 0.25; }

#screen-battle { padding: 0px; background: radial-gradient(60% 50% at 18% 60%, rgba(40, 90, 200, 0.3) 0%, transparent 60%), radial-gradient(60% 50% at 82% 60%, rgba(220, 70, 40, 0.3) 0%, transparent 60%), radial-gradient(at 50% 25%, rgb(26, 31, 72) 0%, rgb(17, 18, 46) 55%, rgb(11, 11, 30) 100%); height: 100dvh; flex-direction: column; overflow: hidden; }

.hp-bar-outer { height: 10px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }

.hp-bar-inner { height: 100%; border-radius: 5px; transition: width 0.4s; }

.hp-bar-inner.hero { background: linear-gradient(90deg, rgb(67, 160, 71), rgb(102, 187, 106)); }

.hp-bar-inner.enemy { background: linear-gradient(90deg, rgb(198, 40, 40), rgb(239, 83, 80)); }

.hp-bar-inner.low { background: linear-gradient(90deg, rgb(230, 81, 0), rgb(255, 112, 67)); animation: 0.8s ease-in-out 0s infinite normal none running hp-pulse; }

@keyframes hp-pulse { 
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.enemy-name-tag { margin-top: 8px; font-size: 13px; color: var(--danger); font-weight: 700; text-shadow: rgba(239, 83, 80, 0.6) 0px 0px 10px; }

.hero-name-tag { margin-top: 8px; font-size: 13px; color: var(--accent); font-weight: 700; text-shadow: rgba(79, 195, 247, 0.6) 0px 0px 10px; }

.vs-text { font-size: 24px; font-weight: 900; color: var(--txt3); margin: 0px 24px; text-shadow: rgba(92, 107, 192, 0.5) 0px 0px 10px; }

@keyframes slash-anim { 
  0% { opacity: 0; transform: translate(-18px, -10px) scale(0.72) skewX(-8deg); }
  22% { opacity: 1; transform: translate(4px, 2px) scale(1.06) skewX(0deg); }
  58% { opacity: 0.95; transform: translate(9px, 5px) scale(1.02); }
  100% { opacity: 0; transform: translate(28px, 16px) scale(1.16); }
}

@keyframes combo-pop { 
  0% { opacity: 0; transform: translateX(-50%) scale(0.5) translateY(0px); }
  20% { opacity: 1; transform: translateX(-50%) scale(1.3) translateY(-10px); }
  60% { opacity: 1; transform: translateX(-50%) scale(1) translateY(-20px); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.9) translateY(-40px); }
}

.combo-num { font-size: 32px; font-weight: 900; color: var(--gold); text-shadow: var(--shadow-gold); }

.combo-txt { font-size: 14px; font-weight: 700; color: var(--gold); }

.dmg-float { position: absolute; z-index: 9; font-size: clamp(34px, 6vw, 52px); font-weight: 900; pointer-events: none; white-space: nowrap; animation: 1s ease 0s 1 normal forwards running dmg-rise; text-shadow: rgba(0, 0, 0, 0.9) 0px 2px 6px, currentcolor 0px 0px 18px; }

@keyframes dmg-rise { 
  0% { opacity: 1; transform: translate(-50%, 0px) scale(0.8); }
  25% { opacity: 1; transform: translate(-50%, -8px) scale(1.25); }
  60% { opacity: 1; transform: translate(-50%, -44px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -78px) scale(0.85); }
}

.choices-section { padding: 8px 16px 12px; }

.choices-label { font-size: 11px; color: var(--txt3); margin-bottom: 8px; text-align: center; letter-spacing: 0.1em; }

.choices-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

@media (max-width: 480px) {
  .choices-grid { grid-template-columns: repeat(2, 1fr); }
}

.choice-btn { background: var(--panel); border: 2px solid var(--border); border-radius: 14px; padding: 14px 8px; font-size: 28px; text-align: center; cursor: pointer; transition: 0.15s; position: relative; overflow: hidden; color: var(--txt); font-family: "Noto Sans JP", sans-serif; }

.choice-btn::before { content: ""; position: absolute; inset: 0px; background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent); }

.choice-btn:hover:not(:disabled) { border-color: var(--accent2); box-shadow: var(--shadow-purple); transform: translateY(-3px) scale(1.05); background: rgb(30, 30, 64); }

.choice-btn:active:not(:disabled) { transform: scale(0.95); }

.choice-btn.correct { border-color: var(--success); background: rgba(102, 187, 106, 0.15); box-shadow: rgba(102, 187, 106, 0.4) 0px 0px 20px; animation: 0.4s ease 0s 1 normal none running correct-flash; }

@keyframes correct-flash { 
  0%, 100% { background: rgba(102, 187, 106, 0.15); }
  50% { background: rgba(102, 187, 106, 0.35); }
}

.choice-btn.wrong { border-color: var(--danger); background: rgba(239, 83, 80, 0.15); box-shadow: rgba(239, 83, 80, 0.4) 0px 0px 20px; animation: 0.4s ease 0s 1 normal none running wrong-flash; }

@keyframes wrong-flash { 
  0%, 100% { background: rgba(239, 83, 80, 0.15); }
  50% { background: rgba(239, 83, 80, 0.3); }
}

.choice-btn:disabled { cursor: not-allowed; }

.choice-romaji { display: block; font-size: 11px; color: var(--txt3); margin-top: 4px; font-family: "Noto Sans TC", sans-serif; opacity: 0; transition: opacity 0.3s; }

.revealed .choice-romaji { opacity: 1; }

.feedback-bar { margin: 0px 16px 8px; min-height: 32px; display: flex; align-items: center; justify-content: center; }

.feedback-msg { font-size: 14px; font-weight: 700; padding: 6px 20px; border-radius: 20px; opacity: 0; transition: opacity 0.2s; }

.feedback-msg.show { opacity: 1; }

.feedback-msg.ok { color: var(--success); background: rgba(102, 187, 106, 0.1); border: 1px solid rgba(102, 187, 106, 0.3); }

.feedback-msg.ng { color: var(--danger); background: rgba(239, 83, 80, 0.1); border: 1px solid rgba(239, 83, 80, 0.3); }

.ult-btn:active.ready { transform: scale(0.95); }

#draw-overlay { display: none; position: fixed; inset: 0px; z-index: 100; background: rgba(0, 0, 0, 0.92); flex-direction: column; align-items: center; justify-content: center; gap: 0px; padding: 12px 16px; }

#draw-overlay.show { display: flex; animation: 0.35s ease 0s 1 normal none running ult-in; }

@keyframes ult-in { 
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.draw-header { text-align: center; margin-bottom: 8px; padding: 0px 1rem; flex-shrink: 0; }

.draw-header .draw-phase { font-size: 11px; letter-spacing: 0.2em; color: var(--accent2); font-weight: 700; margin-bottom: 2px; }

.draw-header .draw-instruct { font-size: clamp(13px, 3.5vw, 17px); font-weight: 700; color: var(--txt); margin-bottom: 2px; }

.draw-header .draw-target { font-size: clamp(36px, 10vw, 56px); font-weight: 900; color: transparent; -webkit-text-stroke: 2px var(--accent); line-height: 1; filter: drop-shadow(rgba(79, 195, 247, 0.7) 0px 0px 18px); animation: 1.2s ease-in-out 0s infinite alternate none running target-pulse; }

@keyframes target-pulse { 
  0% { filter: drop-shadow(rgba(79, 195, 247, 0.5) 0px 0px 10px); -webkit-text-stroke: 2px rgba(79, 195, 247, 0.7); }
  100% { filter: drop-shadow(rgba(124, 77, 255, 0.9) 0px 0px 30px); -webkit-text-stroke: 2px rgb(200, 150, 255); }
}

.draw-header .draw-romaji-hint { font-size: 12px; color: var(--txt2); margin-top: 1px; letter-spacing: 0.1em; }

.draw-canvas-wrap { position: relative; border-radius: 20px; overflow: hidden; box-shadow: rgba(124, 77, 255, 0.5) 0px 0px 40px, rgba(79, 195, 247, 0.2) 0px 0px 80px; border: 2px solid rgba(124, 77, 255, 0.5); width: min(72vw, 72vh, 420px); height: min(72vw, 72vh, 420px); flex-shrink: 0; }

#draw-canvas { display: block; width: 100%; height: 100%; background: rgb(7, 7, 26); touch-action: none; cursor: crosshair; }

.draw-ghost { position: absolute; inset: 0px; display: flex; align-items: center; justify-content: center; font-size: min(52vw, 52vh, 300px); font-weight: 900; color: rgba(255, 255, 255, 0.05); pointer-events: none; font-family: "Noto Sans JP", sans-serif; user-select: none; touch-action: manipulation; }

.stroke-dots { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }

.stroke-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); transition: background 0.2s, box-shadow 0.2s; }

.stroke-dot.done { background: var(--accent2); box-shadow: rgba(124, 77, 255, 0.8) 0px 0px 8px; }

.stroke-dot.current { background: var(--accent); box-shadow: rgb(79, 195, 247) 0px 0px 10px; animation: 0.7s ease-in-out 0s infinite normal none running dot-ping; }

@keyframes dot-ping { 
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.4); }
}

.draw-actions { display: flex; gap: 10px; margin-top: 12px; }

.draw-clear-btn { background: transparent; border: 1px solid var(--border); border-radius: 30px; color: var(--txt2); padding: 8px 20px; cursor: pointer; font-size: 13px; transition: 0.2s; }

.draw-clear-btn:hover { border-color: var(--danger); color: var(--danger); }

.draw-cancel-btn { background: transparent; border: 1px solid var(--border); border-radius: 30px; color: var(--txt3); padding: 8px 20px; cursor: pointer; font-size: 13px; transition: 0.2s; }

.draw-cancel-btn:hover { border-color: var(--txt2); color: var(--txt2); }

.draw-result-msg { min-height: 28px; text-align: center; font-size: 15px; font-weight: 700; letter-spacing: 0.05em; margin-top: 6px; transition: opacity 0.2s; }

.draw-result-msg.ok { color: var(--success); }

.draw-result-msg.ng { color: var(--danger); }

.draw-result-msg.thinking { color: var(--accent2); animation: 0.6s ease-in-out 0s infinite normal none running think-pulse; }

@keyframes think-pulse { 
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#ult-video-overlay { display: none; position: fixed; inset: 0px; z-index: 130; overflow: hidden; background: rgb(0, 0, 0); }

#ult-video-overlay.show { display: block; }

#ult-video { width: 100%; height: 100%; object-fit: cover; object-position: center; background: rgb(0, 0, 0); }

#ult-overlay { display: none; position: fixed; inset: 0px; z-index: 110; overflow: hidden; align-items: center; justify-content: center; background: rgba(4, 4, 18, 0.68); perspective: 1000px; pointer-events: none; }

#ult-overlay.show { display: flex; animation: 0.32s cubic-bezier(0.16, 1, 0.3, 1) 0s 1 normal both running ult-overlay-in; }

#ult-overlay.closing { animation: 0.35s ease-in 0s 1 normal forwards running ult-overlay-out; }

@keyframes ult-overlay-in { 
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes ult-overlay-out { 
  100% { opacity: 0; }
}

.ult-vignette { position: absolute; inset: -10%; background: radial-gradient(circle at 72% 50%, transparent 0px, transparent 14%, rgba(15, 7, 42, 0.18) 35%, rgba(3, 3, 14, 0.88) 76%), repeating-linear-gradient(112deg, transparent 0px, transparent 42px, rgba(79, 195, 247, 0.024) 43px, rgba(79, 195, 247, 0.024) 44px); animation: 4.3s ease 0s 1 normal both running ult-vignette-pulse; }

@keyframes ult-vignette-pulse { 
  0% { opacity: 0; }
  12% { opacity: 1; }
  42% { filter: brightness(0.78); }
  55% { filter: brightness(1.8); }
  100% { opacity: 0.55; filter: brightness(0.8); }
}

.ult-cinematic { position: absolute; left: 72%; top: 50%; width: min(72vmin, 620px); aspect-ratio: 1 / 1; transform: translate(-50%, -50%); transform-style: preserve-3d; will-change: transform, filter; }

.ult-domain-ring { position: absolute; inset: 9%; border-radius: 50%; border: 2px solid rgba(79, 195, 247, 0.82); box-shadow: rgba(79, 195, 247, 0.2) 0px 0px 34px inset, rgba(79, 195, 247, 0.5) 0px 0px 28px; opacity: 0; }

.ring-outer { border-style: dashed; animation: 4.3s cubic-bezier(0.16, 1, 0.3, 1) 0s 1 normal both running ult-ring-outer; }

.ring-inner { inset: 24%; border-color: rgba(255, 213, 79, 0.9); box-shadow: rgba(255, 213, 79, 0.22) 0px 0px 26px inset, rgba(255, 213, 79, 0.55) 0px 0px 24px; animation: 4.3s cubic-bezier(0.16, 1, 0.3, 1) 0s 1 normal both running ult-ring-inner; }

@keyframes ult-ring-outer { 
  0% { opacity: 0; transform: scale(0.08) rotate(-45deg); }
  16% { opacity: 1; transform: scale(1) rotate(0deg); }
  45% { opacity: 0.9; transform: scale(1.08) rotate(145deg); }
  58% { opacity: 1; transform: scale(1.3) rotate(190deg); }
  72% { opacity: 0.25; transform: scale(1.75) rotate(250deg); }
  100% { opacity: 0; transform: scale(0.1) rotate(320deg); }
}

@keyframes ult-ring-inner { 
  0%, 6% { opacity: 0; transform: scale(0.12) rotate(60deg); }
  22% { opacity: 1; transform: scale(1) rotate(0deg); }
  48% { opacity: 1; transform: scale(0.72) rotate(-130deg); }
  60% { opacity: 0.8; transform: scale(1.45) rotate(-190deg); }
  100% { opacity: 0; transform: scale(0.05) rotate(-260deg); }
}

.ult-domain-glyphs { position: absolute; inset: 17%; border-radius: 50%; display: flex; align-items: flex-start; justify-content: center; padding-top: 2%; color: rgba(232, 234, 246, 0.72); font: 900 clamp(13px, 2.2vw, 24px) / 1 "Noto Sans JP", sans-serif; letter-spacing: 0.42em; text-shadow: 0 0 12px var(--accent); opacity: 0; animation: 4.3s cubic-bezier(0.16, 1, 0.3, 1) 0s 1 normal both running ult-glyph-orbit; }

@keyframes ult-glyph-orbit { 
  0%, 8% { opacity: 0; transform: rotate(-40deg) scale(0.4); }
  22% { opacity: 0.9; transform: rotate(0deg) scale(1); }
  52% { opacity: 0.65; transform: rotate(160deg) scale(0.86); }
  65%, 100% { opacity: 0; transform: rotate(230deg) scale(1.35); }
}

.ult-kanji { position: absolute; inset: 0px; display: flex; align-items: center; justify-content: center; font-size: clamp(82px, 22vmin, 190px); font-weight: 900; color: transparent; -webkit-text-stroke: 2px rgba(188, 225, 255, 0.95); text-shadow: 0 0 8px #fff,0 0 22px var(--accent),0 0 54px var(--accent2); opacity: 0; animation: 4.3s cubic-bezier(0.16, 1, 0.3, 1) 0s 1 normal both running ult-kanji-sequence; }

@keyframes ult-kanji-sequence { 
  0% { opacity: 0; transform: scale(2.8) rotate(-18deg); filter: blur(16px); }
  14% { opacity: 1; transform: scale(1) rotate(0deg); filter: blur(0px); }
  33% { opacity: 0.95; transform: scale(0.82); filter: brightness(1.4); }
  48% { opacity: 0.2; transform: scale(0.32); filter: blur(3px) brightness(2.5); }
  55% { opacity: 1; transform: scale(1.25); filter: blur(0px) brightness(4); }
  61% { opacity: 0; transform: scale(3.8); filter: blur(10px); }
  100% { opacity: 0; }
}

.ult-energy-core, .ult-impact-core { position: absolute; left: 50%; top: 50%; border-radius: 50%; transform: translate(-50%, -50%) scale(0); }

.ult-energy-core { width: 18%; aspect-ratio: 1 / 1; background: rgb(255, 255, 255); box-shadow: 0 0 16px #fff,0 0 42px var(--accent),0 0 90px var(--accent2); animation: 4.3s cubic-bezier(0.16, 1, 0.3, 1) 0s 1 normal both running ult-core-charge; }

@keyframes ult-core-charge { 
  0%, 16% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(0.38); }
  47% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  52% { opacity: 1; transform: translate(-50%, -50%) scale(0.15); }
  58% { opacity: 0; transform: translate(-50%, -50%) scale(7); }
  100% { opacity: 0; }
}

.ult-beam { position: absolute; left: 50%; top: 50%; width: 150%; height: clamp(8px, 1.4vmin, 15px); transform-origin: 0px 50%; background: linear-gradient(90deg,transparent 0,#fff 12%,var(--accent) 48%,#fff 72%,transparent 100%); clip-path: polygon(0px 43%, 100% 0px, 94% 50%, 100% 100%, 0px 58%); box-shadow: 0 0 8px #fff,0 0 24px var(--accent),0 0 40px var(--accent2); opacity: 0; }

.beam-a { transform: rotate(-28deg) translateX(-72%); animation: 4.3s ease 0s 1 normal both running ult-beam-a; }

.beam-b { transform: rotate(17deg) translateX(-72%); animation: 4.3s ease 0s 1 normal both running ult-beam-b; }

.beam-c { transform: rotate(-4deg) translateX(-72%); animation: 4.3s ease 0s 1 normal both running ult-beam-c; }

@keyframes ult-beam-a { 
  0%, 29% { opacity: 0; scale: 0.2 1; }
  32% { opacity: 1; scale: 1; }
  38% { opacity: 0; scale: 1.1 0.2; }
  100% { opacity: 0; }
}

@keyframes ult-beam-b { 
  0%, 36% { opacity: 0; scale: 0.2 1; }
  39% { opacity: 1; scale: 1; }
  45% { opacity: 0; scale: 1.1 0.15; }
  100% { opacity: 0; }
}

@keyframes ult-beam-c { 
  0%, 43% { opacity: 0; scale: 0.2 1; }
  46% { opacity: 1; scale: 1; }
  54% { opacity: 0; scale: 1.15 0.1; }
  100% { opacity: 0; }
}

.ult-impact-core { width: 22%; aspect-ratio: 1 / 1; background: radial-gradient(circle, rgb(255, 255, 255) 0px, rgb(255, 255, 255) 14%, rgb(255, 213, 79) 28%, rgb(255, 112, 67) 52%, rgba(124, 77, 255, 0.72) 70%, transparent 72%); box-shadow: 0 0 30px #fff,0 0 70px #ff7043,0 0 130px var(--accent2); animation: 4.3s cubic-bezier(0.16, 1, 0.3, 1) 0s 1 normal both running ult-impact-burst; }

@keyframes ult-impact-burst { 
  0%, 51% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
  54% { opacity: 1; transform: translate(-50%, -50%) scale(0.35); }
  61% { opacity: 1; transform: translate(-50%, -50%) scale(2.1); }
  72% { opacity: 0.75; transform: translate(-50%, -50%) scale(3.5); }
  84%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(4.8); }
}

.ult-shockwave { position: absolute; left: 50%; top: 50%; width: 18%; aspect-ratio: 1 / 1; border: 4px solid rgba(255, 255, 255, 0.9); border-radius: 50%; transform: translate(-50%, -50%) scale(0.2); opacity: 0; }

.shockwave-a { animation: 4.3s cubic-bezier(0.16, 1, 0.3, 1) 0s 1 normal both running ult-shockwave; }

.shockwave-b { animation: 4.3s cubic-bezier(0.16, 1, 0.3, 1) 0.18s 1 normal both running ult-shockwave; }

@keyframes ult-shockwave { 
  0%, 54% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
  57% { opacity: 1; }
  76% { opacity: 0; transform: translate(-50%, -50%) scale(6); }
  100% { opacity: 0; }
}

.ult-sparks { position: absolute; inset: 0px; }

.ult-spark { --angle: 0deg; --distance: 230px; --delay: 0s; position: absolute; left: 50%; top: 50%; width: clamp(3px, 0.6vmin, 7px); height: clamp(18px, 4vmin, 42px); border-radius: 0px; background: linear-gradient(#fff,var(--gold),transparent); box-shadow: 0 0 8px #fff,0 0 14px var(--gold); opacity: 0; transform-origin: 50% 0px; animation: ult-spark-flight 1.05s var(--delay) cubic-bezier(.16,1,.3,1) both; }

@keyframes ult-spark-flight { 
  0% { opacity: 0; transform: translate(-50%,-50%) rotate(var(--angle)) translateY(0) scaleY(.2); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%,-50%) rotate(var(--angle)) translateY(calc(var(--distance) * -1)) scaleY(1.35); }
}

.ult-copy { position: absolute; left: 50%; top: 10%; width: min(92vw, 760px); transform: translateX(-50%); text-align: center; z-index: 3; }

.ult-title { font-size: clamp(22px, 6vw, 46px); font-weight: 900; background-image: ; background-position-x: ; background-position-y: ; background-size: ; background-repeat: ; background-attachment: ; background-origin: ; background-color: ; background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: 0.14em; filter: drop-shadow(rgba(79, 195, 247, 0.8) 0px 0px 20px); animation: 4.3s cubic-bezier(0.16, 1, 0.3, 1) 0s 1 normal both running ult-copy-title; }

.ult-sub { margin-top: 8px; font-size: clamp(12px, 2.4vw, 17px); color: var(--txt2); letter-spacing: 0.2em; text-shadow: rgba(124, 77, 255, 0.8) 0px 0px 12px; animation: 4.3s cubic-bezier(0.16, 1, 0.3, 1) 0s 1 normal both running ult-copy-sub; }

@keyframes ult-copy-title { 
  0% { opacity: 0; transform: translateY(-28px); filter: blur(8px); }
  14% { opacity: 1; transform: translateY(0px); filter: blur(0px) drop-shadow(rgba(79, 195, 247, 0.8) 0px 0px 20px); }
  58% { opacity: 1; transform: scale(1.04); }
  72%, 100% { opacity: 0; transform: scale(1.22); filter: blur(5px); }
}

@keyframes ult-copy-sub { 
  0%, 9% { opacity: 0; transform: translateY(12px); }
  22% { opacity: 1; transform: translateY(0px); }
  58% { opacity: 1; }
  70%, 100% { opacity: 0; }
}

#screen-battle.ult-impacting .field-enemy { animation: 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0s 1 normal none running ult-enemy-impact; }

#screen-battle.ult-impacting .enemy-img-wrap { filter: brightness(2.8) saturate(0.3) drop-shadow(rgb(255, 255, 255) 0px 0px 44px); animation: 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0s 1 normal none running ult-enemy-crush !important; }

@keyframes ult-enemy-impact { 
  0%, 100% { transform: translate(0px); }
  18% { transform: translate(-16px, 7px); }
  35% { transform: translate(13px, -8px); }
  52% { transform: translate(-10px, -4px); }
  72% { transform: translate(8px, 5px); }
}

@keyframes ult-enemy-crush { 
  0%, 100% { transform: scale(1) rotate(0deg); }
  35% { transform: scale(0.9, 1.12) rotate(-4deg); }
  62% { transform: scale(1.08, 0.88) rotate(5deg); }
}

@media (max-width: 600px) {
  .ult-cinematic { left: 50%; top: 24%; width: min(86vmin, 430px); }
  .ult-copy { top: 8%; }
}

.trail-glow { filter: drop-shadow(rgba(79, 195, 247, 0.9) 0px 0px 6px); }

#select-overlay { display: none; position: fixed; inset: 0px; z-index: 105; background: radial-gradient(at 50% 40%, rgba(74, 20, 140, 0.45) 0%, transparent 60%), rgba(5, 3, 15, 0.95); flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; }

#select-overlay.show { display: flex; animation: 0.35s ease 0s 1 normal none running ult-in; }

.sel-score { position: absolute; top: 18px; right: 22px; font-size: clamp(20px, 5vw, 30px); font-weight: 900; color: var(--gold); letter-spacing: 0.05em; text-shadow: rgba(255, 213, 79, 0.7) 0px 0px 16px; font-variant-numeric: tabular-nums; }

.sel-header { text-align: center; }

.sel-phase { font-size: clamp(13px, 3vw, 18px); letter-spacing: 0.2em; font-weight: 900; margin-bottom: 4px; background-image: ; background-position-x: ; background-position-y: ; background-size: ; background-repeat: ; background-attachment: ; background-origin: ; background-color: ; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(rgba(124, 77, 255, 0.7) 0px 0px 12px); }

.sel-instruct { font-size: clamp(13px, 2.4vw, 16px); color: var(--txt2); }

.sel-timer-wrap { width: min(86vw, 520px); height: 12px; border-radius: 6px; background: rgba(124, 77, 255, 0.12); border: 1px solid rgba(124, 77, 255, 0.4); overflow: hidden; }

.sel-timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, rgb(124, 77, 255), rgb(224, 64, 251)); box-shadow: rgba(124, 77, 255, 0.7) 0px 0px 12px; transition: width 0.1s linear; }

.sel-timer-bar.warning { background: linear-gradient(90deg, rgb(213, 0, 0), rgb(255, 23, 68)); animation: 0.35s ease-in-out 0s infinite normal none running atb-pulse; }

.sel-sequence { display: flex; gap: clamp(6px, 2vw, 14px); flex-wrap: wrap; justify-content: center; }

.sel-seq-item { min-width: clamp(46px, 12vw, 72px); padding: 8px 6px; border-radius: 12px; border: 2px solid rgba(124, 77, 255, 0.35); background: rgba(124, 77, 255, 0.08); font-size: clamp(16px, 4vw, 26px); font-weight: 900; color: var(--txt2); text-align: center; letter-spacing: 0.04em; transition: 0.2s; }

.sel-seq-item.current { border-color: var(--accent); color: var(--accent); background: rgba(79, 195, 247, 0.15); box-shadow: rgba(79, 195, 247, 0.6) 0px 0px 18px; transform: translateY(-3px) scale(1.06); }

.sel-seq-item.done { border-color: var(--success); color: var(--success); background: rgba(102, 187, 106, 0.15); text-decoration: line-through; }

.sel-seq-item.miss { border-color: var(--danger); color: var(--danger); background: rgba(239, 83, 80, 0.12); }

.sel-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(8px, 2vw, 14px); width: min(92vw, 460px); }

.sel-tile { aspect-ratio: 1 / 1; border-radius: 16px; border: 2px solid rgba(124, 77, 255, 0.4); background: linear-gradient(145deg, rgb(20, 10, 38), rgb(34, 16, 56)); color: rgb(243, 229, 245); font-family: "Noto Sans JP", sans-serif; font-size: clamp(28px, 7vw, 46px); font-weight: 900; cursor: pointer; transition: 0.15s; text-shadow: rgba(124, 77, 255, 0.6) 0px 0px 10px; display: flex; align-items: center; justify-content: center; }

.sel-tile:hover:not(:disabled) { transform: translateY(-3px) scale(1.05); border-color: rgb(224, 64, 251); box-shadow: rgba(224, 64, 251, 0.6) 0px 0px 20px; }

.sel-tile:active:not(:disabled) { transform: scale(0.94); }

.sel-tile.done { border-color: var(--success); color: var(--success); background: rgba(102, 187, 106, 0.18); cursor: default; box-shadow: rgba(102, 187, 106, 0.4) 0px 0px 18px; }

.sel-tile.miss {
  animation: 0.35s ease 0s 1 normal none running enemy-shake;
  border-color: var(--danger);
  color: #ffcdd2;
  background: rgba(239, 83, 80, 0.2);
  box-shadow: rgba(239, 83, 80, 0.55) 0px 0px 18px;
}

.sel-tile.shake { animation: 0.35s ease 0s 1 normal none running enemy-shake; border-color: var(--danger); }

.sel-result { min-height: 30px; font-size: clamp(16px, 4vw, 24px); font-weight: 900; letter-spacing: 0.06em; text-align: center; }

.sel-result.perfect { background-image: ; background-position-x: ; background-position-y: ; background-size: ; background-repeat: ; background-attachment: ; background-origin: ; background-color: ; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(rgba(255, 213, 79, 0.8) 0px 0px 14px); }

.sel-result.ok { color: var(--accent); }

.sel-result.fail { color: var(--danger); text-shadow: rgba(239, 83, 80, 0.6) 0px 0px 14px; }

#result-overlay { display: none; position: fixed; inset: 0px; z-index: 90; background: rgba(0, 0, 0, 0.8); align-items: center; justify-content: center; }

#result-overlay.show { display: flex; animation: 0.4s ease 0s 1 normal none running ult-in; }

.result-panel { background: var(--panel); border-radius: 24px; border: 1px solid var(--border); padding: 2rem 2.5rem; text-align: center; max-width: 520px; width: 90%; }

.result-icon { font-size: 64px; margin-bottom: 1rem; }

.result-title { font-size: 28px; font-weight: 900; margin-bottom: 0.5rem; }

.result-title.win { color: var(--gold); text-shadow: var(--shadow-gold); }

.result-title.lose { color: var(--danger); text-shadow: rgba(239, 83, 80, 0.5) 0px 0px 20px; }

.result-stats { color: var(--txt2); font-size: 14px; margin-bottom: 1.5rem; line-height: 2; }

.result-stats strong { color: var(--txt); }

.result-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.result-btn { border-radius: 50px; font-size: 14px; font-weight: 700; padding: 10px 24px; cursor: pointer; transition: 0.2s; border-width: medium; border-style: none; border-color: currentcolor; border-image: initial; }

.result-btn.primary { background: linear-gradient(135deg, var(--accent2), #5e35b1); color: rgb(255, 255, 255); box-shadow: var(--shadow-purple); }

.result-btn.secondary { background: var(--bg3); color: var(--txt2); border: 1px solid var(--border); }

.result-btn:hover { transform: translateY(-2px); }

.knowledge-box { background: var(--bg3); border: 1px solid var(--accent2); border-radius: 12px; padding: 12px 16px; margin-top: 1rem; text-align: left; }

.knowledge-box .k-title { font-size: 12px; color: var(--accent2); font-weight: 700; margin-bottom: 4px; }

.knowledge-box .k-txt { font-size: 13px; color: var(--txt2); line-height: 1.6; }

.star-celebration { position: fixed; inset: 0px; pointer-events: none; z-index: 80; }

.confetti-piece { position: absolute; width: 8px; height: 8px; border-radius: 2px; animation: auto linear 0s 1 normal forwards running confetti-fall; top: -20px; }

@keyframes confetti-fall { 
  0% { transform: translateY(0px) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg) scale(0.5); opacity: 0; }
}

#screen-flash { position: fixed; inset: 0px; z-index: 999; pointer-events: none; opacity: 0; }

#screen-flash.flash-blue { animation: 0.3s ease 0s 1 normal none running screen-flash-anim; background: rgba(79, 195, 247, 0.25); }

#screen-flash.flash-red { animation: 0.3s ease 0s 1 normal none running screen-flash-anim; background: rgba(239, 83, 80, 0.25); }

#screen-flash.flash-gold { animation: 0.5s ease 0s 1 normal none running screen-flash-anim; background: rgba(255, 213, 79, 0.3); }

#screen-flash.flash-purple { animation: 0.5s ease 0s 1 normal none running screen-flash-anim; background: rgba(124, 77, 255, 0.35); }

#screen-flash.flash-white { animation: 0.25s ease 0s 1 normal none running screen-flash-anim; background: rgba(255, 255, 255, 0.6); }

@keyframes screen-flash-anim { 
  0%, 100% { opacity: 0; }
  30% { opacity: 1; }
}

.battle-topbar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: rgba(0, 0, 0, 0.45); border-bottom: 1px solid var(--border); flex-shrink: 0; }

.battle-stage-name { flex: 1 1 0%; text-align: center; font-size: clamp(13px, 2.4vw, 17px); font-weight: 700; color: var(--txt); letter-spacing: 0.04em; text-shadow: rgba(124, 77, 255, 0.4) 0px 0px 12px; }

.battle-score-display { font-size: 14px; color: var(--gold); font-weight: 700; white-space: nowrap; }

.retreat-btn { background: linear-gradient(145deg, rgb(42, 14, 18), rgb(26, 10, 14)); border: 1px solid rgba(239, 83, 80, 0.55); border-radius: 10px; color: rgb(255, 138, 128); font-size: 13px; font-weight: 700; padding: 7px 14px; cursor: pointer; letter-spacing: 0.05em; white-space: nowrap; box-shadow: rgba(239, 83, 80, 0.15) 0px 0px 8px inset; transition: 0.2s; }

.retreat-btn:hover { border-color: var(--danger); color: rgb(255, 255, 255); background: linear-gradient(145deg, rgb(74, 18, 24), rgb(42, 10, 16)); box-shadow: rgba(239, 83, 80, 0.6) 0px 0px 16px, rgba(239, 83, 80, 0.3) 0px 0px 10px inset; transform: translateY(-1px); }

.retreat-btn:active { transform: scale(0.96); }

.side-status { width: min(94%, 360px); display: flex; flex-direction: column; gap: 7px; margin-top: 8px; flex-shrink: 0; z-index: 4; }

.status-row { display: flex; align-items: center; gap: 8px; }

.sb-label { font-size: 11px; font-weight: 700; white-space: nowrap; width: 48px; flex-shrink: 0; }

.sb-label.hp { color: rgb(239, 154, 154); }

.sb-label.ult { color: var(--accent2); }

.field-hero .sb-label.hp { color: rgb(165, 214, 167); }

.sb-val { font-size: 11px; color: var(--txt2); white-space: nowrap; min-width: 46px; text-align: right; }

.side-status .hp-bar-outer { flex: 1 1 0%; height: 13px; border-radius: 7px; }

.side-status .hp-bar-inner { border-radius: 7px; }

.side-status .ult-bar-outer { flex: 1 1 0%; height: 11px; border-radius: 6px; }

.side-status .ult-bar-inner { border-radius: 6px; }

.atb-row { display: flex; align-items: center; gap: 8px; }

.atb-skull { font-size: 18px; flex-shrink: 0; width: 48px; text-align: center; }

.atb-row .atb-bar-outer { flex: 1 1 0%; height: 18px; border-radius: 9px; background: rgba(239, 83, 80, 0.12); border: 1px solid rgba(255, 112, 67, 0.45); overflow: hidden; box-shadow: rgba(0, 0, 0, 0.5) 0px 0px 8px inset; }

.atb-bar-inner { height: 100%; border-radius: 9px; background: linear-gradient(90deg, rgb(255, 145, 0), rgb(255, 87, 34), rgb(229, 57, 53)) 0% 0% / 200% 100%; box-shadow: rgba(255, 87, 34, 0.6) 0px 0px 12px; transition: width 0.1s linear; animation: 1.4s linear 0s infinite normal none running atb-shimmer; }

@keyframes atb-shimmer { 
  0% { background-position: 0% 0px; }
  100% { background-position: 200% 0px; }
}

.atb-bar-inner.warning { background: linear-gradient(90deg, rgb(255, 23, 68), rgb(213, 0, 0)); animation: 0.35s ease-in-out 0s infinite normal none running atb-pulse; box-shadow: rgba(255, 23, 68, 0.9) 0px 0px 18px; }

@keyframes atb-pulse { 
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.atb-count { font-size: 14px; font-weight: 900; color: rgb(255, 138, 101); width: 48px; flex-shrink: 0; text-align: center; font-variant-numeric: tabular-nums; }

.atb-count.warning { color: rgb(255, 23, 68); animation: 0.35s ease-in-out 0s infinite normal none running atb-pulse; }

.atb-skull.warning { animation: 0.35s ease-in-out 0s infinite normal none running atb-pulse; }

.ult-bar-outer { flex: 1 1 0%; height: 7px; border-radius: 4px; background: rgba(124, 77, 255, 0.15); border: 1px solid rgba(124, 77, 255, 0.3); overflow: hidden; }

.ult-bar-inner { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width 0.5s; }

.ult-bar-inner.full { animation: 0.8s ease-in-out 0s infinite normal none running ult-ready; box-shadow: rgba(124, 77, 255, 0.8) 0px 0px 10px; }

@keyframes ult-ready { 
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.battle-field { display: flex; flex: 1 1 0%; overflow: hidden; position: relative; min-height: 0px; }

.field-hero { flex: 1 1 0%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 6px 8px 10px; background: radial-gradient(80% 60% at 50% 75%, rgba(50, 110, 230, 0.22) 0%, transparent 65%), linear-gradient(160deg, rgba(30, 70, 180, 0.28) 0%, transparent 55%); position: relative; overflow: hidden; }

.hero-img-wrap { flex: 1 1 0%; width: min(42vw, 420px); min-height: 0px; filter: drop-shadow(rgba(79, 195, 247, 0.6) 0px 0px 22px); animation: 2.5s ease-in-out 0s infinite normal none running hero-idle; }

.hero-img-wrap img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; }

.field-enemy { flex: 1 1 0%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 6px 8px 10px; background: radial-gradient(80% 60% at 50% 75%, rgba(240, 90, 50, 0.22) 0%, transparent 65%), linear-gradient(200deg, rgba(200, 50, 40, 0.28) 0%, transparent 55%); position: relative; overflow: hidden; }

.enemy-img-wrap { flex: 1 1 0%; width: min(42vw, 420px); min-height: 0px; filter: drop-shadow(rgba(239, 83, 80, 0.6) 0px 0px 22px); animation: 3s ease-in-out 0s infinite normal none running enemy-float; }

.enemy-img-wrap img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; }

.enemy-img-wrap svg { width: 100%; height: 100%; }

.enemy-img-wrap.shake { animation: 0.4s ease 0s 1 normal none running enemy-shake !important; }

.enemy-img-wrap.dying { pointer-events: none; animation: 0.75s cubic-bezier(0.55, 0.02, 0.8, 0.25) 0s 1 normal forwards running enemy-die !important; }

.enemy-img-wrap.defeated { opacity: 0; visibility: hidden; transform: scale(0.04) rotate(18deg); pointer-events: none; animation: auto ease 0s 1 normal none running none !important; }

.field-name { font-size: clamp(12px, 1.8vw, 16px); font-weight: 700; margin-top: 6px; }

.prompt-bar { display: flex; justify-content: center; padding: 8px 16px 2px; }

.prompt-bubble { position: static; transform: none; z-index: 6; background: linear-gradient(160deg, rgb(36, 52, 99), rgb(22, 31, 60)); border: 2px solid var(--accent); border-radius: 18px; padding: 6px 28px; display: inline-flex; flex-direction: row; align-items: baseline; gap: 14px; box-shadow: var(--shadow-blue), 0 6px 18px rgba(0,0,0,0.5); max-width: 96%; white-space: nowrap; }

.prompt-romaji { font-size: clamp(32px, 6vw, 56px); font-weight: 900; color: var(--accent); letter-spacing: 0.04em; line-height: 1.05; text-shadow: rgba(79, 195, 247, 0.7) 0px 0px 16px; }

.prompt-hint { margin-top: 2px; font-size: clamp(13px, 2vw, 16px); color: var(--txt2); }

.field-center { position: absolute; inset: 0px; pointer-events: none; display: flex; align-items: center; justify-content: center; z-index: 5; }

.vs-text { font-size: clamp(20px, 4vw, 40px); font-weight: 900; color: var(--txt3); text-shadow: rgba(92, 107, 192, 0.6) 0px 0px 20px; position: absolute; }

#slash-effect { position: absolute; inset: 0px; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; }

#slash-effect.show { animation: 0.5s ease 0s 1 normal forwards running slash-anim; }

#combo-display { position: absolute; top: 15%; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; }

#combo-display.show { animation: 1.2s ease 0s 1 normal forwards running combo-pop; }

.battle-bottom { flex-shrink: 0; background: rgba(0, 0, 0, 0.6); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0px); }

.feedback-bar { min-height: 28px; display: flex; align-items: center; justify-content: center; padding: 4px 16px; }

.feedback-msg { font-size: clamp(12px, 2vw, 15px); font-weight: 700; padding: 4px 20px; border-radius: 20px; opacity: 0; transition: opacity 0.2s; }

.feedback-msg.show { opacity: 1; }

.feedback-msg.ok { color: var(--success); background: rgba(102, 187, 106, 0.1); border: 1px solid rgba(102, 187, 106, 0.3); }

.feedback-msg.ng { color: var(--danger); background: rgba(239, 83, 80, 0.1); border: 1px solid rgba(239, 83, 80, 0.3); }

.choices-section { padding: 6px 16px 8px; }

.choices-label { font-size: 11px; color: var(--txt3); margin-bottom: 6px; text-align: center; letter-spacing: 0.1em; }

.choices-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(6px, 1.5vw, 14px); }

@media (max-width: 480px) {
  .choices-grid { grid-template-columns: repeat(2, 1fr); }
}

@property --bd-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

.choice-btn { position: relative; overflow: hidden; isolation: isolate; background: linear-gradient(145deg, rgb(14, 14, 40), rgb(26, 26, 58)); border: 2px solid transparent; border-radius: 16px; padding: clamp(10px, 2vh, 20px) 8px; cursor: pointer; transition: transform 0.15s; font-family: "Noto Sans JP", sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }

.choice-btn::before { content: ""; position: absolute; inset: 0px; border-radius: inherit; padding: 2px; pointer-events: none; z-index: 3; background: conic-gradient(from var(--bd-angle),
      var(--c1), var(--c2), var(--c1), var(--c2), var(--c1)); mask: linear-gradient(rgb(0, 0, 0) 0px, rgb(0, 0, 0) 0px) content-box exclude, linear-gradient(rgb(0, 0, 0) 0px, rgb(0, 0, 0) 0px); animation: 3s linear 0s infinite normal none running bd-spin; }

@keyframes bd-spin { 
  100% { --bd-angle: 360deg; }
}

.choice-kana { font-size: clamp(26px, 5vw, 44px); font-weight: 900; display: block; position: relative; z-index: 2; transition: 0.15s; }

.choice-romaji { font-size: clamp(9px, 1.2vw, 12px); color: var(--txt3); font-family: "Noto Sans TC", sans-serif; opacity: 0; transition: opacity 0.3s; position: relative; z-index: 2; }

.revealed .choice-romaji { opacity: 1; }

.choice-btn.style-electric { --c1: #4fc3f7; --c2: #7c4dff; background: linear-gradient(145deg, rgb(5, 5, 24), rgb(13, 26, 48)); }

.choice-btn.style-electric .choice-kana { color: rgb(232, 244, 255); text-shadow: rgb(79, 195, 247) 0px 0px 8px, rgb(124, 77, 255) 0px 0px 20px, rgb(79, 195, 247) 0px 0px 40px; animation: 2s ease-in-out 0s infinite normal none running electric-flicker; }

@keyframes electric-flicker { 
  0%, 86%, 100% { text-shadow: rgb(79, 195, 247) 0px 0px 8px, rgb(124, 77, 255) 0px 0px 20px, rgb(79, 195, 247) 0px 0px 40px; transform: translate(0px, 0px); opacity: 1; }
  88% { text-shadow: rgb(79, 195, 247) 0px 0px 2px; transform: translate(-1.5px, 1px); opacity: 0.55; }
  91% { text-shadow: rgb(255, 255, 255) 0px 0px 20px, rgb(79, 195, 247) 0px 0px 42px, rgb(124, 77, 255) 0px 0px 72px; transform: translate(1.5px, -1px); opacity: 1; }
  94% { text-shadow: rgb(79, 195, 247) 0px 0px 5px; transform: translate(-1px, 0px); opacity: 0.8; }
  97% { text-shadow: rgb(255, 255, 255) 0px 0px 16px, rgb(124, 77, 255) 0px 0px 36px; transform: translate(1px, 1px); opacity: 1; }
}

.choice-btn.style-electric::after { content: ""; position: absolute; inset: 0px; z-index: 0; pointer-events: none; background: linear-gradient(115deg, transparent 32%, rgba(120, 210, 255, 0.4) 50%, transparent 68%) 0% 0% / 250% 100%; animation: 2.2s linear 0s infinite normal none running elec-sweep; }

@keyframes elec-sweep { 
  0% { background-position: 130% 0px; }
  100% { background-position: -130% 0px; }
}

.choice-btn.style-fire { --c1: #ff7043; --c2: #ffd54f; background: linear-gradient(145deg, rgb(24, 8, 0), rgb(42, 16, 0)); }

.choice-btn.style-fire .choice-kana { color: rgb(255, 243, 224); text-shadow: rgb(255, 112, 67) 0px 0px 8px, rgb(255, 87, 34) 0px 0px 20px, rgb(255, 213, 79) 0px 0px 40px; animation: 1.4s ease-in-out 0s infinite normal none running fire-flicker; }

@keyframes fire-flicker { 
  0%, 100% { text-shadow: rgb(255, 112, 67) 0px 0px 8px, rgb(255, 87, 34) 0px 0px 20px, rgb(255, 213, 79) 0px 0px 40px; transform: skewX(0deg) scaleY(1) translateY(0px); }
  20% { text-shadow: rgb(255, 87, 34) 0px 0px 18px, rgb(255, 213, 79) 0px 0px 38px, rgb(255, 112, 67) 0px 0px 60px; transform: skewX(-4deg) scaleY(1.08) translateY(-1px); }
  50% { text-shadow: rgb(255, 171, 64) 0px 0px 12px, rgb(255, 112, 67) 0px 0px 28px; transform: skewX(3deg) scaleY(0.95) translateY(1px); }
  75% { text-shadow: rgb(255, 213, 79) 0px 0px 8px, rgb(255, 112, 67) 0px 0px 22px; transform: skewX(4deg) scaleY(1.05) translateY(-1px); }
}

.choice-btn.style-fire::after { content: ""; position: absolute; inset: 0px; z-index: 0; pointer-events: none; background-image: radial-gradient(2px 2px at 20% 100%, rgb(255, 213, 79), transparent 60%), radial-gradient(2px 2px at 50% 100%, rgb(255, 112, 67), transparent 60%), radial-gradient(1.5px 1.5px at 72% 100%, rgb(255, 171, 64), transparent 60%), radial-gradient(2px 2px at 35% 100%, rgb(255, 138, 101), transparent 60%), radial-gradient(1.5px 1.5px at 86% 100%, rgb(255, 213, 79), transparent 60%); animation: 1.3s linear 0s infinite normal none running fire-sparks; }

@keyframes fire-sparks { 
  0% { transform: translateY(8px); opacity: 0; }
  25% { opacity: 0.95; }
  100% { transform: translateY(-60px); opacity: 0; }
}

.choice-btn.style-curse { --c1: #7c4dff; --c2: #e040fb; background: linear-gradient(145deg, rgb(14, 5, 24), rgb(26, 10, 46)); }

.choice-btn.style-curse .choice-kana { color: rgb(243, 229, 245); text-shadow: rgb(206, 147, 216) 0px 0px 8px, rgb(124, 77, 255) 0px 0px 20px, rgb(74, 20, 140) 0px 0px 40px; animation: 2.3s ease-in-out 0s infinite normal none running curse-pulse; }

@keyframes curse-pulse { 
  0%, 100% { text-shadow: rgb(206, 147, 216) 0px 0px 8px, rgb(124, 77, 255) 0px 0px 20px, rgb(74, 20, 140) 0px 0px 40px; transform: scale(1) rotate(0deg); }
  50% { text-shadow: rgb(224, 64, 251) 0px 0px 22px, rgb(124, 77, 255) 0px 0px 46px, rgb(206, 147, 216) 0px 0px 80px; transform: scale(1.1) rotate(1.5deg); }
}

.choice-btn.style-curse::after { content: ""; position: absolute; inset: 0px; z-index: 0; pointer-events: none; background: radial-gradient(circle at 50% 55%, rgba(124, 77, 255, 0.3), transparent 62%); animation: 2.3s ease-in-out 0s infinite normal none running curse-breathe; }

@keyframes curse-breathe { 
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.choice-btn.correct { border-color: var(--success); background: rgba(102, 187, 106, 0.18); box-shadow: rgba(102, 187, 106, 0.5) 0px 0px 24px; }

.choice-btn.wrong { border-color: var(--danger); background: rgba(239, 83, 80, 0.18); box-shadow: rgba(239, 83, 80, 0.5) 0px 0px 24px; }

.choice-btn.correct::before, .choice-btn.wrong::before, .choice-btn:disabled::before, .choice-btn:disabled::after { display: none; }

.choice-btn:hover:not(:disabled) { transform: translateY(-4px) scale(1.04); }

.choice-btn:active:not(:disabled) { transform: scale(0.95); }

.choice-btn:disabled { cursor: not-allowed; }

.btn-burst { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%) scale(0); border-radius: 50%; pointer-events: none; z-index: 5; animation: 0.5s ease-out 0s 1 normal forwards running burst-pop; }

.btn-burst.burst-electric { background: radial-gradient(circle, rgb(255, 255, 255), rgb(79, 195, 247) 38%, transparent 70%); box-shadow: rgb(79, 195, 247) 0px 0px 30px; }

.btn-burst.burst-fire { background: radial-gradient(circle, rgb(255, 243, 224), rgb(255, 112, 67) 38%, transparent 70%); box-shadow: rgb(255, 87, 34) 0px 0px 30px; }

.btn-burst.burst-curse { background: radial-gradient(circle, rgb(243, 229, 245), rgb(124, 77, 255) 38%, transparent 70%); box-shadow: rgb(124, 77, 255) 0px 0px 30px; }

.btn-burst.burst-curse::after { content: ""; position: absolute; inset: 0px; border-radius: 50%; border: 2px solid rgb(206, 147, 216); }

@keyframes burst-pop { 
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(9); opacity: 0; }
}

.ult-btn-wrap { padding: 6px 16px 10px; display: flex; justify-content: center; }

.ult-btn-wrap.ult-ready {
  position: relative;
}

.ult-btn-wrap.ult-ready::before,
.ult-btn-wrap.ult-ready::after {
  content: "";
  position: absolute;
  inset: 0 12px;
  pointer-events: none;
  border-radius: 999px;
  opacity: 0;
}

.ult-btn-wrap.ult-ready::before {
  border: 1px solid color-mix(in srgb, var(--accent2) 65%, white 25%);
  box-shadow: 0 0 18px var(--accent2), 0 0 38px rgba(255, 213, 79, 0.38);
  animation: ult-ready-halo 1.15s ease-in-out infinite;
}

.ult-btn-wrap.ult-ready::after {
  background: linear-gradient(100deg, transparent 18%, rgba(255,255,255,0.72) 48%, transparent 78%);
  transform: translateX(-130%);
  animation: ult-ready-sweep 1.35s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.ult-btn { background: linear-gradient(135deg, #4a148c, var(--accent2)); border: 2px solid var(--accent2); border-radius: 50px; color: rgb(255, 255, 255); font-size: clamp(13px, 2vw, 17px); font-weight: 700; padding: clamp(8px, 1.5vh, 12px) clamp(24px, 4vw, 40px); cursor: pointer; letter-spacing: 0.1em; box-shadow: var(--shadow-purple); transition: 0.2s; opacity: 0.4; pointer-events: none; }

.ult-btn.ready { opacity: 1; pointer-events: all; animation: 1s ease-in-out 0s infinite normal none running ult-btn-pulse; filter: brightness(1.18) saturate(1.25); }

@keyframes ult-btn-pulse { 
  0%, 100% { box-shadow: rgba(124, 77, 255, 0.6) 0px 0px 15px; }
  50% { box-shadow: rgb(124, 77, 255) 0px 0px 35px, rgba(79, 195, 247, 0.4) 0px 0px 60px; }
}

@keyframes ult-ready-halo {
  0%, 100% { opacity: 0.45; transform: scale(0.98); }
  50% { opacity: 1; transform: scale(1.06); }
}

@keyframes ult-ready-sweep {
  0% { opacity: 0; transform: translateX(-130%); }
  18% { opacity: 0.65; }
  58%, 100% { opacity: 0; transform: translateX(130%); }
}

@keyframes hero-idle { 
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

@keyframes hero-attack { 
  0% { transform: translateX(0px) scale(1); }
  40% { transform: translateX(min(8vw, 60px)) scale(1.08); }
  100% { transform: translateX(0px) scale(1); }
}

@keyframes hero-hurt { 
  0% { transform: translateX(0px); filter: drop-shadow(rgba(239, 83, 80, 0.9) 0px 0px 20px); }
  50% { transform: translateX(min(-3vw, -20px)); }
  100% { transform: translateX(0px); }
}

@keyframes enemy-float { 
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

@keyframes enemy-shake { 
  0% { transform: translateX(0px); }
  20% { transform: translateX(-14px); }
  40% { transform: translateX(14px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
  100% { transform: translateX(0px); }
}

@keyframes enemy-die { 
  0% { opacity: 1; transform: translate(0px, 0px) scale(1) rotate(0deg); filter: drop-shadow(rgba(239, 83, 80, 0.6) 0px 0px 22px) brightness(1); }
  18% { opacity: 1; transform: translate(-10px, 2px) scale(1.08) rotate(-3deg); filter: drop-shadow(rgb(255, 255, 255) 0px 0px 32px) brightness(2.4); }
  38% { opacity: 0.9; transform: translate(8px, -6px) scale(0.96) rotate(4deg); filter: drop-shadow(rgb(255, 112, 67) 0px 0px 40px) brightness(1.8); }
  70% { opacity: 0.45; transform: translate(0px, -14px) scale(0.62) rotate(12deg); filter: drop-shadow(rgb(239, 83, 80) 0px 0px 28px) blur(1px); }
  100% { opacity: 0; transform: translate(0px, -24px) scale(0.04) rotate(18deg); filter: drop-shadow(transparent 0px 0px 0px) blur(4px); }
}

.hero-img-wrap.attack { animation: 0.45s ease 0s 1 normal none running hero-attack !important; }

.hero-img-wrap.hurt { animation: 0.4s ease 0s 1 normal none running hero-hurt !important; }

@keyframes enemy-attack { 
  0% { transform: translateX(0px) scale(1); }
  40% { transform: translateX(min(-9vw, -46px)) scale(1.1); }
  100% { transform: translateX(0px) scale(1); }
}

.enemy-img-wrap.attack { animation: 0.4s ease 0s 1 normal none running enemy-attack !important; }

@keyframes cam-shake { 
  0%, 100% { transform: translate(0px, 0px); }
  15% { transform: translate(-7px, 4px); }
  30% { transform: translate(7px, -4px); }
  45% { transform: translate(-6px, -3px); }
  60% { transform: translate(6px, 3px); }
  75% { transform: translate(-4px, 2px); }
  90% { transform: translate(4px, -2px); }
}

.cam-shake { animation: 0.42s ease 0s 1 normal none running cam-shake; }

.side-hitflash { position: absolute; inset: 0px; pointer-events: none; z-index: 7; opacity: 0; }

.field-hero .side-hitflash { background: radial-gradient(circle at 50% 55%, rgba(255, 40, 40, 0.55), transparent 70%); }

.field-enemy .side-hitflash { background: radial-gradient(circle, rgba(120, 210, 255, 0.5), transparent 70%); }

.side-hitflash.show { animation: 0.42s ease 0s 1 normal none running side-hitflash-anim; }

@keyframes side-hitflash-anim { 
  0% { opacity: 0; }
  30% { opacity: 1; }
  100% { opacity: 0; }
}

.enemy-slash { position: absolute; inset: 0px; z-index: 8; pointer-events: none; display: flex; align-items: center; justify-content: center; opacity: 0; }

.enemy-slash svg { width: 96%; height: 96%; overflow: visible; filter: drop-shadow(rgba(255, 255, 255, 0.95) 0px 0px 4px) drop-shadow(rgba(79, 195, 247, 0.8) 0px 0px 10px); }

.enemy-slash.show { animation: 0.42s cubic-bezier(0.12, 0.72, 0.2, 1) 0s 1 normal forwards running slash-anim; }

@media (min-width: 768px) {
  #screen-stage { padding: 2rem 3rem; max-width: 1200px; margin: 0px auto; width: 100%; align-self: center; }
  .stage-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
  .stage-card { padding: 1.5rem; }
  .stage-card .stage-emoji { font-size: 48px; }
  .stage-card .stage-name { font-size: 17px; }
  .screen-header h2 { font-size: 24px; }
}

.stage-chapter {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 14px 2px 0;
  padding: 10px 4px 8px;
  border-bottom: 1px solid rgba(124, 77, 255, 0.45);
}

.stage-chapter span {
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.stage-chapter small {
  color: var(--txt3);
  font-size: 11px;
  letter-spacing: 0.16em;
}

.stage-mastery {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  color: var(--txt3);
  font-size: 10px;
}

.stage-mastery > div {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.stage-mastery i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent2), var(--accent), var(--gold));
  box-shadow: 0 0 10px rgba(79, 195, 247, 0.55);
}

.stage-mastery b { color: #fff; font-variant-numeric: tabular-nums; }

.progression-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(260px, 1.08fr);
  gap: 14px;
  margin: 0 0 18px;
}

.training-panel,
.ultimate-loadout {
  border: 1px solid rgba(124, 77, 255, 0.28);
  border-radius: 14px;
  background: rgba(18, 20, 48, 0.72);
  padding: 14px;
}

.training-panel {
  padding: 10px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 7px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.panel-heading span {
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.panel-heading small {
  color: var(--gold);
  font-weight: 800;
}

.training-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.training-card {
  display: grid;
  grid-template-columns: minmax(104px, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  min-height: 0;
  padding: 7px 8px;
  border: 1px solid rgba(79, 195, 247, 0.22);
  border-radius: 8px;
  background: rgba(10, 12, 32, 0.62);
}

.training-card > div:first-child {
  min-width: 0;
}

.training-card strong,
.ultimate-card b {
  display: block;
  color: #fff;
  font-size: 14px;
  line-height: 1.05;
}

.training-card span,
.ultimate-card span {
  display: block;
  margin-top: 2px;
  color: var(--txt2);
  font-size: 12px;
  line-height: 1.32;
}

.training-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.training-pips {
  display: flex;
  gap: 1px;
  align-items: center;
}

.training-pips i {
  width: 8px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
}

.training-pips i.on {
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  box-shadow: 0 0 8px rgba(79, 195, 247, 0.45);
}

.mini-upgrade-btn {
  align-self: center;
  border: 1px solid rgba(255, 213, 79, 0.55);
  border-radius: 7px;
  background: rgba(255, 213, 79, 0.12);
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}

.mini-reset-btn {
  border: 1px solid rgba(255, 213, 79, 0.48);
  border-radius: 7px;
  background: rgba(255, 213, 79, 0.11);
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  padding: 4px 7px;
  cursor: pointer;
}

.mini-upgrade-btn:disabled,
.mini-reset-btn:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  filter: grayscale(0.4);
}

.ultimate-grid {
  display: grid;
  gap: 8px;
}

.ultimate-card {
  position: relative;
  width: 100%;
  min-height: 62px;
  text-align: left;
  border: 1px solid rgba(124, 77, 255, 0.25);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(26, 18, 58, 0.9), rgba(10, 12, 32, 0.86));
  padding: 9px 12px;
  cursor: pointer;
}

.ultimate-card.active {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(255, 213, 79, 0.22);
}

.ultimate-card em {
  position: absolute;
  right: 10px;
  top: 9px;
  color: var(--gold);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.12em;
}

#screen-stage.stage-theme-wine {
  background:
    radial-gradient(70% 42% at 50% 0%, rgba(132, 28, 54, 0.42), transparent 70%),
    radial-gradient(55% 34% at 12% 32%, rgba(176, 58, 82, 0.26), transparent 72%),
    linear-gradient(180deg, #1b0811 0%, #100611 48%, #09040a 100%);
}

#screen-stage.stage-theme-wine .screen-header {
  border-bottom-color: rgba(190, 76, 96, 0.45);
}

#screen-stage.stage-theme-wine .screen-header .back-btn,
#screen-stage.stage-theme-wine .stage-card .stage-row-label {
  background: rgba(60, 14, 27, 0.78);
  border-color: rgba(190, 76, 96, 0.36);
  color: #e4a2ad;
}

#screen-stage.stage-theme-wine .screen-header .back-btn:hover,
#screen-stage.stage-theme-wine .stage-card.unlocked:hover {
  border-color: #e05f78;
  box-shadow: 0 0 20px rgba(176, 58, 82, 0.35);
}

#screen-stage.stage-theme-wine .theme-toggle-btn,
#screen-stage.stage-theme-wine .mini-upgrade-btn,
#screen-stage.stage-theme-wine .mini-reset-btn {
  border-color: rgba(255, 194, 109, 0.48);
  background: rgba(255, 194, 109, 0.1);
  color: #ffc26d;
}

#screen-stage.stage-theme-wine .training-panel,
#screen-stage.stage-theme-wine .ultimate-loadout {
  border-color: rgba(190, 76, 96, 0.34);
  background: rgba(38, 10, 22, 0.78);
}

#screen-stage.stage-theme-wine .training-card {
  border-color: rgba(224, 95, 120, 0.3);
  background: rgba(23, 7, 16, 0.68);
}

#screen-stage.stage-theme-wine .ultimate-card {
  border-color: rgba(190, 76, 96, 0.28);
  background: linear-gradient(135deg, rgba(66, 13, 30, 0.92), rgba(24, 7, 17, 0.88));
}

#screen-stage.stage-theme-wine .ultimate-card.active {
  border-color: #ffc26d;
  box-shadow: 0 0 18px rgba(255, 194, 109, 0.22);
}

#screen-stage.stage-theme-wine .stage-card {
  border-color: rgba(190, 76, 96, 0.28);
  background: linear-gradient(150deg, rgba(50, 12, 26, 0.94), rgba(24, 8, 18, 0.92));
}

#screen-stage.stage-theme-wine .stage-card.boss-card {
  border-color: rgba(255, 112, 101, 0.58);
  background: linear-gradient(135deg, #42101a, rgba(35, 8, 19, 0.95));
}

#screen-stage.stage-theme-wine .training-pips i.on,
#screen-stage.stage-theme-wine .stage-mastery i {
  background: linear-gradient(90deg, #b83a56, #e05f78, #ffc26d);
  box-shadow: 0 0 8px rgba(224, 95, 120, 0.5);
}

#screen-stage.stage-theme-wine .stage-chapter span,
#screen-stage.stage-theme-wine .stage-summary strong,
#screen-stage.stage-theme-wine .panel-heading small,
#screen-stage.stage-theme-wine .ultimate-card em {
  color: #ffc26d;
}

.training-reward {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--txt2);
  background: rgba(79, 195, 247, 0.1);
}

.training-reward strong { color: var(--gold); }

.ultimate-reward {
  --ult-a: var(--accent);
  --ult-b: var(--accent2);
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 13px;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--ult-a) 70%, white 8%);
  border-radius: 18px;
  text-align: left;
  background: radial-gradient(circle at 18% 50%, color-mix(in srgb, var(--ult-a) 30%, transparent), transparent 38%), rgba(18, 20, 48, 0.92);
  animation: spirit-unlock 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.ultimate-reward-kanji {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font: 900 40px/1 "Noto Sans JP", sans-serif;
  background: linear-gradient(135deg, var(--ult-b), var(--ult-a));
  box-shadow: 0 0 24px color-mix(in srgb, var(--ult-a) 48%, transparent);
}

.ultimate-reward small { display: block; color: var(--ult-a); font-size: 9px; letter-spacing: 0.16em; }
.ultimate-reward strong { display: block; margin-top: 4px; color: #fff; font-size: 16px; }
.ultimate-reward p { margin: 5px 0 0; color: var(--txt2); font-size: 12px; }

.ult-theme-violet { --ult-a: #7c4dff; --ult-b: #4fc3f7; }
.ult-theme-red { --ult-a: #ff7043; --ult-b: #ef5350; }
.ult-theme-blue { --ult-a: #4fc3f7; --ult-b: #5c6bc0; }
.ult-theme-green { --ult-a: #66bb6a; --ult-b: #26a69a; }
.ult-theme-gold { --ult-a: #ffd54f; --ult-b: #ff8f00; }

#ult-overlay.ult-theme-red,
#ult-overlay.ult-theme-blue,
#ult-overlay.ult-theme-green,
#ult-overlay.ult-theme-gold,
#ult-overlay.ult-theme-violet {
  --accent: var(--ult-a);
  --accent2: var(--ult-b);
}

#ult-overlay.ult-effect-domain .ult-vignette {
  background:
    radial-gradient(circle at 72% 50%, transparent 0 14%, rgba(15, 7, 42, 0.2) 35%, rgba(3, 3, 14, 0.9) 76%),
    repeating-linear-gradient(112deg, transparent 0 42px, rgba(79, 195, 247, 0.024) 43px 44px);
}

#ult-overlay.ult-effect-domain .ult-cinematic {
  animation: ult-domain-stage 4.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

#ult-overlay.ult-effect-domain .ult-impact-core {
  background: radial-gradient(circle, #fff 0 10%, #7c4dff 28%, #4fc3f7 48%, rgba(124,77,255,0.68) 64%, transparent 74%);
}

#ult-overlay.ult-effect-slash .ult-cinematic {
  left: 50%;
  width: min(94vmin, 780px);
  animation: ult-slash-stage 4.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

#ult-overlay.ult-effect-slash .ult-domain-ring,
#ult-overlay.ult-effect-slash .ult-domain-glyphs {
  display: none;
}

#ult-overlay.ult-effect-slash .ult-beam {
  height: clamp(14px, 2.6vmin, 30px);
  clip-path: polygon(0 46%, 76% 0, 100% 12%, 22% 100%);
  background: linear-gradient(90deg, transparent, #fff 12%, #ff7043 46%, #ef5350 70%, transparent);
}

#ult-overlay.ult-effect-slash .ult-energy-core,
#ult-overlay.ult-effect-slash .ult-impact-core {
  border-radius: 58% 42% 48% 52%;
  clip-path: polygon(50% 0, 63% 26%, 92% 18%, 75% 50%, 100% 76%, 61% 70%, 50% 100%, 38% 70%, 0 76%, 25% 50%, 8% 18%, 37% 26%);
  background: radial-gradient(circle, #fff 0 8%, #ffd54f 20%, #ff7043 48%, #ef5350 66%, transparent 76%);
}

#ult-overlay.ult-effect-slash .ult-spark {
  height: clamp(24px, 5vmin, 56px);
  background: linear-gradient(#fff, #ffd54f 30%, #ef5350 72%, transparent);
  clip-path: polygon(45% 0, 66% 42%, 54% 100%, 20% 55%);
}

#ult-overlay.ult-effect-slash .beam-a { animation-name: ult-slash-a; }
#ult-overlay.ult-effect-slash .beam-b { animation-name: ult-slash-b; }
#ult-overlay.ult-effect-slash .beam-c { animation-name: ult-slash-c; }

#ult-overlay.ult-effect-barrier .ult-cinematic {
  animation: ult-barrier-stage 4.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

#ult-overlay.ult-effect-barrier .ult-domain-ring {
  border-radius: 16px;
  border-style: solid;
  transform: rotate(45deg);
  box-shadow: 0 0 28px rgba(79, 195, 247, 0.64), inset 0 0 38px rgba(79, 195, 247, 0.24);
}

#ult-overlay.ult-effect-barrier .ring-inner {
  border-radius: 8px;
  border-color: rgba(255,255,255,0.9);
}

#ult-overlay.ult-effect-barrier .ult-beam {
  left: 50%;
  top: 50%;
  width: 76%;
  height: clamp(9px, 1.2vmin, 16px);
  transform-origin: 50% 50%;
  clip-path: none;
  background: linear-gradient(90deg, transparent, #fff 18%, #4fc3f7 50%, #fff 82%, transparent);
}

#ult-overlay.ult-effect-barrier .beam-a { animation-name: ult-barrier-line-a; }
#ult-overlay.ult-effect-barrier .beam-b { animation-name: ult-barrier-line-b; }
#ult-overlay.ult-effect-barrier .beam-c { animation-name: ult-barrier-line-c; }

#ult-overlay.ult-effect-barrier .ult-shockwave {
  border-radius: 12px;
  transform: translate(-50%, -50%) rotate(45deg) scale(0.2);
}

#ult-overlay.ult-effect-barrier .ult-impact-core {
  background: radial-gradient(circle, #fff 0 12%, #4fc3f7 26%, rgba(92,107,192,0.72) 58%, transparent 72%);
  animation-name: ult-barrier-burst;
}

#ult-overlay.ult-effect-ward .ult-cinematic {
  animation: ult-ward-stage 4.3s ease both;
}

#ult-overlay.ult-effect-ward .ult-domain-ring {
  border-radius: 34% 66% 38% 62%;
  border-style: double;
  border-width: 5px;
  border-color: rgba(102, 187, 106, 0.9);
  box-shadow: 0 0 28px rgba(102, 187, 106, 0.42), inset 0 0 34px rgba(38, 166, 154, 0.26);
}

#ult-overlay.ult-effect-ward .ring-inner {
  border-radius: 62% 38% 58% 42%;
  border-color: rgba(178, 255, 218, 0.9);
}

#ult-overlay.ult-effect-ward .ult-domain-glyphs {
  color: rgba(198, 255, 221, 0.86);
  animation-name: ult-ward-glyph-flow;
}

#ult-overlay.ult-effect-ward .ult-beam {
  width: 95%;
  height: clamp(5px, 0.8vmin, 10px);
  opacity: 0.82;
  clip-path: polygon(0 50%, 12% 36%, 24% 54%, 36% 34%, 48% 56%, 60% 36%, 72% 54%, 84% 35%, 100% 50%, 84% 65%, 72% 46%, 60% 64%, 48% 44%, 36% 66%, 24% 46%, 12% 64%);
  background: linear-gradient(90deg, transparent, #eafff4, #66bb6a, #26a69a, transparent);
}

#ult-overlay.ult-effect-ward .ult-impact-core {
  background: radial-gradient(circle, #fff 0 8%, #c8ffd9 22%, #66bb6a 40%, rgba(38,166,154,0.72) 62%, transparent 76%);
}

#ult-overlay.ult-effect-ward .ult-spark {
  border-radius: 999px;
  background: radial-gradient(circle, #fff 0 20%, #66bb6a 44%, transparent 70%);
  box-shadow: 0 0 10px #c8ffd9, 0 0 18px #66bb6a;
}

#ult-overlay.ult-effect-dragon .ult-cinematic {
  left: 50%;
  width: min(96vmin, 850px);
  animation: ult-dragon-coil 4.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

#ult-overlay.ult-effect-dragon .ult-domain-ring {
  border-color: rgba(255, 213, 79, 0.9);
  border-style: dotted;
  box-shadow: 0 0 36px rgba(255, 213, 79, 0.5), inset 0 0 32px rgba(255, 143, 0, 0.24);
}

#ult-overlay.ult-effect-dragon .ult-domain-glyphs {
  color: rgba(255, 245, 180, 0.84);
  animation-name: ult-dragon-glyph-surge;
}

#ult-overlay.ult-effect-dragon .ult-beam {
  height: clamp(10px, 1.9vmin, 24px);
  clip-path: polygon(0 52%, 16% 38%, 24% 56%, 39% 28%, 48% 62%, 62% 34%, 74% 60%, 100% 44%, 78% 72%, 65% 50%, 52% 78%, 42% 48%, 27% 74%, 18% 54%);
  background: linear-gradient(90deg, transparent, #fff 14%, #ffd54f 34%, #4fc3f7 58%, #ff8f00 82%, transparent);
}

#ult-overlay.ult-effect-dragon .ult-energy-core {
  clip-path: polygon(50% 0, 60% 30%, 95% 28%, 66% 48%, 82% 88%, 50% 62%, 18% 88%, 34% 48%, 5% 28%, 40% 30%);
  background: radial-gradient(circle, #fff 0 12%, #4fc3f7 24%, #ffd54f 45%, #ff8f00 70%, transparent 78%);
}

#ult-overlay.ult-effect-dragon .ult-impact-core {
  background: radial-gradient(circle, #fff 0 10%, #ffd54f 24%, #ff8f00 42%, rgba(239,83,80,0.66) 62%, transparent 74%);
}

@keyframes ult-domain-stage {
  0%, 18% { transform: translate(-50%, -50%) scale(0.96); filter: blur(6px); }
  44% { transform: translate(-50%, -50%) scale(1.02); filter: blur(0); }
  62% { transform: translate(-50%, -50%) scale(1.08); filter: brightness(2); }
  100% { transform: translate(-50%, -50%) scale(0.72); filter: blur(12px); }
}

@keyframes ult-slash-stage {
  0%, 22% { transform: translate(-50%, -50%) rotate(-8deg) scale(0.92); filter: blur(8px); }
  42% { transform: translate(-50%, -50%) rotate(0deg) scale(1.03); filter: blur(0); }
  60% { transform: translate(-50%, -50%) rotate(2deg) scale(1.12); filter: brightness(1.8); }
  100% { transform: translate(-50%, -50%) rotate(10deg) scale(0.7); filter: blur(12px); }
}

@keyframes ult-slash-a {
  0%, 24% { opacity: 0; transform: rotate(-34deg) translateX(-76%); scale: 0.25 1; }
  31% { opacity: 1; scale: 1.15 1; }
  42%, 100% { opacity: 0; transform: rotate(-34deg) translateX(30%); scale: 1.2 0.2; }
}

@keyframes ult-slash-b {
  0%, 36% { opacity: 0; transform: rotate(12deg) translateX(-80%); scale: 0.2 1; }
  43% { opacity: 1; scale: 1.1 1; }
  55%, 100% { opacity: 0; transform: rotate(12deg) translateX(28%); scale: 1.2 0.18; }
}

@keyframes ult-slash-c {
  0%, 44% { opacity: 0; transform: rotate(-6deg) translateX(-76%); scale: 0.2 1; }
  51% { opacity: 1; scale: 1.18 1; }
  64%, 100% { opacity: 0; transform: rotate(-6deg) translateX(34%); scale: 1.2 0.15; }
}

@keyframes ult-barrier-burst {
  0%, 48% { opacity: 0; transform: translate(-50%, -50%) scale(0) rotate(45deg); }
  56% { opacity: 0.95; transform: translate(-50%, -50%) scale(1.4) rotate(45deg); }
  78%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(3.8) rotate(135deg); }
}

@keyframes ult-barrier-stage {
  0% { transform: translate(-50%, -50%) rotate(45deg) scale(0.35); filter: blur(12px); }
  30% { transform: translate(-50%, -50%) rotate(45deg) scale(1); filter: blur(0); }
  58% { transform: translate(-50%, -50%) rotate(45deg) scale(1.08); filter: brightness(1.9); }
  100% { transform: translate(-50%, -50%) rotate(45deg) scale(1.55); filter: blur(10px); }
}

@keyframes ult-barrier-line-a {
  0%, 28% { opacity: 0; transform: translate(-50%, -50%) rotate(0deg) scaleX(0.08); }
  39%, 62% { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) scaleX(1); }
  78%, 100% { opacity: 0; transform: translate(-50%, -50%) rotate(0deg) scaleX(1.16); }
}

@keyframes ult-barrier-line-b {
  0%, 33% { opacity: 0; transform: translate(-50%, -50%) rotate(90deg) scaleX(0.08); }
  44%, 66% { opacity: 1; transform: translate(-50%, -50%) rotate(90deg) scaleX(1); }
  82%, 100% { opacity: 0; transform: translate(-50%, -50%) rotate(90deg) scaleX(1.16); }
}

@keyframes ult-barrier-line-c {
  0%, 38% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scaleX(0.08); }
  49%, 68% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scaleX(0.9); }
  84%, 100% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scaleX(1.1); }
}

@keyframes ult-ward-stage {
  0% { transform: translate(-50%, -50%) rotate(-12deg) scale(0.42); filter: blur(14px); }
  34% { transform: translate(-50%, -50%) rotate(8deg) scale(0.98); filter: blur(0); }
  58% { transform: translate(-50%, -50%) rotate(-6deg) scale(1.12); filter: brightness(1.7); }
  100% { transform: translate(-50%, -50%) rotate(12deg) scale(1.42); filter: blur(11px); }
}

@keyframes ult-ward-glyph-flow {
  0%, 10% { opacity: 0; transform: rotate(30deg) scale(0.45); }
  28% { opacity: 0.92; transform: rotate(-24deg) scale(1); }
  54% { opacity: 0.68; transform: rotate(28deg) scale(0.94); }
  70%, 100% { opacity: 0; transform: rotate(-38deg) scale(1.5); }
}

@keyframes ult-dragon-coil {
  0% { transform: translate(-50%, -50%) rotate(-22deg) scale(0.35); filter: blur(18px); }
  28% { transform: translate(-50%, -50%) rotate(18deg) scale(0.92); filter: blur(0); }
  58% { transform: translate(-50%, -50%) rotate(190deg) scale(1.2); filter: brightness(1.9); }
  100% { transform: translate(-50%, -50%) rotate(330deg) scale(0.12); filter: blur(12px); }
}

@keyframes ult-dragon-glyph-surge {
  0%, 8% { opacity: 0; transform: rotate(-120deg) scale(0.38); }
  24% { opacity: 0.95; transform: rotate(25deg) scale(1.08); }
  50% { opacity: 0.7; transform: rotate(210deg) scale(0.88); }
  66%, 100% { opacity: 0; transform: rotate(390deg) scale(1.6); }
}

.ult-btn[data-ultimate-theme="red"] { background: linear-gradient(135deg, #7f1d1d, #ef5350); border-color: #ff7043; }
.ult-btn[data-ultimate-theme="blue"] { background: linear-gradient(135deg, #1a237e, #4fc3f7); border-color: #4fc3f7; }
.ult-btn[data-ultimate-theme="green"] { background: linear-gradient(135deg, #1b5e20, #26a69a); border-color: #66bb6a; }
.ult-btn[data-ultimate-theme="gold"] { background: linear-gradient(135deg, #7f4f00, #ffd54f); border-color: #ffd54f; color: #1b1400; }

.result-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.28em;
}

.result-stars {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 12px 0;
  color: rgba(255, 255, 255, 0.18);
  font-size: 30px;
}

.result-stars .lit {
  color: var(--gold);
  filter: drop-shadow(0 0 8px rgba(255, 213, 79, 0.8));
}

.spirit-reward {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 14px;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid rgba(255, 213, 79, 0.7);
  border-radius: 18px;
  text-align: left;
  background: radial-gradient(circle at 18% 50%, rgba(255, 213, 79, 0.2), transparent 36%), rgba(18, 20, 48, 0.9);
  animation: spirit-unlock 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.spirit-reward-image {
  display: grid;
  width: 84px;
  height: 84px;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: rgba(124, 77, 255, 0.18);
  box-shadow: 0 0 22px rgba(255, 213, 79, 0.38);
}

.spirit-reward-image img { width: 100%; height: 100%; object-fit: contain; }
.spirit-reward-image span { color: #fff; font: 900 52px/1 "Noto Sans JP", sans-serif; text-shadow: 0 0 18px var(--gold); }
.spirit-reward small { display: block; color: var(--gold); font-size: 9px; letter-spacing: 0.16em; }
.spirit-reward strong { display: block; margin-top: 4px; color: #fff; font-size: 16px; }
.spirit-reward p { margin: 5px 0 0; color: var(--txt2); font-size: 12px; }

.review-summary {
  margin: 12px 0;
  padding: 9px;
  border-radius: 10px;
  color: var(--accent);
  background: rgba(79, 195, 247, 0.1);
}

.review-summary.perfect { color: var(--gold); background: rgba(255, 213, 79, 0.12); }

@keyframes spirit-unlock {
  0% { opacity: 0; transform: scale(0.72) translateY(28px); filter: brightness(2.4); }
  55% { opacity: 1; transform: scale(1.04) translateY(0); }
  100% { transform: scale(1); filter: brightness(1); }
}

@media (min-width: 601px) and (max-width: 1024px) {
  #screen-battle { min-height: 100dvh; }
  .battle-field { min-height: 44dvh; }
  .battle-bottom { width: min(720px, 94vw); margin-inline: auto; }
  .choices-grid { gap: 10px; }
  .choice-btn { min-height: 82px; }
  .result-panel { width: min(520px, 88vw); max-width: 520px; max-height: 90dvh; overflow-y: auto; }
  .field-enemy #slash-effect.enemy-slash {
    inset: 4% 10% 36%;
    align-items: center;
    justify-content: center;
  }
  .field-enemy #slash-effect.enemy-slash svg {
    width: min(78%, 360px);
    height: min(78%, 360px);
  }
  .field-enemy .side-hitflash {
    background: radial-gradient(circle at 50% 34%, rgba(120, 210, 255, 0.58), transparent 62%);
  }
  .field-enemy .dmg-float {
    top: 24% !important;
  }
}

@media (max-width: 760px) {
  .progression-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .stage-chapter span { font-size: 16px; }
  .spirit-reward { grid-template-columns: 68px 1fr; gap: 10px; padding: 11px; }
  .spirit-reward-image { width: 68px; height: 68px; }
  .spirit-reward-image span { font-size: 42px; }
  .result-panel { max-height: calc(100dvh - 24px); overflow-y: auto; padding: 1.35rem 1.15rem; }
}


/* Learning-system overlays must never participate in page layout. */
#boss-phase-overlay,
#review-overlay {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#boss-phase-overlay {
  z-index: 120;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(circle at 50% 50%, rgba(239, 83, 80, 0.28), transparent 38%), rgba(4, 5, 18, 0.82);
  backdrop-filter: blur(4px);
}

#boss-phase-overlay.show {
  display: flex;
  animation: boss-phase-reveal 1.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.boss-phase-kicker {
  color: #ff8a80;
  font-size: clamp(12px, 2.4vw, 18px);
  font-weight: 900;
  letter-spacing: 0.28em;
}

.boss-phase-title {
  color: #fff;
  font-size: clamp(30px, 7vw, 72px);
  font-weight: 900;
  line-height: 1.15;
  text-shadow: 0 0 18px rgba(239, 83, 80, 0.9);
}

.boss-phase-message {
  color: #ffcdd2;
  font-size: clamp(15px, 3vw, 24px);
  font-weight: 700;
}

#review-overlay {
  z-index: 115;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(3, 5, 18, 0.88);
  backdrop-filter: blur(8px);
}

#review-overlay.show {
  display: flex;
  pointer-events: auto;
}

.review-panel {
  width: min(520px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: clamp(20px, 5vw, 38px);
  border: 1px solid rgba(79, 195, 247, 0.7);
  border-radius: 22px;
  text-align: center;
  background: linear-gradient(160deg, #17244b, #0d1028 65%);
  box-shadow: 0 0 42px rgba(79, 195, 247, 0.26);
}

.review-kicker {
  color: var(--accent);
  font-size: clamp(22px, 5vw, 38px);
  font-weight: 900;
  letter-spacing: 0.14em;
}

.review-progress {
  margin-top: 6px;
  color: var(--gold);
  font-weight: 800;
}

.review-prompt {
  margin: 18px 0 4px;
  color: #fff;
  font-size: clamp(48px, 14vw, 92px);
  font-weight: 900;
  line-height: 1;
  text-shadow: var(--shadow-blue);
}

.review-hint,
.review-feedback {
  min-height: 24px;
  color: var(--txt2);
  font-size: 14px;
}

.review-choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 20px 0 14px;
}

.review-choices button {
  min-height: 72px;
  border: 2px solid var(--border);
  border-radius: 14px;
  color: #fff;
  background: var(--bg3);
  font: 900 clamp(26px, 7vw, 42px) / 1 "Noto Sans JP", sans-serif;
  cursor: pointer;
}

.review-choices button.correct {
  border-color: var(--success);
  background: rgba(102, 187, 106, 0.2);
}

.review-choices button.wrong {
  border-color: var(--danger);
  background: rgba(239, 83, 80, 0.2);
}

.review-feedback.ok { color: var(--success); }
.review-feedback.ng { color: var(--danger); }

.enemy-img-wrap.phase-shift {
  animation: boss-phase-enemy 0.75s cubic-bezier(0.16, 1, 0.3, 1) both !important;
}

@keyframes boss-phase-reveal {
  0% { opacity: 0; transform: scale(1.08); }
  18%, 74% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.98); }
}

@keyframes boss-phase-enemy {
  0% { transform: scale(0.96); filter: brightness(1); }
  38% { transform: scale(1.08); filter: brightness(2.2) saturate(1.6); }
  100% { transform: scale(1); filter: brightness(1); }
}

@media (max-width: 480px) {
  .review-choices { grid-template-columns: repeat(2, 1fr); }
  .review-choices button { min-height: 62px; }
  .battle-bottom { max-height: 48dvh; overflow-y: auto; }
}


/* Mobile battle cockpit v2 */
@media (max-width: 600px) {
  body.battle-mode {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  #screen-battle.active {
    width: 100%;
    height: 100vh;
    height: 100svh;
    min-height: 0;
    max-height: 100svh;
    overflow: hidden;
  }

  .battle-topbar {
    min-height: 44px;
    gap: 7px;
    padding: 5px 9px;
  }

  .retreat-btn {
    padding: 6px 9px;
    border-radius: 8px;
    font-size: 11px;
    letter-spacing: 0;
  }

  .battle-stage-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    letter-spacing: 0;
  }

  .battle-score-display {
    font-size: 12px;
  }

  .battle-field {
    flex: 0 0 clamp(205px, 34svh, 292px);
    min-height: 0;
  }

  .field-hero,
  .field-enemy {
    padding: 3px 5px 6px;
  }

  .hero-img-wrap,
  .enemy-img-wrap {
    width: min(44vw, 210px);
  }

  .field-name {
    max-width: 96%;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
  }

  .side-status {
    width: 98%;
    gap: 3px;
    margin-top: 4px;
  }

  .status-row,
  .atb-row {
    gap: 4px;
  }

  .sb-label,
  .atb-skull {
    width: 36px;
    font-size: 9px;
  }

  .atb-skull { font-size: 14px; }
  .sb-val { min-width: 39px; font-size: 9px; }
  .atb-count { width: 38px; font-size: 11px; }
  .side-status .hp-bar-outer { height: 9px; }
  .side-status .ult-bar-outer { height: 8px; }
  .atb-row .atb-bar-outer { height: 12px; }

  .battle-bottom {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    background:
      linear-gradient(180deg, rgba(13, 17, 42, 0.98), rgba(5, 6, 20, 0.99)),
      repeating-linear-gradient(90deg, transparent 0 24px, rgba(79, 195, 247, 0.025) 24px 25px);
  }

  .prompt-bar {
    min-height: 38px;
    padding: 4px 9px 1px;
  }

  .prompt-bubble {
    min-height: 34px;
    max-width: 100%;
    padding: 3px 14px;
    gap: 9px;
    border-width: 1px;
    border-radius: 8px 14px 8px 14px;
    box-shadow: 0 0 12px rgba(79, 195, 247, 0.24), inset 0 0 12px rgba(79, 195, 247, 0.08);
  }

  .prompt-romaji {
    font-size: clamp(23px, 8vw, 32px);
  }

  .prompt-hint {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
  }

  .feedback-bar {
    min-height: 25px;
    padding: 1px 8px;
  }

  .feedback-msg {
    max-width: 100%;
    padding: 3px 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
  }

  .choices-section {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    padding: 2px 9px 4px;
  }

  .choices-label {
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 9px;
    letter-spacing: 0.06em;
  }

  .choices-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 7px;
    min-height: 0;
  }

  .choice-btn {
    --blade-cut: 11px;
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 3px 8px;
    border: 1px solid color-mix(in srgb, var(--c1) 72%, white 12%);
    border-radius: 0;
    clip-path: polygon(var(--blade-cut) 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - var(--blade-cut)), calc(100% - var(--blade-cut)) 100%, 4px 100%, 0 calc(100% - 4px), 0 var(--blade-cut));
    background:
      linear-gradient(118deg, transparent 0 42%, color-mix(in srgb, var(--c1) 16%, transparent) 43% 45%, transparent 46%),
      linear-gradient(160deg, color-mix(in srgb, var(--c1) 13%, #0b1025), #080a18 68%);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.16),
      inset 0 -12px 22px rgba(0,0,0,0.34),
      0 3px 0 color-mix(in srgb, var(--c2) 30%, #02030b),
      0 7px 18px rgba(0,0,0,0.42);
    transition: transform 0.12s cubic-bezier(0.16, 1, 0.3, 1), filter 0.12s;
  }

  .choice-btn::before {
    inset: 3px;
    padding: 1px;
    border-radius: 0;
    clip-path: inherit;
    background:
      linear-gradient(90deg, var(--c1), transparent 22% 78%, var(--c2)) top / 100% 1px no-repeat,
      linear-gradient(90deg, var(--c2), transparent 35% 65%, var(--c1)) bottom / 100% 1px no-repeat;
    mask: none;
    animation: blade-frame-pulse 1.8s ease-in-out infinite;
  }

  .choice-btn::after {
    clip-path: inherit;
    opacity: 0.5;
  }

  .choice-btn .choice-kana {
    font-size: clamp(25px, 8vw, 36px);
    line-height: 1;
    filter: drop-shadow(0 3px 0 rgba(0,0,0,0.58));
  }

  .choice-btn.roman-choice .choice-kana {
    font-size: clamp(20px, 6vw, 28px);
    letter-spacing: 0.08em;
  }

  .choice-romaji {
    margin-top: 1px;
    font-size: 8px;
  }

  .choice-btn:active:not(:disabled) {
    transform: translateY(3px) scale(0.97);
    filter: brightness(1.35);
    box-shadow: inset 0 3px 14px rgba(0,0,0,0.5);
  }

  .choice-btn.correct {
    animation: mobile-answer-correct 0.48s cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  .choice-btn.wrong {
    animation: mobile-answer-wrong 0.38s ease both;
  }

  .ult-btn-wrap {
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    padding: 4px 9px max(7px, env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(4,5,16,0), rgba(4,5,16,0.98) 28%);
  }

  .ult-btn {
    width: 100%;
    min-height: 43px;
    padding: 7px 18px;
    border: 1px solid rgba(124, 77, 255, 0.72);
    border-radius: 0;
    clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 16px 100%, 0 50%);
    background:
      linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent) -100% 0 / 45% 100% no-repeat,
      linear-gradient(135deg, #24113f, #4a148c 45%, #142b54);
    font-size: 13px;
    letter-spacing: 0.16em;
    box-shadow: inset 0 0 18px rgba(124,77,255,0.25), 0 0 12px rgba(124,77,255,0.24);
  }

  .ult-btn.ready {
    background:
      linear-gradient(100deg, transparent 25%, rgba(255,255,255,0.9) 48%, transparent 70%) -80% 0 / 40% 100% no-repeat,
      linear-gradient(135deg, #391060, #7c4dff 44%, #0d6f8e);
    animation: mobile-ult-ready 1.15s cubic-bezier(0.16, 1, 0.3, 1) infinite;
  }

  #screen-stage {
    padding: 14px 12px 28px;
  }

  .screen-header {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 10px;
  }

  .screen-header .back-btn {
    padding: 7px 9px;
    white-space: nowrap;
    font-size: 11px;
  }

  .screen-header h2 {
    white-space: nowrap;
    font-size: 17px;
  }

  .stage-summary {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    overflow: hidden;
    white-space: nowrap;
    color: var(--txt2);
    font-size: 10px;
  }

  .stage-summary span {
    display: inline-flex;
    gap: 2px;
  }

  .stage-summary strong {
    color: #fff;
    font-size: 11px;
  }

  .theme-toggle-btn {
    padding: 7px 8px;
    font-size: 11px;
  }

  .stage-chapter {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) and (max-height: 720px) {
  .battle-field { flex-basis: clamp(176px, 29svh, 210px); }
  .battle-topbar { min-height: 40px; padding-block: 3px; }
  .prompt-bar { min-height: 33px; padding-top: 2px; }
  .prompt-bubble { min-height: 30px; }
  .prompt-romaji { font-size: 22px; }
  .feedback-bar { min-height: 21px; }
  .choice-btn .choice-kana { font-size: 25px; }
  .ult-btn { min-height: 39px; padding-block: 5px; }
}

@keyframes blade-frame-pulse {
  0%, 100% { opacity: 0.42; filter: brightness(0.8); }
  50% { opacity: 1; filter: brightness(1.35); }
}

@keyframes mobile-answer-correct {
  0% { transform: scale(1); }
  35% { transform: scale(0.94); filter: brightness(2.2); }
  70% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes mobile-answer-wrong {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-1deg); }
  55% { transform: translateX(5px) rotate(1deg); }
  78% { transform: translateX(-3px); }
}

@keyframes mobile-ult-ready {
  0%, 100% { filter: brightness(1); box-shadow: inset 0 0 20px rgba(124,77,255,0.38), 0 0 14px rgba(79,195,247,0.34); background-position: -80% 0, 0 0; }
  48% { filter: brightness(1.28); box-shadow: inset 0 0 28px rgba(255,255,255,0.22), 0 0 24px rgba(124,77,255,0.66); background-position: 170% 0, 0 0; }
}


/* Mobile battle cockpit v2.1 compact keys */
@media (max-width: 600px) {
  .battle-field {
    flex: 1 1 auto;
    min-height: 0;
  }

  .battle-bottom {
    display: block;
    flex: 0 0 auto;
    min-height: 0;
  }

  .choices-section {
    display: block;
    padding: 2px 9px 4px;
  }

  .choices-grid {
    grid-template-rows: repeat(2, clamp(58px, 8.2svh, 68px));
  }

  .choice-btn {
    height: auto;
  }
}

/* Portrait battle stack: enemy 30%, hero 30%, controls 40%. */
@media (max-width: 600px), (orientation: portrait) {
  #screen-battle.active {
    position: relative;
    display: grid;
    grid-template-rows: 60svh 40svh;
    height: 100svh;
    min-height: 0;
  }

  .battle-topbar {
    position: absolute;
    inset: 0 0 auto;
    z-index: 20;
    min-height: 40px;
    background: linear-gradient(180deg, rgba(3, 5, 18, 0.96), rgba(3, 5, 18, 0.72));
    backdrop-filter: blur(7px);
  }

  .retreat-btn {
    font-size: 13px;
  }

  .battle-stage-name {
    font-size: 16px;
    font-weight: 900;
  }

  .battle-score-display {
    font-size: 14px;
  }

  #screen-battle.active > .battle-field {
    display: grid !important;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    grid-template-columns: minmax(0, 1fr);
    grid-auto-flow: row;
    width: 100%;
    height: 60svh;
    min-height: 0;
    overflow: hidden;
  }

  #screen-battle.active .field-enemy,
  #screen-battle.active .field-hero {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    isolation: isolate;
  }

  #screen-battle.active .field-enemy {
    grid-row: 1;
    grid-column: 1;
    background:
      linear-gradient(180deg, rgba(92, 10, 16, 0.16), rgba(50, 4, 10, 0.64)),
      radial-gradient(90% 100% at 50% 40%, rgba(239, 83, 80, 0.24), transparent 72%);
    border-bottom: 1px solid rgba(255, 112, 67, 0.6);
  }

  #screen-battle.active .field-hero {
    grid-row: 2;
    grid-column: 1;
    background:
      linear-gradient(180deg, rgba(5, 24, 76, 0.2), rgba(3, 12, 48, 0.72)),
      radial-gradient(90% 100% at 50% 42%, rgba(79, 195, 247, 0.23), transparent 72%);
    border-bottom: 1px solid rgba(79, 195, 247, 0.68);
  }

  .field-enemy::before,
  .field-hero::before {
    content: "";
    position: absolute;
    inset: auto 0 0;
    z-index: 2;
    height: 48%;
    pointer-events: none;
    background: linear-gradient(180deg, transparent, rgba(3, 5, 18, 0.92));
  }

  .hero-img-wrap,
  .enemy-img-wrap {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .hero-img-wrap img,
  .enemy-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: var(--portrait-focus, 50% 20%);
  }

  .field-name {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 21px;
    z-index: 5;
    max-width: none;
    margin: 0;
    color: #fff;
    font-size: 16px;
    font-weight: 900;
    line-height: 1;
    text-align: left;
    text-shadow: 0 2px 7px #000;
  }

  .enemy-name-tag { color: #ffb4aa; }
  .hero-name-tag { color: #bdeaff; }

  #screen-battle.active .field-enemy .field-name {
    top: 62px;
    bottom: auto;
  }

  .side-status {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    width: auto;
    margin: 0;
    gap: 0;
  }

  #screen-battle.active .field-enemy .side-status {
    top: 44px;
    bottom: auto;
  }

  .status-row,
  .atb-row {
    display: block;
    min-height: 0;
    height: auto;
    gap: 0;
  }

  .side-status .sb-label,
  .side-status .sb-val,
  .side-status .atb-skull,
  .side-status .atb-count {
    display: none;
  }

  .side-status .hp-bar-outer,
  .side-status .ult-bar-outer,
  .atb-row .atb-bar-outer {
    width: 100%;
    border-radius: 0;
    border-inline: 0;
    box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.72);
  }

  .side-status .hp-bar-outer {
    height: 7px;
  }

  .side-status .ult-bar-outer,
  .atb-row .atb-bar-outer {
    height: 5px;
    margin: 0;
  }

  .side-status .hp-bar-inner,
  .side-status .ult-bar-inner,
  .side-status .atb-bar-inner {
    border-radius: 0;
  }

  .enemy-status .hp-bar-inner {
    background: linear-gradient(90deg, #7f1018, #ff374b 72%, #ff8a80);
  }

  .enemy-status .atb-bar-inner {
    background: linear-gradient(90deg, #8e2a00, #ff5a1f 68%, #ffd166);
  }

  .hero-status .hp-bar-inner {
    background: linear-gradient(90deg, #087f5b, #45d483 68%, #a7f3d0);
  }

  .hero-status .ult-bar-inner {
    background: linear-gradient(90deg, #4527a0, #7c4dff 62%, #4fc3f7);
  }

  .field-center {
    z-index: 9;
  }

  .vs-text {
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    color: rgba(225, 235, 255, 0.72);
  }

  #combo-display {
    top: 19%;
  }

  .battle-bottom {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    width: 100%;
    height: 40svh;
    min-height: 0;
    max-height: 40svh;
    overflow: hidden;
  }

  .choices-section {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }

  .choices-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, clamp(70px, 9.2svh, 82px));
    align-content: center;
    min-height: 0;
  }

  .choice-btn {
    height: 100%;
    min-height: 0;
    padding-block: 1px;
  }

  .choice-btn .choice-kana {
    font-size: clamp(23px, 7vw, 32px);
  }

  .prompt-bar {
    min-height: 64px;
    padding: 2px 9px;
  }

  .prompt-bubble {
    min-width: min(78vw, 330px);
    min-height: 60px;
    padding: 5px 18px;
    gap: 1px;
    border-width: 2px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: inherit;
  }

  .prompt-romaji,
  .prompt-hint {
    width: 100%;
    text-align: center;
  }

  .prompt-bubble:disabled {
    opacity: 1;
    cursor: default;
  }

  .prompt-bubble.audio-question {
    cursor: pointer;
    animation: audio-callout 1.4s ease-in-out infinite;
  }

  .prompt-romaji {
    font-size: clamp(34px, 11vw, 46px);
    line-height: 1;
  }

  .prompt-hint {
    min-height: 18px;
    font-size: 15px;
    font-weight: 800;
    color: #d9e5ff;
  }

  .prompt-hint:empty {
    display: none;
  }

  .feedback-bar {
    min-height: 34px;
    padding: 1px 8px;
  }

  .feedback-msg {
    padding: 5px 12px;
    font-size: 14px;
    line-height: 1.15;
  }

  .choices-section {
    padding-top: 0;
  }

  .choices-label {
    display: none;
  }

  .choices-grid {
    gap: 5px 7px;
  }

  .ult-btn-wrap {
    padding-top: 3px;
    padding-bottom: max(5px, env(safe-area-inset-bottom));
  }

  .ult-btn {
    min-height: 36px;
    padding-block: 4px;
  }
}

@media (max-width: 600px) and (max-height: 720px) {
  .battle-field { flex: 1 1 auto; min-height: 0; }
  .choices-grid { grid-template-rows: repeat(2, 56px); }
}


/* Mobile ultimate damage visibility */
#ult-damage-display {
  position: absolute;
  left: 72%;
  top: 49%;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 190px;
  padding: 10px 18px 12px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.45);
  border: 2px solid rgba(255, 213, 79, 0.92);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
  color: #fff7cf;
  background: radial-gradient(circle at 50% 35%, rgba(255, 213, 79, 0.28), transparent 58%), rgba(10, 7, 20, 0.86);
  box-shadow: 0 0 12px #fff, 0 0 34px rgba(255, 213, 79, 0.95), inset 0 0 18px rgba(255, 213, 79, 0.22);
  text-align: center;
  pointer-events: none;
}

#ult-damage-display strong {
  color: #fff;
  font-size: clamp(40px, 9vw, 74px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-shadow: 0 3px 0 #8c4b00, 0 0 12px #fff, 0 0 28px #ffd54f;
}

#ult-damage-display span {
  margin-top: 8px;
  color: #fff2aa;
  font-size: clamp(12px, 2.6vw, 18px);
  font-weight: 900;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 5px #000;
}

#ult-damage-display.show {
  animation: ult-damage-boom 1.55s cubic-bezier(0.16, 1, 0.3, 1) 0.18s both;
}

@keyframes audio-callout {
  0%, 100% { filter: brightness(0.92); box-shadow: 0 0 8px rgba(79, 195, 247, 0.2); }
  50% { filter: brightness(1.24); box-shadow: 0 0 18px rgba(79, 195, 247, 0.58); }
}

@keyframes ult-damage-boom {
  0%, 10% { opacity: 0; transform: translate(-50%, -50%) scale(0.35); filter: blur(8px); }
  28% { opacity: 1; transform: translate(-50%, -50%) scale(1.22); filter: blur(0); }
  46% { transform: translate(-50%, -50%) scale(0.96); }
  62%, 86% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -64%) scale(0.92); }
}

@media (max-width: 700px) {
  #ult-damage-display {
    left: 68%;
    top: 52%;
    min-width: 148px;
    padding: 8px 12px 10px;
  }

  #ult-damage-display strong { font-size: clamp(38px, 12vw, 58px); }
  #ult-damage-display span { font-size: 11px; }
}


/* Disable browser long-press and selection menus on the game surface. */
html,
body,
button,
img,
canvas,
.screen,
.screen * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

img,
svg {
  -webkit-user-drag: none;
  user-drag: none;
}
