/* Rattlebone — styles. Palette: ink plum, parchment, ember, gold. */
:root {
  --ink: #1b1320;
  --ink2: #2a1d30;
  --ink3: #3a2a42;
  --parch: #f4e6c4;
  --parch2: #d9c79c;
  --ember: #ff9a3c;
  --gold: #ffd23f;
  --blood: #d9432f;
  --good: #7fe08a;
  --cyan: #8fd3ff;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --display: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--parch);
  font-family: var(--font); touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; background: var(--ink); }

/* ---------- loading ---------- */
#loading { position: absolute; inset: 0; z-index: 50; display: grid; place-content: center; gap: 18px; background: var(--ink); text-align: center; transition: opacity .5s; }
#loading.done { opacity: 0; pointer-events: none; }
.ld-title { font-family: var(--display); font-size: clamp(28px, 7vw, 56px); letter-spacing: .25em; color: var(--ember); }
.ld-bar { width: min(260px, 60vw); height: 6px; background: var(--ink3); border-radius: 3px; overflow: hidden; margin: 0 auto; }
.ld-bar i { display: block; height: 100%; width: 40%; background: var(--ember); animation: ld 1s infinite ease-in-out; }
@keyframes ld { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; display: none; z-index: 5; }
#hud.on { display: block; }
#hud button { pointer-events: auto; }
.hud-top {
  position: absolute; left: calc(10px + var(--sal)); right: calc(10px + var(--sar)); top: calc(8px + var(--sat));
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.hud-left { width: min(34vw, 300px); }
#hp-name { font-weight: 800; font-size: 13px; letter-spacing: .04em; text-shadow: 0 1px 3px #000; margin: 0 0 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp-bar { position: relative; height: 22px; border-radius: 11px; background: rgba(15, 8, 18, .72); border: 2px solid #0b060d; overflow: hidden; }
#hp-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#6fe27c, #2f9e44); width: 100%; transition: width .15s; }
#hp-fill.low { background: linear-gradient(#ff7a5c, #c0321f); animation: pulse .8s infinite alternate; }
#hp-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.hp-bar.p2 { display: none; margin-top: 4px; height: 12px; }
body.duel .hp-bar.p2 { display: block; position: fixed; right: calc(10px + var(--sar)); top: calc(54px + var(--sat)); width: min(34vw, 300px); height: 20px; margin: 0; }
body.duel #hp2-fill { right: 0; left: auto; }
#hp2-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#7ab7ff, #2f6fbf); width: 100%; transition: width .15s; }
@keyframes pulse { to { filter: brightness(1.4); } }
#armor-pips { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.pip { position: relative; width: 28px; height: 24px; border-radius: 6px; background: rgba(15, 8, 18, .7); border: 1.5px solid #0b060d; overflow: hidden; display: grid; place-items: center; }
.pip b { font-size: 13px; z-index: 1; filter: drop-shadow(0 1px 1px #000); }
.pip u { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--cyan); }
.pip.weak u { background: var(--ember); }
.pip.broken { opacity: .45; }
.pip.broken b { filter: grayscale(1); }
.hud-center { text-align: center; text-shadow: 0 2px 4px #000; }
#wave-label { white-space: nowrap; font-family: var(--display); font-size: clamp(18px, 3.2vw, 28px); font-weight: 700; letter-spacing: .12em; color: var(--gold); }
#wave-sub { font-size: clamp(11px, 1.6vw, 14px); color: var(--parch); opacity: .9; }
.hud-right { display: flex; gap: 8px; align-items: center; }
.coins.bump { animation: bump .4s; }
.coins { white-space: nowrap; background: rgba(15, 8, 18, .72); border: 2px solid #0b060d; border-radius: 16px; padding: 4px 12px; font-weight: 700; color: var(--gold); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 2px solid #0b060d; background: rgba(15, 8, 18, .72); color: var(--parch);
  font-size: 15px; cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }

#boss-bar { position: absolute; top: calc(62px + var(--sat)); left: 50%; transform: translateX(-50%); width: min(60vw, 520px); display: none; text-align: center; }
#boss-bar.on { display: block; }
.boss-name { font-family: var(--display); font-weight: 700; letter-spacing: .1em; text-shadow: 0 2px 3px #000; color: #ff8a5c; font-size: 15px; margin-bottom: 3px; }
.boss-track { position: relative; height: 14px; border-radius: 7px; background: rgba(15, 8, 18, .8); border: 2px solid #0b060d; overflow: hidden; }
#boss-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#ff7a5c, #a1241a); width: 100%; transition: width .2s; }
#boss-ticks i { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, .6); }

#wind { position: absolute; top: calc(128px + var(--sat)); left: 50%; transform: translateX(-50%); display: none; gap: 8px; align-items: center; padding: 3px 12px; border-radius: 12px; background: rgba(15, 8, 18, .6); font-size: 12px; }
#wind.on { display: flex; }
#wind span { opacity: .7; letter-spacing: .1em; }
#wind b { color: var(--cyan); }
body:not(.windy-offset) #boss-bar:not(.on) ~ #wind { top: calc(62px + var(--sat)); }

#banner { position: absolute; left: 0; right: 0; top: 22%; text-align: center; pointer-events: none; opacity: 0; }
#banner.show { animation: banner 2.6s ease-out forwards; }
.bn-title { font-family: var(--display); font-size: clamp(30px, 7vw, 68px); font-weight: 800; letter-spacing: .12em; text-shadow: 0 3px 0 #0b060d, 0 0 24px rgba(0,0,0,.6); }
.bn-sub { margin-top: 6px; font-size: clamp(13px, 2.2vw, 20px); text-shadow: 0 2px 3px #000; }
@keyframes banner { 0% { opacity: 0; transform: scale(1.4); } 12% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }

#hint {
  position: absolute; left: 50%; bottom: calc(96px + var(--sab)); transform: translateX(-50%); max-width: min(86vw, 460px); text-align: center;
  background: rgba(15, 8, 18, .78); border: 2px solid var(--ember); border-radius: 14px; padding: 10px 16px; font-size: clamp(13px, 2vw, 17px);
  opacity: 0; transition: opacity .25s; text-shadow: 0 1px 2px #000;
}
#hint.on { opacity: 1; animation: bob 1.6s ease-in-out infinite; }
#hint small { opacity: .7; }
@keyframes bob { 50% { transform: translateX(-50%) translateY(-5px); } }

#hotbar { position: absolute; left: 50%; bottom: calc(10px + var(--sab)); transform: translateX(-50%); display: flex; gap: 6px; max-width: 70vw; overflow-x: auto; padding: 2px; pointer-events: auto; }
.hb {
  position: relative; min-width: 54px; height: 58px; border-radius: 12px; border: 2px solid #0b060d; background: rgba(15, 8, 18, .75); color: var(--parch);
  cursor: pointer; display: grid; grid-template-rows: 1fr auto; place-items: center; padding: 2px 4px; font-family: inherit;
}
.hb.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 210, 63, .35), inset 0 0 14px rgba(255, 210, 63, .2); }
.hb.dis { opacity: .38; filter: grayscale(1); }
.hb.dis .hb-ico { text-shadow: none; opacity: .5; }
.hb.dis .hb-n { visibility: hidden; }
.hb.cd { filter: saturate(.5); }
.hb.want { border-color: rgba(255, 210, 63, .5); border-style: dashed; }
.hb-cd, .hb-x { position: absolute; bottom: 2px; right: 4px; font-size: 9px; font-weight: 800; letter-spacing: .03em; color: #ffd9a0; }
.hb-x { left: 0; right: 0; text-align: center; color: #ff9a8a; bottom: 1px; font-size: 8px; }
.hb-ico { font-size: 24px; color: var(--c, #fff); text-shadow: 0 0 8px var(--c, #fff); transform: rotate(-30deg); }
.hb-n { font-size: 12px; font-weight: 700; }
.hb-key { position: absolute; top: 2px; left: 5px; font-size: 10px; opacity: .6; }
.hb-name { display: none; }

.touch-ctl { position: absolute; bottom: calc(10px + var(--sab)); display: none; gap: 10px; pointer-events: none; }
.touch-ctl.left { left: calc(10px + var(--sal)); }
.touch-ctl.right { right: calc(10px + var(--sar)); }
.touch-ctl.p2-left { right: calc(10px + var(--sar)); }
.touch-ctl.p2-right { display: none !important; }
.ctl {
  pointer-events: auto; width: 74px; height: 74px; border-radius: 22px; border: 2px solid #0b060d; background: rgba(15, 8, 18, .55); color: var(--parch);
  font-size: 24px; font-family: inherit; touch-action: none;
}
.ctl.wide { width: 98px; font-size: 14px; font-weight: 700; }
.ctl.held, .ctl:active { background: rgba(255, 154, 60, .5); }
@media (pointer: coarse) {
  .touch-ctl.left, .touch-ctl.right { display: flex; }
  body.duel .touch-ctl.right { display: none; }
  body.duel .touch-ctl.p2-left { display: flex; }
  #hotbar { bottom: calc(96px + var(--sab)); max-width: 56vw; }
  #hint { bottom: calc(170px + var(--sab)); }
  body.duel #hotbar { display: none; }
}
@media (pointer: coarse) and (max-height: 520px) {
  .ctl { width: 62px; height: 62px; }
  .ctl.wide { width: 84px; }
  #hotbar { bottom: calc(10px + var(--sab)); max-width: 48vw; }
  .hb { min-width: 46px; height: 50px; }
  #hint { bottom: calc(76px + var(--sab)); }
}

@media (pointer: coarse) and (max-aspect-ratio: 1/1) {
  /* portrait phones: let the hotbar wrap above the touch controls instead of hiding slots behind them */
  #hotbar { max-width: 96vw; flex-wrap: wrap; justify-content: center; overflow: visible; bottom: calc(96px + var(--sab)); }
  .hb { min-width: 48px; height: 50px; }
}

/* ---------- overlays / screens ---------- */
#screens { position: absolute; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: calc(10px + var(--sat)) calc(10px + var(--sar)) calc(10px + var(--sab)) calc(10px + var(--sal)); }
#screens.on { display: flex; animation: fade .25s ease-out; background: radial-gradient(ellipse at 50% 40%, rgba(27, 19, 32, .15), rgba(12, 7, 16, .72)); }
#screens.s-title { background: radial-gradient(ellipse at 50% 60%, rgba(27, 19, 32, 0), rgba(12, 7, 16, .78)); }
#screens.s-summary, #screens.s-gameover, #screens.s-pause, #screens.s-duelover, #screens.s-confirm { background: rgba(12, 7, 16, .66); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

.panel {
  width: min(960px, 100%); max-height: 100%; overflow: auto; background: linear-gradient(180deg, rgba(48, 34, 56, .96), rgba(27, 19, 32, .97));
  border: 2px solid #0b060d; border-radius: 20px; padding: 16px 18px 18px; box-shadow: 0 18px 60px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(255, 220, 160, .12);
  animation: rise .3s ease-out; touch-action: pan-y; overscroll-behavior: contain;
}
.panel.wide { width: min(1100px, 100%); height: min(720px, 100%); display: flex; flex-direction: column; }
.panel.narrow { width: min(460px, 100%); }
.panel.center { text-align: center; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-family: var(--display); font-size: clamp(20px, 3vw, 28px); letter-spacing: .08em; flex: 1; color: var(--parch); }
h2, h3 { font-family: var(--display); }
.sec { margin: 18px 0 8px; color: var(--ember); letter-spacing: .08em; }
.muted { color: var(--parch2); opacity: .85; }
.tiny { font-size: 12px; }

.btn {
  font-family: inherit; font-size: 16px; font-weight: 700; color: var(--ink); background: linear-gradient(#f9ecc9, #d9c08a);
  border: 2px solid #0b060d; border-bottom-width: 4px; border-radius: 14px; padding: 10px 18px; cursor: pointer; touch-action: manipulation;
  transition: transform .08s, filter .15s;
}
.btn small { font-weight: 600; opacity: .7; margin-left: 6px; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn.primary { background: linear-gradient(#ffc468, #f0802a); color: #2a1306; }
.btn.big { font-size: 20px; padding: 14px 24px; }
.btn.small { font-size: 14px; padding: 6px 12px; }
.btn.ghost { background: rgba(255, 255, 255, .08); color: var(--parch); border-color: rgba(255, 255, 255, .2); }
.btn.danger { background: linear-gradient(#ff8a73, #c0321f); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; filter: grayscale(.6); }
.btn[data-poor] { background: linear-gradient(#b8a98a, #8d7f66); }
.btn.nope { animation: nope .3s; }
@keyframes nope { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.btn:focus-visible, .card:focus-visible, .tab:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

.coin-badge { background: rgba(0, 0, 0, .35); border: 2px solid #0b060d; border-radius: 16px; padding: 5px 14px; color: var(--gold); font-weight: 700; white-space: nowrap; }
.coin-badge.bump { animation: bump .4s; }
@keyframes bump { 40% { transform: scale(1.18); } }

/* title */
.title-wrap { display: grid; justify-items: center; gap: 22px; width: 100%; max-height: 100%; padding-bottom: 36px; }
.logo { text-align: center; text-shadow: 0 4px 0 #0b060d, 0 0 40px rgba(255, 154, 60, .35); animation: rise .6s ease-out; }
.logo-top { font-size: clamp(11px, 1.8vw, 15px); letter-spacing: .5em; color: var(--parch2); }
.logo h1 { margin: 2px 0 0; font-family: var(--display); font-size: clamp(44px, 11vw, 112px); line-height: .95; letter-spacing: .06em; color: var(--parch); }
.logo h1 span { color: var(--ember); }
.tagline { margin: 8px 0 0; color: var(--parch); opacity: .85; font-size: clamp(13px, 2vw, 18px); }
.menu { display: grid; gap: 10px; width: min(380px, 92vw); animation: rise .5s .1s ease-out both; }
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wave-pick { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 14px; }
.title-wrap .coin-badge { position: fixed; top: calc(10px + var(--sat)); right: calc(12px + var(--sar)); }
.credit { position: fixed; bottom: calc(8px + var(--sab)); left: 0; right: 0; text-align: center; font-size: 12px; color: var(--parch2); opacity: .75; pointer-events: none; }
.credit a { color: var(--parch); pointer-events: auto; }
.panel .credit { position: static; margin-top: 14px; }

@media (max-height: 560px) {
  .title-wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 300px); align-items: center; gap: 14px; padding-bottom: 0; justify-items: stretch; }
  .logo h1 { font-size: clamp(30px, 11vh, 64px); }
  .logo-top { letter-spacing: .3em; }
  .menu { gap: 6px; width: 100%; }
  .btn { padding: 7px 10px; font-size: 14px; }
  .btn.big { padding: 9px 12px; font-size: 16px; }
  .wave-pick { font-size: 12px; }
}
@media (max-width: 480px) {
  .hud-left { width: 40vw; }
  #wave-label { font-size: 16px; }
  .hud-center { flex: 1; }
  .coins { padding: 3px 8px; font-size: 13px; }
  .icon-btn { width: 34px; height: 34px; }
  #toast { top: calc(130px + var(--sat)); }
}

/* equipment */
.eq-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; flex: 1; min-height: 0; }
.eq-preview { background: radial-gradient(circle at 50% 40%, #3b2a42, #1f1626); border-radius: 16px; border: 2px solid #0b060d; display: flex; flex-direction: column; min-height: 0; }
#pv { width: 100%; flex: 1; min-height: 0; display: block; }
.pv-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; font-size: 12px; }
.pv-stats div { background: rgba(0, 0, 0, .3); border-radius: 8px; padding: 4px 8px; display: flex; justify-content: space-between; gap: 6px; }
.pv-stats span { opacity: .7; }
.eq-main { display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tab { font-family: inherit; font-weight: 700; background: rgba(255, 255, 255, .08); color: var(--parch); border: 2px solid transparent; border-radius: 10px; padding: 6px 12px; cursor: pointer; }
.tab.on { background: var(--ember); color: #2a1306; }
.eq-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-height: 0; flex: 1; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; overflow: auto; align-content: start; padding: 2px; touch-action: pan-y; }
.card {
  position: relative; text-align: left; font-family: inherit; color: var(--parch); background: rgba(255, 255, 255, .06); border: 2px solid rgba(255, 255, 255, .12);
  border-radius: 12px; padding: 10px 10px 10px 18px; cursor: pointer; min-height: 62px;
}
.card .swatch { position: absolute; left: 0; top: 0; bottom: 0; width: 8px; border-radius: 10px 0 0 10px; background: var(--tier, #888); }
.card .thumb { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 44px; height: 46px; object-fit: contain; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.5)); }
.card:has(.thumb) .card-name, .card:has(.thumb) .card-sub { padding-right: 46px; }
.card.sel { border-color: var(--gold); background: rgba(255, 210, 63, .12); }
.card.locked { opacity: .8; }
.card.equipped { border-color: var(--good); }
.card-name { font-weight: 700; font-size: 14px; }
.card-sub { font-size: 12px; opacity: .8; margin-top: 2px; }
.tag { position: absolute; right: 6px; top: 6px; font-size: 10px; background: var(--good); color: #0c2a10; border-radius: 6px; padding: 1px 6px; font-weight: 800; }
.detail { overflow: auto; background: rgba(0, 0, 0, .22); border-radius: 14px; padding: 12px 14px; touch-action: pan-y; }
.detail h3 { margin: 0 0 4px; color: var(--gold); }
.stats { display: grid; gap: 4px; margin: 10px 0; }
.stat { display: flex; align-items: center; gap: 8px; font-size: 13px; background: rgba(255, 255, 255, .05); border-radius: 8px; padding: 5px 9px; }
.stat span { flex: 1; opacity: .75; }
.stat em { font-style: normal; font-size: 12px; font-weight: 700; }
.stat em.up { color: var(--good); }
.stat em.down { color: #ff8a73; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.actions.col { flex-direction: column; align-items: stretch; margin-top: 16px; }

@media (max-width: 820px) and (max-aspect-ratio: 13/10) {
  .eq-layout { grid-template-columns: 1fr; grid-template-rows: 150px 1fr; }
  .eq-preview { flex-direction: row; }
  #pv { width: 40%; }
  .pv-stats { grid-template-columns: 1fr; align-content: center; flex: 1; }
  .eq-body { grid-template-columns: 1fr; grid-template-rows: minmax(110px, 1fr) minmax(120px, 1fr); }
  .panel.wide { height: 100%; padding: 10px; }
}
@media (max-height: 520px) and (min-aspect-ratio: 13/10) {
  .panel.wide { padding: 8px 10px; }
  .eq-layout { grid-template-columns: 120px 1fr; gap: 10px; }
  .panel-head { margin-bottom: 6px; }
  .panel-head h2 { font-size: 18px; }
  .pv-stats { display: none; }
  .tabs { margin-bottom: 6px; flex-wrap: nowrap; overflow-x: auto; }
  .tab { padding: 5px 9px; font-size: 13px; white-space: nowrap; }
  .eq-body { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cards { grid-template-columns: 1fr; }
  .card { min-height: 52px; padding: 7px 8px 7px 16px; }
  .detail { padding: 8px 10px; }
  .stat { padding: 3px 8px; font-size: 12px; }
  .upg-grid { grid-template-columns: 1fr; }
  .upg { padding: 8px; gap: 8px; grid-template-columns: 36px 1fr auto; }
  .upg-ico { width: 36px; height: 36px; font-size: 18px; }
  .upg p { display: none; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* upgrades */
.upg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 10px; overflow: auto; flex: 1; align-content: start; touch-action: pan-y; }
.upg { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; background: rgba(255, 255, 255, .06); border: 2px solid rgba(255, 255, 255, .1); border-radius: 14px; padding: 12px; }
.upg.flash { animation: upflash .7s; }
@keyframes upflash { 0% { box-shadow: 0 0 0 0 rgba(255, 210, 63, .9); background: rgba(255, 210, 63, .3); } 100% { box-shadow: 0 0 0 16px rgba(255, 210, 63, 0); } }
.upg-ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: linear-gradient(#5a3f66, #34233c); border: 2px solid #0b060d; }
.upg h3 { margin: 0; font-size: 17px; }
.upg h3 small { color: var(--parch2); font-weight: 400; font-size: 12px; margin-left: 6px; }
.upg p { margin: 2px 0 6px; font-size: 12px; }
.pips { display: flex; gap: 3px; }
.pips i { width: 14px; height: 7px; border-radius: 3px; background: rgba(255, 255, 255, .14); }
.pips i.on { background: var(--ember); box-shadow: 0 0 6px rgba(255, 154, 60, .6); }
.upg-fx { margin-top: 6px; font-size: 12px; line-height: 1.5; }
.upg-fx span { display: inline-block; width: 36px; color: var(--parch2); opacity: .7; }
.upg-fx .nxt { color: var(--good); opacity: 1; }
.upg.maxed { border-color: var(--gold); }

/* stats */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.tiles.small { margin: 14px 0; }
.tile { background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 10px; text-align: center; }
.tile b { display: block; font-size: 22px; color: var(--gold); font-family: var(--display); }
.tile span { font-size: 12px; opacity: .75; }
.achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.ach { background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 8px 10px; opacity: .6; font-size: 13px; }
.ach b { display: block; }
.ach span { font-size: 12px; opacity: .8; }
.ach.got { opacity: 1; border: 1px solid rgba(255, 210, 63, .5); }
.ach.got b { color: var(--gold); }

/* name entry / text inputs */
.text-in { width: 100%; margin-top: 12px; font: inherit; font-size: 20px; font-weight: 700; text-align: center; color: var(--parch); background: var(--ink); border: 2px solid var(--ember); border-radius: 12px; padding: 10px 12px; user-select: text; -webkit-user-select: text; outline: none; }
.text-in.sm { width: 52%; margin: 0; font-size: 15px; padding: 6px 10px; border-color: #0b060d; text-align: left; }
.pv-name { text-align: center; font-weight: 800; padding: 6px 8px 0; color: var(--gold); font-family: var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* settings */
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 2px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.row input[type=range] { width: 52%; accent-color: var(--ember); }
.row select { background: var(--ink2); color: var(--parch); border: 2px solid #0b060d; border-radius: 10px; padding: 6px 10px; font-family: inherit; }
.row input[type=checkbox] { position: absolute; opacity: 0; }
.switch { width: 46px; height: 26px; border-radius: 13px; background: rgba(255, 255, 255, .16); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--parch); transition: transform .2s; }
input:checked + .switch { background: var(--ember); }
input:checked + .switch::after { transform: translateX(20px); }

/* summary */
.big-title { font-size: clamp(28px, 6vw, 44px); letter-spacing: .1em; margin: 4px 0; text-shadow: 0 3px 0 #0b060d; }
.big-title.win { color: var(--gold); }
.big-title.lose { color: #ff7a63; }
.rewards { list-style: none; margin: 14px 0 6px; padding: 0; text-align: left; }
.rewards li { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px dashed rgba(255, 255, 255, .12); opacity: 0; animation: pop .35s calc(var(--i) * .14s + .15s) ease-out forwards; }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rewards b { color: var(--gold); }
.total { font-size: 22px; margin: 10px 0; font-weight: 700; }
.total b { color: var(--gold); font-size: 30px; font-family: var(--display); }
.mini-stats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; font-size: 13px; opacity: .85; }
.mini-stats b { color: var(--parch); }
.drop { color: var(--cyan); margin: 10px 0 0; }
.coin-line { margin-top: 12px; font-size: 13px; opacity: .8; }

/* toast */
#toast {
  position: absolute; left: 50%; top: calc(70px + var(--sat)); transform: translate(-50%, -10px); z-index: 40; pointer-events: none;
  background: rgba(15, 8, 18, .9); border: 2px solid var(--ember); border-radius: 14px; padding: 8px 16px; font-weight: 700; opacity: 0; transition: opacity .25s, transform .25s;
  max-width: 90vw; text-align: center;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.highlights { font-size: 13px; color: #ffe08a; margin: 6px 0 2px; line-height: 1.4; }

#boss-armor { font-size: 11px; font-weight: 700; margin-top: 3px; color: #e2e9ef; text-shadow: 0 1px 3px #000; background: rgba(15,8,18,.75); border-radius: 4px; padding: 3px; }
#boss-armor .armor-damaged { color: #ffd9a0; }
#boss-armor .armor-critical { color: #ff9a3c; }
#boss-armor .armor-broken { color: #7ff0b2; }
#boss-armor span { white-space: nowrap; }
@media (max-width: 600px) {
  #boss-bar.on ~ #wind { top: calc(150px + var(--sat)); }
}

/* Phase recovery belongs to the health bar; the phase banner names the earned HP. */
.hp-bar.second-wind { animation: second-wind .7s ease-out 2; }
.hp-bar.second-wind #hp-fill { background: linear-gradient(#edfff2, #70e795); }
@keyframes second-wind { from { box-shadow: 0 0 12px 4px #b9ffcd; } to { box-shadow: 0 0 0 0 transparent; } }

/* Keep phase announcements beneath the boss health/armor strip, including phone landscape. */
#boss-bar.on ~ #banner { top: max(140px, 22%); }
#boss-bar.on ~ #banner .bn-title { font-size: clamp(24px, 4.5vw, 48px); letter-spacing: .06em; }
