@font-face { font-family: 'Cinzel'; src: url(../fonts/cinzel.woff2) format('woff2'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Inter'; src: url(../fonts/inter.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --bg-0: #07060d;
  --bg-1: #151026;
  --bg-2: #261a3f;
  --panel: rgba(28, 22, 48, 0.72);
  --panel-solid: #1d1730;
  --line: rgba(255, 230, 170, 0.14);
  --text: #f3eee2;
  --muted: #a69fb8;
  --gold: #f2c25b;
  --gold-2: #b9842b;
  --hp: #e5484d;
  --hp-2: #8f1d24;
  --block: #5aa9e6;
  --good: #6fdc8c;
  --violet: #a97bff;
  --gutter: 12px;
  --display: 'Cinzel', Georgia, serif;
  --ui: 'Inter', system-ui, -apple-system, sans-serif;
  --glow: #b04cff;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--text);
  font: 500 15px/1.35 var(--ui);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(120% 60% at 50% 0%, var(--bg-2) 0%, transparent 70%),
    radial-gradient(90% 50% at 50% 100%, #1a0f22 0%, transparent 70%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-color: var(--bg-0);
}

/* stone texture + vignette */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.012) 0 2px, transparent 2px 46px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.01) 0 2px, transparent 2px 92px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.65) 100%);
}

/* drifting dust */
.dust { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.dust i {
  position: absolute;
  bottom: -10px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffdca0;
  opacity: 0;
  box-shadow: 0 0 6px #ffcb6b;
  animation: dust 14s linear infinite;
}
.dust i:nth-child(1) { left: 8%;  animation-delay: 0s; }
.dust i:nth-child(2) { left: 22%; animation-delay: -4s; animation-duration: 18s; }
.dust i:nth-child(3) { left: 41%; animation-delay: -9s; }
.dust i:nth-child(4) { left: 57%; animation-delay: -2s; animation-duration: 20s; }
.dust i:nth-child(5) { left: 73%; animation-delay: -12s; }
.dust i:nth-child(6) { left: 88%; animation-delay: -6s; animation-duration: 16s; }
.dust i:nth-child(7) { left: 33%; animation-delay: -15s; animation-duration: 22s; }
.dust i:nth-child(8) { left: 65%; animation-delay: -8s; animation-duration: 17s; }
@keyframes dust {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: .5; }
  90% { opacity: .3; }
  100% { transform: translate(30px, -105vh); opacity: 0; }
}

body.redflash::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(229, 72, 77, .45));
  animation: fadeout .4s forwards;
}
@keyframes fadeout { to { opacity: 0; } }

#app { position: relative; height: 100%; z-index: 1; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

button { font: inherit; color: inherit; border: 0; background: none; touch-action: manipulation; cursor: pointer; }
svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* ---------- Frame ---------- */

.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) var(--gutter) calc(env(safe-area-inset-bottom) + 12px);
  max-width: 560px;
  margin: 0 auto;
}
.screen.fresh { animation: screenin .35s ease-out; }
@keyframes screenin { from { opacity: 0; transform: translateY(8px); } }

.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 0 6px; }
.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px 0 8px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(6px);
}
.pill svg { width: 18px; height: 18px; }
.pill small { color: var(--muted); font-weight: 600; }
.pill.hp { margin-left: auto; }
.pill.hp b { color: #ff8c8f; }
.pill.icon { width: 32px; padding: 0; justify-content: center; color: var(--muted); }

.dock { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; position: relative; }
h1 { font-family: var(--display); font-weight: 900; font-size: 34px; letter-spacing: .04em; }
.gold {
  background: linear-gradient(180deg, #fff3c4, var(--gold) 50%, var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 10px rgba(242, 194, 91, .35));
}
.red { color: #ff6b6b; text-shadow: 0 0 20px rgba(229, 72, 77, .5); }
.sub { color: var(--muted); font-size: 14px; text-align: center; max-width: 280px; }

.btn {
  position: relative;
  border-radius: 14px;
  padding: 14px 16px;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: .05em;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: transform .08s;
}
.btn.big { padding: 18px 16px; font-size: 19px; }
.btn.small { padding: 8px; font-size: 13px; font-family: var(--ui); font-weight: 600; letter-spacing: 0; }
.btn small { font-family: var(--ui); font-size: 15px; opacity: .75; margin-left: 6px; }
.btn.primary {
  color: #2a1804;
  background: linear-gradient(180deg, #ffe39a, var(--gold) 45%, #c98b2a);
  border: 1px solid #ffe7a8;
  box-shadow: 0 4px 0 #7a4f12, 0 8px 22px rgba(242, 194, 91, .25), inset 0 1px 0 rgba(255,255,255,.6);
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
}
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #7a4f12, 0 4px 12px rgba(242, 194, 91, .2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }

/* (map styles: see "Metro map" below) */

/* ---------- Combat: stage ---------- */

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.stage::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 52%;
  width: 280px;
  height: 280px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, color-mix(in srgb, var(--glow) 35%, transparent), transparent 65%);
  filter: blur(10px);
  pointer-events: none;
  animation: breathe-glow 4s ease-in-out infinite;
}
@keyframes breathe-glow { 50% { opacity: .65; transform: translate(-50%, -50%) scale(1.08); } }

.intent {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: bob 2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-4px); } }
.ibits {
  display: flex;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(10, 6, 18, .75);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.ib { display: flex; align-items: center; gap: 4px; font-family: var(--display); font-weight: 900; font-size: 20px; }
.ib svg { width: 22px; height: 22px; }
.ib.attack b { color: #ff8478; }
.ib.block b { color: #9fd0ff; }
.iname { font-size: 11px; color: var(--muted); margin-top: 3px; letter-spacing: .05em; text-transform: uppercase; font-weight: 700; }

.enemy { position: relative; z-index: 1; width: clamp(130px, 25vh, 210px); aspect-ratio: 1; }
.enemy.tier-elite { width: clamp(145px, 27vh, 225px); }
.enemy.tier-boss { width: clamp(165px, 30vh, 250px); }
.enemy-art { width: 100%; height: 100%; transform-origin: 50% 95%; animation: idle 3.2s ease-in-out infinite; filter: drop-shadow(0 10px 18px rgba(0,0,0,.55)); }
@keyframes idle { 50% { transform: scale(1.03, .97) translateY(2px); } }
.enemy.enter { animation: drop-in .55s cubic-bezier(.2,1.4,.4,1); }
@keyframes drop-in { from { transform: translateY(-40px) scale(.7); opacity: 0; } }
.enemy.hit { animation: recoil .35s ease-out; }
.enemy.hit .enemy-art { filter: drop-shadow(0 10px 18px rgba(0,0,0,.55)) brightness(2.2) saturate(.3); }
@keyframes recoil { 30% { transform: translate(6px, -4px) rotate(3deg); } 60% { transform: translate(-4px, 0) rotate(-2deg); } }
.enemy.lunge { animation: lunge .4s cubic-bezier(.5,-0.4,.5,1.4); }
@keyframes lunge { 50% { transform: translateY(46px) scale(1.15); } }
.enemy.dying { animation: die .8s ease-in forwards; }
@keyframes die {
  20% { transform: scale(1.08); filter: brightness(3); }
  100% { transform: scale(.4) translateY(30px); filter: brightness(4) blur(6px); opacity: 0; }
}

.ename { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 900; font-size: 18px; letter-spacing: .03em; text-shadow: 0 2px 6px #000; }
.tier { font-family: var(--ui); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; padding: 2px 7px; border-radius: 999px; background: #8f1d24; color: #ffd6d6; }

.hpbar {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 280px;
  height: 20px;
  border-radius: 999px;
  background: #120b14;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.6);
}
.hpbar .ghost, .hpbar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.hpbar .ghost { background: #ffe1c2; opacity: .8; transition: width .6s ease-in .25s; }
.hpbar .fill {
  background: linear-gradient(180deg, #ff7a7e, var(--hp) 50%, var(--hp-2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
  transition: width .2s;
}
.hptext { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; text-shadow: 0 1px 2px #000; }
.blockbadge {
  position: absolute;
  left: -14px;
  top: 50%;
  width: 34px;
  height: 36px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
}
.blockbadge svg { position: absolute; inset: 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
.blockbadge b { position: relative; font-size: 13px; font-weight: 900; color: #fff; text-shadow: 0 1px 2px #0b2a4a; }
.pop { animation: pop .35s ease-out; }
@keyframes pop { 40% { transform: translateY(-50%) scale(1.35); } }

.chips { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; min-height: 20px; }
.chip { display: flex; gap: 3px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(10, 6, 18, .7); border: 1px solid var(--line); }
.chip.strength { color: var(--gold); }
.chip.vulnerable { color: #ff9b7a; }
.chip.weak { color: var(--violet); }
.chip.metallicize { color: #9fd0ff; }

.log { min-height: 18px; font-size: 12px; color: var(--muted); text-align: center; margin: 4px 0; }

.hint { height: 18px; font-size: 12px; font-weight: 700; color: var(--gold); text-align: center; opacity: .85; }
.hint.show { animation: hintpulse 1.4s; }
@keyframes hintpulse { 0% { opacity: 0; transform: translateY(4px); } 15%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- Cards ---------- */

.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 150px;
  margin: 0 calc(9px - var(--gutter));
  padding: 16px 0 14px;
}
.hand.hidden { visibility: hidden; }

.card {
  --w: 90px;
  --edge: #ff8a7a;
  --frame: linear-gradient(160deg, #a8323a, #5a1418 60%, #2e0a0d);
  position: relative;
  flex: none;
  width: var(--w);
  height: calc(var(--w) * 1.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--w) * .07);
  padding-top: calc(var(--w) * .12);
  border-radius: calc(var(--w) * .1);
  background: var(--frame);
  border: 1.5px solid var(--edge);
  box-shadow: 0 6px 14px rgba(0,0,0,.55), inset 0 0 0 2px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.25);
  text-align: center;
  transform: translateY(var(--y, 0)) rotate(var(--rot, 0));
  transform-origin: 50% 120%;
  transition: transform .14s ease-out, filter .2s;
}
.card.t-skill { --edge: #8cc8ff; --frame: linear-gradient(160deg, #2f6aa8, #163a66 60%, #0b1c36); }
.card.t-power { --edge: #ffe08a; --frame: linear-gradient(160deg, #b98a2a, #6a4a12 60%, #352306); }

.card .c-cost {
  position: absolute;
  top: calc(var(--w) * -.09);
  left: calc(var(--w) * -.09);
  width: calc(var(--w) * .3);
  height: calc(var(--w) * .3);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 900;
  font-size: calc(var(--w) * .19);
  color: #2a1804;
  background: radial-gradient(circle at 35% 30%, #fff1b8, var(--gold) 55%, #9a6418);
  border: 1.5px solid #fff1c4;
  box-shadow: 0 2px 6px rgba(0,0,0,.6), 0 0 10px rgba(242,194,91,.45);
  z-index: 2;
}
.card .c-name {
  width: 100%;
  font-family: var(--display);
  font-weight: 900;
  font-size: calc(var(--w) * .13);
  line-height: 1.05;
  min-height: 2.2em;
  display: grid;
  place-items: center;
  color: #fff8e6;
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.card .c-art {
  width: 100%;
  height: calc(var(--w) * .42);
  flex: none;
  padding: calc(var(--w) * .04);
  border-radius: calc(var(--w) * .06);
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.18), rgba(0,0,0,.45));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), inset 0 4px 10px rgba(0,0,0,.4);
}
.card .c-type {
  margin-top: calc(var(--w) * -.05);
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0,0,0,.65);
  font-size: calc(var(--w) * .085);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--edge);
  position: relative;
}
.card .c-text {
  flex: 1;
  display: grid;
  place-items: center;
  width: 100%;
  margin-top: 2px;
  font-size: calc(var(--w) * .132);
  font-weight: 600;
  line-height: 1.15;
  color: #f1e9db;
}
.card .c-text b { color: #fff; font-weight: 900; font-size: 1.1em; }
.card .c-text b.up { color: var(--good); }
.card .c-text b.down { color: #ff8478; }
.card .c-text em { font-style: normal; color: var(--gold); font-weight: 700; }

.hand .card.ok { box-shadow: 0 6px 14px rgba(0,0,0,.55), 0 0 12px color-mix(in srgb, var(--edge) 45%, transparent), inset 0 1px 0 rgba(255,255,255,.25); }
.hand .card.ok:active { transform: translateY(calc(var(--y, 0px) - 22px)) rotate(0) scale(1.12); z-index: 30 !important; }
.hand .card.dim { filter: grayscale(.75) brightness(.55); }
.hand .card.dim .c-cost { background: radial-gradient(circle at 35% 30%, #ffb3b3, #c43a3a 55%, #6a1414); box-shadow: 0 2px 6px rgba(0,0,0,.6); }
.card.nope { animation: nope .32s; }
@keyframes nope { 25% { margin-top: 0; translate: -6px 0; } 75% { translate: 6px 0; } }

.card.deal { animation: deal .42s cubic-bezier(.2,.9,.3,1.15) backwards; }
@keyframes deal { from { transform: translate(-45vw, 80px) rotate(-40deg) scale(.4); opacity: 0; } }
.card.discard { animation: discard .35s ease-in forwards; }
@keyframes discard { to { transform: translate(45vw, 80px) rotate(40deg) scale(.4); opacity: 0; } }

.card.flying { position: fixed; z-index: 60; transform-origin: 50% 50%; }

/* reward cards */
.reward-row { display: flex; justify-content: center; gap: 10px; padding: 14px 0 6px; }
.card.big { animation: rise .5s cubic-bezier(.2,1.2,.4,1) backwards; }
.card.big:active { transform: scale(1.05); }
@keyframes rise { from { transform: translateY(60px) rotate(8deg); opacity: 0; } }
.card.chosen { animation: chosen .5s ease-out forwards; z-index: 5; }
@keyframes chosen { 40% { transform: scale(1.15); filter: brightness(1.4); } 100% { transform: translateY(-80px) scale(.6); opacity: 0; } }
.card.faded { transition: opacity .3s, transform .3s; opacity: 0; transform: translateY(30px) scale(.9); }

/* ---------- Controls ---------- */

.controls { display: flex; align-items: center; gap: 10px; }
.energy {
  position: relative;
  width: 62px;
  height: 62px;
  flex: none;
  border-radius: 50%;
  display: flex;
  align-items: baseline;
  justify-content: center;
  padding-top: 12px;
  color: #2a1804;
  background: radial-gradient(circle at 35% 30%, #fff4c2, var(--gold) 50%, #94600f);
  border: 2px solid #ffe7a8;
  box-shadow: 0 0 20px rgba(242,194,91,.55), inset 0 -4px 8px rgba(0,0,0,.25);
  animation: energy 2.4s ease-in-out infinite;
}
@keyframes energy { 50% { box-shadow: 0 0 30px rgba(242,194,91,.8), inset 0 -4px 8px rgba(0,0,0,.25); } }
.energy b { font-family: var(--display); font-size: 26px; font-weight: 900; }
.energy small { font-size: 13px; font-weight: 800; opacity: .7; }
.energy.empty { filter: grayscale(.8) brightness(.6); animation: none; }
.energy.pop { animation: energypop .35s; }
@keyframes energypop { 40% { transform: scale(1.2); } }

.piles { flex: 1; display: flex; gap: 12px; }
.pile { display: flex; flex-direction: column; align-items: center; font-size: 10px; color: var(--muted); font-weight: 700; }
.pile svg { width: 22px; height: 22px; }
.pile b { font-size: 13px; color: var(--text); margin-top: -2px; }
.pile.discard svg { filter: hue-rotate(160deg) saturate(.6); }
.btn.end { padding: 18px 22px; font-size: 17px; }
.btn.end.nudge { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { box-shadow: 0 4px 0 #7a4f12, 0 0 30px rgba(242,194,91,.8), inset 0 1px 0 rgba(255,255,255,.6); transform: scale(1.04); } }

/* ---------- Rest / End ---------- */

.hero::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 40%;
  width: 300px;
  height: 300px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
}
.rest .hero::before { background: radial-gradient(circle, rgba(255,140,50,.35), transparent 65%); animation: flicker 1.8s ease-in-out infinite; }
.reward .hero::before, .end.won .hero::before { background: radial-gradient(circle, rgba(242,194,91,.28), transparent 65%); }
.end.lost .hero::before { background: radial-gradient(circle, rgba(229,72,77,.25), transparent 65%); }
@keyframes flicker { 30% { opacity: .75; } 60% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } }

.campfire { width: 150px; height: 150px; position: relative; animation: fire 1.2s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes fire { 50% { transform: scale(1.04, .96); } }
.campfire.roar { animation: roar .9s ease-out; }
@keyframes roar { 30% { transform: scale(1.25); filter: brightness(1.5); } }
.laurel { width: 56px; height: 56px; filter: drop-shadow(0 0 14px rgba(242,194,91,.6)); animation: bob 2s ease-in-out infinite; }
.end-art { width: 150px; height: 150px; position: relative; }
.end.won .end-art { animation: bob 2s ease-in-out infinite; filter: drop-shadow(0 0 24px rgba(242,194,91,.6)); }
.end.lost .end-art { filter: grayscale(.4) brightness(.7) drop-shadow(0 0 20px rgba(229,72,77,.4)); }

.stats { display: flex; gap: 10px; margin-top: 10px; }
.stats span {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 78px;
  padding: 10px 8px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.stats b { font-family: var(--display); font-size: 24px; font-weight: 900; color: var(--gold); }
.stats small { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Effects ---------- */

.floater {
  position: absolute;
  top: 30%;
  z-index: 40;
  transform: translateX(-50%);
  font-family: var(--display);
  font-weight: 900;
  font-size: 30px;
  white-space: nowrap;
  pointer-events: none;
  -webkit-text-stroke: 1.5px rgba(0,0,0,.7);
  text-shadow: 0 3px 8px rgba(0,0,0,.7);
  animation: float 1.05s cubic-bezier(.2,.8,.3,1) forwards;
}
.floater.dmg { color: #ff5c5c; }
.floater.block { color: #8fcaff; font-size: 22px; }
.floater.buff { color: var(--gold); font-size: 18px; }
.floater.debuff { color: var(--violet); font-size: 18px; }
.floater.heal { color: var(--good); }
.floater.big { font-size: 46px; }
@keyframes float {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(.5); }
  15% { opacity: 1; transform: translate(-50%, -6px) scale(1.25); }
  30% { transform: translate(-50%, -12px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60px) scale(.95); }
}

.spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff1b8;
  box-shadow: 0 0 8px #ffb347;
  pointer-events: none;
  z-index: 30;
  animation: spark .55s ease-out forwards;
}
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }

.shake { animation: shake .4s; }
@keyframes shake {
  20% { transform: translate(-7px, 3px); }
  40% { transform: translate(6px, -4px); }
  60% { transform: translate(-4px, 2px); }
  80% { transform: translate(3px, -1px); }
}

.banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 38%;
  display: flex;
  justify-content: center;
  animation: banner .9s ease-in-out forwards;
}
.banner span {
  font-family: var(--display);
  font-weight: 900;
  font-size: 28px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 10px 0;
  width: 100%;
  text-align: center;
  background: linear-gradient(90deg, transparent, rgba(10,6,18,.9) 20%, rgba(10,6,18,.9) 80%, transparent);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.banner.b-enemy span { color: #ff8478; }
.banner.b-you span { color: var(--gold); }
@keyframes banner {
  0% { opacity: 0; transform: scaleY(.2); }
  20%, 70% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-10px); }
}

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

/* larger reward cards carry proportionally smaller text */
.card.big .c-text { font-size: calc(var(--w) * .108); }
.card.big .c-name { font-size: calc(var(--w) * .118); }
.card.long .c-art { height: calc(var(--w) * .3); }
.card.long .c-art svg { width: 70%; margin: 0 auto; }
.card.long .c-text { font-size: calc(var(--w) * .118); }
.card.big.long .c-text { font-size: calc(var(--w) * .1); }
.card.longname .c-name { font-size: calc(var(--w) * .108); letter-spacing: -.02em; }

/* held-card preview */
.card.preview {
  position: fixed;
  left: 50%;
  top: 44%;
  z-index: 70;
  transform: translate(-50%, -50%);
  box-shadow: 0 20px 60px rgba(0,0,0,.8), 0 0 40px color-mix(in srgb, var(--edge) 40%, transparent);
  animation: preview .16s ease-out;
}
.card.preview.long .c-art { height: calc(var(--w) * .38); }
.card.preview .c-text, .card.preview.long .c-text { font-size: calc(var(--w) * .1); }
.card.preview .c-name, .card.preview.longname .c-name { font-size: calc(var(--w) * .11); }
@keyframes preview { from { opacity: 0; transform: translate(-50%, -40%) scale(.8); } }

/* =====================================================================
   Last Train: screens added with the metro concept
   ===================================================================== */

:root { --line-a: #ff9f43; --line-b: #2ec4b6; }

.orb {
  position: relative;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #3a2f5a, #17122a);
  border: 2px solid rgba(255, 230, 170, .25);
  box-shadow: 0 4px 10px rgba(0,0,0,.5);
}
.orb svg { position: absolute; inset: 0; margin: auto; width: 58%; height: 58%; }

.prompt { text-align: center; font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* ---------- Topbar extras ---------- */
.pill.station { min-width: 0; flex: 1 1 auto; }
.pill.station span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.pill.coins b { color: var(--gold); }
.pill.hp { margin-left: 0; }
.pill.pop { animation: pillpop .35s; }
@keyframes pillpop { 40% { transform: scale(1.15); } }

/* ---------- Title ---------- */
.title-screen .hero { gap: 6px; }
.train-art { width: min(78vw, 300px); aspect-ratio: 240 / 200; animation: arrive 1.4s cubic-bezier(.2,.8,.3,1); }
@keyframes arrive { from { transform: scale(.4) translateY(30px); filter: brightness(.3); opacity: 0; } }
.train-art .headlight { animation: headlight 2.4s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes headlight { 50% { transform: scale(1.35); opacity: .8; } }
.logo {
  font-size: clamp(40px, 13vw, 58px);
  line-height: 1;
  background: linear-gradient(180deg, #fff3c4, var(--gold) 50%, #b9562b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255, 159, 67, .45));
  margin-top: 4px;
}
.tagline { font-family: var(--display); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: 12px; color: var(--muted); }
.howto { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: 13px; color: #d9d2e8; text-align: center; }
.howto em { font-style: normal; color: var(--gold); font-weight: 800; }

/* ---------- Metro map ---------- */
.metro { position: relative; flex: 1; min-height: 0; margin: 6px 0 8px; }
.metro svg { position: absolute; inset: 0; }
.rail { stroke: rgba(255,255,255,.12); stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.rail.a.open { stroke: var(--line-a); opacity: .9; stroke-dasharray: 4 5; animation: railflow 0.8s linear infinite; }
.rail.b.open { stroke: var(--line-b); opacity: .9; stroke-dasharray: 4 5; animation: railflow 0.8s linear infinite; }
.rail.mid.open { stroke: var(--gold); opacity: .9; stroke-dasharray: 4 5; animation: railflow 0.8s linear infinite; }
.rail.done { stroke: var(--gold); stroke-width: 5; opacity: .85; }
@keyframes railflow { to { stroke-dashoffset: -9; } }

.station-node { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; }
.station-node .orb { width: 34px; height: 34px; }
.station-node.boss .orb { width: 46px; height: 46px; border-color: rgba(255, 107, 94, .7); box-shadow: 0 0 22px rgba(255, 59, 48, .4); }
.station-node.skipped { opacity: .3; }
.station-node.done .orb { border-color: var(--gold); filter: saturate(.5) brightness(.75); }
.station-node.current .orb { border-color: var(--gold); animation: beacon 1.6s ease-in-out infinite; }
.station-node.current.left .orb { border-color: var(--line-a); }
.station-node.current.right .orb { border-color: var(--line-b); }
@keyframes beacon {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 194, 91, .6), 0 0 18px rgba(242, 194, 91, .4); transform: scale(1); }
  50% { box-shadow: 0 0 0 10px rgba(242, 194, 91, 0), 0 0 26px rgba(242, 194, 91, .6); transform: scale(1.1); }
}
.sname { position: absolute; font-size: 10px; font-weight: 700; color: var(--muted); white-space: nowrap; letter-spacing: .02em; }
.station-node.left .sname { right: calc(100% + 6px); }
.station-node.right .sname, .station-node.mid .sname { left: calc(100% + 6px); }
.station-node.current .sname { color: var(--text); }

.choices { display: flex; gap: 8px; }
.choice {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 16px;
  text-align: left;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
  animation: rise .45s cubic-bezier(.2,1.2,.4,1) backwards;
  transition: transform .08s;
}
.choice.line-a { border-color: color-mix(in srgb, var(--line-a) 70%, transparent); }
.choice.line-b { border-color: color-mix(in srgb, var(--line-b) 70%, transparent); animation-delay: 80ms; }
.choice.solo { border-color: var(--gold); }
.choice:active { transform: scale(.97); }
.choice .orb { width: 44px; height: 44px; }
.choice .ctext { display: flex; flex-direction: column; min-width: 0; }
.choice b { font-family: var(--display); font-size: 17px; line-height: 1.1; }
.choice small { font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.choice i { font-style: normal; font-size: 11px; color: #cfc6e2; line-height: 1.2; margin-top: 2px; }
.choice.elite b, .choice.boss b { color: #ff8478; }
.choice.treasure b, .choice.shop b { color: var(--gold); }
.choice.rest b { color: #ffb36b; }
.choice.event b { color: var(--violet); }

.dock-row { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.deckbtn { margin-left: auto; color: var(--text); }

/* ---------- Relics ---------- */
.relics { display: flex; gap: 4px; flex-wrap: wrap; }
.relic {
  width: 30px;
  height: 30px;
  padding: 4px;
  border-radius: 9px;
  background: rgba(10, 6, 18, .7);
  border: 1px solid rgba(203, 184, 255, .3);
  box-shadow: 0 0 10px rgba(123, 92, 214, .25);
}
.controls .relics { max-width: 70px; }
.controls .relic { width: 24px; height: 24px; padding: 3px; }

.toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  max-width: 300px;
  width: calc(100% - 48px);
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(16, 10, 28, .95);
  border: 1px solid rgba(203, 184, 255, .35);
  box-shadow: 0 12px 30px rgba(0,0,0,.6);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: toast 2.6s ease forwards;
}
.toast b { font-family: var(--display); font-size: 16px; color: var(--gold); }
.toast span { font-size: 13px; color: #ddd5ec; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 8px); } 8%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* ---------- Combat: tunnel, hero, combo ---------- */
.tunnel { position: absolute; inset: -10px calc(-1 * var(--gutter)) 0; z-index: 0; opacity: .9; pointer-events: none; }
.tunnel svg { width: 100%; height: 100%; }
.tunnel .lamp { animation: lamp 3s ease-in-out infinite; filter: drop-shadow(0 0 6px #ffb347); }
.tunnel .farlight { animation: farlight 4s ease-in-out infinite; transform-origin: 200px 150px; }
@keyframes lamp { 50% { opacity: .5; } }
@keyframes farlight { 50% { transform: scale(1.6); opacity: .6; } }
.stage::before { z-index: 0; }
.stage > *:not(.tunnel) { position: relative; z-index: 1; }

.you { position: relative; display: flex; align-items: center; gap: 10px; padding: 0 2px; }
.hero-art {
  position: relative;
  width: 74px;
  height: 74px;
  flex: none;
  transform-origin: 50% 95%;
  animation: idle 3s ease-in-out infinite;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.6));
}
.hero-art.strike { animation: herostrike .38s ease-out; }
@keyframes herostrike { 40% { transform: translate(10px, -18px) rotate(8deg) scale(1.08); } }
.hero-art.hurt { animation: herohurt .4s; }
.hero-art.hurt svg { filter: drop-shadow(0 0 0 #f00) brightness(1.4) sepia(1) saturate(6) hue-rotate(-30deg); }
@keyframes herohurt { 25% { transform: translateX(-6px) rotate(-6deg); } 75% { transform: translateX(4px); } }
.hero-art.guard::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid rgba(143, 202, 255, .8);
  box-shadow: 0 0 20px rgba(90, 169, 230, .7), inset 0 0 16px rgba(90, 169, 230, .5);
  animation: guard .5s ease-out forwards;
}
@keyframes guard { from { transform: scale(.7); opacity: 1; } to { transform: scale(1.15); opacity: 0; } }
.you-main { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.you-main .hpbar { max-width: none; }
.you-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 26px; }
.you-row .chips { justify-content: flex-start; }
.you.hit .hpbar { animation: jolt .3s; }
@keyframes jolt { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.combo {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 9px 2px 4px;
  border-radius: 999px;
  background: rgba(10, 6, 18, .7);
  border: 1px solid var(--line);
  opacity: .35;
  transition: opacity .2s;
}
.combo svg { width: 20px; height: 20px; filter: grayscale(1); }
.combo b { font-family: var(--display); font-weight: 900; font-size: 16px; }
.combo small { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.combo.on { opacity: 1; border-color: rgba(255, 140, 50, .6); box-shadow: 0 0 14px rgba(255, 122, 41, .35); }
.combo.on svg { filter: none; }
.combo.on b { color: #ffb36b; }
.combo.lvl-3, .combo.lvl-4 { box-shadow: 0 0 22px rgba(255, 122, 41, .7); animation: comboheat .8s ease-in-out infinite; }
@keyframes comboheat { 50% { box-shadow: 0 0 32px rgba(255, 160, 60, .9); } }
.combo.pop { animation: energypop .35s; }

.combo-burst {
  position: absolute;
  left: 0;
  right: 0;
  top: 47%;
  text-align: center;
  pointer-events: none;
  animation: burst .8s cubic-bezier(.2,1.4,.4,1) forwards;
}
.combo-burst span {
  font-family: var(--display);
  font-weight: 900;
  font-size: 34px;
  letter-spacing: .06em;
  background: linear-gradient(180deg, #fff3c4, #ff9f43 60%, #e5484d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.6)) drop-shadow(0 0 16px rgba(255, 122, 41, .7));
}
.combo-burst.lvl-3 span { font-size: 42px; }
.combo-burst.lvl-4 span { font-size: 50px; }
@keyframes burst {
  0% { opacity: 0; transform: scale(.4) rotate(-6deg); }
  25% { opacity: 1; transform: scale(1.1) rotate(2deg); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: translateY(-30px) scale(.95); }
}

.controls .piles { flex: 0 0 auto; }
.controls .btn.end { margin-left: auto; }

/* ---------- Cards: rarity + upgrades ---------- */
.card.r-uncommon .c-type { box-shadow: 0 0 0 1px #8cc8ff; }
.card.r-rare { box-shadow: 0 6px 14px rgba(0,0,0,.55), 0 0 16px rgba(242, 194, 91, .55), inset 0 1px 0 rgba(255,255,255,.3); }
.card.r-rare .c-type { box-shadow: 0 0 0 1px var(--gold); color: var(--gold); }
.card.r-rare::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.28) 50%, transparent 65%);
  background-size: 250% 100%;
  animation: foil 3s ease-in-out infinite;
}
@keyframes foil { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.card.upgraded .c-name { color: #9dffb0; }
.card.shine { animation: shine .7s ease-out; }
@keyframes shine { 40% { filter: brightness(1.8) drop-shadow(0 0 20px #9dffb0); transform: scale(1.08); } }
.card.selected { outline: 3px solid var(--gold); outline-offset: 2px; transform: translateY(-4px); }

/* ---------- Reward ---------- */
.reward .hero { gap: 12px; }
.loots { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.loot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  animation: rise .45s cubic-bezier(.2,1.2,.4,1) backwards;
}
.loot svg { width: 26px; height: 26px; flex: none; }
.loot b { font-family: var(--display); font-size: 20px; color: var(--gold); }
.loot small { color: var(--muted); font-weight: 700; font-size: 12px; }
.relic-loot { max-width: 320px; text-align: left; border-color: rgba(203, 184, 255, .4); box-shadow: 0 0 22px rgba(123, 92, 214, .3); animation-delay: 150ms; }
.relic-loot svg { width: 40px; height: 40px; }
.relic-loot span { display: flex; flex-direction: column; }
.relic-loot b { font-size: 16px; color: #e3d7ff; }
.relic-loot.reveal { animation: reveal .6s cubic-bezier(.2,1.4,.4,1); }
@keyframes reveal { from { transform: translateY(30px) scale(.6); opacity: 0; } }

/* ---------- Rest ---------- */
.duo { display: flex; gap: 8px; }
.duo .btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.duo .btn small { margin: 0; font-size: 13px; }
.btn.off { opacity: .45; }

/* ---------- Shop ---------- */
.shop-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 8px; }
.kiosk { width: 52px; height: 52px; flex: none; filter: drop-shadow(0 0 14px rgba(242,194,91,.45)); animation: bob 2s ease-in-out infinite; }
.shop-head h1 { font-size: 24px; }
.shop-head .sub { text-align: left; font-style: italic; }
.shop-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; padding-bottom: 10px; }
.wares { display: flex; justify-content: center; gap: 8px; padding-top: 10px; }
.ware { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ware.sold .card, .service.sold { opacity: .3; filter: grayscale(1); }
.ware.poor .price, .service.poor .price { color: #ff8478; }
.price { display: flex; align-items: center; gap: 4px; font-family: var(--display); font-weight: 900; font-size: 14px; color: var(--gold); }
.price svg { width: 16px; height: 16px; }
.service {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
}
.service .sicon { width: 34px; height: 34px; flex: none; }
.service .stext { flex: 1; display: flex; flex-direction: column; }
.service b { font-family: var(--display); font-size: 15px; }
.service small { font-size: 12px; color: var(--muted); }

/* ---------- Event ---------- */
.story { gap: 10px; padding: 0 8px; }
.event-art { width: 74px; height: 74px; filter: drop-shadow(0 0 24px rgba(155, 107, 240, .6)); animation: bob 2.4s ease-in-out infinite; }
.story h1 { font-size: 26px; }
.story-text { font-size: 16px; line-height: 1.45; color: #e6dff2; max-width: 320px; font-style: italic; }
.gains { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.gain { padding: 4px 10px; border-radius: 999px; font-weight: 800; font-size: 13px; background: var(--panel); border: 1px solid var(--line); animation: reveal .5s backwards; }
.gain.good { color: var(--good); }
.gain.bad { color: #ff8478; }
.btn.option { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; padding: 14px 16px; }
.btn.option b { font-size: 17px; }
.btn.option small { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Treasure ---------- */
.chest { width: 130px; height: 130px; filter: drop-shadow(0 10px 20px rgba(0,0,0,.6)); animation: chestwait 1.6s ease-in-out infinite; position: relative; }
@keyframes chestwait { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-5deg); } 85% { transform: rotate(5deg); } }
.chest.open { animation: chestopen .6s cubic-bezier(.2,1.4,.4,1); filter: drop-shadow(0 0 30px rgba(242,194,91,.8)); }
@keyframes chestopen { 30% { transform: scale(1.25) translateY(-10px); } }
.treasure .hero::before { background: radial-gradient(circle, rgba(242,194,91,.25), transparent 65%); }

/* ---------- End ---------- */
.newbest {
  font-family: var(--display);
  font-weight: 900;
  font-size: 14px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
  color: #2a1804;
  background: linear-gradient(180deg, #ffe39a, var(--gold));
  box-shadow: 0 0 20px rgba(242,194,91,.6);
  animation: pillpop .5s, bob 2s ease-in-out .5s infinite;
}
.end .end-art { width: 170px; height: 150px; }

/* ---------- Deck sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(4, 2, 10, .75); backdrop-filter: blur(4px); display: flex; align-items: flex-end; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.sheet-panel {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 16px 12px calc(env(safe-area-inset-bottom) + 12px);
  border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, #221a38, #120d20);
  border-top: 1px solid var(--line);
  animation: sheetup .3s cubic-bezier(.2,1,.4,1);
}
@keyframes sheetup { from { transform: translateY(40%); } }
.sheet h2 { font-family: var(--display); font-size: 18px; text-align: center; margin-bottom: 10px; }
.sheet-grid { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 6px; padding: 10px 4px; }
.sheet-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.compare { display: flex; align-items: center; justify-content: center; gap: 10px; }
.compare .arrow { font-size: 26px; color: var(--good); font-weight: 900; }

/* ---------- Train ride ---------- */
.ride {
  position: absolute;
  inset: 0;
  pointer-events: all;
  background: radial-gradient(ellipse at center, #120c22, #030208 75%);
  display: grid;
  place-items: center;
  animation: ridein .25s ease-out;
  overflow: hidden;
}
.ride.out { animation: rideout .5s ease-in forwards; }
@keyframes ridein { from { opacity: 0; } }
@keyframes rideout { to { opacity: 0; } }
.streaks i {
  position: absolute;
  left: -40%;
  width: 40%;
  height: 2px;
  border-radius: 2px;
  background: #ffcf7a;
  box-shadow: 0 0 10px #ffb347;
  animation: streak .5s linear infinite;
}
@keyframes streak { to { transform: translateX(350%); } }
.ride { animation: ridein .25s ease-out, sway .3s ease-in-out infinite alternate; }
@keyframes sway { to { transform: translateY(2px); } }
.sign {
  position: relative;
  min-width: 250px;
  padding: 14px 24px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #1b2a4a, #0d1630);
  border: 3px solid #e8edf5;
  box-shadow: 0 0 0 4px #0d1630, 0 20px 50px rgba(0,0,0,.7), 0 0 40px rgba(90, 169, 230, .25);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: signin .5s cubic-bezier(.2,1.4,.4,1) .15s backwards;
}
@keyframes signin { from { transform: translateY(20px) scale(.85); opacity: 0; } }
.sign small { font-size: 11px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: #9fd0ff; }
.sign b { font-family: var(--display); font-weight: 900; font-size: 26px; color: #fff; }
.sign span { display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 800; font-size: 13px; color: var(--gold); }
.sign span svg { width: 20px; height: 20px; }
.sign.elite span, .sign.boss span { color: #ff8478; }
.stage > .stage-relics { position: absolute; left: 0; top: 2px; z-index: 3; }
.stage-relics .relics { flex-direction: column; }
.stage-relics .relic { width: 28px; height: 28px; }
