html, body { margin: 0; height: 100%; overflow: hidden; background: #2a1a0c; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; color: #fff8e8; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
/* --hud-below: just under the 4-row HUD panel (146 px tall with its 8 px margin) */
:root { --ol: #3a1e08; --hud-below: 160px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-weight: 900; }
#hudPanel {
  position: absolute; left: calc(8px + env(safe-area-inset-left)); top: calc(8px + env(safe-area-inset-top));
  width: 206px; box-sizing: border-box; padding: 4px 6px;
  border-style: solid; border-color: transparent; border-width: 12px;
  border-image: url(../assets/ui-panel.webp) 90 fill / 24px stretch;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.35));
  animation: popIn .35s cubic-bezier(.34,1.56,.64,1);
}
/* the panel picture trimmed of its transparent margins (set by src/ui-art.js): whole corner gems */
.ui-trim #hudPanel, .ui-trim #tip, .ui-trim #stageCard { border-image: var(--panel-img) var(--panel-slice) fill / 28px stretch; }
.ui-trim #hudPanel { padding: 6px 8px; }
#hudPanel .row { display: flex; align-items: center; gap: 6px; height: 26px; }
#hudPanel .row.top { justify-content: space-between; height: 28px; }
#hudPanel img { width: 24px; height: 24px; object-fit: contain; filter: drop-shadow(0 2px 0 rgba(0,0,0,.4)); }
#hudPanel #objRow { height: 22px; }
#objLabel { flex: 1; min-width: 0; font-size: 14px; color: #fff3d8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ruleIcons { display: flex; gap: 2px; flex: none; }
#hudPanel img.ruleIcon { width: 22px; height: 22px; }
#killRow.urgent #killText { color: #ff8a6a; animation: pulse .5s ease-in-out infinite; }
.stage { font-size: 16px; color: #ffd27a; white-space: nowrap; }
.score { font-size: 22px; color: #fff; }
.num { font-size: 16px; min-width: 22px; white-space: nowrap; }
.stage, .score, .num, #objLabel, #dashPill span, .bossName, #banner, #subtitle, #tip, .dmg, #startPrompt, #keysHint, .gbtn, #loadingMsg, #upTitle, .upName, .upDesc, #upHint,
#scStage, #scDiff, #scObjText, .scRuleName, .scRuleDesc, .scChip span {
  text-shadow: 2px 0 0 var(--ol), -2px 0 0 var(--ol), 0 2px 0 var(--ol), 0 -2px 0 var(--ol), 1.5px 1.5px 0 var(--ol), -1.5px 1.5px 0 var(--ol), 1.5px -1.5px 0 var(--ol), -1.5px -1.5px 0 var(--ol), 0 3px 0 rgba(0,0,0,.35);
}
.bar { flex: 1; height: 12px; background: #2a1406; border: 2px solid #1a0c02; border-radius: 8px; overflow: hidden; }
#killFill { height: 100%; width: 0; background: linear-gradient(#ffe07a, #f0a020); transition: width .2s; }
#dashPill { position: relative; margin-left: auto; width: 92px; height: 22px; border-radius: 12px; background: #2a1406; border: 2px solid #1a0c02; overflow: hidden; display: flex; align-items: center; justify-content: center; }
#dashFill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(#8ad0ff, #3a8ad8); }
#dashPill.ready #dashFill { background: linear-gradient(#fff08a, #ffb02a); }
#dashPill.ready { animation: pulse 1s ease-in-out infinite; }
#dashPill span { position: relative; font-size: 13px; white-space: nowrap; }
#bossBar { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--hud-below) + env(safe-area-inset-top)); width: min(80%, 330px); display: flex; align-items: center; gap: 8px; animation: dropIn .4s cubic-bezier(.34,1.56,.64,1); }
#bossBar .bar { height: 16px; border-color: #1a0402; }
#bossFill { height: 100%; width: 100%; background: linear-gradient(#ff7a5a, #c02010); transition: width .15s; }
.bossName { font-size: 18px; color: #ff9a7a; white-space: nowrap; }

/* floating text */
#dmgLayer { position: fixed; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.dmg { position: absolute; left: 0; top: 0; font-size: 17px; font-weight: 900; line-height: 1; color: #fff; white-space: nowrap; will-change: transform; }
.dmg.hurt { color: #ff6a5a; }
.dmg.big { color: #ffd27a; font-size: 22px; }
.dmg.gold { color: #ffe36a; font-size: 20px; }
.dmg.gem { color: #8aeaff; font-size: 20px; }
.dmg.crash { color: #ffb0a0; font-size: 22px; }
.dmg.alert { color: #ff4a2a; font-size: 34px; }

/* the banner is out of sight between its shows (visibility, so it never sits invisibly over a panel) */
#banner { position: fixed; left: 0; right: 0; top: 42%; text-align: center; font-size: 42px; font-weight: 900; color: #fff; z-index: 6; pointer-events: none; opacity: 0; visibility: hidden; padding: 0 16px; }
#banner.show { visibility: visible; animation: slam 1.8s cubic-bezier(.2,1.4,.4,1) forwards; }
#banner.gold { color: #ffe36a; }
#banner.red { color: #ff8a6a; }
/* width: max-content keeps short lines on one line (left: 50% alone would wrap them at half the screen);
   it sits below the tip box (which starts at --hud-below) even on short screens */
#subtitle { position: fixed; left: 50%; top: max(33%, calc(var(--hud-below) + 120px + env(safe-area-inset-top))); transform: translateX(-50%); width: max-content; max-width: calc(86% - 32px); padding: 8px 16px; border-radius: 14px; background: rgba(30, 15, 5, .55); font-size: 17px; font-weight: 800; text-align: center; z-index: 6; pointer-events: none; opacity: 0; transition: opacity .25s; }
#subtitle.show { opacity: 1; }
#tip { position: fixed; left: 50%; top: calc(var(--hud-below) + env(safe-area-inset-top)); transform: translateX(-50%); width: min(88%, 340px); padding: 6px 12px; box-sizing: border-box; font-size: 15px; font-weight: 800; text-align: center; z-index: 6; pointer-events: none; opacity: 0; transition: opacity .4s;
  border-style: solid; border-color: transparent; border-width: 12px; border-image: url(../assets/ui-panel.webp) 90 fill / 24px stretch; }
.ui-trim #tip { padding: 8px 14px; }
#tip.show { opacity: 1; }
/* a boss fight: the boss bar sits under the HUD, so the tip box (trap and charge tips) and the subtitle move below it */
body:has(#hud:not(.hidden) #bossBar:not(.hidden)) #tip { top: calc(var(--hud-below) + 34px + env(safe-area-inset-top)); }
body:has(#hud:not(.hidden) #bossBar:not(.hidden)) #subtitle { top: max(33%, calc(var(--hud-below) + 154px + env(safe-area-inset-top))); }
#loadingMsg { position: fixed; left: 0; right: 0; top: 48%; text-align: center; font-size: 22px; font-weight: 900; z-index: 16; opacity: 0; pointer-events: none; transition: opacity .2s; }
#loadingMsg.show { opacity: 1; }

/* stage card: stage number, difficulty, map and traps, goal and special rules, shown while the party waits at the start */
#stageCard { position: fixed; left: 50%; top: calc(var(--hud-below) + env(safe-area-inset-top)); transform: translateX(-50%); width: min(88%, 350px); box-sizing: border-box; padding: 6px 12px 10px; z-index: 7; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border-style: solid; border-color: transparent; border-width: 14px; border-image: url(../assets/ui-panel.webp) 90 fill / 28px stretch;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.45)); }
/* it drops in, stays while the party waits (also while paused) and leaves when the march starts */
#stageCard.show { animation: cardEnter .42s cubic-bezier(.34,1.56,.64,1) both; }
#stageCard.out { animation: cardOut .3s ease-in forwards; }
#scStage { font-size: 34px; font-weight: 900; color: #ffe36a; line-height: 1.1; text-align: center; }
#stageCard.boss #scStage { color: #ff9a7a; }
#scDiffRow { display: flex; align-items: center; gap: 8px; }
#scDiff { font-size: 15px; font-weight: 800; color: #fff3d8; }
#scStars span { font-size: 22px; line-height: 1; display: inline-block; }
#scStars .on { color: #ffd23a; text-shadow: 0 0 6px rgba(255, 200, 60, .8), 0 2px 0 var(--ol); animation: starPop .35s cubic-bezier(.34,1.56,.64,1) backwards; animation-delay: calc(var(--i) * 80ms + 250ms); }
#scStars .off { color: #5a3a1c; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
/* the map and trap chips (they wrap to a second line when a long English name needs it) */
#scMapRow { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: 100%; }
#scMapRow:empty { display: none; }
.scChip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 10px 1px 5px; border-radius: 13px; background: rgba(40, 20, 6, .5); white-space: nowrap;
  animation: ruleIn .35s cubic-bezier(.34,1.56,.64,1) backwards; animation-delay: calc(var(--i) * 110ms + 380ms); }
.scChip img { width: 24px; height: 24px; flex: none; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.scChip span { font-size: 15px; font-weight: 900; color: #bfe8ff; line-height: 24px; }
.scChip.trap { background: rgba(96, 22, 6, .55); }
.scChip.trap span { color: #ffa27a; }
#scObj { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 4px 8px; box-sizing: border-box; border-radius: 12px; background: rgba(40, 20, 6, .45); }
#scObjIcon { width: 40px; height: 40px; object-fit: contain; flex: none; filter: drop-shadow(0 2px 0 rgba(0,0,0,.4)); }
#scObjText { font-size: 20px; font-weight: 900; color: #fff; text-align: center; }
#scRules { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.scRule { display: flex; align-items: center; gap: 8px; animation: ruleIn .35s cubic-bezier(.34,1.56,.64,1) backwards; animation-delay: calc(var(--i) * 140ms + 550ms); }
.scRuleIcon { width: 36px; height: 36px; object-fit: contain; flex: none; filter: drop-shadow(0 2px 0 rgba(0,0,0,.4)); }
.scRuleName { font-size: 16px; font-weight: 900; color: #ff9a6a; line-height: 1.15; }
.scRuleDesc { font-size: 14px; font-weight: 800; color: #fff3d8; line-height: 1.2; }

/* upgrade cards (after each stage clear) */
#upgrade { position: fixed; inset: 0; z-index: 9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 0 18px; box-sizing: border-box;
  background: radial-gradient(ellipse at 50% 50%, rgba(30, 15, 4, .45), rgba(20, 10, 2, .82)); }
#upgrade.show { animation: fadeIn .25s ease-out; }
#upTitle { font-size: 32px; font-weight: 900; color: #ffe36a; text-align: center; }
#upgrade.show #upTitle { animation: titleSlam .5s cubic-bezier(.34,1.56,.64,1) backwards; }
#upCards { display: flex; flex-direction: column; gap: 14px; width: min(100%, 360px); }
.upCard { position: relative; display: flex; align-items: center; gap: 12px; min-height: 100px; box-sizing: border-box; padding: 8px 12px; cursor: pointer;
  border-style: solid; border-color: transparent; border-width: 14px; border-image: url(../assets/ui-panel.webp) 90 fill / 28px stretch;
  filter: drop-shadow(0 5px 6px rgba(0,0,0,.45));
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), filter .15s;
  animation: cardIn .42s cubic-bezier(.34,1.56,.64,1) backwards; animation-delay: calc(var(--d) * 90ms + 150ms);
  -webkit-tap-highlight-color: transparent; }
.ui-trim .upCard { border-image: var(--panel-img) var(--panel-slice) fill / 30px stretch; }
.upCard.focus { transform: scale(1.05); filter: brightness(1.15) drop-shadow(0 0 12px rgba(255, 214, 90, .95)); }
.upCard:active { transform: scale(.96); }
.upCard.chosen { animation: chosen .6s ease-out forwards; }
.upCard.gone { opacity: 0; transform: scale(.85); transition: opacity .3s, transform .3s; }
.upIcon { width: 66px; height: 66px; flex: none; object-fit: contain; filter: drop-shadow(0 3px 0 rgba(0,0,0,.45)); }
.upCard.focus .upIcon { animation: iconBob 1s ease-in-out infinite; }
.upText { flex: 1; min-width: 0; }
.upName { font-size: 20px; font-weight: 900; color: #ffd27a; line-height: 1.2; }
.upDesc { font-size: 15px; font-weight: 800; color: #fff8e8; margin-top: 3px; line-height: 1.3; }
.upLv { position: absolute; top: -10px; right: 2px; font-size: 13px; font-weight: 900; color: #3a1e08; background: linear-gradient(#fff08a, #ffb02a); border: 2px solid #3a1e08; border-radius: 10px; padding: 0 8px; line-height: 18px; }
#upHint { font-size: 15px; font-weight: 800; color: #fff3d8; text-align: center; animation: pulse 1.4s ease-in-out infinite; }

/* buttons: the plate picture has transparent space above and below, drawn outside the box */
.gbtn { font-family: inherit; font-weight: 900; font-size: 18px; color: #fff8e8; min-height: 50px; min-width: 140px; padding: 4px 24px; cursor: pointer; background: transparent;
  border-style: solid; border-color: transparent; border-width: 10px 16px;
  border-image-source: url(../assets/ui-button.webp); border-image-slice: 38% 16% 38% 16% fill; border-image-width: 40px 26px; border-image-outset: 29px 5px; border-image-repeat: stretch;
  transition: transform .09s ease-out, filter .12s; -webkit-tap-highlight-color: transparent; }
.gbtn:hover { filter: brightness(1.12); transform: translateY(-2px); }
.gbtn:active { transform: translateY(2px) scale(.95); }

/* title */
#title { position: fixed; inset: 0; z-index: 10; overflow: hidden; background: #8fc8ef; cursor: pointer; }
#titleBg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: slowZoom 18s ease-in-out infinite alternate; }
#titleLogo { position: absolute; left: 50%; top: 5%; width: 84%; max-height: 30%; object-fit: contain; transform: translateX(-50%); filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); }
#title.enter #titleLogo { animation: logoDrop .7s cubic-bezier(.34,1.56,.64,1) both, logoFloat 3.5s ease-in-out .7s infinite; }
#titleBottom { position: absolute; left: 0; right: 0; bottom: 8%; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0 16px; }
#startPrompt { font-size: 24px; font-weight: 900; color: #fff; animation: pulse 1.4s ease-in-out infinite; text-align: center; }
#keysHint { font-size: 13px; font-weight: 800; color: #fff3d8; text-align: center; max-width: 92%; }
#keysHint:empty { display: none; }
#title.enter #titleBottom { animation: riseIn .6s ease-out .3s both; }

/* cutscene: Skip sits top-right but below the corner the platform's pause / menu button uses */
#cutscene { position: fixed; inset: 0; z-index: 12; background: #000 url(../assets/cover-bg.webp) center / cover no-repeat; }
#cutscene video { width: 100%; height: 100%; object-fit: cover; display: block; }
#skipBtn { position: absolute; top: calc(74px + env(safe-area-inset-top)); right: calc(14px + env(safe-area-inset-right)); min-width: 100px; font-size: 16px; }

#fade { position: fixed; inset: 0; background: #1a0e04; opacity: 0; pointer-events: none; z-index: 15; transition: opacity .4s; }
#fade.on { opacity: 1; }

@keyframes slam { 0% { opacity: 0; transform: scale(2.4); } 12% { opacity: 1; transform: scale(.92); } 20% { transform: scale(1.05); } 28% { transform: scale(1); } 80% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.1) translateY(-20px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.06); opacity: .8; } }
@keyframes logoDrop { 0% { opacity: 0; transform: translateX(-50%) translateY(-60%) scale(.7); } 100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@keyframes logoFloat { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(6px); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
@keyframes slowZoom { from { transform: scale(1); } to { transform: scale(1.06); } }
@keyframes popIn { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
@keyframes dropIn { from { opacity: 0; transform: translate(-50%, -30px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes titleSlam { from { opacity: 0; transform: scale(1.8); } to { opacity: 1; transform: scale(1); } }
@keyframes cardIn { from { opacity: 0; transform: translateX(-60px) scale(.8); } to { opacity: 1; transform: none; } }
@keyframes chosen { 0% { transform: scale(1.05); } 30% { transform: scale(1.14); filter: brightness(1.6) drop-shadow(0 0 22px rgba(255, 230, 120, 1)); } 100% { transform: scale(1.1); opacity: 0; } }
@keyframes iconBob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-4px) rotate(-6deg); } }
@keyframes cardEnter { 0% { opacity: 0; transform: translateX(-50%) translateY(-24px) scale(.8); } 60% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.04); } 100% { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes cardOut { from { opacity: 1; transform: translateX(-50%) scale(1); } to { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(.96); } }
@keyframes starPop { from { opacity: 0; transform: scale(2.2) rotate(-30deg); } to { opacity: 1; transform: none; } }
@keyframes ruleIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
