:root {
  --ink: #2b2118;
  --paper: #f6eddc;
  --panel: rgba(43, 33, 24, 0.82);
  --gold: #e8b44a;
  --red: #c8493c;
  --green: #79b257;
  --blue: #5a8fc8;
  --lv: #3a78d8;
  --xp: #5ee06e;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #8fa4b4;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; color: var(--paper);
  user-select: none; -webkit-user-select: none; overscroll-behavior: none;
}
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

/* name tags: name and level badge on a row, a red HP bar underneath. Your own badge has a green XP ring. */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag3d {
  position: absolute; left: 0; top: 0; transform-origin: 50% 100%; white-space: nowrap;
  text-align: center; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000, 0 0 3px #000;
  will-change: transform;
}
.tag3d .row { display: flex; align-items: center; justify-content: center; gap: 4px; }
.tag3d .lvc {
  --p: 0%; position: relative; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(var(--xp) var(--p), rgba(0,0,0,.55) 0); flex: none;
}
.tag3d .lvc b {
  display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--lv); color: #fff;
  font-size: 10px; line-height: 1; text-shadow: 0 1px 1px rgba(0,0,0,.6); box-shadow: inset 0 -2px 0 rgba(0,0,0,.25);
}
.tag3d.foe .lvc { background: rgba(0,0,0,.45); width: 20px; height: 20px; }
.tag3d.me .lvc { width: 28px; height: 28px; }
.tag3d.me .lvc b { width: 20px; height: 20px; font-size: 12px; }
.tag3d.me .nm { color: #ffe9a8; }
.tag3d .hpb { width: 54px; height: 6px; margin: 3px auto 0; background: rgba(0,0,0,.6); border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.tag3d.me .hpb { width: 66px; height: 8px; }
.tag3d .hpb i { display: block; height: 100%; background: linear-gradient(#ff6a5a, var(--red)); border-radius: 3px; transition: width .12s; }
.tag3d.target .nm { color: #ff9a8a; }
.tag3d.lord .nm { color: #ffd76a; }
.tag3d .lvc.pop { animation: lvpop .6s cubic-bezier(.2, 1.8, .4, 1); }
.tag3d .lvc.xp { animation: xpglow .45s ease-out; }
@keyframes lvpop { 0% { transform: scale(1); } 30% { transform: scale(1.9); filter: brightness(1.8); } 100% { transform: scale(1); } }
@keyframes xpglow { 0% { box-shadow: 0 0 0 0 rgba(90,230,110,.9); filter: brightness(1.5); } 100% { box-shadow: 0 0 0 7px rgba(90,230,110,0); } }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }

#levelup {
  position: absolute; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%);
  width: min(580px, calc(100vw - 20px)); pointer-events: auto; text-align: center;
  animation: pop .25s ease-out;
}
.lu-title { font-weight: 900; color: var(--gold); text-shadow: 0 2px 0 #000; font-size: 17px; margin-bottom: 6px; }
#lu-cards { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 8px; }
.card {
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 12px; padding: 8px 6px;
  cursor: pointer; font: inherit; min-height: 92px; box-shadow: 0 4px 0 var(--ink); transition: transform .08s;
}
.card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.card .ic { font-size: 26px; line-height: 30px; }
.card .nm { font-weight: 900; font-size: 13px; }
.card .ds { font-size: 11px; opacity: .8; margin-top: 2px; }
.card .lv { font-size: 10px; font-weight: 800; color: #8a5a3a; }
.card.passive { background: #efe1f6; }
.card { border-bottom: 6px solid var(--tint, var(--ink)); }
.tag3d.lion .nm { color: #ffd27a; font-size: 13px; }
.tag3d.lion .hpb { width: 96px; height: 8px; }
.card .key { font-size: 10px; opacity: .5; }
/* power picks: dark, gold-trimmed cards */
.card.power { background: linear-gradient(#2a2234, #17131e); color: #f4e8c8; border-color: #e8b44a; box-shadow: 0 4px 0 #6a4e10, 0 0 14px rgba(232,180,74,.45); }
.card.power .nm { color: #ffd76a; }
.card.power .ds { opacity: .9; }
.card.power .lv { color: #e8b44a; }
.card.power .fit.slot { background: #e8b44a; color: #17131e; }
.card.voidcard { background: linear-gradient(#2a2238, #0e0b14); color: #e4dcf4; border-color: #6a4ab0; box-shadow: 0 4px 0 #2a1f48, 0 0 14px rgba(140,100,255,.4); }
.card.voidcard .nm { color: #c8b0ff; }
.card.voidcard .lv { color: #9a7ae0; }
.card.voidcard .fit.slot { background: #6a4ab0; color: #fff; }
#levelup.void .lu-title { color: #c8b0ff; text-shadow: 0 2px 0 #000, 0 0 12px rgba(150,110,255,.8); }
#levelup.power .lu-title { color: #ffd76a; text-shadow: 0 2px 0 #000, 0 0 12px rgba(255,200,80,.8); }

.icon-btn {
  position: absolute; right: calc(10px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); pointer-events: auto;
  width: 42px; height: 42px; border-radius: 21px; border: none; background: var(--panel); font-size: 20px; cursor: pointer;
}
#levelup:not(.hidden) ~ #mute { bottom: calc(160px + var(--safe-b)); }

/* the final countdown */
#final-bar { position: fixed; z-index: 29; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); pointer-events: none;
  display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 999px; max-width: calc(100vw - 24px);
  background: rgba(20,15,10,.8); box-shadow: 0 0 0 2.5px #ffd34a; white-space: nowrap; }
#final-bar b { font-size: 22px; color: #ffd76a; font-variant-numeric: tabular-nums; text-shadow: 0 2px 0 #000; }
#final-bar span { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
#final-bar.last b { color: #fff; animation: fin-pulse 1s infinite; }
@keyframes fin-pulse { 50% { transform: scale(1.15); } }
@media (max-width: 460px) { #final-bar span { font-size: 11px; } #final-bar b { font-size: 18px; } }
/* the Tab menu's crown line, tabs, map and settings */
.st-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.st-top img { width: 36px; height: 36px; flex: none; }
.st-top #st-lord { flex: 1; min-width: 0; font-size: 13px; }
.st-top #st-lord b { display: block; font-size: 18px; color: #ffd76a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-top #st-lord i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--c); margin-right: 6px; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
#st-final { background: rgba(255,210,80,.15); border-radius: 8px; padding: 5px 9px; margin-bottom: 8px; font-size: 13px; }
#st-final b { color: #ffd76a; font-variant-numeric: tabular-nums; }
.st-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.st-tabs button { flex: 1; border: none; border-radius: 999px; padding: 7px 0; font: inherit; font-weight: 800; font-size: 13px; cursor: pointer;
  background: rgba(0,0,0,.3); color: var(--paper); }
.st-tabs button.on { background: var(--gold); color: #2a1a08; }
#minimap { display: block; width: min(100%, 52dvh, 380px); aspect-ratio: 1; margin: 0 auto; }
.st-legend { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 6px; font-size: 11px; opacity: .85; margin: 6px 0 0; }
.st-legend span, .st-legend img { display: inline-block; vertical-align: middle; }
.lg-you { width: 11px; height: 11px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px #2a1a08; margin-left: 4px; }
.lg-bird { width: 8px; height: 8px; border-radius: 50%; background: #b07a4a; box-shadow: 0 0 0 1px #2a1a08; margin-left: 6px; }
.lg-crown, .lg-lion { width: 18px; height: 18px; margin-left: 6px; }
.set-row { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.25); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; font-weight: 700; }
.set-row span { flex: 1; }
.set-row input[type=range] { flex: 2; accent-color: var(--gold); }
.set-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--gold); }
.set-row b { width: 3em; text-align: right; font-variant-numeric: tabular-nums; }

/* a round won: a banner across the top for everyone, gold when it's you */
#victory { position: fixed; z-index: 30; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%); pointer-events: none;
  display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 12px; border-radius: 16px; max-width: calc(100vw - 24px);
  background: rgba(20,15,10,.82); box-shadow: 0 0 0 3px #ffd34a, 0 6px 24px rgba(0,0,0,.5); animation: vic-in .5s cubic-bezier(.2,1.6,.4,1); }
#victory img { width: 54px; height: 54px; flex: none; }
#victory b { display: block; font-size: 24px; color: #ffd76a; text-shadow: 0 2px 0 #000; }
#victory small { display: block; font-size: 13px; opacity: .9; }
#victory.mine { box-shadow: 0 0 0 3px #ffd34a, 0 0 40px rgba(255,210,80,.7); }
@keyframes vic-in { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
@media (max-width: 460px) { #victory b { font-size: 19px; } #victory img { width: 42px; height: 42px; } }
/* the leaders page */
.lb-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lb-cols h3 { margin: 0 0 4px; font-size: 14px; color: var(--gold); }
.lb-cols ol { margin: 0; padding: 0; list-style: none; counter-reset: r; font-size: 13px; }
.lb-cols li { counter-increment: r; display: flex; gap: 6px; padding: 3px 6px; border-radius: 6px; }
.lb-cols li:nth-child(odd) { background: rgba(0,0,0,.2); }
.lb-cols li::before { content: counter(r) "."; opacity: .6; min-width: 1.4em; }
.lb-cols li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-cols li i { font-style: normal; opacity: .5; font-size: 11px; }
.lb-cols li em { font-style: normal; font-size: 10px; background: var(--gold); color: #2a1a08; border-radius: 4px; padding: 0 4px; }
.lb-cols li.you { box-shadow: inset 0 0 0 1.5px var(--gold); }
.lb-cols .none, .mp-board .none { opacity: .7; font-size: 13px; }
.lb-me { font-size: 12px; opacity: .8; margin: 8px 0 0; }
@media (max-width: 420px) { .lb-cols { grid-template-columns: 1fr; } }

/* overlays */
.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(43,33,24,.25), rgba(43,33,24,.65));
  overflow-y: auto;
}
.panel {
  background: var(--panel); border-radius: 18px; padding: 20px 22px; width: min(420px, 100%); text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.35); border: 2px solid rgba(232,180,74,.4); animation: pop .3s ease-out;
}
h1 { margin: 0 0 4px; font-size: clamp(26px, 7vw, 38px); line-height: 1.05; letter-spacing: 1px; text-shadow: 0 3px 0 #000; }
h1 .g { color: var(--gold); font-size: 1.15em; }
h2 { margin: 0 0 6px; color: var(--gold); text-shadow: 0 2px 0 #000; }
.tag { margin: 0 0 14px; opacity: .9; }
#name {
  width: 100%; font: inherit; font-size: 18px; font-weight: 700; padding: 11px 14px; border-radius: 10px;
  border: 3px solid var(--ink); background: var(--paper); color: var(--ink); text-align: center; outline: none;
  user-select: text; -webkit-user-select: text;
}
#colors { display: flex; justify-content: center; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 16px; border: 3px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--paper); box-shadow: 0 0 0 2px var(--ink); }
.big-btn {
  width: 100%; font: inherit; font-size: 20px; font-weight: 900; padding: 12px; border-radius: 12px; cursor: pointer;
  border: 3px solid var(--ink); background: var(--gold); color: var(--ink); box-shadow: 0 4px 0 var(--ink);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.big-btn:disabled { opacity: .6; }
.error { color: #ff9a8a; min-height: 1.2em; margin: 8px 0 0; font-weight: 700; }
.small { font-size: 12px; opacity: .75; margin: 4px 0 0; }
/* the menu: title stacked on the left, the logo on the right, then swipeable pages */
/* the whole menu always fits the window: the header and name box keep their size, the pages take what's left and scroll */
.panel.menu { width: min(560px, 100%); text-align: center; display: flex; flex-direction: column;
  max-height: calc(100dvh - 32px - var(--safe-t) - var(--safe-b)); margin: auto 0; }
.panel.menu > * { flex: none; }
.panel.menu > #pages { flex: 1 1 auto; min-height: 90px; }
#join { align-items: flex-start; }
#join .panel.menu { margin: auto; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.brand h1 { display: flex; flex-direction: column; text-align: left; font-size: clamp(30px, 9vw, 46px); line-height: .92; letter-spacing: 1px; text-transform: uppercase; margin: 0; }
.brand h1 span:nth-child(2) { color: var(--gold); }
.brand .logo { width: clamp(86px, 24vw, 120px); height: auto; flex: none; filter: drop-shadow(0 4px 0 rgba(0,0,0,.35)); }
.panel.menu .tag { text-align: left; font-weight: 700; margin: 6px 0 12px; }
.pg-bar { display: flex; align-items: center; gap: 4px; margin: 12px -6px 6px; }
.pg-arrow { flex: none; width: 30px; height: 30px; border-radius: 15px; border: none; background: rgba(0,0,0,.3); color: var(--paper); font-size: 20px; line-height: 1; cursor: pointer; }
.pg-arrow:disabled { opacity: .3; }
#pg-tabs { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; flex: 1; padding: 2px; }
#pg-tabs::-webkit-scrollbar { display: none; }
#pg-tabs button { flex: none; font: inherit; font-size: 12px; font-weight: 800; padding: 5px 10px 5px 8px; border-radius: 14px; border: 2px solid transparent;
  background: rgba(0,0,0,.28); color: var(--paper); cursor: pointer; display: flex; align-items: center; gap: 5px; }
#pg-tabs button::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
#pg-tabs button.on { border-color: var(--c); background: rgba(0,0,0,.5); }
#pages { display: flex; min-height: 0; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; gap: 0; text-align: left; overscroll-behavior-x: contain; }
#pages::-webkit-scrollbar { display: none; }
.mp { flex: 0 0 100%; scroll-snap-align: start; overflow-y: auto; padding: 4px 4px 8px; }
.mp-lead { font-size: 13px; opacity: .92; margin: 2px 0 8px; }
.mp-perks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
@media (max-width: 460px) { .mp-perks { grid-template-columns: 1fr; } }
.mp-perk { display: flex; gap: 8px; align-items: flex-start; background: rgba(0,0,0,.25); border-radius: 10px; padding: 6px 8px; }
.mp-perk .ic { flex: none; line-height: 0; }
.mp-perk b { display: block; font-size: 13px; }
.mp-perk b i { font-style: normal; font-size: 9px; text-transform: uppercase; letter-spacing: .5px; padding: 1px 5px; border-radius: 6px; background: rgba(255,255,255,.15); vertical-align: 2px; }
.mp-perk small { display: block; font-size: 11px; opacity: .85; line-height: 1.25; margin-top: 1px; }
.mp-note { background: rgba(0,0,0,.25); border-left: 4px solid var(--gold); border-radius: 8px; padding: 7px 9px; font-size: 12px; line-height: 1.35; margin-top: 8px; }
.mp-note b { display: block; color: var(--gold); font-size: 13px; margin-bottom: 2px; }
.mp-void { margin-top: 10px; background: linear-gradient(#2a2238, #0e0b14); border: 2px solid #6a4ab0; border-radius: 10px; padding: 8px; }
.mp-void > b { color: #c8b0ff; display: block; }
.mp-void > small { display: block; font-size: 11px; opacity: .85; margin-bottom: 6px; }
.mp-food { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
@media (max-width: 460px) { .mp-food { grid-template-columns: 1fr; } }
.mp-item { display: flex; gap: 8px; align-items: center; background: rgba(0,0,0,.25); border-radius: 10px; padding: 4px 8px 4px 4px; }
.mp-item img, .mp-item .noimg { width: 56px; height: 56px; flex: none; border-radius: 8px; background: radial-gradient(circle at 50% 60%, rgba(246,237,220,.28), rgba(246,237,220,.06)); }
.mp-item b { display: block; font-size: 13px; }
.mp-item small { display: block; font-size: 11px; opacity: .85; line-height: 1.25; }
.mp-lord { display: flex; align-items: center; gap: 12px; background: rgba(0,0,0,.28); border-radius: 12px; padding: 10px 12px; }
.mp-crownpic { width: 64px; height: 64px; flex: none; }
.mp-lord small { display: block; font-size: 12px; opacity: .8; }
.mp-lord b { display: flex; align-items: center; gap: 7px; font-size: 22px; color: #ffd76a; margin: 2px 0; }
.mp-lord b i { width: 14px; height: 14px; border-radius: 50%; background: var(--c, #8a5a3a); box-shadow: 0 0 0 2px rgba(0,0,0,.5); }
.mp-lord > div:nth-child(2) { flex: 1; min-width: 0; }
.mp-lord b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-best { flex: none; text-align: right; border-left: 1px solid rgba(246,237,220,.15); padding-left: 12px; }
.mp-best b { color: var(--gold); font-size: 20px; justify-content: flex-end; }
.mp-crown .how { margin-top: 10px; font-size: 13px; }
.mp-crown .how li { margin: 4px 0; padding-left: 14px; position: relative; }
.mp-crown .how li::before { content: ''; position: absolute; left: 2px; top: .5em; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.how { text-align: left; font-size: 13px; padding-left: 4px; list-style: none; margin: 12px 0 0; opacity: .9; }
.how li { margin: 3px 0; }
#dead-by { font-size: 17px; }
#dead-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 12px 0 16px; }
#dead-stats div { background: rgba(0,0,0,.3); border-radius: 8px; padding: 6px; }
#dead-stats b { display: block; font-size: 20px; color: var(--gold); }
#dead-stats .crownstat { grid-column: span 2; }
/* the Tab menu: your run so far, while the game carries on underneath */
#stats-btn { left: calc(10px + var(--safe-l)); right: auto; }
#stats { background: rgba(20,15,10,.35); }
.stats-panel { width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; text-align: left; padding: 14px 16px; }
.st-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.st-head > div { flex: 1; min-width: 0; }
.st-head b { display: block; font-size: 20px; color: var(--gold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-head small { opacity: .8; font-size: 12px; }
#st-swatch { width: 26px; height: 26px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(0,0,0,.5); }
#st-close { flex: none; width: 32px; height: 32px; border-radius: 16px; border: none; background: rgba(0,0,0,.35); color: var(--paper); font-size: 22px; line-height: 1; cursor: pointer; }
#st-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
#st-tiles div, #st-core div { background: rgba(0,0,0,.3); border-radius: 8px; padding: 6px 4px; font-size: 11px; }
#st-tiles b { display: block; font-size: 18px; color: var(--gold); }
#st-core { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; text-align: center; margin: 6px 0; }
#st-core b { display: block; font-size: 15px; color: var(--paper); }
@media (max-width: 460px) { #st-tiles { grid-template-columns: repeat(2, 1fr); } #st-core { grid-template-columns: repeat(3, 1fr); } }
#st-lord { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.25); border-radius: 10px; padding: 7px 10px; margin: 6px 0 8px; font-size: 13px; }
#st-lord img { width: 30px; height: 30px; }
#st-lord b { color: #ffd76a; }
#st-lord i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
#st-build .perks { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
@media (max-width: 460px) { #st-build .perks { grid-template-columns: 1fr; } }
#st-build .perk { display: grid; grid-template-columns: 30px 1fr; column-gap: 6px; background: rgba(0,0,0,.25); border-radius: 8px; padding: 5px 6px; border-left: 4px solid var(--tint); }
#st-build .perk .ic { grid-row: span 2; line-height: 0; }
#st-build .perk .pn { font-weight: 800; font-size: 12px; }
#st-build .perk .pn i { font-style: normal; color: var(--gold); }
#st-build .perk .pd { font-size: 10px; opacity: .8; line-height: 1.2; }
#st-build .none { opacity: .7; font-size: 13px; text-align: center; padding: 8px; }
.st-hint { text-align: center; margin-top: 8px; }
#dead-stats .crownstat.best { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(232,180,74,.5); }

#status {
  position: fixed; left: 50%; bottom: calc(70px + var(--safe-b)); transform: translateX(-50%);
  background: var(--panel); padding: 6px 14px; border-radius: 10px; font-weight: 700;
}

@keyframes pop { from { transform: translateX(var(--tx, 0)) scale(.9); opacity: 0; } to { opacity: 1; } }
#levelup { --tx: -50%; }

@media (max-width: 600px) {
  #lu-cards { grid-template-columns: repeat(var(--n, 3), 1fr); gap: 5px; }
  .card .nm { font-size: 12px; }
  .card { min-height: 64px; padding: 5px 4px; }
  .card .ic { font-size: 20px; line-height: 22px; }
  .card .ds { font-size: 10px; }
  .card .key { display: none; }
  #levelup:not(.hidden) ~ #mute { bottom: calc(170px + var(--safe-b)); }
}

/* level-up cards that suit your playstyle, and the build on the death screen */
.card { position: relative; }
.card .fit {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: var(--gold); color: var(--ink); border-radius: 8px; padding: 0 6px; font-size: 10px; font-weight: 900;
}
.card .fit.from { background: #c8823a; color: #fff; }
#dead-build { margin: -4px 0 14px; text-align: left; }
#dead-build .style { font-size: 13px; margin-bottom: 6px; text-align: center; }
#dead-build .style small { display: block; opacity: .75; margin-top: 2px; }
#dead-build .perks { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; max-height: 34vh; overflow-y: auto; }
#dead-build .perk {
  display: grid; grid-template-columns: 26px 1fr; column-gap: 4px; align-items: center;
  background: rgba(0,0,0,.3); border-left: 4px solid var(--tint); border-radius: 7px; padding: 4px 6px;
}
#dead-build .perk .ic { grid-row: span 2; font-size: 18px; text-align: center; }
#dead-build .perk .pn { font-weight: 800; font-size: 12px; }
#dead-build .perk .pn i { font-style: normal; color: var(--gold); white-space: nowrap; }
#dead-build .perk .pd { font-size: 10px; opacity: .8; line-height: 1.2; }
#dead-build .none { text-align: center; opacity: .7; font-size: 13px; }
@media (max-width: 600px) {
  .panel { padding: 16px 14px; }
  #dead-stats { margin: 8px 0 12px; }
  #dead-stats b { font-size: 17px; }
}

/* level-up cards: a colour-family stripe and a label for what each slot leans toward */
.card { border-top: 6px solid var(--fam, var(--ink)); }
.card .fit.slot { background: var(--ink); color: var(--paper); font-weight: 700; }
/* death screen: which of the seven styles, and the red/green/blue split */
#dead-build .style b { color: var(--fam, var(--gold)); }
#dead-build .rgb { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 6px auto 3px; max-width: 260px; }
#dead-build .rgb i { display: block; min-width: 2px; }

/* perk icons */
.perk-icon { display: inline-block; vertical-align: middle; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.card .ic { line-height: 0; margin: 2px 0 3px; }
#dead-build .perk .ic { line-height: 0; }

@media (max-height: 760px) {
  .brand h1 { font-size: clamp(24px, 6.5vh, 40px); }
  .brand .logo { width: clamp(60px, 13vh, 104px); }
  .panel.menu { padding: 14px 16px; }
  .panel.menu .tag { margin: 4px 0 8px; font-size: 14px; }
  #name { padding: 8px 12px; font-size: 16px; }
  .panel.menu .big-btn { padding: 8px; font-size: 18px; }
  .pg-bar { margin: 6px -6px 4px; }
  #join-error { margin: 4px 0 0; min-height: 0; }
}
@media (max-height: 520px) {
  .brand h1 { flex-direction: row; gap: .3em; font-size: clamp(20px, 6vh, 30px); }
  .brand .logo { width: 48px; }
  .panel.menu .tag { display: none; }
}
@media (max-width: 460px) {
  .mp-lord { gap: 8px; padding: 8px 10px; }
  .mp-crownpic { width: 44px; height: 44px; }
  .mp-lord b { font-size: 18px; }
  .mp-best { padding-left: 8px; }
}
.mp-lord b i { flex: none; }
#levelup:not(.hidden) ~ #stats-btn { bottom: calc(160px + var(--safe-b)); }
