/* DigiTech Lessons boss battle game: tiles, locks, dialogs, trophy cabinet and the battle itself.
   Used by the home page. After changing this file, bump the ?v= number where it is linked. */
html { overflow-x: hidden; }
#logo { cursor: default; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }

/* ---------- trophy button under the year row ---------- */
.tool-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; max-width: 460px; margin: 10px auto 0; }
.tool-btn { display: flex; align-items: center; justify-content: center; gap: 6px; height: 52px; padding: 0 14px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary2); background: var(--bg2); border: 1px solid var(--border); border-radius: 2px; cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s; }
.tool-btn svg { width: 16px; height: 16px; }
.tool-btn:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 0 14px rgba(52, 225, 255, 0.25); outline: none; }
.tool-btn:focus-visible { border-color: var(--primary); box-shadow: 0 0 14px rgba(52, 225, 255, 0.25); outline: none; }
.trophy-btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; height: 52px; padding: 0 10px; white-space: nowrap; font-family: var(--display); font-size: 12px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: #ffd447; background: linear-gradient(90deg, rgba(255, 198, 26, 0.08), rgba(255, 198, 26, 0.16), rgba(255, 198, 26, 0.08)), var(--bg2); border: 1px solid rgba(255, 198, 26, 0.45); border-radius: 2px; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; }
.trophy-btn svg, .tool-btn svg { flex: none; }
.trophy-btn svg { width: 24px; height: 24px; }
.trophy-btn small { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--muted); }
@media (max-width: 560px) {
  .tool-btn { width: 52px; padding: 0; }
  .tool-btn span { display: none; }
  .tool-btn svg { width: 20px; height: 20px; }
  .trophy-btn { letter-spacing: 0.1em; gap: 8px; }
}
@media (max-width: 340px) { .trophy-btn { font-size: 11px; letter-spacing: 0.06em; } }
.trophy-btn:hover { transform: translateY(-1px); border-color: #ffd447; box-shadow: 0 0 20px rgba(255, 198, 26, 0.3); }
.trophy-btn:focus-visible { border-color: #ffd447; box-shadow: 0 0 20px rgba(255, 198, 26, 0.3); }

/* ---------- quest tiles ---------- */
.q-slot { position: relative; }
.tiles .tile { grid-template-rows: 10px minmax(0, 1fr) auto auto; }
.q-slot:not(.is-soon) .tile { transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, filter 0.2s; }
.q-slot:not(.is-soon):hover .tile, .q-slot:focus-within .tile { transform: translateY(-4px); border-color: var(--tp); box-shadow: 0 10px 30px -8px color-mix(in srgb, var(--tp) 55%, transparent), 0 0 0 1px var(--tp); }
.q-slot:hover .tile-icon svg { transform: scale(1.06) rotate(-3deg); }
a.tile-icon { text-decoration: none; }
.q-num { position: absolute; top: 18px; left: 11px; z-index: 2; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--muted); pointer-events: none; }
.q-corner { position: absolute; top: 16px; right: 10px; z-index: 2; width: 26px; pointer-events: none; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6)); }
.q-corner svg { width: 100%; height: auto; display: block; }
.q-lock { animation: lockGlint 3.2s ease-in-out infinite; }
@keyframes lockGlint { 0%, 80%, 100% { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6)); } 90% { filter: drop-shadow(0 0 10px #ffd447); } }
.q-trophy { width: 28px; }
.t-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; height: 34px; margin: 10px; }
.t-actions:has(> :only-child) { grid-template-columns: 1fr; }
.t-btn { display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; height: 100%; padding: 0 6px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none; white-space: nowrap; border-radius: 2px; cursor: pointer; transition: background 0.15s, box-shadow 0.15s, transform 0.15s; }
.t-start { color: var(--tb); background: var(--tp); border: 1px solid var(--tp); font-weight: 700; }
.t-start:hover, .t-start:focus-visible { box-shadow: 0 0 16px color-mix(in srgb, var(--tp) 70%, transparent); outline: none; }
.t-boss { color: var(--tp2); background: color-mix(in srgb, var(--tp) 12%, transparent); border: 1px solid color-mix(in srgb, var(--tp) 45%, transparent); }
.t-boss:hover, .t-boss:focus-visible { background: color-mix(in srgb, var(--tp) 25%, transparent); border-color: var(--tp); outline: none; }
.is-beaten .tile { border-color: var(--tp); box-shadow: 0 0 0 1px var(--tp), 0 0 24px -6px var(--tp); }
.is-beaten .t-boss { color: #ffd447; border-color: rgba(255, 212, 71, 0.5); background: rgba(255, 212, 71, 0.08); }
.q-locked { cursor: pointer; border-style: dashed !important; }
.q-locked .tile-icon svg { filter: grayscale(0.85) brightness(0.6); }
.q-locked .tile-name { color: #aab4c5; }
.q-locked::before { filter: grayscale(0.8) brightness(0.7); }
.t-code { color: #ffd447; background: rgba(255, 198, 26, 0.08); border: 1px solid rgba(255, 198, 26, 0.45); }
.t-code:hover, .t-code:focus-visible { background: rgba(255, 198, 26, 0.18); border-color: #ffd447; outline: none; }
.is-soon .tile-boss { color: var(--muted); }
.just-unlocked .tile { animation: unlockPop 0.8s; }
@keyframes unlockPop { 0% { transform: scale(0.94); box-shadow: 0 0 0 0 #ffd447; } 40% { transform: scale(1.04); box-shadow: 0 0 40px 6px #ffd447; } }
.world .xp-text { min-width: 110px; }

/* ---------- shared buttons ---------- */
.q-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 190px; height: 46px; padding: 0 18px; font-family: var(--display); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; text-decoration: none; color: var(--tb, var(--bg)); background: var(--tp, var(--primary)); border: 1px solid var(--tp, var(--primary)); border-radius: 3px; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
/* hover lifts a button; keyboard focus only glows, so a focused button never sits out of line with the one beside it */
.q-btn:hover { transform: translateY(-1px); box-shadow: 0 0 22px color-mix(in srgb, var(--tp, var(--primary)) 55%, transparent); }
.q-btn:focus-visible { box-shadow: 0 0 0 2px var(--bg, #070a12), 0 0 0 4px var(--tp, var(--primary)), 0 0 22px color-mix(in srgb, var(--tp, var(--primary)) 55%, transparent); outline: none; }
.q-btn.ghost { background: transparent; color: var(--tp, var(--primary)); }
.q-btn.small { min-width: 0; height: 34px; font-size: 10px; padding: 0 12px; }

/* ---------- small dialogs ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(3, 5, 10, 0.8); backdrop-filter: blur(4px); }
dialog.small { margin: auto; padding: 0; overflow: hidden; border-radius: 6px; }
#code-dlg { width: min(430px, calc(100vw - 32px)); border: 1px solid var(--tp); background: var(--tb); box-shadow: 0 0 60px -10px var(--tp); }
.code-box { padding: 26px 24px 22px; text-align: center; }
.code-box h3 { font-family: var(--tf); font-weight: var(--tw); text-transform: uppercase; color: var(--tp2); font-size: 20px; margin: 12px 0 6px; }
.code-box p { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.code-box .code-how { color: #ffd447; font-size: 13px; }
.code-box label { display: block; margin: 16px 0 6px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--tp); }
.code-box input { width: 100%; height: 48px; padding: 0 12px; text-align: center; font-family: var(--mono); font-size: 20px; letter-spacing: 0.18em; text-transform: uppercase; color: #fff; background: var(--tb2); border: 1px solid color-mix(in srgb, var(--tp) 50%, transparent); border-radius: 3px; }
.code-box input:focus { outline: none; border-color: var(--tp); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tp) 25%, transparent); }
.code-msg { min-height: 1.6em; margin-top: 8px; color: var(--tp2) !important; }
.code-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.code-row .q-btn { min-width: 0; }
.code-icon { position: relative; width: 84px; margin: 0 auto; }
.code-icon > svg { width: 84px; height: 84px; border-radius: 18%; filter: grayscale(0.85) brightness(0.6); transition: filter 0.5s; }
.code-icon .q-lock { position: absolute; right: -14px; top: -14px; width: 38px; transition: transform 0.6s cubic-bezier(.3, 1.6, .5, 1), opacity 0.6s; }
.code-icon .q-lock svg { width: 100%; height: auto; display: block; }
.code-icon.opened .q-lock { transform: translate(30px, -40px) rotate(35deg); opacity: 0; }
.code-icon.opened > svg { filter: none; }
.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

#teacher-dlg { width: min(620px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); border: 1px solid #ffd447; background: var(--bg); box-shadow: 0 0 60px -10px rgba(255, 212, 71, 0.6); }
.teacher { display: flex; flex-direction: column; max-height: calc(100dvh - 40px); }
.teacher header { padding: 20px 24px 12px; text-align: center; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.teacher header h3 { font-family: var(--display); font-size: 18px; letter-spacing: 0.12em; text-transform: uppercase; color: #ffd447; }
.teacher header p { color: var(--muted); font-size: 13px; margin-top: 4px; }
#teacher-codes { overflow-y: auto; padding: 8px 24px 16px; }
#teacher-codes h4 { font-family: var(--display); font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; margin: 14px 0 6px; }
#teacher-codes table { width: 100%; border-collapse: collapse; font-size: 14px; }
#teacher-codes td { padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
#teacher-codes td:first-child { width: 36px; font-family: var(--mono); color: var(--muted); }
#teacher-codes td:last-child { text-align: right; white-space: nowrap; }
#teacher-codes code { font-family: var(--mono); font-size: 15px; letter-spacing: 0.1em; color: #ffd447; }
#teacher-codes em { color: var(--muted); font-size: 12px; }
.teacher footer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px 24px 20px; border-top: 1px solid rgba(255, 255, 255, 0.08); --tp: #ffd447; --tb: #070a12; }
.teacher footer .q-btn { min-width: 0; font-size: 10px; padding: 0 8px; }

#trophy-dlg { margin: auto; padding: 0; overflow: hidden; border-radius: 6px; width: min(1120px, calc(100vw - 24px)); height: fit-content; max-width: none; max-height: none; border: 1px solid rgba(255, 198, 26, 0.5); background: radial-gradient(ellipse 70% 50% at 50% 0%, rgba(255, 198, 26, 0.12), transparent 70%), var(--bg); }
.trophy-wrap { display: flex; flex-direction: column; }
.trophy-wrap header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid rgba(255, 198, 26, 0.2); }
.trophy-wrap h3 { font-family: var(--display); font-size: clamp(15px, 2.4vw, 20px); letter-spacing: 0.12em; text-transform: uppercase; color: #ffd447; }
.trophy-wrap h3 small { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; color: var(--muted); margin-top: 2px; }
.cab-wrap { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: calc(100dvh - 190px); background: radial-gradient(ellipse 70% 60% at 50% 40%, #1c2438, #121829); }
#cabinet canvas { opacity: 0; transition: opacity 0.4s; }
#cabinet canvas.ready { opacity: 1; }
.cab-loading { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: #ffd447; pointer-events: none; }
.cab-loading i { width: 34px; height: 34px; border: 3px solid rgba(255, 212, 71, 0.2); border-top-color: #ffd447; border-radius: 50%; animation: spin 0.8s linear infinite; }
.cab-wrap.loading .cab-loading { display: flex; }
#cabinet { position: absolute; inset: 0; }
#cabinet canvas { display: block; width: 100%; height: 100%; }
.cab-legend { display: flex; justify-content: center; gap: 22px; flex-wrap: nowrap; white-space: nowrap; padding: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); border-top: 1px solid rgba(255, 198, 26, 0.2); }
.tip { position: absolute; z-index: 5; transform: translate(-50%, calc(-100% - 16px)); padding: 8px 12px; font-family: var(--mono); font-size: 12px; line-height: 1.5; text-align: center; color: var(--text); background: rgba(7, 10, 18, 0.94); border: 1px solid var(--border); border-radius: 3px; pointer-events: none; white-space: nowrap; }
.fallback { display: none; padding: 40px 16px; text-align: center; color: var(--muted); }
.no-3d #cabinet { display: none; } .no-3d .fallback { display: block; }
.x-btn { display: grid; place-items: center; padding: 0; width: 42px; height: 42px; flex: none; color: var(--text); background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 3px; cursor: pointer; }
.x-btn:hover, .x-btn:focus-visible { border-color: #fff; }
html.dlg-open, html.modal-open { overflow: hidden; }

#toast { inset: auto; margin: 0; color: var(--text); overflow: visible; position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%); width: max-content; max-width: min(480px, calc(100vw - 32px)); padding: 12px 18px; font-size: 14px; text-align: center; background: rgba(7, 10, 18, 0.96); border: 1px solid var(--border); border-radius: 3px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }

#toast[hidden] { display: none; }

/* ==================== BATTLE ==================== */
html.modal-open .container, html.modal-open .site-footer, html.modal-open .to-top { visibility: hidden; }
.battle { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; display: none; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; background: var(--tb); }
.battle[open] { display: grid; }
.battle::backdrop { background: #000; }
.b-top { position: relative; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; background: linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.25)); border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.b-top::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: linear-gradient(90deg, var(--tp), var(--ts), var(--tp)); }
.b-title { display: flex; flex-direction: column; line-height: 1.15; padding-top: 2px; min-width: 0; }
.b-title small { font-family: var(--mono); font-size: 10px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--ts); white-space: nowrap; }
.b-title b { font-family: var(--tf); font-weight: var(--tw); font-size: clamp(16px, 3vw, 22px); text-transform: uppercase; color: var(--tp2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-tools { display: flex; gap: 8px; }
.b-icon { display: grid; place-items: center; padding: 0; width: 42px; height: 42px; font-size: 18px; line-height: 1; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 50%; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.b-icon svg { width: 20px; height: 20px; }
.b-icon:hover, .b-icon:focus-visible { border-color: var(--tp); background: rgba(255, 255, 255, 0.12); outline: none; }

.b-stage { position: relative; overflow: hidden; min-height: 210px; container-type: size; }
.arena-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.arena-art .layers { animation: drift 10s ease-in-out infinite alternate; }
.arena-art .bokeh { animation: drift 7s ease-in-out infinite alternate-reverse; }
@keyframes drift { to { transform: translateY(-16px); } }
.b-stage::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: radial-gradient(ellipse 75% 70% at 50% 55%, transparent 55%, rgba(0, 0, 0, 0.55)); }
.b-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; }

.b-hud { position: absolute; left: 0; right: 0; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 18px; }
.b-glass { padding: 8px 12px; background: rgba(8, 11, 20, 0.55); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 10px; backdrop-filter: blur(8px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.b-player { display: flex; align-items: center; gap: 10px; }
.b-tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.b-lives { display: flex; gap: 6px; }
.heart { display: block; width: 26px; transition: transform 0.4s, filter 0.4s, opacity 0.4s; filter: drop-shadow(0 0 6px rgba(255, 59, 92, 0.6)); }
.heart svg { width: 100%; height: auto; display: block; }
.heart.lost { filter: grayscale(1) brightness(0.4); opacity: 0.5; transform: scale(0.8) rotate(-12deg); animation: heartBreak 0.5s; }
@keyframes heartBreak { 0% { transform: scale(1.4); filter: brightness(2); } }
.b-bosshud { width: min(46%, 480px); }
.b-hp-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.b-hp-name { font-family: var(--tf); font-weight: var(--tw); font-size: clamp(11px, 1.8vw, 15px); text-transform: uppercase; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-hp-num { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.b-hp-bar { position: relative; height: 14px; border-radius: 7px; background: rgba(0, 0, 0, 0.6); overflow: hidden; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7); }
.b-hp-bar i { position: absolute; right: 0; top: 0; bottom: 0; width: 100%; border-radius: 7px; }
.b-hp-bar .ghost { background: #fff; opacity: 0.6; transition: width 0.7s ease-in; }
.b-hp-bar .fill { background: linear-gradient(90deg, #ff3b5c, var(--ts)); box-shadow: 0 0 12px var(--ts); transition: width 0.25s ease-out; }
.b-hp-bar .fill::after { content: ""; position: absolute; left: 0; right: 0; top: 2px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.35); }
.b-hp-bar::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(100% / var(--n) - 2px), rgba(0, 0, 0, 0.45) calc(100% / var(--n) - 2px) calc(100% / var(--n))); }

.b-hero, .b-boss { position: absolute; bottom: 9%; z-index: 2; }
/* sized by the arena's width AND height (cqh), so a short arena never pushes them under the health bars */
.b-hero { left: 9%; width: min(clamp(84px, 13vw, 150px), 40cqh); }
.b-boss { right: 8%; width: min(clamp(160px, 27vw, 330px), 60cqh); }
.b-hero > svg, .b-boss > svg { width: 100%; height: auto; display: block; overflow: visible; }
.b-hero > svg { animation: breathe 2.6s ease-in-out infinite; transform-origin: 50% 100%; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 14px color-mix(in srgb, var(--tp) 40%, transparent)); }
.b-boss > svg { animation: breathe 3.2s ease-in-out infinite; transform-origin: 50% 100%; filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.55)); }
@keyframes breathe { 50% { transform: translateY(-8px) scale(1.02, 0.98); } }
.b-hero .glow { animation: glow 0.9s ease-in-out infinite alternate; }
@keyframes glow { to { opacity: 0.45; } }
.spin { animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.b-boss .aura { animation: aura 2.4s ease-in-out infinite; transform-origin: center; }
@keyframes aura { 50% { opacity: 0.55; transform: scale(0.94); } }
.b-boss .pupil { animation: look 4s ease-in-out infinite; }
@keyframes look { 0%, 100% { transform: translateX(0); } 40% { transform: translateX(-4px); } 70% { transform: translateX(3px); } }
.b-boss .eyes { animation: blink 5s infinite; transform-origin: 110px 102px; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(0.1); } }
.b-boss .glitch { animation: glitch 3.5s steps(1) infinite; }
@keyframes glitch { 0%, 92%, 100% { transform: none; } 93% { transform: translateX(-5px) skewX(6deg); } 95% { transform: translateX(4px); } 97% { transform: translateX(-2px) skewX(-4deg); } }
.enraged .b-boss > svg { filter: drop-shadow(0 0 22px #ff2a2a) drop-shadow(0 14px 22px rgba(0, 0, 0, 0.55)) saturate(1.4); animation-duration: 0.9s; }
.battle.shake .b-stage { animation: shake 0.4s; }
.battle.shake .b-stage::before { content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none; background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 0, 40, 0.45)); animation: fadeout 0.6s forwards; }
.battle.flash .b-stage::before { content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none; background: #fff; animation: flash 0.25s forwards; }
@keyframes flash { from { opacity: 0.35; } to { opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }
.battle.lost .b-stage::before { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(ellipse at 70% 60%, rgba(255, 40, 60, 0.18), rgba(0, 0, 0, 0.55)); animation: fadeIn 1.2s both; }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------- character animations ----------
   Each boss file picks one boss style and one hero style (style: { boss, hero }). Every style has its own idle,
   attack, hit, enrage, defeat and victory. The game sets data-anim on the character for each moment. */
/* boss style "blob" (Spaghetti Monster): wobbles, whips, squashes when hit, unravels into a puddle */
.boss-blob > svg { animation: spgIdle 2.8s ease-in-out infinite; }
@keyframes spgIdle { 0%, 100% { transform: skewX(0) scale(1, 1); } 25% { transform: skewX(-3deg) scale(1.03, 0.97); } 50% { transform: translateY(-6px) scale(0.98, 1.03); } 75% { transform: skewX(3deg) scale(1.02, 0.98); } }
.battle .boss-blob[data-anim="attack"] > svg { animation: spgAttack 0.8s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes spgAttack { 30% { transform: scale(0.88, 1.18) rotate(-8deg); } 55% { transform: translateX(-60px) scale(1.18, 0.9) rotate(12deg); } 75% { transform: translateX(-20px) rotate(-4deg); } }
.battle .boss-blob[data-anim="hit"] > svg { animation: spgHit 0.7s ease-out; }
@keyframes spgHit { 0% { filter: brightness(4) saturate(0); transform: scale(1.3, 0.65) translateY(30px); } 30% { transform: scale(0.85, 1.2) skewX(10deg); } 55% { transform: scale(1.08, 0.93) skewX(-6deg); } 80% { transform: skewX(3deg); } }
.battle .boss-blob[data-anim="enrage"] > svg { animation: spgEnrage 0.8s; }
@keyframes spgEnrage { 20%, 60% { transform: scale(1.25) rotate(-4deg); filter: brightness(1.6) hue-rotate(-30deg); } 40%, 80% { transform: scale(1.2) rotate(4deg); } }
.battle .boss-blob[data-anim="defeat"] > svg { animation: spgDefeat 1.6s forwards; }
@keyframes spgDefeat { 15% { transform: scale(1.2, 0.8) rotate(-10deg); filter: brightness(3); } 35% { transform: scale(0.9, 1.15) rotate(8deg); } 70% { transform: translateY(40px) scale(1.5, 0.15); filter: brightness(1.5); opacity: 1; } 100% { transform: translateY(50px) scale(1.7, 0.05); opacity: 0; } }
.battle .boss-blob[data-anim="victory"] > svg { animation: spgVictory 0.7s ease-in-out infinite; }
@keyframes spgVictory { 0%, 100% { transform: translateY(0) scale(1.05, 0.95); } 40% { transform: translateY(-34px) rotate(-8deg) scale(0.95, 1.08); } 70% { transform: translateY(-20px) rotate(8deg); } }

/* boss style "ghost" (404 Phantom): floats and glitches, teleports to attack, flickers when hit, switches off like an old screen */
.boss-ghost > svg { animation: phIdle 3.6s ease-in-out infinite; }
@keyframes phIdle { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-18px) rotate(2deg); } }
.battle .boss-ghost[data-anim="attack"] > svg { animation: phAttack 0.8s steps(1, end), phMove 0.8s ease-in-out; }
@keyframes phAttack { 20% { opacity: 0.2; } 30% { opacity: 0; } 45% { opacity: 1; filter: brightness(2) drop-shadow(-6px 0 0 #ff2e6d) drop-shadow(6px 0 0 #2ef0ff); } 70% { filter: none; } }
@keyframes phMove { 45% { transform: translateX(-80px) scale(1.15); } 70% { transform: translateX(-60px) scale(1.1); } }
.battle .boss-ghost[data-anim="hit"] > svg { animation: phHit 0.6s steps(2, end); }
@keyframes phHit { 0% { filter: brightness(4) drop-shadow(-8px 0 0 #ff2e6d) drop-shadow(8px 0 0 #2ef0ff); transform: translateX(14px) skewX(-12deg); } 25% { opacity: 0.3; transform: translateX(-10px) skewX(10deg); } 50% { opacity: 1; filter: hue-rotate(90deg); transform: translateX(6px); } 75% { opacity: 0.6; } }
.battle .boss-ghost[data-anim="enrage"] > svg { animation: phEnrage 0.8s; }
@keyframes phEnrage { 30%, 70% { transform: scale(1.25); filter: brightness(1.5) drop-shadow(0 0 30px #ff2a2a); } 50% { transform: scale(1.18) skewX(6deg); } }
.battle .boss-ghost[data-anim="defeat"] > svg { animation: phDefeat 1.4s forwards; }
@keyframes phDefeat { 10%, 30% { filter: brightness(2) drop-shadow(-8px 0 0 #ff2e6d) drop-shadow(8px 0 0 #2ef0ff); transform: skewX(14deg); } 20% { transform: skewX(-14deg); } 60% { transform: scale(1.3, 0.03); filter: brightness(5); } 85% { transform: scale(0.02, 0.02); opacity: 1; } 100% { transform: scale(0, 0); opacity: 0; } }
.battle .boss-ghost[data-anim="victory"] > svg { animation: phVictory 1.1s ease-in-out infinite; }
@keyframes phVictory { 0%, 100% { transform: rotate(-10deg) translateY(0); } 50% { transform: rotate(10deg) translateY(-24px) scale(1.08); } }

/* hero style "hover" (printer hot end): plunges down to fire, gets knocked back, hops when it wins, droops when it loses */
.battle .hero-hover[data-anim="attack"] > svg { animation: nzAttack 0.7s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes nzAttack { 30% { transform: translateY(-26px) scale(0.95); } 55% { transform: translate(30px, 10px) scale(1.08, 0.94); } }
.battle .hero-hover[data-anim="hit"] > svg { animation: nzHit 0.6s ease-out; }
@keyframes nzHit { 0% { filter: brightness(3) sepia(1) hue-rotate(-50deg) saturate(5); transform: translateX(-24px) rotate(-16deg); } 40% { transform: translateX(8px) rotate(6deg); } 70% { transform: rotate(-3deg); } }
.battle .hero-hover[data-anim="victory"] > svg { animation: nzVictory 0.8s ease-in-out infinite; }
@keyframes nzVictory { 0%, 100% { transform: translateY(0) scale(1.05, 0.95); } 45% { transform: translateY(-40px) rotate(-6deg) scale(0.96, 1.05); } }
.battle .hero-hover[data-anim="victory"] .spin { animation-duration: 0.15s; }
.battle .hero-hover[data-anim="defeat"] > svg { animation: nzDefeat 1.4s forwards; }
@keyframes nzDefeat { 30% { transform: rotate(10deg); } 100% { transform: translate(-10px, 30px) rotate(-70deg); filter: grayscale(1) brightness(0.5); } }
.battle .hero-hover[data-anim="defeat"] .spin, .battle .hero-hover[data-anim="defeat"] .glow { animation: none; opacity: 0.2; }

/* hero style "pointer" (cursor): clicks to fire, spins when hit, bounces when it wins, falls over when it loses */
.battle .hero-pointer[data-anim="attack"] > svg { animation: cuAttack 0.6s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes cuAttack { 25% { transform: scale(0.82) translateY(8px); } 50% { transform: translateX(36px) scale(1.1) rotate(8deg); } }
.battle .hero-pointer[data-anim="hit"] > svg { animation: cuHit 0.6s ease-out; }
@keyframes cuHit { 0% { filter: brightness(3) sepia(1) hue-rotate(-50deg) saturate(5); transform: rotate(-200deg) translateX(-20px); } 100% { transform: rotate(0); } }
.battle .hero-pointer[data-anim="victory"] > svg { animation: nzVictory 0.7s ease-in-out infinite; }
.battle .hero-pointer[data-anim="defeat"] > svg { animation: cuDefeat 1.2s forwards; }
@keyframes cuDefeat { 40% { transform: rotate(20deg); } 100% { transform: translate(10px, -10px) rotate(75deg) scale(0.9); filter: grayscale(1) brightness(0.5); } }

.b-fx { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.callout { position: absolute; top: 34%; font-family: var(--tf); font-weight: var(--tw); font-size: clamp(20px, 3.6vw, 38px); text-transform: uppercase; white-space: nowrap; animation: callout 1.3s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.callout.mine { left: 12%; color: #fff; -webkit-text-stroke: 1px var(--tp); text-shadow: 0 0 18px var(--tp), 0 4px 0 color-mix(in srgb, var(--tp) 60%, #000); }
.callout.theirs { right: 10%; color: #fff; -webkit-text-stroke: 1px #ff3b5c; text-shadow: 0 0 18px #ff3b5c, 0 4px 0 #7a0016; }
.callout.rage { right: 12%; top: 24%; color: #ff3b3b; text-shadow: 0 0 24px #ff0000; }
.callout.defeat { left: 50%; top: 36%; translate: -50% 0; font-size: clamp(32px, 7vw, 68px); color: #ff6b81; text-shadow: 0 0 30px #ff0030, 0 6px 0 #4a0010; animation-duration: 1.8s; }
.callout.victory { left: 50%; top: 38%; translate: -50% 0; font-size: clamp(36px, 8vw, 80px); color: #fff; text-shadow: 0 0 30px var(--tp), 0 0 60px var(--ts), 0 6px 0 color-mix(in srgb, var(--tp) 50%, #000); animation-duration: 1.6s; }
@keyframes callout { 0% { transform: scale(0.4); opacity: 0; } 18% { transform: scale(1.12); opacity: 1; } 30% { transform: scale(1); } 75% { opacity: 1; } 100% { transform: translateY(-24px); opacity: 0; } }
.dmg { position: absolute; bottom: 52%; font-family: var(--display); font-weight: 900; font-size: 34px; color: #fff; -webkit-text-stroke: 1px #000; text-shadow: 0 0 14px rgba(0, 0, 0, 0.8); animation: rise 1s forwards; }
.dmg.on-boss { right: 20%; } .dmg.on-hero { left: 11%; color: #ff6b81; }
@keyframes rise { 0% { transform: scale(0.5); } 20% { transform: scale(1.2); } 100% { transform: translateY(-70px); opacity: 0; } }

/* VS splash when the fight starts: your project on top, VS in the middle, the boss underneath (full names fit) */
.b-vs { position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2%; padding: 0 5%; text-align: center; background: rgba(0, 0, 0, 0.6); opacity: 0; visibility: hidden; pointer-events: none; }
.b-vs span { max-width: 100%; font-family: var(--tf); font-weight: var(--tw); font-size: clamp(20px, 4.4vw, 46px); line-height: 1.1; text-transform: uppercase; color: #fff; text-wrap: balance; }
.b-vs .vs-l { text-shadow: 0 0 22px var(--tp), 0 4px 0 color-mix(in srgb, var(--tp) 45%, #000); } .b-vs .vs-r { text-shadow: 0 0 22px var(--ts), 0 4px 0 color-mix(in srgb, var(--ts) 45%, #000); }
.b-vs b { font-family: var(--display); font-weight: 900; font-size: clamp(44px, 10vw, 110px); line-height: 1; color: #ffd447; text-shadow: 0 0 30px #ff8a00, 0 6px 0 #7a3d00; }
.vs-show .b-vs { animation: vsIn 1.5s forwards; visibility: visible; }
.vs-show .vs-l { animation: slideDown 1.5s cubic-bezier(.2, 1.2, .4, 1) forwards; }
.vs-show .vs-r { animation: slideUp 1.5s cubic-bezier(.2, 1.2, .4, 1) forwards; }
.vs-show .b-vs b { animation: vsPop 1.5s forwards; }
@keyframes vsIn { 0% { opacity: 0; } 10%, 82% { opacity: 1; } 100% { opacity: 0; } }
@keyframes slideDown { from { transform: translateY(-50px); opacity: 0; } 22% { transform: none; opacity: 1; } }
@keyframes slideUp { from { transform: translateY(50px); opacity: 0; } 22% { transform: none; opacity: 1; } }
@keyframes vsPop { 0% { transform: scale(3); opacity: 0; } 20% { transform: scale(1); opacity: 1; } 28% { transform: scale(1.12); } 36% { transform: scale(1); } }

/* boss style "mech": a heavy machine that hums, stomps forward, throws sparks when hit and collapses in a heap */
.boss-mech > svg { animation: mechIdle 2.4s ease-in-out infinite; }
@keyframes mechIdle { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-4px) rotate(-1deg); } }
.battle .boss-mech[data-anim="attack"] > svg { animation: mechAttack 0.8s cubic-bezier(.4, 1.6, .5, 1); }
@keyframes mechAttack { 30% { transform: translateY(-30px) rotate(-4deg); } 55% { transform: translate(-50px, 6px) scale(1.06, 0.94); } 70% { transform: translate(-40px, 0); } }
.battle .boss-mech[data-anim="hit"] > svg { animation: mechHit 0.6s ease-out; }
@keyframes mechHit { 0% { filter: brightness(4) saturate(0); transform: translateX(18px) rotate(6deg); } 20% { transform: translateX(-8px) rotate(-3deg); } 40% { transform: translateX(5px) rotate(2deg); filter: brightness(1.6); } }
.battle .boss-mech[data-anim="enrage"] > svg { animation: mechEnrage 0.8s steps(2); }
@keyframes mechEnrage { 25%, 75% { transform: translate(3px, -2px) scale(1.12); filter: brightness(1.6) drop-shadow(0 0 20px #ff2a2a); } 50% { transform: translate(-3px, 2px) scale(1.12); } }
.battle .boss-mech[data-anim="defeat"] > svg { animation: mechDefeat 1.6s forwards; transform-origin: 70% 100%; }
@keyframes mechDefeat { 15% { transform: rotate(6deg); filter: brightness(3); } 30% { transform: rotate(-4deg); } 70% { transform: translateY(20px) rotate(28deg); filter: brightness(0.5) grayscale(0.6); opacity: 1; } 100% { transform: translateY(50px) rotate(34deg); filter: brightness(0.3) grayscale(1); opacity: 0; } }
.battle .boss-mech[data-anim="victory"] > svg { animation: mechVictory 0.9s ease-in-out infinite; }
@keyframes mechVictory { 0%, 100% { transform: translateY(0); } 30% { transform: translateY(-26px) rotate(-3deg); } 55% { transform: translateY(0) scale(1.06, 0.94); } }

/* boss style "beast": a creature that breathes heavily, pounces, flinches and topples over */
.boss-beast > svg { animation: beastIdle 2.2s ease-in-out infinite; }
@keyframes beastIdle { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.04, 0.96) translateY(3px); } }
.battle .boss-beast[data-anim="attack"] > svg { animation: beastAttack 0.8s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes beastAttack { 25% { transform: scale(1.1, 0.85) translateY(14px); } 55% { transform: translate(-90px, -40px) rotate(-10deg); } 80% { transform: translate(-30px, 0); } }
.battle .boss-beast[data-anim="hit"] > svg { animation: beastHit 0.6s ease-out; }
@keyframes beastHit { 0% { filter: brightness(4) saturate(0); transform: translateX(22px) skewX(-10deg) scale(0.92, 1.08); } 40% { transform: translateX(-6px) skewX(4deg); } }
.battle .boss-beast[data-anim="enrage"] > svg { animation: beastEnrage 0.9s; }
@keyframes beastEnrage { 20% { transform: scale(0.9, 1.1); } 45%, 70% { transform: scale(1.28) translateY(-10px); filter: brightness(1.5) drop-shadow(0 0 26px #ff2a2a); } }
.battle .boss-beast[data-anim="defeat"] > svg { animation: beastDefeat 1.6s forwards; transform-origin: 50% 100%; }
@keyframes beastDefeat { 20% { transform: rotate(-12deg); filter: brightness(2.5); } 60% { transform: rotate(80deg) translateY(-10px); opacity: 1; } 100% { transform: rotate(92deg) translateY(10px); filter: grayscale(1) brightness(0.4); opacity: 0; } }
.battle .boss-beast[data-anim="victory"] > svg { animation: beastVictory 0.6s ease-in-out infinite; }
@keyframes beastVictory { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-30px) rotate(8deg); } }

/* boss style "royal": a floating ruler or sorcerer that rises and spins to strike, and shatters in light */
.boss-royal > svg { animation: royalIdle 4s ease-in-out infinite; }
@keyframes royalIdle { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-16px) rotate(2deg); } }
.battle .boss-royal[data-anim="attack"] > svg { animation: royalAttack 0.9s ease-in-out; }
@keyframes royalAttack { 35% { transform: translateY(-40px) rotate(-360deg) scale(1.1); filter: brightness(1.8); } 65% { transform: translate(-50px, -10px) scale(1.15); } }
.battle .boss-royal[data-anim="hit"] > svg { animation: royalHit 0.6s steps(3, end); }
@keyframes royalHit { 0% { filter: brightness(4); transform: translateX(16px) rotate(8deg); opacity: 0.6; } 50% { opacity: 1; transform: translateX(-6px) rotate(-4deg); } }
.battle .boss-royal[data-anim="enrage"] > svg { animation: royalEnrage 1s; }
@keyframes royalEnrage { 50% { transform: translateY(-24px) scale(1.25); filter: brightness(1.7) drop-shadow(0 0 30px #ff2a2a); } }
.battle .boss-royal[data-anim="defeat"] > svg { animation: royalDefeat 1.6s forwards; }
@keyframes royalDefeat { 30% { transform: scale(1.3) rotate(10deg); filter: brightness(4) blur(1px); } 100% { transform: translateY(-40px) scale(0.1) rotate(720deg); filter: brightness(6) blur(8px); opacity: 0; } }
.battle .boss-royal[data-anim="victory"] > svg { animation: royalVictory 1.6s linear infinite; }
@keyframes royalVictory { 0% { transform: translateY(-10px) rotateY(0); } 100% { transform: translateY(-10px) rotateY(360deg); } }

/* boss style "swarm": a jittery critter or virus that zips about, scatters when hit and blinks out */
.boss-swarm > svg { animation: swarmIdle 0.5s steps(3) infinite; }
@keyframes swarmIdle { 0%, 100% { transform: translate(0, 0); } 33% { transform: translate(2px, -3px); } 66% { transform: translate(-2px, 1px); } }
.battle .boss-swarm[data-anim="attack"] > svg { animation: swarmAttack 0.7s steps(6); }
@keyframes swarmAttack { 20% { transform: translate(-30px, -20px); } 40% { transform: translate(-60px, 10px); } 60% { transform: translate(-80px, -10px); } 80% { transform: translate(-30px, 5px); } }
.battle .boss-swarm[data-anim="hit"] > svg { animation: swarmHit 0.6s steps(4); }
@keyframes swarmHit { 0% { filter: brightness(4) hue-rotate(90deg); transform: translateX(20px) scale(1.2); } 25% { opacity: 0.2; } 50% { opacity: 1; transform: translateX(-10px) scale(0.9); } 75% { opacity: 0.4; } }
.battle .boss-swarm[data-anim="enrage"] > svg { animation: swarmEnrage 0.8s steps(8); }
@keyframes swarmEnrage { 50% { transform: scale(1.3) rotate(10deg); filter: brightness(1.6) drop-shadow(0 0 22px #ff2a2a); } }
.battle .boss-swarm[data-anim="defeat"] > svg { animation: swarmDefeat 1.4s steps(10) forwards; }
@keyframes swarmDefeat { 10%, 30%, 50%, 70% { opacity: 0; } 20%, 40%, 60% { opacity: 1; transform: scale(0.8) rotate(20deg); } 100% { opacity: 0; transform: scale(0.2); } }
.battle .boss-swarm[data-anim="victory"] > svg { animation: swarmVictory 0.4s steps(4) infinite; }
@keyframes swarmVictory { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-20px) rotate(-10deg); } }

/* boss style "machine": an appliance or screen that vibrates, recoils as it fires, jolts when hit and powers down */
.boss-machine > svg { animation: machineIdle 0.25s linear infinite; }
@keyframes machineIdle { 50% { transform: translate(0.6px, -0.6px); } }
.battle .boss-machine[data-anim="attack"] > svg { animation: machineAttack 0.7s ease-out; }
@keyframes machineAttack { 20% { transform: scale(1.08) translateX(10px); } 35% { transform: translateX(26px) scale(0.95); } 60% { transform: translateX(0); } }
.battle .boss-machine[data-anim="hit"] > svg { animation: machineHit 0.6s steps(3); }
@keyframes machineHit { 0% { filter: brightness(4) saturate(0); transform: translate(14px, -6px) rotate(5deg); } 33% { filter: hue-rotate(120deg); transform: translate(-8px, 4px) rotate(-3deg); } 66% { filter: invert(0.4); } }
.battle .boss-machine[data-anim="enrage"] > svg { animation: machineEnrage 0.8s steps(4); }
@keyframes machineEnrage { 50% { transform: scale(1.15); filter: brightness(1.6) drop-shadow(0 0 24px #ff2a2a); } }
.battle .boss-machine[data-anim="defeat"] > svg { animation: machineDefeat 1.6s forwards; }
@keyframes machineDefeat { 20% { filter: brightness(3); } 40% { filter: brightness(0.6); transform: rotate(-3deg); } 55% { filter: brightness(2); } 100% { filter: brightness(0.15) grayscale(1); transform: translateY(24px) rotate(8deg) scale(0.92); opacity: 0.25; } }
.battle .boss-machine[data-anim="victory"] > svg { animation: machineVictory 0.5s ease-in-out infinite; }
@keyframes machineVictory { 0%, 100% { transform: translateY(0) scale(1); filter: brightness(1); } 50% { transform: translateY(-14px) scale(1.05); filter: brightness(1.4); } }

/* hero style "bot": a little robot or vehicle that hops forward to attack and topples when it loses */
.battle .hero-bot[data-anim="attack"] > svg { animation: botAttack 0.7s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes botAttack { 30% { transform: translateY(-20px) rotate(-6deg); } 60% { transform: translateX(40px) rotate(4deg); } }
.battle .hero-bot[data-anim="hit"] > svg { animation: botHit 0.6s ease-out; }
@keyframes botHit { 0% { filter: brightness(3) sepia(1) hue-rotate(-50deg) saturate(5); transform: translateX(-26px) rotate(-14deg); } 50% { transform: translateX(6px) rotate(4deg); } }
.battle .hero-bot[data-anim="victory"] > svg { animation: botVictory 0.7s ease-in-out infinite; }
@keyframes botVictory { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-36px) rotate(-8deg); } 60% { transform: translateY(-36px) rotate(8deg); } }
.battle .hero-bot[data-anim="defeat"] > svg { animation: botDefeat 1.2s forwards; transform-origin: 30% 100%; }
@keyframes botDefeat { 100% { transform: rotate(-80deg) translateY(-10px); filter: grayscale(1) brightness(0.5); } }

/* hero style "spin": a tool or object that whirls to attack */
.battle .hero-spin[data-anim="attack"] > svg { animation: spinAttack 0.7s ease-in-out; }
@keyframes spinAttack { 60% { transform: rotate(360deg) translateX(20px) scale(1.1); } 100% { transform: rotate(360deg); } }
.battle .hero-spin[data-anim="hit"] > svg { animation: botHit 0.6s ease-out; }
.battle .hero-spin[data-anim="victory"] > svg { animation: spinVictory 1s linear infinite; }
@keyframes spinVictory { 50% { transform: translateY(-30px) rotate(180deg); } 100% { transform: rotate(360deg); } }
.battle .hero-spin[data-anim="defeat"] > svg { animation: botDefeat 1.2s forwards; }

/* hero style "bounce": a soft character that squashes and springs */
.battle .hero-bounce[data-anim="attack"] > svg { animation: bounceAttack 0.7s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bounceAttack { 25% { transform: scale(1.2, 0.75); } 55% { transform: translate(40px, -30px) scale(0.85, 1.2); } }
.battle .hero-bounce[data-anim="hit"] > svg { animation: bounceHit 0.6s ease-out; }
@keyframes bounceHit { 0% { filter: brightness(3) sepia(1) hue-rotate(-50deg) saturate(5); transform: translateX(-20px) scale(1.3, 0.7); } 50% { transform: scale(0.9, 1.1); } }
.battle .hero-bounce[data-anim="victory"] > svg { animation: nzVictory 0.6s ease-in-out infinite; }
.battle .hero-bounce[data-anim="defeat"] > svg { animation: bounceDefeat 1.2s forwards; }
@keyframes bounceDefeat { 100% { transform: translateY(20px) scale(1.4, 0.3); filter: grayscale(1) brightness(0.5); } }

/* question panel: ONE fixed height for every stage (intro, questions, feedback, win, lose) so the arena never jumps */
.battle { --ph: 340px; }
.b-panel { position: relative; z-index: 6; height: var(--ph); box-sizing: border-box; display: flex; align-items: center; justify-content: center; padding: 14px 18px; overflow: hidden; background: linear-gradient(rgba(6, 9, 16, 0.92), rgba(6, 9, 16, 0.98)); border-top: 1px solid rgba(255, 255, 255, 0.1); box-shadow: 0 -20px 40px rgba(0, 0, 0, 0.4); }
.b-q, .b-card { width: 100%; max-width: 880px; margin: 0 auto; text-align: center; }
.b-q { display: flex; flex-direction: column; gap: 10px; }
.b-meta { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 20px; white-space: nowrap; line-height: 20px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.b-meta > :first-child { text-align: left; } .b-meta .b-time { text-align: right; }
.b-time b { display: inline-block; min-width: 1.4em; font-family: var(--display); font-size: 15px; color: #fff; }
.streak { color: #ffb347; letter-spacing: 0.1em; }
.b-timer { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.b-timer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--ts), var(--tp)); border-radius: 3px; transition: width 0.1s linear; }
.hurry .b-timer i { background: #ff3b5c; animation: glow 0.25s ease-in-out infinite alternate; }
.hurry .b-time b { color: #ff6b81; }
/* the question box is always exactly 2 lines tall (3 on phones), so the answers never move */
.b-qtext { --lines: 2; display: flex; align-items: center; justify-content: center; height: calc(var(--lines) * 1.35em); font-size: clamp(16px, 2.2vw, 21px); font-weight: 600; line-height: 1.35; margin: 2px 0 0; color: #fff; overflow: hidden; }
.b-answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.b-ans { display: flex; align-items: center; gap: 12px; height: 56px; padding: 6px 14px; overflow: hidden; font: inherit; font-size: 15px; line-height: 1.3; text-align: left; color: var(--text); background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 10px; cursor: pointer; transition: border-color 0.12s, background 0.12s, box-shadow 0.12s; }
.b-ans span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.b-ans:hover:not(:disabled), .b-ans:focus-visible { border-color: var(--tp); outline: none; background: linear-gradient(180deg, color-mix(in srgb, var(--tp) 18%, transparent), color-mix(in srgb, var(--tp) 6%, transparent)); box-shadow: 0 8px 22px -8px var(--tp); }
.b-ans kbd { flex: none; display: grid; place-items: center; width: 30px; height: 30px; font-family: var(--display); font-size: 13px; font-weight: 900; color: var(--tb); background: linear-gradient(180deg, var(--tp2), var(--tp)); border-radius: 8px; box-shadow: 0 2px 0 color-mix(in srgb, var(--tp) 50%, #000); }
.b-ans.right { border-color: #3ddc84; background: linear-gradient(180deg, rgba(61, 220, 132, 0.28), rgba(61, 220, 132, 0.1)); box-shadow: 0 0 24px -4px #3ddc84; }
.b-ans.right kbd { background: #3ddc84; }
.b-ans.wrong { border-color: #ff4d6a; background: linear-gradient(180deg, rgba(255, 77, 106, 0.26), rgba(255, 77, 106, 0.08)); animation: shake 0.4s; }
.b-ans.wrong kbd { background: #ff4d6a; }
.b-ans:disabled { cursor: default; }
.b-ans:disabled:not(.right):not(.wrong) { opacity: 0.5; }
.b-foot { display: flex; align-items: center; justify-content: center; gap: 14px; height: 40px; }
.b-feedback { min-width: 0; margin: 0; font-size: 14px; line-height: 1.3; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-feedback .ok { color: #3ddc84; } .b-feedback .bad { color: #ff6b81; }
.b-next { flex: none; min-width: 110px; }
.b-card { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.b-card h3 { font-family: var(--tf); font-weight: var(--tw); font-size: clamp(18px, 2.8vw, 26px); text-transform: uppercase; color: #fff; line-height: 1.2; margin: 0; }
.b-card h3 span { color: var(--ts); }
.b-card > p { color: var(--muted); margin: 0; max-width: 640px; }
.b-rules { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 2px 0 0; }
.b-rules li { padding: 7px 12px; font-size: 14px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 20px; white-space: nowrap; }
.b-row { display: flex; justify-content: center; gap: 12px; margin-top: 4px; }
.b-row .q-btn { width: 220px; }
.b-slot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 84px; }
.b-claim { margin: 0; font-size: 14px; color: var(--muted); }
.b-claim b { color: #fff; }
.code-chip { display: inline-flex; align-items: center; gap: 12px; padding: 6px 8px 6px 14px; border: 2px dashed var(--tp); border-radius: 6px; background: color-mix(in srgb, var(--tp) 10%, transparent); animation: popup 0.6s cubic-bezier(.3, 1.8, .5, 1) both; }
.code-chip span { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.code-chip b { font-family: var(--mono); font-size: 21px; letter-spacing: 0.12em; color: #fff; }
.code-chip .q-btn { width: 86px; padding: 0; }

/* the reward appears in the arena, where the boss stood */
.b-reward { position: absolute; left: 0; right: 0; top: 64px; bottom: 6px; z-index: 6; display: grid; place-items: center; }
.b-reward[hidden] { display: none; }
.chest { display: block; background: none; border: 0; padding: 0; cursor: pointer; animation: dropIn 0.7s cubic-bezier(.3, 1.6, .5, 1) both; }
.chest[hidden], .reward-art[hidden] { display: none; }
.chest svg { width: clamp(120px, 16vw, 170px); max-height: 100%; height: auto; overflow: visible; display: block; animation: wiggle 1.4s ease-in-out infinite; filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.6)); }
.chest:focus-visible { outline: 2px solid var(--tp); outline-offset: 6px; border-radius: 8px; }
.chest .lid { transform-origin: 22px 66px; transition: transform 0.45s cubic-bezier(.3, 1.6, .5, 1); }
.chest .light { opacity: 0.35; animation: glow 0.8s ease-in-out infinite alternate; }
.chest.opening .lid { transform: rotate(-40deg) translateY(-6px); }
.chest.opening .light { opacity: 1; animation: none; }
.chest.opening svg { animation: open 0.65s 0.25s forwards; }
@keyframes dropIn { from { transform: translateY(-200px); opacity: 0; } }
@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-8deg); } 86% { transform: rotate(8deg); } 94% { transform: rotate(-4deg); } }
@keyframes open { to { transform: scale(1.5); opacity: 0; } }
.reward-art { height: 100%; max-height: 260px; aspect-ratio: 260 / 210; }
.reward-art svg { width: 100%; height: 100%; filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.6)); }
.reward-art .pop { transform-origin: 130px 150px; animation: popup 0.8s cubic-bezier(.3, 1.8, .5, 1) both; }
@keyframes popup { from { transform: translateY(60px) scale(0.3); opacity: 0; } }

@media (max-width: 760px) {
  .q-num { top: 13px; left: 8px; font-size: 10px; }
  .q-corner { top: 12px; right: 7px; width: 20px; }
  .t-actions { height: 30px; margin: 8px; gap: 4px; }
  .t-btn { font-size: 9.5px; padding: 0 3px; letter-spacing: 0.02em; }
  .b-hud { padding: 10px; }
  .b-glass { padding: 6px 8px; }
  .b-tag { display: none; }
  .heart { width: 22px; }
  .b-bosshud { width: 58%; }
  .battle { --ph: 420px; }
  .b-panel { padding: 10px 12px 14px; }
  .b-q { gap: 8px; }
  .b-answers { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .b-ans { height: 50px; font-size: 14px; padding: 4px 12px; }
  .b-ans kbd { width: 26px; height: 26px; font-size: 12px; }
  .b-qtext { --lines: 3; font-size: 16px; }
  .b-card > p { font-size: 14px; }
  .b-rules li { font-size: 12.5px; padding: 5px 10px; }
  .b-row { width: 100%; }
  .b-row .q-btn { width: auto; flex: 1; min-width: 0; padding: 0 8px; font-size: 11px; }
  .b-foot { height: 44px; }
  .b-feedback { font-size: 13px; }
  .b-next { min-width: 52px; padding: 0 12px; }
  .b-next span { display: none; }
  .b-hero { left: 5%; } .b-boss { right: 4%; }
  .teacher footer { grid-template-columns: 1fr; }
  .trophy-wrap header { padding: 12px 14px; }
  .cab-legend { gap: 12px; font-size: 10px; letter-spacing: 0.06em; padding: 10px 8px; }
}
@media (max-height: 640px) and (min-width: 761px) { .battle { --ph: 300px; } .b-ans { height: 46px; } }
@media (prefers-reduced-motion: reduce) {
  .b-vs, .callout, .dmg { display: none; }
}

/* home intro line: one line; the script at the end of index.html shrinks it to fit, and only a phone lets it wrap */
.header-sub.one-line { max-width: none; white-space: nowrap; }
.header-sub.one-line.wrap { white-space: normal; max-width: 600px; }

/* ==================== the player and the save file ==================== */
/* Import is green, Export is magenta; Export glows with a dot while there is unsaved progress */
.tool-btn.import { --tc: #3ddc97; }
.tool-btn.export { --tc: #ff2ee8; }
.tool-btn.import, .tool-btn.export { color: var(--tc); border-color: color-mix(in srgb, var(--tc) 45%, transparent); background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 10%, transparent), color-mix(in srgb, var(--tc) 4%, transparent)), var(--bg2); position: relative; }
.tool-btn.import:hover, .tool-btn.import:focus-visible, .tool-btn.export:hover, .tool-btn.export:focus-visible { border-color: var(--tc); box-shadow: 0 0 14px color-mix(in srgb, var(--tc) 40%, transparent); }
.tool-btn.export.unsaved { border-color: var(--tc); animation: unsaved 1.6s ease-in-out infinite; }
.tool-btn.export.unsaved::after { content: ''; position: absolute; top: -5px; right: -5px; width: 12px; height: 12px; border-radius: 50%; background: #ff3b5c; border: 2px solid var(--bg); box-shadow: 0 0 8px #ff3b5c; }
@keyframes unsaved { 50% { box-shadow: 0 0 18px color-mix(in srgb, var(--tc) 65%, transparent); } }

/* the player chip: same place as the Home button on the project pages (top left; centred on phones) */
.player-chip { position: absolute; left: 12px; z-index: 12; margin-top: 12px; height: 40px; max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 9px; padding: 0 14px 0 4px; font-family: var(--display); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary2); background: color-mix(in srgb, var(--bg2) 88%, transparent); border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent); border-radius: 3px; cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s; }
.player-chip[hidden] { display: none; }
.player-chip .pc-av { width: 32px; height: 32px; flex: none; }
.player-chip .pc-av svg { width: 100%; height: 100%; display: block; border-radius: 6px; }
.player-chip .pc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-chip:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 0 14px rgba(52, 225, 255, 0.4); outline: none; }
.player-chip:focus-visible { border-color: var(--primary); box-shadow: 0 0 14px rgba(52, 225, 255, 0.4); outline: none; }
@media (max-width: 760px) {
  .player-chip { left: 50%; transform: translateX(-50%); }
  .player-chip:hover { transform: translateX(-50%) translateY(-1px); }
  .player-chip:focus-visible { transform: translateX(-50%); }
  body.has-player .header { padding-top: 70px; }
}

/* player dialogs: welcome, player panel, confirm */
.player-dlg { --tp: #34e1ff; --tb: #070a12; margin: auto; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; color: var(--text); background: linear-gradient(180deg, rgba(52, 225, 255, 0.07), transparent 40%), var(--bg2); border: 1px solid rgba(52, 225, 255, 0.35); border-radius: 6px; box-shadow: 0 0 60px rgba(52, 225, 255, 0.15), 0 0 120px rgba(255, 46, 232, 0.08); }
.player-dlg.small { width: min(440px, calc(100vw - 24px)); }
.player-dlg::before { content: ''; display: block; height: 4px; background: linear-gradient(90deg, #ffb703, #ff2ee8, #34e1ff, #9be564); }
.player-dlg.drop { border-color: #3ddc97; box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.5), 0 0 60px rgba(61, 220, 151, 0.3); }
.pl-box { padding: 24px 26px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pl-box h2, .pl-box h3 { font-family: var(--display); font-weight: 900; text-transform: uppercase; color: #fff; line-height: 1.15; margin: 0; letter-spacing: 0.04em; }
.pl-box h2 { font-size: clamp(22px, 5vw, 30px); }
.pl-box h2 span { background: linear-gradient(90deg, #ffb703, #ff2ee8 50%, #34e1ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pl-box h3 { font-size: 18px; }
.pl-box p { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.55; }
.pl-box p b { color: #fff; }
.pl-label { font-family: var(--mono); font-size: 11px !important; letter-spacing: 0.3em; text-transform: uppercase; color: #ff2ee8 !important; }
.wl-sub { font-size: 15px !important; }
.wl-steps { list-style: none; display: grid; gap: 8px; width: 100%; margin: 6px 0 4px; padding: 0; text-align: left; }
.wl-steps li { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 12px; padding: 10px 14px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 4px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.wl-steps li > b { font-size: 24px; text-align: center; }
.wl-steps strong { display: block; font-family: var(--display); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--primary2); margin-bottom: 2px; }
.wl-steps li:nth-child(3) { border-color: rgba(255, 46, 232, 0.4); background: rgba(255, 46, 232, 0.06); }
.wl-steps li:nth-child(3) strong { color: #ff2ee8; }
.pl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 4px; }
.pl-row .q-btn { min-width: 0; padding: 0 10px; }
.pl-row.foot { margin-top: 2px; }
.q-btn.load-btn { --tp: #3ddc97; }
.q-btn.save-btn { --tp: #ff2ee8; --tb: #fff; }
.pl-msg { min-height: 1.4em; color: #ff8fa3 !important; font-size: 13px !important; }
.pl-msg:empty { min-height: 0; }
.pl-note { font-size: 12px !important; }
.pl-box label { align-self: stretch; font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--primary); margin-top: 4px; }
.pl-box input { width: 100%; height: 50px; padding: 0 14px; text-align: center; font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: 0.08em; color: #fff; background: var(--bg); border: 1px solid rgba(52, 225, 255, 0.35); border-radius: 3px; }
.pl-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(52, 225, 255, 0.25); }
.av-pick { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.av-big { width: 116px; height: 116px; border-radius: 18px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12), 0 0 30px rgba(52, 225, 255, 0.25); }
.av-big svg { width: 100%; height: 100%; display: block; border-radius: 18px; }
.av-big.landed { animation: av-land 0.45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes av-land { 0% { transform: scale(0.85); } 100% { transform: none; } }
.av-pick .q-btn.small { min-width: 130px; --tp: #ffb703; }
.pf-stats { font-family: var(--mono); letter-spacing: 0.1em; text-transform: uppercase; font-size: 13px !important; }
.pf-stats b { color: #ffd447 !important; font-size: 18px; }
.pf-saved.warn { color: #ffb4c2 !important; }
.cf-av { width: 72px; height: 72px; }
.cf-av svg { width: 100%; height: 100%; border-radius: 12px; }
.b-row .q-btn.save-btn { width: 220px; }
@media (max-width: 480px) {
  .pl-box { padding: 20px 16px 18px; }
  .pl-row { grid-template-columns: 1fr; }
  .wl-steps li { grid-template-columns: 30px 1fr; padding: 8px 10px; font-size: 13px; }
  .wl-steps li > b { font-size: 20px; }
}
@media (max-height: 640px) { .av-big { width: 84px; height: 84px; } .wl-steps li { padding: 6px 12px; } }
.wl-steps { grid-auto-rows: 1fr; }
.pl-note.one-line { align-self: stretch; white-space: nowrap; }
.pl-note.one-line.wrap { white-space: normal; }
.pl-row.foot { grid-template-columns: repeat(3, 1fr); }
.pl-row.foot .q-btn { font-size: 10px; letter-spacing: 0.08em; padding: 0 6px; }
.q-btn.reset-btn { --tp: #ff6b81; }
.stay-btn { min-width: 0; gap: 10px; height: 40px; padding: 0 14px 0 4px; margin-top: 2px; }
.stay-btn .cf-av { width: 30px; height: 30px; }
.stay-btn .cf-av svg { border-radius: 6px; display: block; }
@media (max-width: 480px) { .pl-row.foot { grid-template-columns: 1fr; } }
/* short phone screens: the two welcome buttons come before the three steps, so both are in view without scrolling */
@media (max-width: 480px) and (max-height: 760px) {
  .wl .wl-steps { order: 2; }
  .wl .pl-note { order: 3; }
  .wl .stay-btn { order: 4; }
}

/* the unsaved banner: a magenta strip along the bottom while there is progress to save */
#unsaved-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; justify-content: center; gap: 16px; min-height: 56px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); font-size: 14px; color: #fff; background: linear-gradient(90deg, rgba(255, 46, 232, 0.22), rgba(255, 46, 232, 0.34), rgba(255, 46, 232, 0.22)), rgba(7, 10, 18, 0.96); border-top: 2px solid #ff2ee8; box-shadow: 0 -8px 30px rgba(255, 46, 232, 0.25); backdrop-filter: blur(6px); }
#unsaved-bar[hidden] { display: none; }
#unsaved-bar.in { animation: ub-in 0.35s ease-out; }
@keyframes ub-in { from { transform: translateY(100%); } }
#unsaved-bar b { font-family: var(--display); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: #ff9cf3; }
#unsaved-bar .q-btn { flex: none; min-width: 120px; }
body.unsaved .site-footer { padding-bottom: 56px; }
body.unsaved .to-top { bottom: 72px; }
body.unsaved #toast { bottom: 72px; }
@media (max-width: 560px) { #unsaved-bar .ub-long { display: none; } }
@media (prefers-reduced-motion: reduce) { #unsaved-bar.in { animation: none; } }

/* tile names: one line, sized per year by fitNames() in game.js; the name row keeps its height */
.tile-name { overflow: hidden; }
.tile-name .tn { display: inline-block; white-space: nowrap; line-height: 1.2; }
