:root {
  --ink: #0c0e10;
  --text: #e8e6df;
  --muted: #a7aca6;
  --steel: #2a2f34;
  --steel2: #1b1f23;
  --olive: #5d6450;
  --accent: #f28c28;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e1012; touch-action: none; }
#app { position: fixed; inset: 0; overflow: hidden; }
#stage, #fx { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stage { background: #2a2e34 center / cover no-repeat; } /* buildEnv sets the stage's own backdrop picture when a battle needs it */
#fx { z-index: 2; }
#ui { position: absolute; inset: 0; z-index: 5; pointer-events: none; color: var(--text); font-weight: 800; letter-spacing: 0.02em; }
.hidden { display: none !important; }

.outline { text-shadow: 0 2px 0 var(--ink), 1.5px 0 0 var(--ink), -1.5px 0 0 var(--ink), 0 -1.5px 0 var(--ink), 1.5px 1.5px 0 var(--ink), -1.5px 1.5px 0 var(--ink), 1.5px -1.5px 0 var(--ink), -1.5px -1.5px 0 var(--ink), 0 4px 6px rgba(0, 0, 0, 0.6); }

.screen { position: absolute; inset: 0; pointer-events: none; }
.screen .tap { pointer-events: auto; }
.fade-in { animation: fadeIn 0.22s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.85); opacity: 0; } 70% { transform: scale(1.03); opacity: 1; } 100% { transform: scale(1); } }
@keyframes drop { 0% { transform: translateY(-40px); opacity: 0; } 70% { transform: translateY(4px); opacity: 1; } 100% { transform: none; } }
@keyframes slideIn { 0% { transform: translateX(-30px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ---------- title ---------- */
#title { pointer-events: auto; background: #1b1f23; }
#title, #home { overflow: hidden; }
#title .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center 70%; }
.art-blur { position: absolute; inset: -6%; width: 112%; height: 112%; object-fit: cover; filter: blur(16px) brightness(0.55) saturate(0.8); pointer-events: none; }
#title .logo { position: absolute; left: 50%; top: 11%; width: 82%; max-height: 30%; object-fit: contain; transform: translateX(-50%); animation: logoIn 0.6s cubic-bezier(.3,1.4,.5,1) both, none; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.6)); }
#title .logo.idle { animation: logoFloat 3.4s ease-in-out infinite; }
#ui { container-type: inline-size; }
/* code-drawn tactical logo: steel gradient letters, dark outline, hard shadow, signal-orange bar */
.logo-text { display: flex; flex-direction: column; align-items: center; gap: 0.12em; max-height: none !important; line-height: 1; white-space: nowrap; }
.logo-text .lt { font-weight: 900; letter-spacing: 0.04em; color: #e9ebe6; text-shadow: 0.03em 0 0 #0c0e10, -0.03em 0 0 #0c0e10, 0 0.03em 0 #0c0e10, 0 -0.03em 0 #0c0e10, 0.03em 0.03em 0 #0c0e10, -0.03em 0.03em 0 #0c0e10, 0.03em -0.03em 0 #0c0e10, -0.03em -0.03em 0 #0c0e10, 0.06em 0.08em 0 #0c0e10, 0 0.14em 0.25em rgba(0, 0, 0, 0.7); transform: skewX(-6deg); }
.logo-text .bar { display: block; width: 72%; height: 0.11em; background: linear-gradient(90deg, transparent, #f28c28 15%, #f28c28 85%, transparent); box-shadow: 0 0 0.2em rgba(242, 140, 40, 0.6); }
.logo-text .lt-sub { font-weight: 900; letter-spacing: 0.4em; padding-left: 0.4em; color: #f28c28; text-shadow: 0.06em 0 0 #0c0e10, -0.06em 0 0 #0c0e10, 0 0.06em 0 #0c0e10, 0 -0.06em 0 #0c0e10, 0.08em 0.1em 0 #0c0e10; transform: skewX(-6deg); }
@keyframes logoIn { 0% { transform: translateX(-50%) translateY(-60px) scale(0.8); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }
@keyframes logoFloat { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-4px); } }
#title .prompt { position: absolute; left: 10%; right: 10%; bottom: 9%; text-align: center; font-size: 20px; letter-spacing: 0.12em; animation: pulse 1.6s ease-in-out infinite; padding: 6px 20px; background: linear-gradient(90deg, transparent, rgba(12, 14, 16, 0.65) 20%, rgba(12, 14, 16, 0.65) 80%, transparent); border-top: 1px solid rgba(242, 140, 40, 0.6); border-bottom: 1px solid rgba(242, 140, 40, 0.6); }
.corner-btn { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); width: 48px; height: 48px; border-radius: 50%; background: rgba(20, 24, 28, 0.7); border: 2px solid rgba(200, 205, 200, 0.55); display: flex; align-items: center; justify-content: center; pointer-events: auto; cursor: pointer; padding: 0; }
.corner-btn svg { width: 26px; height: 26px; }
.corner-btn .key { position: absolute; right: 54px; font-size: 12px; color: var(--text); background: rgba(20, 24, 28, 0.7); padding: 2px 6px; border-radius: 4px; white-space: nowrap; }

/* ---------- panels & buttons (9-slice art) ---------- */
.panel { position: relative; border-style: solid; border-width: 22px; border-image: url(assets/ui-panel-tac.webp) 18% fill / 22px stretch; color: var(--text); }
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; min-width: 52px; padding: 6px 22px; border-style: solid; border-width: 14px 20px; border-image: url(assets/ui-button-tac.webp) 30% 24% fill / 14px 20px stretch; background: none; color: var(--text); font: inherit; font-weight: 800; font-size: 20px; letter-spacing: 0.06em; cursor: pointer; pointer-events: auto; transition: transform 0.1s, filter 0.15s; }
.btn:active, .btn.pressed { transform: scale(0.95); }
.btn.focus { transform: scale(1.04); filter: brightness(1.25) drop-shadow(0 0 6px rgba(242, 140, 40, 0.9)); }
.btn.disabled { filter: grayscale(1) brightness(0.6); }
.btn.small { min-height: 46px; font-size: 16px; padding: 4px 14px; }
.btn.green { filter: sepia(0.6) hue-rotate(-15deg) saturate(2.2) brightness(0.95); }
.btn.green.focus { filter: sepia(0.6) hue-rotate(-15deg) saturate(2.2) brightness(1.2) drop-shadow(0 0 6px rgba(242, 140, 40, 0.9)); }
.btn img.ic { width: 24px; height: 24px; object-fit: contain; }

/* ---------- home ---------- */
.topbar { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; display: flex; gap: 8px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(20, 24, 28, 0.82); border: 1px solid rgba(200, 205, 200, 0.4); border-left: 3px solid var(--accent); border-radius: 4px; padding: 4px 14px 4px 6px; font-size: 20px; min-height: 40px; }
.pill img { width: 30px; height: 30px; object-fit: contain; }
#home .logo-small-unused { position: absolute; left: 50%; top: 9%; width: 62%; max-height: 18%; object-fit: contain; transform: translateX(-50%); filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6)); animation: logoFloat 3.4s ease-in-out infinite; }
#home .home-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center 50%; animation: fadeIn 0.4s ease-out both; }
#home::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to bottom, rgba(8, 10, 12, 0.55), rgba(8, 10, 12, 0) 26%, rgba(8, 10, 12, 0) 70%, rgba(8, 10, 12, 0.7)); }
#home > *:not(.home-art):not(.art-blur) { z-index: 1; }
#home .actions { position: absolute; left: 50%; transform: translateX(-50%); width: min(88%, 440px); bottom: 6%; display: flex; flex-direction: row; align-items: stretch; justify-content: center; gap: 8px; }
#ui:has(.sheet-wrap) #home .actions { display: none; }
#home .actions .btn { flex: 1.25 1 0; min-width: 0; font-size: 24px; min-height: 64px; animation: slideIn 0.3s ease-out both; }
#home .actions .btn:nth-child(2) { flex: 1 1 0; animation-delay: 0.06s; font-size: 20px; }
#home .actions .btn { white-space: nowrap; padding-left: 6px; padding-right: 6px; gap: 6px; }
#home .actions .btn img.ic { flex: 0 0 22px; width: 22px; height: 22px; }
/* 進階升級: the endless stage's entrance, one row above sortie / upgrade (same width) */
#home .endless-btn { position: absolute; left: 0; right: 0; margin: 0 auto; width: min(88%, 440px); bottom: calc(6% + 76px); min-height: 56px; font-size: 20px; white-space: nowrap; padding-left: 8px; padding-right: 8px; filter: hue-rotate(-28deg) saturate(1.25) brightness(0.95); animation: slideIn 0.3s ease-out 0.1s both; }
#home .endless-btn span { overflow: hidden; text-overflow: ellipsis; }
#ui:has(.sheet-wrap) #home .endless-btn { display: none; }
.result .survived { font-size: 30px; font-weight: 900; color: var(--accent); margin: 2px 0 4px; letter-spacing: 0.04em; }
#hud .banner.fart { color: #d6f06a; font-size: 34px; }

/* ---------- sheet (stage select / upgrades) ---------- */
.sheet-wrap { position: absolute; inset: 0; background: rgba(6, 8, 10, 0.6); display: flex; align-items: center; justify-content: center; pointer-events: auto; padding: 64px 14px 20px; }
.sheet { width: 100%; max-width: 420px; max-height: 100%; display: flex; flex-direction: column; animation: pop 0.24s ease-out both; }
.sheet h2 { margin: 0 0 8px; text-align: center; font-size: 24px; letter-spacing: 0.1em; color: var(--text); border-bottom: 2px solid var(--accent); padding-bottom: 6px; }
.sheet .list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px 6px; touch-action: pan-y; }
.sheet .foot { display: flex; justify-content: center; padding-top: 10px; }
.card { display: flex; align-items: center; gap: 10px; background: linear-gradient(180deg, rgba(52, 58, 62, 0.95), rgba(34, 38, 42, 0.95)); border: 1px solid rgba(160, 168, 160, 0.35); border-left: 3px solid var(--olive); border-radius: 4px; padding: 8px 10px; min-height: 64px; color: var(--text); pointer-events: auto; cursor: pointer; transition: transform 0.1s; }
.card.focus { transform: scale(1.02); border-color: var(--accent); box-shadow: 0 0 0 2px rgba(242, 140, 40, 0.6); }
.card.locked { opacity: 0.5; filter: grayscale(1); }
.card .num { flex: 0 0 44px; height: 44px; border-radius: 4px; background: var(--olive); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.card .num.boss { background: #8a3a2a; }
.card .info { flex: 1; min-width: 0; }
.card .info .t { font-size: 17px; line-height: 1.2; }
.card .info .s { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.card .tag { font-size: 12px; padding: 3px 8px; border-radius: 3px; background: var(--olive); color: #fff; white-space: nowrap; }
.card .tag.boss { background: #8a3a2a; }
.card .portrait { flex: 0 0 56px; height: 56px; border-radius: 4px; background: #15181b; border: 1px solid rgba(160, 168, 160, 0.3); object-fit: contain; }
.card .stats { display: flex; flex-wrap: wrap; column-gap: 10px; row-gap: 1px; color: #d8dcd4; font-size: 14px; line-height: 1.3; margin-top: 3px; font-variant-numeric: tabular-nums; }
.card .stats span { white-space: nowrap; }
.sheet .card { gap: 8px; flex-shrink: 0; }
.sheet .card .portrait, .sheet .card .ic-sofa { flex-basis: 48px; height: 48px; }
.card .btn { flex: 0 0 auto; min-width: 84px; max-width: 112px; font-size: 16px; padding: 0 4px; gap: 4px; min-height: 48px; border-width: 12px 14px; border-image-width: 12px 14px; white-space: nowrap; overflow: hidden; letter-spacing: 0; }
.card .btn span { display: block; min-width: 0; overflow: hidden; line-height: 1.1; }
.card .btn img.ic { width: 20px; height: 20px; flex: 0 0 20px; }
.card .info .t, .card .info .s { overflow-wrap: anywhere; word-break: normal; }
.card .info .t .nm { display: inline-block; max-width: 100%; white-space: nowrap; overflow: hidden; vertical-align: bottom; }
.card .info .t .lvl { display: inline-block; font-size: 13px; color: var(--accent); margin-left: 6px; white-space: nowrap; }
.card .ic-sofa { flex: 0 0 56px; height: 56px; border-radius: 4px; background: #15181b; border: 1px solid rgba(160, 168, 160, 0.3); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.card .ic-sofa svg { width: 60%; height: 60%; }

/* ---------- dialogue ---------- */
#dialog { pointer-events: auto; background: linear-gradient(to top, rgba(6, 8, 10, 0.75), rgba(6, 8, 10, 0) 60%); }
#dialog .por { position: absolute; bottom: 24%; width: 62%; max-height: 46%; object-fit: contain; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.6)); animation: slideIn 0.28s ease-out both; }
#dialog .por.left { left: 2%; }
#dialog .por.right { right: 2%; }
#dialog .box { position: absolute; left: 12px; right: 12px; bottom: max(18px, env(safe-area-inset-bottom)); min-height: 22%; padding: 8px 8px 22px; animation: drop 0.22s ease-out both; }
#dialog .name { position: absolute; top: -40px; left: 8px; background: var(--steel2); color: #fff; border-radius: 3px; padding: 4px 16px; font-size: 19px; border-left: 4px solid var(--accent); }
#dialog .text { font-size: 18px; line-height: 1.55; color: var(--text); font-weight: 600; }
#dialog .skip-dlg { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 3; min-width: 96px; min-height: 44px; font-size: 15px; animation: drop 0.22s ease-out both; }
#dialog .next { position: absolute; right: 4px; bottom: -4px; font-size: 13px; color: var(--accent); animation: pulse 1.2s infinite; }

/* ---------- battle HUD ---------- */
#hud { pointer-events: none; }
#hud .top { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 10px; right: 66px; display: flex; flex-direction: column; gap: 4px; }
#hud .titles { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
#hud .stage-name { font-size: 14px; letter-spacing: 0.04em; overflow-wrap: anywhere; }
#hud .wave { font-size: 12px; color: var(--accent); }
#hud .raid { display: inline-block; align-self: flex-start; margin-top: 2px; padding: 1px 6px; font-size: 12px; font-weight: 800; letter-spacing: 0.03em; color: #ffd2a6; background: rgba(20, 24, 28, 0.55); border-left: 3px solid var(--accent); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#hud .raid.hidden { display: none; }
#hud .raid.up { animation: raidUp 0.45s ease-out; }
@keyframes raidUp { 0% { transform: scale(1.25); color: #fff; } 100% { transform: scale(1); } }
#hud .raid.up { transform-origin: left center; }
/* the landlord's escape clock: one thin highlighted strip (countdown, then the time used) */
#hud .lord { display: inline-flex; align-items: baseline; gap: 8px; align-self: flex-start; margin-top: 3px; padding: 1px 7px 2px; background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(20, 24, 28, 0.6) 40%); border-top: 1px solid rgba(232, 238, 242, 0.55); border-left: 3px solid #cfd8de; white-space: nowrap; max-width: 100%; font-variant-numeric: tabular-nums; animation: drop 0.25s ease-out both; }
#hud .lord.hidden { display: none; }
#hud .lord .ll { font-size: 14px; font-weight: 900; letter-spacing: 0.03em; color: #eef4f7; }
#hud .lord .lu { font-size: 11px; font-weight: 700; color: #b8c4cc; }
#hud .lord.warn { border-left-color: #f28c28; border-top-color: rgba(242, 140, 40, 0.7); }
#hud .lord.warn .ll { color: #f28c28; animation: pulse 1s infinite; }
#hud .lord.warn .lu { color: #ffc89a; }
#hud .meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* thin vitals (team HP, sofa) side by side: number above a slim bar with a highlight line */
#hud .vits { display: flex; gap: 10px; }
#hud .vit { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#hud .vh { display: flex; align-items: center; gap: 4px; height: 14px; font-size: 12px; line-height: 1; white-space: nowrap; }
#hud .vh .ico { width: 12px; height: 12px; flex: 0 0 12px; }
#hud .vh .ico svg { width: 12px; height: 12px; display: block; filter: drop-shadow(0 1px 0 #000); }
#hud .vit.hp .ico { color: #ff8a72; }
#hud .vit.cover .ico { color: #c6dca0; }
#hud .vit.low .lbl { color: #ff8a70; }
.bar.thin { height: 7px; border-radius: 4px; background: rgba(6, 8, 10, 0.82); border: 1px solid rgba(225, 232, 225, 0.6); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55); }
.bar.thin .fill::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 45%; background: linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0)); }
.bar.thin.hp .fill { background: linear-gradient(90deg, #c8402e, #ff7a5c); box-shadow: 0 0 6px rgba(255, 110, 80, 0.7); }
.bar.thin.cover .fill { background: linear-gradient(90deg, #7a925e, #c2dc96); box-shadow: 0 0 6px rgba(190, 220, 140, 0.6); }
#hud .vit.low .bar.thin { border-color: #ff8a70; animation: pulse 0.5s infinite; }
#hud .vit.cover.low .bar.thin .fill { background: linear-gradient(90deg, #c8642e, #ffae5c); }
/* destroyed sofa: dark bar, a draining striped countdown in the lag strip, red label */
#hud .vit.cover.broken .bar.thin { border-color: #ff6a3a; background: rgba(36, 10, 6, 0.9); }
#hud .vit.cover.broken .bar.thin .lag { transition: none; background: repeating-linear-gradient(135deg, #ff6a3a 0 4px, #7a2410 4px 8px); }
#hud .vit.cover.broken .lbl, #hud .vit.cover.broken .ico { color: #ff7a50; }
#hud .banner.buff { top: 22%; font-size: 24px; letter-spacing: 0.04em; color: #ffb066; padding: 5px 16px; }
.card .info .t .evo { display: inline-block; margin-left: 5px; padding: 1px 5px; font-size: 11px; line-height: 1.25; color: #1a1408; background: linear-gradient(180deg, #ffc46a, #f28c28); border-radius: 3px; white-space: nowrap; vertical-align: 2px; box-shadow: 0 0 6px rgba(242, 140, 40, 0.6); }
/* burst gauge: a slim segmented upright bar on the right edge, above the touch buttons */
#hud .burst-gauge { position: absolute; right: max(8px, env(safe-area-inset-right)); top: 58%; height: 25%; width: 32px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#hud .burst-gauge .bico { width: 22px; height: 22px; color: var(--accent); flex: 0 0 22px; }
#hud .burst-gauge .bico svg { width: 22px; height: 22px; display: block; filter: drop-shadow(0 1px 0 #000) drop-shadow(0 0 3px rgba(0, 0, 0, 0.8)); }
#hud .burst-gauge .track { position: relative; flex: 1 1 auto; width: 12px; border-radius: 3px; overflow: hidden; background: rgba(6, 8, 10, 0.8); border: 1px solid rgba(225, 232, 225, 0.55); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55); }
#hud .burst-gauge .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(0deg, #c8600c, #ffb862); box-shadow: 0 0 8px rgba(242, 140, 40, 0.8); transition: height 0.15s; }
#hud .burst-gauge .track::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0, transparent calc(10% - 2px), rgba(6, 8, 10, 0.95) calc(10% - 2px), rgba(6, 8, 10, 0.95) 10%), linear-gradient(90deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 45%); }
#hud .burst-gauge .bpct { font-size: 11px; line-height: 1; color: #f0e6d6; white-space: nowrap; }
#hud .burst-gauge.ready .track { border-color: #ffd2a0; box-shadow: 0 0 12px var(--accent), 0 0 0 1px #000; animation: pulse 0.6s infinite; }
#hud .burst-gauge.ready .bico, #hud .burst-gauge.ready .bpct { color: #ffd2a0; animation: pulse 0.6s infinite; }
#hud .burst-gauge.active .fill { background: linear-gradient(0deg, #ff8a20, #fff0c8); }
#hud .coins { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px 2px 4px; background: rgba(20, 24, 28, 0.72); border: 1px solid rgba(200, 205, 200, 0.3); border-left: 3px solid #c9a75a; border-radius: 4px; font-size: 18px; font-weight: 900; color: #f1e2b8; transition: transform 0.12s; }
#hud .coins img { width: 18px; height: 18px; object-fit: contain; }
#hud .coins { font-size: 16px; padding: 1px 8px 1px 3px; flex: 0 0 auto; }
#hud .coins.bump { transform: scale(1.15); }
.result .keep { font-size: 14px; color: #d9c48a; margin-top: -2px; }
.bar { position: relative; height: 18px; border-radius: 2px; background: rgba(12, 14, 16, 0.75); border: 1px solid rgba(200, 205, 200, 0.5); overflow: hidden; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; transition: width 0.15s; }
.bar .lag { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.4); transition: width 0.6s 0.15s; }
.bar .lbl { position: absolute; left: 24px; right: 0; top: 0; bottom: 0; display: flex; align-items: center; padding-left: 0; font-size: 12px; line-height: 1; }
.bar .ico { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: #fff; z-index: 1; }
.bar .ico svg { width: 14px; height: 14px; display: block; filter: drop-shadow(0 1px 0 #000); }
.bar.hp .fill { background: linear-gradient(#c84a3a, #8e2a20); }
.bar.cover .fill { background: linear-gradient(#8a9278, #5d6450); }
.bar.burst .fill { background: linear-gradient(#ffb15a, #d06a10); }
.bar.burst.ready { animation: pulse 0.6s infinite; box-shadow: 0 0 10px var(--accent); }
.bar.boss { height: 15px; }
.bar.boss .lbl { font-size: 11px; }
.bar.boss .fill { background: linear-gradient(#7a5a8a, #4a2a5a); }
#hud .support { display: flex; gap: 6px; flex-wrap: wrap; min-height: 0; }
#hud .chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 4px; background: rgba(12, 14, 16, 0.75); border: 1px solid rgba(200, 205, 200, 0.4); border-left: 3px solid var(--olive); border-radius: 2px; font-size: 12px; }
#hud .chip .ci { width: 16px; height: 16px; color: #cfd6c4; }
#hud .chip .ci svg { width: 16px; height: 16px; display: block; }
#hud .chip.hot { border-left-color: var(--accent); animation: pulse 0.5s infinite; }
#hud .chip.hot .ci { color: var(--accent); }
#hud .burst-hint { font-size: 13px; color: var(--accent); min-height: 0; }
#hud .burst-hint:empty { display: none; }
#hud .banner { position: absolute; left: 0; right: 0; top: 36%; text-align: center; font-size: 32px; letter-spacing: 0.08em; animation: drop 0.3s ease-out both; padding: 6px 0; background: linear-gradient(90deg, transparent, rgba(12, 14, 16, 0.6) 25%, rgba(12, 14, 16, 0.6) 75%, transparent); }
#hud .banner.warn { color: #ff6a50; font-size: 38px; }
#hud .banner.boss { color: #d8c0ff; }
#hud .banner.talk { color: #f0ece0; font-size: 22px; padding: 6px 24px; top: 30%; letter-spacing: 0; }
#hud .banner.burst { color: var(--accent); font-size: 40px; }
#hud .tutorial { white-space: pre-line; position: absolute; left: 6%; right: 6%; top: 47%; text-align: center; font-size: 17px; background: rgba(12, 14, 16, 0.7); border: 1px solid rgba(242, 140, 40, 0.6); border-radius: 3px; padding: 8px 10px; animation: pulse 1.8s infinite; }
#hud .cutin { position: absolute; left: 0; right: 0; top: 30%; height: 150px; background: linear-gradient(90deg, rgba(20, 24, 28, 0), rgba(20, 24, 28, 0.92) 20%, rgba(40, 30, 20, 0.92) 80%, rgba(20, 24, 28, 0)); border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); animation: cutin 1s ease-out both; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#hud .cutin img { height: 180px; margin-top: 30px; }
#hud .cutin .skill { font-size: 28px; margin-left: -10px; letter-spacing: 0.08em; }
#hud .cutin .cut-txt { display: flex; flex-direction: column; gap: 6px; max-width: 52%; min-width: 0; }
#hud .cutin .say { font-size: 16px; line-height: 1.3; color: var(--text); margin-left: -10px; overflow-wrap: anywhere; }
#hud .cheer { position: absolute; left: 0; right: 0; top: 34%; display: flex; flex-direction: column; align-items: center; pointer-events: none; z-index: 6; animation: cheerOut 1.6s ease-in both; }
#hud .cheer.with-art { top: 24%; }
#hud .cheer-art { width: min(100%, 520px); aspect-ratio: 3 / 2; object-fit: cover; border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); box-shadow: 0 0 24px rgba(242, 140, 40, 0.45); animation: cheerArt 1.6s ease-out both; -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
#hud .cheer-title { margin-top: -28px; max-width: 92%; text-align: center; font-weight: 900; font-size: clamp(26px, 8.6vw, 44px); line-height: 1.1; letter-spacing: 0.04em; color: #fff3e4; -webkit-text-stroke: 0; text-shadow: 2px 0 0 #2a1606, -2px 0 0 #2a1606, 0 2px 0 #2a1606, 0 -2px 0 #2a1606, 2px 2px 0 #2a1606, -2px 2px 0 #2a1606, 2px -2px 0 #2a1606, -2px -2px 0 #2a1606, 0 4px 0 #2a1606, 0 0 18px rgba(242, 140, 40, 0.95); background: linear-gradient(90deg, rgba(20, 24, 28, 0), rgba(30, 22, 14, 0.85) 15%, rgba(30, 22, 14, 0.85) 85%, rgba(20, 24, 28, 0)); border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); padding: 6px 22px; animation: cheerPop 0.45s cubic-bezier(.2, 1.6, .4, 1) both; }
#hud .cheer:not(.with-art) .cheer-title { margin-top: 0; }
#hud .buff-tag { position: absolute; transform: translate(-50%, -100%); font-size: 13px; font-weight: 800; color: #ffd9a8; white-space: nowrap; pointer-events: none; background: rgba(20, 24, 28, 0.55); border: 1px solid rgba(242, 140, 40, 0.7); border-radius: 3px; padding: 1px 6px; opacity: 0; animation: buffUp 1.5s ease-out both; }
#hud .lucky { position: absolute; left: 0; right: 0; top: 12%; display: flex; flex-direction: column; align-items: center; gap: 2px; pointer-events: none; z-index: 6; animation: cheerOut 1.6s ease-in both; }
#hud .lucky-title { max-width: 90%; text-align: center; font-weight: 900; font-size: clamp(20px, 6.2vw, 32px); line-height: 1.15; letter-spacing: 0.03em; color: #ffe2b8; overflow-wrap: anywhere; text-shadow: 2px 0 0 #2a1606, -2px 0 0 #2a1606, 0 2px 0 #2a1606, 0 -2px 0 #2a1606, 2px 2px 0 #2a1606, -2px 2px 0 #2a1606, 2px -2px 0 #2a1606, -2px -2px 0 #2a1606, 0 3px 0 #2a1606, 0 0 14px rgba(242, 140, 40, 0.9); border-bottom: 2px solid var(--accent); padding: 0 10px 3px; animation: cheerPop 0.4s cubic-bezier(.2, 1.6, .4, 1) both; }
#hud .lucky-sub { display: inline-flex; align-items: center; gap: 5px; font-size: 20px; font-weight: 900; color: var(--accent); text-shadow: 2px 0 0 #1a1008, -2px 0 0 #1a1008, 0 2px 0 #1a1008, 0 -2px 0 #1a1008; animation: cheerPop 0.4s 0.08s cubic-bezier(.2, 1.6, .4, 1) both; }
#hud .lucky-sub img { width: 22px; height: 22px; }
.result .coin-rows { width: 86%; margin: 2px auto 4px; display: flex; flex-direction: column; gap: 3px; }
.result .coin-rows .cr { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 15px; color: var(--text); border-bottom: 1px solid rgba(160, 168, 160, 0.22); padding: 1px 2px; }
.result .coin-rows .cr span:first-child { text-align: left; min-width: 0; overflow-wrap: anywhere; }
.result .coin-rows .cr span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.result .coin-rows .cr.lucky { color: var(--accent); }
.result .coin-rows .cr.total { font-weight: 900; font-size: 17px; border-bottom: 0; border-top: 2px solid var(--accent); padding-top: 3px; }
@keyframes cheerPop { 0% { transform: scale(2.2); opacity: 0; } 60% { transform: scale(0.94); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes cheerArt { 0% { transform: scale(1.12); opacity: 0; } 20% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.03); } }
@keyframes cheerOut { 0%, 78% { opacity: 1; } 100% { opacity: 0; } }
@keyframes buffUp { 0% { opacity: 0; transform: translate(-50%, -60%); } 18% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -260%); } }
@keyframes cutin { 0% { transform: translateX(100%) skewX(-12deg); } 18% { transform: translateX(0) skewX(-6deg); } 80% { transform: translateX(-4%) skewX(-6deg); opacity: 1; } 100% { transform: translateX(-110%) skewX(-12deg); opacity: 0; } }

/* ---------- results ---------- */
.result { width: 100%; max-width: 380px; text-align: center; animation: pop 0.26s ease-out both; }
.result h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: 0.1em; color: var(--text); }
.result .row { font-size: 17px; margin: 6px 0; color: var(--text); }
.result .reward { display: inline-flex; align-items: center; gap: 8px; font-size: 26px; margin: 8px 0; color: var(--text); }
.result .reward img { width: 40px; height: 40px; }
.result .bonus { font-size: 14px; color: var(--accent); }
.result .btns { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 12px; }
.result .btns .btn { width: 86%; }
.result .trophy { position: absolute; top: -8px; right: -8px; width: 46px; height: 46px; }
.toast { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); background: rgba(20, 24, 28, 0.9); border-left: 3px solid var(--accent); padding: 8px 18px; border-radius: 3px; font-size: 17px; animation: drop 0.25s ease-out both; white-space: nowrap; z-index: 20; }

/* ---------- intro video ---------- */
#video-wrap { position: absolute; inset: 0; z-index: 30; background: #000 center / cover; }
#video-wrap video { width: 100%; height: 100%; object-fit: cover; }
/* the trailer's first frame is fetched only when the trailer is opened (not at page load) */
#video-wrap:not(.hidden) { background-image: url(assets/trailer-first.webp); }
/* pre-boot title: loading bar and a load-failure message with a retry button */
#title .bootbar { position: absolute; left: 22%; right: 22%; bottom: calc(9% + 54px); height: 6px; background: rgba(12, 14, 16, 0.7); border: 1px solid rgba(242, 140, 40, 0.5); border-radius: 3px; overflow: hidden; box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); }
#title .bootbar .fill { height: 100%; width: 4%; background: linear-gradient(90deg, #c96a18, #f28c28 70%, #ffd2a0); box-shadow: 0 0 6px rgba(242, 140, 40, 0.8); transition: width 0.25s linear; }
#title .bootbar.bad .fill { background: #b84a3a; }
#title .bootbar.done { opacity: 0; transition: opacity 0.5s; }
#title .prompt.boot-msg { animation: pulse 1.6s ease-in-out infinite; font-size: 17px; }
#title .prompt.boot-msg.bad { animation: none; color: #ffb4a0; white-space: normal; }
#title .boot-retry { position: absolute; left: 50%; bottom: calc(9% - 64px + 0px); transform: translateX(-50%); bottom: 3%; pointer-events: auto; }
#intro-sub.trailer-text { position: absolute; left: 5%; right: 5%; top: 40%; bottom: auto; transform: translateY(-50%) scale(1.4); text-align: center; font-weight: 900; font-size: clamp(22px, 7.2vw, 38px); line-height: 1.2; letter-spacing: 0.04em; color: #f4efe6; background: linear-gradient(90deg, transparent, rgba(16, 18, 20, 0.78) 12%, rgba(16, 18, 20, 0.78) 88%, transparent); border-top: 2px solid #f28c28; border-bottom: 2px solid #f28c28; padding: 10px 14px; text-shadow: 2px 0 0 #0c0e10, -2px 0 0 #0c0e10, 0 2px 0 #0c0e10, 0 -2px 0 #0c0e10, 2px 2px 0 #0c0e10, -2px 2px 0 #0c0e10, 2px -2px 0 #0c0e10, -2px -2px 0 #0c0e10, 0 4px 0 #0c0e10, 0 0 16px rgba(242, 140, 40, 0.8); overflow-wrap: anywhere; opacity: 0; transition: opacity 0.5s ease-out, transform 0.5s cubic-bezier(.2, 1.4, .4, 1); pointer-events: none; }
#intro-sub.trailer-text.show { opacity: 1; transform: translateY(-50%) scale(1); }
#intro-skip { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 2; }
/* landlord-defeated ending: caption → sunset picture (whole picture shown, contain) → thanks */
.lend { position: absolute; inset: 0; z-index: 40; background: #07090b; pointer-events: auto; cursor: pointer; overflow: hidden; }
.lend-bg { position: absolute; inset: -4%; background: #2a1a10 url("assets/ending-sunset.webp") center / cover no-repeat; opacity: 0; transition: opacity 1.2s ease-out; }
.lend-bg::after { content: ""; position: absolute; inset: 0; background: rgba(7, 9, 11, 0.62); }
.lend-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transform: scale(1.04); transition: opacity 1.2s ease-out, transform 6s ease-out, filter 0.8s; }
.lend-bg.on, .lend-img.on { opacity: 1; }
.lend-img.on { transform: scale(1); }
.lend-bg.dim, .lend-img.dim { filter: brightness(0.42); }
.lend-text { position: absolute; left: 7%; right: 7%; top: 50%; transform: translateY(-50%) scale(0.94); text-align: center; font-weight: 900; font-size: clamp(22px, 7cqw, 34px); line-height: 1.3; color: #f4efe6; letter-spacing: 0.06em; white-space: pre-line; word-break: keep-all; overflow-wrap: anywhere; opacity: 0; transition: opacity 0.7s ease-out, transform 0.7s cubic-bezier(.2, 1.3, .4, 1); pointer-events: none; }
.lend-text.big { font-size: clamp(22px, 7.2cqw, 38px); color: #ffd9a8; border-top: 2px solid #f28c28; border-bottom: 2px solid #f28c28; padding: 12px 6px; background: linear-gradient(90deg, transparent, rgba(16, 18, 20, 0.7) 12%, rgba(16, 18, 20, 0.7) 88%, transparent); }
.lend-text.on { opacity: 1; transform: translateY(-50%) scale(1); }
.lend-tap { position: absolute; left: 8%; right: 8%; bottom: 9%; text-align: center; font-size: 16px; font-weight: 800; color: #e0ddd2; opacity: 0; transition: opacity 0.5s; pointer-events: none; }
.lend-tap.on { opacity: 1; animation: lendPulse 1.6s ease-in-out infinite; }
@keyframes lendPulse { 50% { opacity: 0.45; } }
.subtitle { position: absolute; left: 6%; right: 6%; bottom: 10%; text-align: center; font-size: 18px; color: #fff; font-weight: 700; text-shadow: 0 2px 0 #000, 0 0 6px #000; }
