/* Wing 67 duel. One portrait column (max 480px). Indigo museum night, ghost-teal for "you can act",
   lantern orange for buttons, gold for attack, blood red for health. */
:root {
  /* sizes; the responsive block at the end retunes them per screen */
  --mw: 60px; --mh: 82px; --cw: 62px; --ch: 92px; --nm: 26px; --nm-fs: 10px; --pt: 58px; --board-max: 190px; --wide: 1000px;
  --ink: #0f0d1c; --ink-2: #181530; --ink-3: #241f44; --line: #3a3466;
  --paper: #f1e8d6; --dim: #aaa3c4; --teal: #5fe0d0; --lamp: #ff9b45; --gold: #ffcf5a; --blood: #ff5a6a; --ice: #9fd8ff; --mana: #6fa8ff;
  --display: 'Lilita One', 'ZCOOL KuaiLe', 'Arial Rounded MT Bold', sans-serif;
  --body: 'Nunito', 'Noto Sans SC', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { margin: 0; background: var(--ink); color: var(--paper); font-family: var(--body); overscroll-behavior: none; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
:lang(zh) { --display: 'ZCOOL KuaiLe', 'Lilita One', sans-serif; }
[hidden] { display: none !important; }

#app { position: relative; height: 100%; max-width: 480px; margin: 0 auto; overflow: hidden; display: flex; flex-direction: column;
  background: radial-gradient(120% 60% at 50% 0%, #241c4a 0%, var(--ink) 70%);
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.screen { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 10px max(12px, env(safe-area-inset-left, 0px)) 10px max(12px, env(safe-area-inset-right, 0px)); gap: 10px; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---------- buttons ---------- */
.big-btn { border: 0; border-radius: 16px; padding: 15px 18px; font-family: var(--display); font-size: 24px; letter-spacing: 1px;
  background: linear-gradient(180deg, #ffb46b, var(--lamp)); color: #2a1305; box-shadow: 0 5px 0 #a8501b, 0 0 30px rgba(255,155,69,.3); }
.big-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #a8501b; }
.big-btn:disabled { filter: grayscale(.8) brightness(.7); }
.ghost-btn { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--ink-2); font-size: 15px; font-weight: 800; }
.ghost-btn.teal { border-color: var(--teal); color: var(--teal); }
.ghost-btn:disabled { opacity: .45; }
.chip { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--ink-3); color: var(--dim); }
.topbar { display: flex; align-items: center; gap: 8px; }
.topbar h2 { font-family: var(--display); font-weight: 400; font-size: 24px; margin: 0; flex: 1; }
.icon-btn { border: 1px solid var(--line); background: var(--ink-2); border-radius: 12px; min-width: 40px; height: 40px; padding: 0 10px; font-weight: 800; font-size: 14px; }

/* ---------- title ---------- */
#title { justify-content: flex-end; position: relative; }
#title .bg { position: absolute; inset: 0; background: url(img/bg_hall.jpg) center 30% / cover; opacity: .7; }
#title .bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15,13,28,.1) 0%, rgba(15,13,28,.55) 45%, var(--ink) 82%); }
#title .corner { position: absolute; top: 10px; right: max(12px, env(safe-area-inset-right, 0px)); display: flex; gap: 6px; z-index: 2; }
#title .inner { position: relative; display: flex; flex-direction: column; gap: 12px; padding-bottom: 6px; }
#title h1 { font-family: 'Lilita One', var(--display); font-weight: 400; font-size: 76px; line-height: .9; margin: 0; letter-spacing: 1px; text-shadow: 0 0 30px rgba(95,224,208,.45), 0 4px 0 #000; }
#title h1 small { display: block; font-size: 13px; letter-spacing: 2px; color: var(--teal); text-shadow: none; margin-bottom: 6px; font-family: var(--body); font-weight: 800; }
#title .sub { color: var(--dim); font-size: 14px; margin: 0; line-height: 1.6; }
.menu { display: grid; gap: 8px; }
.menu .row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.record { font-size: 12px; color: var(--dim); text-align: center; }

/* ---------- hero select ---------- */
.heroes { display: grid; gap: 10px; }
.hero-pick { display: grid; grid-template-columns: 84px 1fr; gap: 12px; text-align: left; border: 1px solid var(--line); border-radius: 16px; padding: 10px; background: var(--ink-2); align-items: center; }
.hero-pick img { width: 84px; height: 84px; object-fit: cover; border-radius: 50%; border: 2px solid var(--teal); }
.hero-pick b { font-family: var(--display); font-weight: 400; font-size: 20px; display: block; }
.hero-pick .pw { color: var(--teal); font-size: 13px; font-weight: 800; margin: 2px 0; }
.hero-pick p { margin: 0; font-size: 13px; color: var(--dim); line-height: 1.45; }

/* ---------- matchmaking ---------- */
#match { align-items: center; justify-content: center; text-align: center; gap: 16px; }
#match .vs { display: flex; align-items: center; gap: 18px; }
#match .vs img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 3px solid var(--teal); }
#match .vs .foe img { border-color: var(--blood); }
#match .vs b { display: block; margin-top: 6px; font-size: 14px; }
#match .vs .vs-deck { display: block; margin-top: 4px; font-size: 12px; color: var(--gold); }   /* the opponent's deck, under their name */
#match .vs i { font-family: var(--display); font-style: normal; font-size: 34px; color: var(--gold); }
#match .spin { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--teal); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#match p { margin: 0; color: var(--dim); max-width: 22em; line-height: 1.6; }

/* ---------- duel ---------- */
#duel { padding-top: 6px; padding-bottom: 6px; gap: 6px; position: relative; }
#duel .bg { position: absolute; inset: 0; background: url(img/bg_hall.jpg) center / cover; opacity: .22; pointer-events: none; }
#duel > * { position: relative; }
.herobar { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.portrait { position: relative; width: var(--pt); height: var(--pt); border-radius: 50%; border: 2px solid var(--line); background: var(--ink-2) center / cover; flex: none; }
.portrait .hp { position: absolute; right: -6px; bottom: -4px; min-width: 26px; height: 26px; border-radius: 13px; background: var(--blood); color: #fff; font-family: 'Lilita One', var(--display); font-size: 16px; display: grid; place-items: center; padding: 0 5px; box-shadow: 0 2px 0 #7a1622; }
.portrait .armor { position: absolute; left: -6px; bottom: -4px; min-width: 24px; height: 24px; border-radius: 6px; background: #8b93a8; color: #fff; font-family: 'Lilita One', var(--display); font-size: 14px; display: grid; place-items: center; padding: 0 4px; }
.portrait.tgt { border-color: var(--blood); box-shadow: 0 0 0 3px rgba(255,90,106,.45), 0 0 18px rgba(255,90,106,.6); animation: pulse 1s ease-in-out infinite; }
.who { min-width: 0; }
.who b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The tutorial's opponent ("Trainee Curator" + its AI tag) sits beside the wide Skip tutorial button: two lines, not "Trainee Curat…". */
#duel.in-tut .herobar .who b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.15; }
.who span { font-size: 12px; color: var(--dim); }
.mana { display: flex; align-items: center; gap: 4px; font-family: 'Lilita One', var(--display); font-size: 16px; color: var(--mana); }
.mana .gem { width: 22px; height: 22px; border-radius: 6px; transform: rotate(45deg); background: linear-gradient(135deg, #a8ccff, var(--mana)); box-shadow: 0 0 10px rgba(111,168,255,.6); display: grid; place-items: center; }
.mana .gem span { transform: rotate(-45deg); color: #0b1a3a; font-size: 13px; }
.side-info { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 12px; color: var(--dim); }
.power { border: 2px solid var(--teal); background: var(--ink-2); border-radius: 50%; width: 52px; height: 52px; padding: 0; position: relative; display: grid; place-items: center; font-size: 11px; font-weight: 900; line-height: 1.1; }
.power em { position: absolute; top: -6px; left: -6px; width: 20px; height: 20px; border-radius: 5px; transform: rotate(45deg); background: var(--mana); display: grid; place-items: center; font-style: normal; }
.power em span { transform: rotate(-45deg); color: #0b1a3a; font-family: 'Lilita One', var(--display); font-size: 12px; }
.power:disabled { border-color: var(--line); opacity: .55; }
.power.sel { box-shadow: 0 0 0 3px var(--teal); }

.board { display: flex; justify-content: center; gap: 5px; flex: 1 1 0; min-height: calc(var(--mh) + 4px); max-height: var(--board-max); container-type: inline-size; align-items: center; padding: 4px 0; }
.board.foe { border-bottom: 1px dashed rgba(58,52,102,.7); }
.mn { position: relative; width: min(var(--mw), calc((100cqw - 30px) / 6)); height: min(var(--mh), calc((100cqw - 30px) / 6 * 1.37)); border-radius: 28px 28px 12px 12px; background: var(--ink-2) center / cover; border: 2px solid #6c6596; box-shadow: 0 3px 0 rgba(0,0,0,.4); flex: none; transition: transform .18s ease; }
.mn .a, .mn .h { position: absolute; bottom: -6px; min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; font-family: 'Lilita One', var(--display); font-size: 14px; padding: 0 4px; color: #1d1405; }
.mn .a { left: -5px; background: var(--gold); }
.mn .h { right: -5px; background: var(--blood); color: #fff; }
.mn .h.hurt { color: #ffd0d4; background: #b8243a; }
.mn .h.up, .mn .a.up { box-shadow: 0 0 0 2px var(--teal); }
.mn.taunt { border-radius: 10px; border-color: #c9c2e6; border-width: 3px; box-shadow: 0 0 0 2px #4b4475, 0 3px 0 rgba(0,0,0,.4); }
.mn.shield::after { content: ""; position: absolute; inset: -5px; border-radius: inherit; border: 2px solid rgba(255,215,120,.9); box-shadow: 0 0 14px rgba(255,207,90,.7) inset, 0 0 12px rgba(255,207,90,.6); pointer-events: none; }
.mn.frozen { filter: saturate(.3) brightness(1.15) hue-rotate(160deg); }
.mn.frozen::before { content: "❄"; position: absolute; top: 2px; right: 4px; font-size: 14px; color: var(--ice); z-index: 1; }
.mn .tag { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 900; padding: 1px 5px; border-radius: 6px; background: var(--ink-3); color: var(--dim); white-space: nowrap; }
.mn.ready { border-color: var(--teal); box-shadow: 0 0 12px rgba(95,224,208,.55), 0 3px 0 rgba(0,0,0,.4); }
.mn.sel { transform: translateY(-8px) scale(1.06); border-color: var(--gold); box-shadow: 0 0 18px rgba(255,207,90,.7); }
.mn.tgt { border-color: var(--blood); animation: pulse 1s ease-in-out infinite; }
.mn.pop { animation: pop .35s ease-out; }
.mn.dying { animation: die .45s ease-in forwards; }
.mn.mine-stolen { animation: pop .5s ease-out; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(255,90,106,.35), 0 0 20px rgba(255,90,106,.7); } }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
@keyframes die { to { transform: scale(.4) rotate(-12deg); opacity: 0; filter: grayscale(1); } }
.hitflash { animation: hitflash .3s ease; }
@keyframes hitflash { 30% { filter: brightness(2.2) saturate(.2); transform: translateX(-3px); } 60% { transform: translateX(3px); } }

.mid { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; min-height: 46px; }
.ladder { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; color: var(--dim); min-width: 0; }
/* Next to the squares when there's room, else on its own line (never squeezed to a word per line). */
.ladder > span { flex: 1 1 9em; min-width: 0; }
.ladder b { color: var(--teal); }
.ladder.bump { animation: ladderbump .4s ease; }
@keyframes ladderbump { 40% { transform: scale(1.08); filter: brightness(1.5); } }
.end-btn { border: 0; border-radius: 12px; padding: 10px 14px; font-family: var(--display); font-size: 17px; background: linear-gradient(180deg, #ffd57a, var(--gold)); color: #2a1a02; box-shadow: 0 3px 0 #a37a16; white-space: nowrap; }
.end-btn.done { background: linear-gradient(180deg, #8ef0e3, var(--teal)); box-shadow: 0 3px 0 #2a8a7f, 0 0 16px rgba(95,224,208,.6); }
.end-btn:disabled { background: var(--ink-3); color: var(--dim); box-shadow: none; }

.hand { margin-top: auto; display: flex; gap: 4px; justify-content: center; align-items: flex-end; min-height: calc(var(--ch) + 12px); container-type: inline-size; padding-top: 6px; padding-bottom: 4px; }
#duel .board.foe { align-items: flex-end; padding-bottom: 12px; } #duel .board.mine { align-items: flex-start; padding-top: 10px; }
.card { position: relative; width: var(--cw); height: var(--ch); border-radius: 9px; border: 2px solid #6c6596; background: var(--ink-2); overflow: hidden; flex: none; padding: 0; text-align: left; transition: transform .15s ease; }
.card .art { position: absolute; inset: 0 0 var(--nm) 0; background: center / cover; }
.card .nm { position: absolute; left: 0; right: 0; bottom: 0; height: var(--nm); font-size: var(--nm-fs); font-weight: 900; line-height: 1.1; padding: 2px 3px; background: #1f1a3a; display: grid; place-items: center; text-align: center; }
.card .cost { position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--mana); color: #0b1a3a; font-family: 'Lilita One', var(--display); font-size: 14px; display: grid; place-items: center; box-shadow: 0 1px 0 #24427a; }
.card .ca, .card .ch { position: absolute; bottom: calc(var(--nm) + 2px); width: 20px; height: 20px; border-radius: 50%; font-family: 'Lilita One', var(--display); font-size: 12px; display: grid; place-items: center; }
.card .ca { left: 2px; background: var(--gold); color: #1d1405; }
.card .ch { right: 2px; background: var(--blood); color: #fff; }
.card .bonus { position: absolute; top: 2px; right: 2px; font-size: 12px; font-weight: 900; padding: 1px 4px; border-radius: 6px; background: var(--teal); color: var(--ink); }
.card.spell { border-radius: 12px 12px 9px 9px; border-color: #8a7ec9; }
.card.legend { border-color: var(--gold); }
.card.can { border-color: var(--lamp); box-shadow: 0 0 10px rgba(255,155,69,.5); }
.card.cont { border-color: var(--teal); box-shadow: 0 0 12px rgba(95,224,208,.7); }
.card.cant { filter: brightness(.55) saturate(.6); }
.card.sel { transform: translateY(-14px) scale(1.06); z-index: 2; }
.foe-hand { display: flex; gap: 2px; }
.foe-hand i { width: 10px; height: 15px; border-radius: 2px; background: linear-gradient(135deg, #5a4fa3, #2a2456); border: 1px solid #6c6596; }
/* Card backs (ui.js backTile): a picture fills the tile; my own sits small beside my deck count. */
.foe-hand i.bk, .who .my-back.bk { background-size: cover; background-position: center; box-shadow: none; }
.who .my-back { display: inline-block; vertical-align: -3px; width: 10px; height: 14px; margin-right: 5px; background: var(--blue); border: 1px solid var(--ink); }

.preview { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); width: min(300px, 86%); background: rgba(24,21,48,.97); border: 1px solid var(--line); border-radius: 18px; padding: 12px; display: grid; grid-template-columns: 96px 1fr; gap: 12px; z-index: 5; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.preview .pa { width: 96px; height: 128px; border-radius: 12px; background: center / cover; position: relative; }
.preview h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 20px; }
.preview .meta { font-size: 12px; color: var(--dim); margin: 2px 0 6px; }
.preview p { margin: 0 0 8px; font-size: 13px; line-height: 1.5; }
.preview .why { font-size: 12px; color: var(--teal); margin: 0 0 8px; }
.preview .acts { display: flex; gap: 6px; }
.preview .acts button { flex: 1; padding: 9px; font-size: 14px; }
.preview.top { bottom: auto; top: 90px; }

/* Inset so the pop-in scale (up to 1.1) never pushes the box past the screen edge on a phone. */
.banner { position: absolute; left: 24px; right: 24px; top: 42%; text-align: center; font-family: var(--display); font-size: 34px; color: var(--paper); text-shadow: 0 0 24px rgba(95,224,208,.7), 0 3px 0 #000; z-index: 8; pointer-events: none; animation: banner 1.1s ease forwards; }
.banner.foe { text-shadow: 0 0 24px rgba(255,90,106,.7), 0 3px 0 #000; }
@keyframes banner { 0% { opacity: 0; transform: scale(.7); } 20% { opacity: 1; transform: scale(1.05); } 75% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.1); } }
.float { position: absolute; z-index: 9; pointer-events: none; font-family: 'Lilita One', var(--display); font-size: 26px; color: #fff; text-shadow: 0 0 8px var(--blood), 0 2px 0 #000; animation: float .9s ease-out forwards; transform: translate(-50%, -50%); }
.float.heal { text-shadow: 0 0 8px var(--teal), 0 2px 0 #000; }
.float.armor { text-shadow: 0 0 8px #8b93a8, 0 2px 0 #000; }
.float.down { color: #ffd0d4; }
@keyframes float { 0% { opacity: 0; margin-top: 6px; } 20% { opacity: 1; } 100% { opacity: 0; margin-top: -36px; } }
.played { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); z-index: 7; width: 132px; pointer-events: none; animation: played 1.1s ease forwards; }
.played .card { width: 132px; height: 194px; border-radius: 14px; }
.played .card .nm { height: 44px; font-size: 15px; }
.played .card .art { bottom: 44px; }
.played .card .cost { width: 34px; height: 34px; font-size: 20px; }
.played .card .ca, .played .card .ch { width: 30px; height: 30px; font-size: 17px; bottom: 48px; }
@keyframes played { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(.9); } }
.bubble { position: absolute; z-index: 9; transform: translate(-50%, -100%); background: var(--paper); color: var(--ink); font-size: 12px; font-weight: 800; padding: 4px 8px; border-radius: 10px; white-space: nowrap; pointer-events: none; animation: float 1.4s ease-out forwards; }

.lightsout { position: absolute; inset: 0; z-index: 20; background: #000; display: grid; place-items: center; text-align: center; pointer-events: none; animation: lo 1.8s ease forwards; }
.lightsout b { font-family: var(--display); font-size: 56px; color: var(--paper); text-shadow: 0 0 30px var(--teal); display: block; }
.lightsout span { color: var(--teal); font-weight: 800; }
@keyframes lo { 0% { opacity: 0; } 10% { opacity: 1; } 20% { opacity: .2; } 30% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; } }
/* The tutorial boss's skip ahead: the room goes dark, "a few turns later", the mana it is now. */
.tut-later { position: fixed; inset: 0; z-index: 100; background: #05040a; display: grid; place-items: center; text-align: center; pointer-events: none; animation: later 2.6s ease forwards; }
.tut-later b { display: block; font-weight: 400; font-size: 28px; color: var(--cream); }
.tut-later span { display: block; margin-top: 8px; font-size: 20px; color: var(--teal); }
@keyframes later { 0% { opacity: 0; } 15% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
.sixseven { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; pointer-events: none; background: radial-gradient(circle, rgba(255,207,90,.25), rgba(15,13,28,.85)); animation: lo 1.8s ease forwards; }
.sixseven b { font-family: 'Lilita One', var(--display); font-size: 120px; color: var(--gold); text-shadow: 0 0 40px var(--gold), 0 6px 0 #000; }
.vignette { position: absolute; inset: 0; z-index: 6; pointer-events: none; box-shadow: inset 0 0 80px rgba(255,40,60,.7); animation: lo .5s ease forwards; }
#app.shake { animation: shake 280ms cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 20%, 80% { transform: translate(-2px, 1px); } 40%, 60% { transform: translate(3px, -1px); } }
.toast { position: absolute; left: 0; right: 0; margin-inline: auto; width: fit-content; bottom: 128px; z-index: 12;   /* centred without a transform: the banner keyframes' scale() replaces any */ background: rgba(24,21,48,.95); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13px; max-width: 86%; text-align: center; pointer-events: none; animation: banner 2.2s ease forwards;
  white-space: normal; overflow-wrap: anywhere; }   /* every line shows; ui.js sets how long it stays */

/* ---------- tutorial ---------- */
.big-btn.teach { background: linear-gradient(180deg, #8ef0e3, var(--teal)); color: #06231f; box-shadow: 0 5px 0 #2a8a7f, 0 0 30px rgba(95,224,208,.35); }
.big-btn.teach small { display: block; font-family: var(--body); font-size: 12px; font-weight: 800; letter-spacing: 0; opacity: .8; }
.big-btn.second { font-size: 19px; padding: 11px 18px; }
/* Tutorial spotlight: dim everything, cut a hole round the one thing to tap, a pixel hand taps it. */
.tut { position: absolute; pointer-events: none; }
.tut-dim, .tut-fx { inset: 0; }
.tut-dim { z-index: 6; animation: tutin .24s steps(3) both; }
.tut-fx { z-index: 13; }
.tut-dim svg, .tut-fx svg { display: block; overflow: visible; }
.tut-fx .ring { fill: none; stroke: var(--gold); stroke-width: 3; animation: blink .8s steps(2) infinite; }
.tut-fx .arrow { fill: none; stroke: var(--gold); stroke-width: 6; stroke-dasharray: 6 6; animation: tutdash .5s steps(4) infinite; }
.tut-hand { z-index: 14; width: 36px; height: 42px; --tap: -9px; animation: tuttap .7s steps(2) infinite; filter: drop-shadow(3px 3px 0 rgba(11,10,20,.7)); }
.tut-hand.down { --tap: 9px; }
.tut-hand.down svg { transform: scaleY(-1); }
.tut-hand svg { display: block; }
.tut-say { z-index: 14; max-width: min(320px, calc(100% - 16px)); padding: 4px 10px; text-align: center; line-height: 1.25; font-size: 24px;
  border: 6px solid transparent; border-image: var(--win-paper) 3 fill / 6px / 0 stretch; color: var(--ink); animation: tutin .24s steps(3) both; }
.tut-say small { display: block; font-size: 12px; color: #6b5f45; margin-top: 2px; }
.tut-say .pips { display: flex; gap: 3px; justify-content: center; margin-top: 6px; }
.tut-say .pips i { width: 6px; height: 6px; background: var(--creamlo); }
.tut-say .pips i.on { background: var(--orange); }
.tut-say.free { border-image-source: var(--win-dark); color: var(--gold); }
.tut-note { z-index: 14; transform: translate(-50%, -100%); background: var(--ink); color: var(--gold); font-size: 12px; padding: 3px 6px; white-space: nowrap; box-shadow: var(--frame); }
.tut-dim.again, .tut-say.again, .tut-stairs.again { animation: none; }
/* Finale stairs: one block per cost, rising left to right; what each step pays sits on top. */
.stairs { display: flex; align-items: flex-end; gap: 6px; }
.tut-stairs { z-index: 14; padding: 4px 8px 6px; animation: tutin .24s steps(3) both;
  border: 9px solid transparent; border-image: var(--win-dark) 3 fill / 9px / 0 stretch; }
.stairs div { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 42px; }
.stairs em { font-style: normal; font-size: 12px; color: var(--dim); white-space: nowrap; }
.stairs b { height: calc(var(--h) * 1px); width: 100%; display: flex; align-items: center; justify-content: center; font-weight: 400; font-size: 12px; color: var(--cream); background: var(--panel); box-shadow: var(--frame); }
.stairs b small { font-size: 12px; }
.stairs .on b { background: var(--gold); color: var(--ink); }
.stairs .on em { color: var(--gold); }
.stairs .next b { background: var(--teallo); color: var(--cream); animation: blink .8s steps(2) infinite; }
.stairs .next em { color: var(--teal); }
.stairs .lights em { color: var(--red); }
.tut-recap { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 24px; color: var(--dim); white-space: nowrap; }
.tut-recap span { font-size: 12px; }
.tut-recap i { font-style: normal; width: 33px; height: 33px; display: grid; place-items: center; background: var(--gold); color: var(--ink); box-shadow: var(--frame); }
.tut-recap b { font-weight: 400; color: var(--gold); }
.tut-nudge { animation: nudge .3s steps(4) !important; }
@keyframes tutin { from { opacity: 0; } }
@keyframes tuttap { 50% { transform: translateY(var(--tap)); } }
@keyframes tutdash { to { stroke-dashoffset: -12; } }
@keyframes nudge { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- modal ---------- */
.modal { position: absolute; inset: 0; z-index: 30; background: rgba(8,6,16,.82); display: grid; place-items: center; padding: 20px; }
.modal .box { width: 100%; max-width: 380px; background: var(--ink-2); border: 1px solid var(--line); border-radius: 20px; padding: 18px; display: grid; gap: 12px; text-align: center; max-height: 100%; overflow-y: auto; }
.modal h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 34px; }
.modal h2.win { color: var(--gold); text-shadow: 0 0 20px rgba(255,207,90,.5); }
.modal h2.lose { color: var(--blood); }
.modal p { margin: 0; color: var(--dim); line-height: 1.6; font-size: 14px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stats div { background: var(--ink-3); border-radius: 10px; padding: 8px; font-size: 12px; color: var(--dim); }
.stats b { display: block; font-family: 'Lilita One', var(--display); font-size: 22px; color: var(--paper); font-weight: 400; }
/* the result screen: four stats in one row, and the way back stays on screen when the panels run long */
.modal .stats.four { grid-template-columns: repeat(4, 1fr); gap: 4px; }
.modal .stats.four div { padding: 6px 2px; font-size: 11px; line-height: 1.2; }
.modal .stats.four b { font-size: 20px; }
.modal .box.res > [data-act="home"] { position: sticky; bottom: 0; z-index: 2; box-shadow: 0 10px 0 var(--ink-2), 0 -8px 12px var(--ink-2); }

/* ---------- deck builder & codex ---------- */
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; border: 1px solid var(--line); background: var(--ink-2); border-radius: 12px; padding: 8px 4px; font-size: 13px; font-weight: 800; }
.tabs button[aria-pressed="true"] { border-color: var(--teal); color: var(--teal); }
.decklist { display: grid; gap: 6px; }
.dl-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; }
.dl-row .th { width: 44px; height: 44px; border-radius: 10px; background: center / cover; position: relative; }
.dl-row .th span { position: absolute; top: -4px; left: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--mana); color: #0b1a3a; font-family: 'Lilita One', var(--display); font-size: 12px; display: grid; place-items: center; }
.dl-row b { font-size: 14px; display: block; }
.dl-row small { font-size: 11px; color: var(--dim); display: block; line-height: 1.35; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--ink-3); font-size: 18px; font-weight: 900; padding: 0; }
.qty b { min-width: 16px; text-align: center; font-family: 'Lilita One', var(--display); font-size: 18px; font-weight: 400; }
.dl-row.in { border-color: var(--teal); }
.deckbar { display: flex; gap: 8px; align-items: center; }
.deckbar .count { flex: 1; font-weight: 900; }
.deckbar .count.ok { color: var(--teal); }
.deckbar .count.bad { color: var(--blood); }
.curve { display: flex; gap: 4px; align-items: flex-end; height: 44px; }
.curve div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; font-size: 11px; color: var(--dim); height: 100%; }
.curve i { display: block; width: 100%; background: var(--mana); border-radius: 3px 3px 0 0; min-height: 2px; }
.codex { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.codex button { border: 1px solid var(--line); background: var(--ink-2); border-radius: 12px; padding: 0 0 6px; overflow: hidden; font-size: 12px; font-weight: 800; }
.codex button div { height: 96px; background: center / cover; margin-bottom: 6px; }
.lore { text-align: left; }.lore .pa { height: 220px; border-radius: 14px; background: center / cover; }
.rules { display: grid; gap: 12px; font-size: 14px; line-height: 1.65; color: var(--paper); }
.rules h3 { margin: 6px 0 0; font-family: var(--display); font-weight: 400; font-size: 20px; color: var(--teal); }
.rules p, .rules ul { margin: 0; color: var(--dim); }
.rules ul { padding-left: 18px; }
.rules b { color: var(--paper); }

/* ========== responsive: every screen size ==========
   Phone portrait is the base design above. Below: hand fanning, short/tall phones, phone landscape
   (two-column duel), and tablet/desktop tiers that widen the play area and scale cards up. */

/* The card preview sits over the board, above the hand (it was falling into the flex flow). */
#duel > .preview { position: absolute; bottom: calc(var(--ch) + 28px); }

/* Hand: cards overlap just enough to fit the row, however many there are. */
.hand .card { margin-inline: min(0px, calc((100cqw - var(--n, 1) * (var(--cw) + 4px)) / (2 * var(--n, 1)))); }
.hand:has(> :nth-child(2)) { --n: 2; } .hand:has(> :nth-child(3)) { --n: 3; } .hand:has(> :nth-child(4)) { --n: 4; }
.hand:has(> :nth-child(5)) { --n: 5; } .hand:has(> :nth-child(6)) { --n: 6; } .hand:has(> :nth-child(7)) { --n: 7; }
.hand:has(> :nth-child(8)) { --n: 8; } .hand:has(> :nth-child(9)) { --n: 9; } .hand:has(> :nth-child(10)) { --n: 10; }
@media (hover: hover) and (pointer: fine) {
  .hand .card:hover:not(.sel) { transform: translateY(-8px); z-index: 1; }
  .mn:hover { filter: brightness(1.12); }
}

/* Phone portrait, tall and short. */
@media (min-height: 760px) {
  :root { --mw: 66px; --mh: 90px; --cw: 70px; --ch: 104px; --nm: 28px; --nm-fs: 11px; --pt: 64px; }
}
@media (max-height: 700px) {
  :root { --mw: 52px; --mh: 70px; --cw: 56px; --ch: 84px; --pt: 50px; }
}
@media (max-height: 600px) and (orientation: portrait) {
  :root { --mw: 48px; --mh: 64px; --cw: 52px; --ch: 78px; --nm: 24px; --nm-fs: 9px; --pt: 46px; }
  #duel { gap: 4px; }
  .mid { min-height: 38px; } .end-btn { padding: 8px 12px; font-size: 15px; }
  .power { width: 46px; height: 46px; }
}

/* Anything wider than a phone held upright: use the whole width, keep content readable. */
@media (min-width: 640px) {
  #app { max-width: none; }
  #duel { padding-inline: max(12px, env(safe-area-inset-left, 0px), calc((100% - var(--wide)) / 2)); }
  #heroes, #decks, #codex { padding-inline: max(16px, calc((100% - 900px) / 2)); }
  #rules { padding-inline: max(16px, calc((100% - 720px) / 2)); }
  #title .inner { width: min(100%, 520px); margin-inline: auto; }
  .heroes { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .decklist { grid-template-columns: 1fr 1fr; }
  .codex { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .codex button div { height: 130px; }
  .toast, .bubble { max-width: 420px; }
}

/* Phone landscape (and any short, wide window): two-column duel, heroes on the left. */
@media (orientation: landscape) and (max-height: 560px) {
  :root { --mw: 54px; --mh: 74px; --cw: 54px; --ch: 80px; --nm: 24px; --nm-fs: 9px; --pt: 46px; --board-max: none; --wide: 1100px; }
  #app { max-width: none; }
  #duel { display: grid; grid-template-columns: minmax(170px, 24%) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr) auto;
    column-gap: 12px; row-gap: 2px; padding-top: 4px; padding-bottom: 2px; }
  #duel > .herobar { grid-template-columns: auto minmax(0, 1fr); row-gap: 4px; }
  #duel > .herobar > :nth-child(3) { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px; }
  #duel > .herobar:nth-child(2) { grid-area: 1 / 1; align-self: start; }
  #duel > .board.foe { grid-area: 1 / 2; min-height: 0; padding-bottom: 8px; }
  #duel > .mid { grid-area: 2 / 1 / 3 / 3; min-height: 46px; }
  #duel > .board.mine { grid-area: 3 / 2; min-height: 0; padding-top: 8px; }
  #duel > .board.mine + .herobar { grid-area: 3 / 1 / 5 / 2; align-self: end; padding-bottom: 6px; }
  #duel > .hand { grid-area: 4 / 2; min-height: calc(var(--ch) + 8px); padding-top: 4px; padding-bottom: 2px; }
  #duel > .preview { bottom: calc(var(--ch) + 14px); }
  #duel > .preview.top { top: 8px; bottom: auto; }
  .power { width: 46px; height: 46px; font-size: 11px; }
  .end-btn { padding: 7px 14px; font-size: 16px; }
  .preview { width: min(420px, 70%); grid-template-columns: 84px 1fr; padding: 10px; }
  .preview .pa { width: 84px; height: 112px; }
  .preview p { font-size: 12px; margin-bottom: 4px; }
  .modal { padding: 10px; }
  .modal .box { max-width: 460px; padding: 14px; gap: 8px; }

  #title { justify-content: center; padding-top: 6px; padding-bottom: 6px; }
  #title .inner { width: min(100%, 860px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 1fr); column-gap: 24px; row-gap: 8px; align-items: center;
    grid-template-areas: "h m" "s m" "s r"; }
  #title h1 { grid-area: h; font-size: 60px; }
  #title h1 small { line-height: 1.3; }
  #title .corner { top: auto; bottom: 8px; right: auto; left: max(12px, env(safe-area-inset-left, 0px)); }
  #title .sub { grid-area: s; align-self: start; font-size: 13px; }
  #title .menu { grid-area: m; }
  #title .record { grid-area: r; }
  #title .big-btn { padding: 11px 16px; font-size: 20px; }
  #title .ghost-btn { padding: 9px; }
  #match .vs img { width: 72px; height: 72px; }
  #match { gap: 10px; }
}

/* Tablets and desktop. */
@media (min-width: 900px) and (min-height: 601px) and (max-height: 700px) {
  :root { --mw: 70px; --mh: 96px; --cw: 74px; --ch: 108px; --nm: 28px; --nm-fs: 11px; --pt: 60px; }
}
@media (min-width: 700px) and (min-height: 701px) {
  :root { --mw: 84px; --mh: 114px; --cw: 90px; --ch: 132px; --nm: 32px; --nm-fs: 12px; --pt: 76px; --board-max: 260px; --wide: 1000px; }
  #duel { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .board { gap: 10px; }
  .mn { border-radius: 36px 36px 14px 14px; }
  .mn .a, .mn .h { min-width: 28px; height: 28px; border-radius: 14px; font-size: 17px; bottom: -8px; }
  .mn .tag { font-size: 11px; }
  .card { border-radius: 11px; }
  .card .cost { width: 28px; height: 28px; font-size: 17px; }
  .card .ca, .card .ch { width: 26px; height: 26px; font-size: 15px; }
  .card .bonus { font-size: 12px; }
  .hand { gap: 8px; }
  .hand .card { margin-inline: min(0px, calc((100cqw - var(--n, 1) * (var(--cw) + 8px)) / (2 * var(--n, 1)))); }
  .portrait .hp { min-width: 32px; height: 32px; border-radius: 16px; font-size: 19px; }
  .portrait .armor { min-width: 28px; height: 28px; font-size: 16px; }
  .who b { font-size: 17px; } .who span { font-size: 14px; }
  .side-info { font-size: 14px; }
  .mana { font-size: 20px; gap: 6px; } .mana .gem { width: 28px; height: 28px; } .mana .gem span { font-size: 16px; }
  .power { width: 66px; height: 66px; font-size: 13px; }
  .power em { width: 24px; height: 24px; } .power em span { font-size: 14px; }
  .mid { min-height: 52px; }
  .ladder { font-size: 14px; gap: 10px; }
  .end-btn { padding: 12px 20px; font-size: 20px; }
  .foe-hand i { width: 13px; height: 19px; }
  .preview { width: min(400px, 86%); grid-template-columns: 128px 1fr; padding: 14px; gap: 14px; }
  .preview .pa { width: 128px; height: 170px; }
  .preview h3 { font-size: 24px; } .preview p { font-size: 15px; } .preview .meta, .preview .why { font-size: 13px; }
  .preview.top { top: 120px; }
  .banner { font-size: 48px; }
  .played { width: 180px; } .played .card { width: 180px; height: 264px; }
  .modal .box { max-width: 440px; padding: 24px; }
  .toast { bottom: calc(var(--ch) + 40px); font-size: 15px; }
}
@media (min-width: 1200px) and (min-height: 900px), (min-width: 700px) and (min-height: 960px) and (orientation: portrait) {
  :root { --mw: 104px; --mh: 142px; --cw: 112px; --ch: 164px; --nm: 38px; --nm-fs: 14px; --pt: 92px; --board-max: 320px; --wide: 1200px; }
  .mn .a, .mn .h { min-width: 34px; height: 34px; border-radius: 17px; font-size: 20px; }
  .card .cost { width: 34px; height: 34px; font-size: 20px; }
  .card .ca, .card .ch { width: 30px; height: 30px; font-size: 17px; }
  .power { width: 78px; height: 78px; font-size: 14px; }
  .who b { font-size: 19px; }
  .end-btn { font-size: 22px; padding: 14px 24px; }
}

/* Desktop (900 x 600 and up): like Hearthstone's full-window board, the duel is laid out at least 1100 x 800 with
   the big sizes above, then scaled to fill the window (ui.js fitDuel sets --fit, --fitw, --fith). Phones never get .fit. */
#duel.fit { --mw: 104px; --mh: 142px; --cw: 112px; --ch: 164px; --nm: 38px; --nm-fs: 14px; --pt: 92px; --board-max: 320px; --wide: 1200px;
  position: absolute; left: 0; top: 0; width: var(--fitw); height: var(--fith, 800px); transform: scale(var(--fit)); transform-origin: 0 0;
  gap: 8px; padding-top: 10px; padding-bottom: 10px;
  /* The side gutter from the board's own (unscaled) width: the plain rule's 100% is the window's, which on a big
     screen left the scaled board almost no room (2560 px wide: a 62 px hand). */
  padding-inline: max(12px, calc((var(--fitw) - var(--wide)) / 2)); }
#duel.fit .board { gap: 10px; }
#duel.fit .mn { border-radius: 36px 36px 14px 14px; }
#duel.fit .mn .a, #duel.fit .mn .h { min-width: 34px; height: 34px; border-radius: 17px; font-size: 20px; bottom: -8px; }
#duel.fit .mn .tag { font-size: 11px; }
#duel.fit .card { border-radius: 11px; }
#duel.fit .card .cost { width: 34px; height: 34px; font-size: 20px; }
#duel.fit .card .ca, #duel.fit .card .ch { width: 30px; height: 30px; font-size: 17px; }
#duel.fit .card .bonus, #duel.in-tut .card .bonus, #duel.boss .card .bonus { font-size: 12px; }
#duel.fit .hand { gap: 8px; }
#duel.fit .hand .card { margin-inline: min(0px, calc((100cqw - var(--n, 1) * (var(--cw) + 8px)) / (2 * var(--n, 1)))); }
#duel.fit .portrait .hp { min-width: 32px; height: 32px; border-radius: 16px; font-size: 19px; }
#duel.fit .portrait .armor { min-width: 28px; height: 28px; font-size: 16px; }
#duel.fit .who b { font-size: 19px; } #duel.fit .who span { font-size: 14px; }
#duel.fit .side-info { font-size: 14px; }
#duel.fit .mana { font-size: 20px; gap: 6px; } #duel.fit .mana .gem { width: 28px; height: 28px; } #duel.fit .mana .gem span { font-size: 16px; }
#duel.fit .mid { min-height: 52px; }
#duel.fit .ladder { font-size: 14px; gap: 10px; }
#duel.fit .end-btn { font-size: 22px; padding: 14px 24px; }
#duel.fit .foe-hand i { width: 13px; height: 19px; }
#duel.fit .preview { width: min(400px, 86%); grid-template-columns: 128px 1fr; padding: 14px; gap: 14px; }
#duel.fit .preview h3 { font-size: 24px; } #duel.fit .preview p { font-size: 15px; } #duel.fit .preview .meta, #duel.fit .preview .why { font-size: 13px; }
#duel.fit .preview.top { top: 120px; }

/* ---- 新手教学 redo (feat/tutorial-v3, ported 2026-10-25): level map, puzzle rounds, ladder beats, boss duel ---- */
@keyframes throb { 50% { transform: scale(1.12); filter: brightness(1.4); } }
@keyframes combo { 0% { opacity: 0; transform: scale(.6); } 20% { opacity: 1; transform: scale(1.15); } 70% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: translateY(-24px); } }
@keyframes lo2 { 0% { opacity: 0; } 8% { opacity: 1; } 16% { opacity: .3; } 24% { opacity: 1; } 55% { opacity: 1; } 70% { opacity: .35; } 100% { opacity: 0; } }
/* The level map: a column of stops; done ones show stars, the next one glows, later ones are locked. */
#levels { gap: 12px; }
.lv-total { font-size: 12px; color: var(--gold); }
.lvs { display: grid; gap: 10px; }
.lv { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; text-align: left; padding: 10px;
  border: 9px solid transparent; border-image: var(--win-dark) 3 fill / 9px / 0 stretch; background: none; color: var(--cream); }
.lv i { width: 36px; height: 36px; display: grid; place-items: center; font-style: normal; font-size: 24px; background: var(--ink); color: var(--dim); box-shadow: var(--frame); }
.lv b { display: block; font-size: 24px; font-weight: 400; color: var(--gold); }
.lv small { display: block; font-size: 12px; color: var(--dim); line-height: 1.4; }
.lv em { font-style: normal; font-size: 12px; color: var(--gold); white-space: nowrap; }
.lv.done i { background: var(--teal); color: var(--ink); }
.lv.now i { background: var(--orange); color: var(--ink); animation: throb .6s steps(2) infinite; }
.lv.now { border-image-source: var(--win-paper); color: var(--ink); }
.lv.now small { color: #5a4f3a; } .lv.now b { color: var(--orangelo); }
.lv.locked { opacity: .45; }
.lv-stars { font-size: 36px; color: var(--gold); letter-spacing: 6px; }
.knock { color: var(--teal); }
/* A cleared level: what it taught, then the next one with a card from it. */
.lv-got { margin: 4px 0; }
.lv-next { margin: 4px auto 8px; max-width: 300px; }
.lv-next .card { width: 64px; }
.lv-next p { color: var(--teal); }
/* Round cleared: a big star (or check, after a miss) in the middle of the board. */
.round-clear { position: absolute; left: 0; right: 0; top: 34%; z-index: 16; text-align: center; pointer-events: none; animation: combo 1.2s steps(6, end) forwards; }
.round-clear b { display: block; font-weight: 400; font-size: 72px; color: var(--gold); text-shadow: var(--ink-outline), 0 6px 0 var(--ink); }
.round-clear span { font-size: 24px; color: var(--cream); text-shadow: var(--ink-outline); }
/* A ladder payoff, paused on: the number that changed is the headline, the reason is one small line. */
.tut-beat { z-index: 15; display: grid; gap: 2px; text-align: center; padding: 6px 12px; max-width: min(320px, calc(100% - 16px));
  border: 6px solid transparent; border-image: var(--win-paper) 3 fill / 6px / 0 stretch; color: var(--ink); animation: tutin .24s steps(3) both; }
.tut-beat b { font-size: 24px; font-weight: 400; color: var(--orangelo); }
.tut-beat span { font-size: 12px; }
.tut-beat small { font-size: 12px; color: #6b5f45; }
/* A miss: a small panel over the board with the reason and one button. */
.tut-fail { position: absolute; inset: 0; z-index: 17; display: grid; place-items: center; background: rgba(11,10,20,.6); }
.tut-fail > div { display: grid; gap: 8px; text-align: center; width: min(300px, 86%); padding: 12px;
  border: 9px solid transparent; border-image: var(--win-dark) 3 fill / 9px / 0 stretch; }
.tut-fail b { font-size: 36px; font-weight: 400; color: var(--gold); }
.tut-fail span { font-size: 12px; color: var(--cream); }
.tut-fail small { font-size: 12px; color: var(--dim); }
/* The trainee's speech bubble, hanging off their portrait. */
.tut-quip { z-index: 14; max-width: calc(100% - 110px); padding: 2px 8px; font-size: 12px; color: var(--ink); line-height: 1.4;
  border: 6px solid transparent; border-image: var(--win-paper) 3 fill / 6px / 0 stretch; animation: tutin .24s steps(3) both; }
.tut-quip.again { animation: none; }
/* Finale stairs: a lit step wears the card that landed on it; step 4 throbs red before it lands; a wrong card shakes the needed step. */
.tut-stairs { padding: 0 4px 2px; border-width: 6px; }
.stairs div { gap: 2px; width: 48px; }
.stairs em { line-height: 12px; }
.stairs .on b { background: var(--gold) center 25% / cover; color: #fff; text-shadow: var(--ink-outline); box-shadow: var(--frame), inset 0 0 0 2px var(--gold);
  align-items: flex-end; justify-content: flex-start; padding: 0 0 2px 4px; }
.stairs .on b small { display: none; }
.stairs div.next.lights b { background: var(--redlo); animation: throb .5s steps(2) infinite; }
.stairs div.next.lights em { animation: throb .5s steps(2) infinite; }
/* In a real duel the stairs sit in the ladder bar: smaller blocks, no frame. */
.ladder .stairs { gap: 3px; }
.ladder .stairs div { width: 34px; gap: 4px; }
.ladder > span { line-height: 1.2; }
/* The fitted desktop board has room: bigger blocks and labels, in a bar tall enough for the highest rung (backlog #94). */
#duel.fit .mid { min-height: 62px; }
#duel.fit .ladder .stairs { gap: 4px; }
#duel.fit .ladder .stairs div { width: 48px; }
#duel.fit .ladder .stairs b { height: calc((var(--h) + 6) * 1px); font-size: 14px; }
#duel.fit .ladder .stairs b small { font-size: 14px; }
#duel.fit .ladder .stairs em { font-size: 14px; line-height: 14px; }
.tut-stairs.miss .next b { animation: nudge .3s steps(4) 3; box-shadow: var(--frame), inset 0 0 0 3px var(--red); }
@media (min-width: 700px) and (min-height: 701px) { .tut-stairs { transform: scale(1.4); transform-origin: left center; } }
.tut-recap { flex-wrap: wrap; padding-top: 18px; }
.tut-recap i { position: relative; }
/* The bonus over each step: its own dark tag, so it reads as clearly as the card's "+1" (not faint teal on the panel). */
.tut-recap i em { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); font-style: normal; font-size: 12px; line-height: 14px;
  padding: 0 3px; background: var(--ink); color: var(--teal); white-space: nowrap; }
/* The deck as a small pile beside the hand (turns level), so draws visibly come from somewhere. */
.deck-pile { position: absolute !important; right: max(12px, env(safe-area-inset-right, 0px)); bottom: 12px; width: 40px; height: 56px; z-index: 2; }
.deck-pile i { position: absolute; inset: 0; background: var(--blue); border: 3px solid var(--ink); box-shadow: inset 3px 3px 0 #9cc0ff, 4px 4px 0 var(--bluelo), 8px 8px 0 var(--ink); }
.deck-pile b { position: absolute; left: 0; right: 0; bottom: -18px; text-align: center; font-size: 12px; font-weight: 400; color: var(--dim); }
/* In tutorial puzzles the end-turn slot holds a quiet restart instead. */
.end-btn.redo { border-image-source: var(--btn-dark); color: var(--dim); text-shadow: none; font-size: 12px; padding: 6px 12px; }
/* The boss duel: its own hall, a title splash, a knockout line. */
#duel.boss .bg { background-image: url(img/bg_boss.jpg); opacity: .35; }
.boss-intro { position: absolute; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 6px; pointer-events: none;
  background: rgba(11,10,20,.85); animation: lo2 1.9s steps(8, end) forwards; }
.boss-intro img { width: 132px; height: 132px; object-fit: cover; box-shadow: var(--frame); border: 3px solid var(--red); }
.boss-intro b { font-size: 36px; font-weight: 400; color: var(--gold); text-shadow: var(--ink-outline); }
.boss-intro span { font-size: 24px; color: var(--red); letter-spacing: 6px; }
/* 今晚的鬼's opening (ui.js dailyIntro): the boss splash in gold, with the mode name above and the opponent under it. */
.daily-intro img { border-color: var(--gold); }
.daily-intro span { font-size: 16px; color: var(--gold); letter-spacing: 2px; }
.daily-intro b { font-size: 32px; color: var(--cream); }
.daily-intro small { font-size: 14px; color: var(--cream); max-width: 90vw; text-align: center; }
.boss-ko { position: absolute; left: 0; right: 0; top: 30%; z-index: 21; text-align: center; pointer-events: none; animation: combo 1.8s steps(8, end) forwards; }
.boss-ko b { font-size: 48px; font-weight: 400; color: var(--gold); text-shadow: 0 9px 0 var(--orangelo), var(--ink-outline); }
.portrait.ko { filter: grayscale(1) brightness(.6); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
