/* Whisker Wars — UI styles */
:root {
  --bg: #2b1d3a;
  --bg2: #3b2850;
  --cream: #fff8ee;
  --cream2: #fbeedd;
  --ink: #4a2f27;
  --ink2: #7a5a4c;
  --pink: #ff7aa8;
  --pink-d: #d9467c;
  --orange: #ffa94d;
  --orange-d: #d97a1c;
  --mint: #4fd1a0;
  --mint-d: #23996c;
  --sky: #6cc4ff;
  --sky-d: #2f8fd1;
  --gold: #ffcf4d;
  --gold-d: #c9971b;
  --red: #ff5468;
  --blue: #3d9bff;
  --glass: rgba(30, 18, 44, 0.72);
  --radius: 18px;
  --font: Fredoka, "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); font-family: var(--font); color: var(--ink); user-select: none; -webkit-user-select: none; }
body { overscroll-behavior: none; }
button, input, select { font-family: inherit; }
kbd { font-family: inherit; }

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; transition: filter .5s; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
body { -webkit-touch-callout: none; }
#game.attract { filter: saturate(1.05) brightness(0.8) blur(1.2px); }

/* ---------- loader ---------- */
#loader { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; text-align: center; gap: 10px; background: var(--bg); color: #fff; font-size: 20px; transition: opacity .5s; }
#loader.done { opacity: 0; pointer-events: none; }
.loader-cat { font-size: 64px; animation: bounce 0.8s infinite alternate ease-in-out; }
@keyframes bounce { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-16px) rotate(4deg); } }

/* ---------- screens ---------- */
.screens { position: fixed; inset: 0; z-index: 10; overflow-y: auto; overflow-x: hidden; display: none; padding: 0 16px 40px; background: radial-gradient(ellipse at center, rgba(43, 29, 58, 0.15), rgba(30, 15, 45, 0.7)); }
.screens.show { display: block; animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.topbar { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 0; max-width: 1200px; margin: 0 auto; }
.screen-title { margin: 0; text-align: center; color: #fff; font-size: clamp(22px, 3.4vw, 34px); text-shadow: 0 3px 0 rgba(0,0,0,.3), 0 0 20px rgba(255,122,168,.4); }
.logo-small { color: #fff; font-weight: 700; font-size: 20px; text-shadow: 0 2px 0 rgba(0,0,0,.3); }
.wallet { display: flex; gap: 8px; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px; border-radius: 999px; background: var(--cream); color: var(--ink); font-weight: 600; box-shadow: 0 3px 0 rgba(0,0,0,.25); font-size: 16px; white-space: nowrap; }
.pill.tiny { padding: 1px 8px; font-size: 12px; box-shadow: none; background: rgba(0,0,0,.08); }
.pill.coins { background: linear-gradient(#fff4c9, #ffe08a); }
.pill.bump { animation: bump .5s ease; }
@keyframes bump { 40% { transform: scale(1.25); } }
.fish { display: inline-block; filter: drop-shadow(0 1px 0 rgba(0,0,0,.15)); }

.card { background: var(--cream); border-radius: var(--radius); box-shadow: 0 6px 0 rgba(0,0,0,.18), 0 12px 30px rgba(0,0,0,.25); }
.panel { padding: 18px 20px; }
.panel h2, .panel h3 { margin: 0 0 10px; }
.clickable { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.clickable:hover { transform: translateY(-3px); }
.muted { color: var(--ink2); opacity: .85; }
.screens > .muted, .screens .center.muted { color: #e9dcff; }
.small { font-size: 13px; }
.center { text-align: center; justify-content: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn { --c: var(--cream2); --cd: #c9b39a; --tc: var(--ink); position: relative; border: 0; cursor: pointer; border-radius: 14px; padding: 10px 18px; font-size: 17px; font-weight: 600; color: var(--tc); background: var(--c); box-shadow: 0 5px 0 var(--cd), 0 8px 16px rgba(0,0,0,.18); transition: transform .08s, box-shadow .08s, filter .15s; display: inline-flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 6px; line-height: 1.1; }
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--cd), 0 3px 8px rgba(0,0,0,.18); }
.btn small { font-size: 12px; font-weight: 500; opacity: .85; flex-basis: 100%; text-align: center; }
.btn.primary { --c: linear-gradient(#ff9cc0, var(--pink)); --cd: var(--pink-d); --tc: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.btn.gold { --c: linear-gradient(#ffe38a, var(--gold)); --cd: var(--gold-d); }
.btn.danger { --c: linear-gradient(#ff8a8a, #ff5a5a); --cd: #b82a2a; --tc: #fff; }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 11px; box-shadow: 0 3px 0 var(--cd); }
.btn.small:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--cd); }
.btn.big { padding: 14px 26px; font-size: 20px; }
.btn.huge { padding: 18px 30px; font-size: 26px; width: 100%; }
.btn.off, .btn:disabled { filter: grayscale(.7) brightness(.92); cursor: not-allowed; opacity: .75; }
.btn.on { --c: linear-gradient(#8fe0ff, var(--sky)); --cd: var(--sky-d); --tc: #fff; }
.btn.icon { width: 52px; height: 52px; padding: 0; font-size: 26px; border-radius: 50%; }
.btn.back { --c: rgba(255,255,255,.92); }
.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 5px 0 var(--cd), 0 0 0 0 rgba(255,122,168,.6); } 50% { box-shadow: 0 5px 0 var(--cd), 0 0 0 14px rgba(255,122,168,0); } }
.seg { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
input[type=text], input:not([type]), .code-in, .name-in, select { border: 3px solid #e8d6c0; border-radius: 12px; padding: 10px 14px; font-size: 18px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--pink); }

/* ---------- home ---------- */
.home { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 18px; padding-top: 2vh; }
.logo { text-align: center; position: relative; margin: 8px 0 4px; animation: logoIn .8s cubic-bezier(.2,1.6,.4,1); }
@keyframes logoIn { from { transform: scale(.4) rotate(-8deg); opacity: 0; } }
.logo-text { display: flex; flex-direction: column; line-height: .9; font-weight: 700; }
.logo-text span { font-size: clamp(54px, 11vw, 104px); color: #fff; -webkit-text-stroke: 3px #3a1f4e; text-shadow: 0 6px 0 #3a1f4e, 0 12px 26px rgba(0,0,0,.4); letter-spacing: 1px; }
.logo-text .w1 { color: #ffd1e3; transform: rotate(-3deg); }
.logo-text .w2 { color: #ffd76b; transform: rotate(2deg); margin-top: -6px; }
.logo-ears { position: absolute; left: 50%; top: -26px; transform: translateX(-50%); width: 220px; height: 40px; }
.logo-ears span { position: absolute; top: 0; width: 0; height: 0; border-left: 26px solid transparent; border-right: 26px solid transparent; border-bottom: 44px solid #ffd1e3; filter: drop-shadow(0 -3px 0 #3a1f4e); }
.logo-ears span:first-child { left: 10px; transform: rotate(-18deg); }
.logo-ears span:last-child { right: 10px; transform: rotate(18deg); }
.logo-sub { color: #fff; font-size: 18px; margin-top: 10px; opacity: .9; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.home-main { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.home-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.btn.tile { padding: 14px 8px; font-size: 18px; }
.btn.tile .ti { font-size: 32px; margin-bottom: 2px; flex-basis: 100%; text-align: center; }
.home-me { position: fixed; left: 16px; bottom: 16px; display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 8px; }
.home-me img { width: 56px; height: 56px; }
.hm-name { font-weight: 700; font-size: 18px; }
.hm-sub { font-size: 13px; color: var(--ink2); }
.settings-btn { position: fixed; right: 16px; bottom: 16px; }

/* ---------- friend ---------- */
.friend { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 820px; margin: 20px auto; }
.friend .panel { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 26px; }
.big-emoji { font-size: 56px; }
.code-in { text-align: center; font-size: 32px; letter-spacing: 8px; width: 220px; text-transform: uppercase; font-weight: 700; }
.net-mode { margin-top: 10px; color: #e9dcff !important; }

/* ---------- lobby ---------- */
.lobby { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.room { padding: 14px; text-align: center; }
.room-l { font-size: 13px; letter-spacing: 3px; color: var(--ink2); font-weight: 600; }
.room-code { display: flex; justify-content: center; gap: 8px; margin: 6px 0 10px; }
.room-code span { width: 52px; height: 64px; display: grid; place-items: center; font-size: 40px; font-weight: 700; background: #fff; border-radius: 12px; border: 3px solid #f0dcc4; color: var(--pink-d); box-shadow: 0 4px 0 #e6cfb3; }
.room-mode { margin-top: 6px; }
.vs-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; }
.vs { font-size: 34px; font-weight: 700; color: #fff; -webkit-text-stroke: 2px #3a1f4e; text-shadow: 0 4px 0 #3a1f4e; }
.pcard-l { position: relative; display: flex; align-items: center; gap: 14px; background: var(--cream); border-radius: var(--radius); padding: 12px 16px; border: 4px solid var(--tc, #ddd); box-shadow: 0 6px 0 rgba(0,0,0,.2); min-height: 110px; }
.pcard-l.empty { flex-direction: column; justify-content: center; text-align: center; gap: 2px; border-style: dashed; border-color: #d8c3a8; color: var(--ink2); }
.waiting-cat { font-size: 30px; animation: bounce .7s infinite alternate; }
.pl-hero { width: 84px; height: 84px; border-radius: 50%; }
.pl-info { flex: 1; }
.pl-name { font-size: 20px; font-weight: 700; }
.pl-hero-n { color: var(--ink2); }
.pl-cat img { width: 48px; height: 48px; }
.pl-ready { font-weight: 700; padding: 6px 12px; border-radius: 10px; background: #eee3d4; color: var(--ink2); font-size: 14px; }
.pl-ready.on { background: var(--mint); color: #fff; }
.lemote-pop, .emote-pop { position: absolute; top: -18px; left: 50%; transform: translateX(-50%) scale(0); background: #fff; color: var(--ink); padding: 6px 14px; border-radius: 16px; font-weight: 600; white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.25); pointer-events: none; opacity: 0; z-index: 3; }
.lemote-pop.show, .emote-pop.show { animation: emotePop 2.4s ease forwards; }
@keyframes emotePop { 0% { transform: translateX(-50%) scale(.3); opacity: 0; } 10% { transform: translateX(-50%) scale(1.1); opacity: 1; } 15% { transform: translateX(-50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-12px); } }
.lobby-cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; }
.lobby-bar { position: sticky; bottom: 0; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 12px 0; }
.lobby-status { color: #fff; text-align: center; font-size: 17px; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.time-row { margin: 12px 0 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; }
.lobby-emotes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.lobby-emotes .btn { font-size: 20px; padding: 4px 10px; }

/* ---------- hero cards ---------- */
.hero-strip { display: flex; gap: 10px; overflow-x: auto; padding: 6px 4px 12px; scrollbar-width: thin; }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.hero-card { position: relative; padding: 10px; text-align: center; background: linear-gradient(180deg, color-mix(in srgb, var(--clan) 30%, #fff), #fff); border: 3px solid transparent; }
.hero-card img { width: 100%; max-width: 120px; aspect-ratio: 1; border-radius: 50%; }
.hero-card.small { flex: 0 0 96px; padding: 6px; }
.hero-card.small img { max-width: 76px; }
.hero-card.sel { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255,122,168,.35), 0 6px 0 rgba(0,0,0,.18); }
.hero-card.locked img { filter: grayscale(.85) brightness(.85); }
.hc-name { font-weight: 700; font-size: 15px; line-height: 1.1; margin-top: 4px; }
.hero-card.small .hc-name { font-size: 12px; }
.hc-title { font-size: 12px; color: var(--ink2); }
.hc-lock { position: absolute; top: 6px; right: 6px; background: rgba(40,25,50,.85); color: #fff; font-size: 12px; padding: 3px 7px; border-radius: 10px; font-weight: 600; }
.hero-detail { --clan: #ffcf4d; }
.hd-top { display: flex; gap: 16px; align-items: center; margin-bottom: 10px; }
.hd-portrait { width: 120px; height: 120px; border-radius: 50%; box-shadow: 0 0 0 5px var(--clan); flex: none; }
.hd-top h2 { margin: 0; font-size: 28px; }
.hd-clan { font-weight: 700; color: color-mix(in srgb, var(--clan) 70%, #000); font-size: 14px; }
.hd-title { color: var(--ink2); font-style: italic; }
.hd-blurb { margin: 6px 0 0; }
.ability { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 14px; background: #fff; margin: 8px 0; border: 2px solid #f1e4d2; }
.ability.passive { background: color-mix(in srgb, var(--clan) 18%, #fff); }
.ab-icon { flex: none; width: 46px; height: 46px; display: grid; place-items: center; font-size: 26px; background: var(--cream2); border-radius: 12px; }
.ab-tag { font-size: 11px; background: var(--ink); color: #fff; padding: 1px 7px; border-radius: 8px; vertical-align: 2px; }
.ab-meta { font-size: 12px; color: var(--ink2); margin-top: 3px; }
.clan-row { margin: 18px auto; max-width: 1100px; }
.clan-row h3 { font-size: 24px; text-shadow: 0 2px 0 rgba(0,0,0,.4); margin: 0 0 10px; }
.clan-row h3 .muted { color: #e9dcff; text-shadow: none; font-weight: 400; }
.heroes > p { color: #e9dcff !important; max-width: 700px; margin: 6px auto; }

/* ---------- maps ---------- */
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.map-card { padding: 6px 6px 8px; text-align: center; background: #fff; border: 3px solid transparent; }
.map-card.sel { border-color: var(--pink); }
.map-svg { width: 100%; aspect-ratio: 16/9; display: block; border-radius: 8px; }
.map-svg.rnd { display: grid; place-items: center; font-size: 36px; background: linear-gradient(135deg, #ffd1e3, #c9e9ff); }
.mc-name { font-weight: 700; font-size: 14px; margin-top: 4px; }
.mc-size { font-size: 11px; color: var(--ink2); }

/* ---------- setup / practice ---------- */
.setup { max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
.setup .seg .btn { min-width: 92px; }
.setup .row { margin: 10px 0 14px; }
.setup .start { margin-top: 16px; }

/* ---------- campaign ---------- */
.campaign { max-width: 1100px; margin: 0 auto; }
.camp-head { padding: 12px 18px; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; font-size: 17px; }
.camp-path { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin: 20px 0; }
.camp-node { position: relative; padding: 12px; text-align: center; animation: popIn .4s calc(var(--d) * 40ms) both cubic-bezier(.2,1.5,.4,1); }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } }
.camp-node img { width: 76px; height: 76px; border-radius: 50%; }
.camp-node.locked { filter: grayscale(.9) brightness(.8); }
.camp-node.current { box-shadow: 0 0 0 4px var(--gold), 0 6px 0 rgba(0,0,0,.2); animation: popIn .4s calc(var(--d) * 40ms) both, glow 1.6s infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 7px rgba(255,207,77,.6), 0 6px 0 rgba(0,0,0,.2); } }
.cn-num { position: absolute; top: 8px; left: 10px; background: var(--ink); color: #fff; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.cn-name { font-weight: 700; margin-top: 4px; }
.cn-stars span, .res-stars span { color: #d8cbb8; font-size: 20px; }
.cn-stars span.on, .res-stars span.on { color: var(--gold); text-shadow: 0 0 8px rgba(255,207,77,.8); }
.cn-ai { font-size: 12px; color: var(--ink2); }
.cn-lock { position: absolute; inset: 0; display: grid; place-items: center; font-size: 36px; }
.level-card .lc-top { display: flex; gap: 16px; align-items: center; }
.level-card .lc-top img { width: 110px; height: 110px; border-radius: 50%; }
.level-card h2 { margin: 2px 0 6px; }
.tip { background: #fff4c9; border-radius: 12px; padding: 10px 14px; margin: 12px 0; }

/* ---------- shop ---------- */
.shop { max-width: 1100px; margin: 0 auto; }
.shop-preview { display: flex; gap: 16px; align-items: center; padding: 10px 20px; margin-bottom: 14px; }
.shop-cat { width: 110px; height: 110px; }
.tabs .btn { min-width: 120px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.shop-item { padding: 10px; text-align: center; border: 3px solid transparent; }
.shop-item img { width: 100px; height: 100px; }
.shop-item.sel { border-color: var(--mint); }
.si-name { font-weight: 700; }
.si-price { font-size: 14px; color: var(--ink2); font-weight: 600; }

/* ---------- profile ---------- */
.profile { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.prof-head { display: flex; gap: 20px; align-items: center; }
.prof-head img { width: 110px; height: 110px; }
.ph-main { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.xpbar { position: relative; height: 22px; background: #eadbc6; border-radius: 11px; overflow: hidden; }
.xpbar > div { height: 100%; background: linear-gradient(90deg, var(--sky), var(--mint)); border-radius: 11px; transition: width 1s; }
.xpbar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { padding: 12px; text-align: center; display: flex; flex-direction: column; }
.stat .si { font-size: 26px; }
.stat b { font-size: 24px; }
.stat span { font-size: 13px; color: var(--ink2); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.ach { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: #f3e8d8; opacity: .7; }
.ach.got { background: #fff4c9; opacity: 1; }
.ach-i { font-size: 26px; }
.ach > div:nth-child(2) { flex: 1; }
.ach-r { font-weight: 700; font-size: 13px; color: var(--gold-d); }
.hist { display: flex; flex-direction: column; gap: 6px; }
.hist-row { display: grid; grid-template-columns: 60px 80px 1fr 1fr 1fr; gap: 8px; padding: 8px 12px; border-radius: 10px; background: #fff; font-size: 14px; }
.hist-row span:first-child { font-weight: 700; }
.hist-row.w span:first-child { color: var(--mint-d); }
.hist-row.l span:first-child { color: var(--red); }

/* ---------- how to ---------- */
.howto { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.how { display: flex; gap: 16px; align-items: flex-start; }
.how-i { font-size: 44px; flex: none; width: 64px; text-align: center; }
.how h3 { margin: 0 0 6px; }
.how p { margin: 0 0 6px; }
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.bitem { display: flex; gap: 10px; align-items: center; background: #fff; padding: 8px; border-radius: 12px; }
.bitem img { width: 74px; height: 74px; flex: none; }

/* ---------- settings ---------- */
.settings { max-width: 560px; margin: 20px auto; display: flex; flex-direction: column; gap: 16px; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 600; font-size: 17px; }
.settings input[type=range] { width: 220px; accent-color: var(--pink); }
.settings input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--pink); }
.settings hr { border: 0; border-top: 2px dashed #e8d6c0; width: 100%; }

/* ---------- results ---------- */
.results { max-width: 1050px; margin: 0 auto; padding-top: 3vh; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.res-banner { font-size: clamp(48px, 9vw, 90px); font-weight: 700; color: #fff; -webkit-text-stroke: 3px #3a1f4e; text-shadow: 0 6px 0 #3a1f4e, 0 0 40px rgba(255,215,107,.6); animation: logoIn .7s cubic-bezier(.2,1.6,.4,1); }
.results.win .res-banner { color: #ffd76b; }
.results.lose .res-banner { color: #c9d4ff; text-shadow: 0 6px 0 #3a1f4e; }
.res-sub { color: #fff; font-size: 18px; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.res-stars span { font-size: 54px; animation: popIn .5s both; }
.res-stars span:nth-child(2) { animation-delay: .25s; } .res-stars span:nth-child(3) { animation-delay: .5s; }
.res-vs { display: flex; gap: 24px; align-items: center; color: #fff; font-weight: 700; font-size: 18px; }
.res-p img { width: 100px; height: 100px; border-radius: 50%; box-shadow: 0 0 0 4px #fff; }
.res-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; text-align: left; }
table.stats { width: 100%; border-collapse: collapse; }
table.stats td, table.stats th { padding: 7px 8px; border-bottom: 2px dashed #eedfcb; }
table.stats td:nth-child(2), table.stats td:nth-child(3), table.stats th { text-align: center; font-weight: 700; }
.rw-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 2px dashed #eedfcb; animation: slideIn .4s both; }
@keyframes slideIn { from { transform: translateX(-20px); opacity: 0; } }
.rw-line b { color: var(--gold-d); }
.rw-total { font-size: 26px; margin: 10px 0; text-align: right; font-weight: 700; }
.next-hero { display: flex; gap: 10px; align-items: center; margin-top: 12px; background: #fff; padding: 8px; border-radius: 12px; }
.next-hero img { width: 54px; height: 54px; border-radius: 50%; }
.next-hero > div { flex: 1; }
.progress { height: 12px; background: #eadbc6; border-radius: 6px; overflow: hidden; margin: 4px 0; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--gold), var(--orange)); }
.res-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 10px 0 30px; }

/* ---------- modal / toasts ---------- */
#modal { position: fixed; z-index: 50; }
.modal-bg { position: fixed; inset: 0; background: rgba(20, 10, 30, .6); display: grid; place-items: center; padding: 16px; animation: fadeIn .2s; backdrop-filter: blur(3px); }
.modal { position: relative; background: var(--cream); border-radius: 22px; padding: 22px; max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 0 rgba(0,0,0,.2), 0 20px 60px rgba(0,0,0,.4); animation: popIn .3s cubic-bezier(.2,1.5,.4,1); }
.modal.wide { max-width: 680px; }
.modal-x { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #f0e2cf; font-size: 18px; cursor: pointer; z-index: 2; }
.modal-actions { display: flex; justify-content: center; margin-top: 14px; }
.modal img { max-width: 100%; }
.welcome, .daily { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.welcome-cat { width: 130px; height: 130px; }
.welcome h2, .daily h2 { margin: 0; }
.welcome .row { justify-content: center; }
.gift { font-size: 80px; animation: bounce .6s infinite alternate; }
#toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.mtoast { background: var(--cream); color: var(--ink); padding: 10px 18px; border-radius: 14px; font-weight: 500; box-shadow: 0 4px 0 rgba(0,0,0,.2), 0 8px 20px rgba(0,0,0,.25); animation: toastIn .35s cubic-bezier(.2,1.5,.4,1); max-width: 90vw; text-align: center; }
.mtoast.good { background: #e6fff3; border: 2px solid var(--mint); }
.mtoast.warn { background: #fff0f0; border: 2px solid #ff9a9a; }
.mtoast.out { opacity: 0; transform: translateY(-10px); transition: .4s; }
@keyframes toastIn { from { transform: translateY(-20px) scale(.9); opacity: 0; } }

/* ================= HUD ================= */
.hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; display: none; color: #fff; }
.hud.active { display: block; }
.hud button { pointer-events: auto; }
.hud-top { position: absolute; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 10px; padding: 8px 10px; }
.pcard { position: relative; display: flex; align-items: center; gap: 10px; background: var(--glass); border-radius: 16px; padding: 5px 14px 5px 5px; border: 3px solid var(--tc); max-width: 330px; backdrop-filter: blur(4px); box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.pcard.opp { justify-self: end; flex-direction: row-reverse; padding: 5px 5px 5px 14px; text-align: right; }
.pcard .portrait { width: 48px; height: 48px; border-radius: 50%; box-shadow: 0 0 0 3px var(--tc); }
.pname { font-weight: 700; font-size: 16px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.pname .tag { font-size: 10px; background: rgba(255,255,255,.2); padding: 1px 5px; border-radius: 5px; vertical-align: 2px; }
.phero { font-size: 12px; opacity: .8; }
.pmeta { display: flex; gap: 10px; font-size: 14px; align-items: center; }
.pcard.opp .pmeta { justify-content: flex-end; }
.stars { color: #ffd84d; letter-spacing: 1px; text-shadow: 0 0 6px rgba(255,216,77,.6); }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.timer { background: var(--glass); padding: 2px 16px; border-radius: 12px; font-weight: 700; font-size: 22px; min-width: 86px; text-align: center; border: 2px solid rgba(255,255,255,.2); }
.timer.low { color: #ff8a8a; animation: pulseText 1s infinite; }
@keyframes pulseText { 50% { transform: scale(1.08); } }
.armybar { position: relative; display: flex; width: min(34vw, 360px); height: 18px; border-radius: 9px; overflow: hidden; background: rgba(0,0,0,.4); border: 2px solid rgba(255,255,255,.3); }
.armybar .fill { height: 100%; transition: width .4s; }
.armybar span { position: absolute; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.armybar .l { left: 8px; } .armybar .r { right: 8px; }

.hud-bottom { position: absolute; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; padding: 8px 12px 10px; }
.pct { display: flex; align-items: center; gap: 4px; background: var(--glass); padding: 6px; border-radius: 14px; justify-self: start; pointer-events: auto; }
.pct-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; writing-mode: vertical-rl; transform: rotate(180deg); opacity: .7; padding: 0 2px; }
.pct-btn { position: relative; border: 0; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; font-weight: 700; font-size: 15px; padding: 10px 10px; cursor: pointer; min-width: 54px; }
.pct-btn.on { background: linear-gradient(#ff9cc0, var(--pink)); box-shadow: 0 3px 0 var(--pink-d); }
.pct-btn kbd, .spell kbd { position: absolute; bottom: 1px; right: 4px; font-size: 9px; opacity: .55; }
.spellbar { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--glass); padding: 8px 12px 6px; border-radius: 18px; pointer-events: auto; }
.catnip { position: relative; width: 100%; min-width: 230px; height: 18px; background: rgba(0,0,0,.45); border-radius: 9px; overflow: hidden; border: 2px solid rgba(120,230,150,.4); }
.catnip-fill { height: 100%; background: linear-gradient(90deg, #3fc97a, #9cf07a); box-shadow: 0 0 12px rgba(120,240,140,.6); transition: width .1s linear; }
.catnip-txt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.spells { display: flex; gap: 10px; }
.spell { position: relative; width: 66px; height: 66px; border-radius: 18px; border: 3px solid rgba(255,255,255,.35); background: radial-gradient(circle at 35% 30%, #6a4d8f, #2c1d44); cursor: pointer; display: grid; place-items: center; transition: transform .1s, border-color .2s; overflow: hidden; }
.spell:hover { transform: translateY(-3px); }
.spell .sicon { font-size: 32px; z-index: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
.spell .scost { position: absolute; top: 2px; left: 4px; font-size: 11px; font-weight: 700; background: rgba(40,160,90,.9); padding: 0 5px; border-radius: 6px; z-index: 3; }
.spell .scd { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.spell .scdtxt { position: absolute; z-index: 3; font-size: 22px; font-weight: 700; text-shadow: 0 2px 3px rgba(0,0,0,.7); }
.spell.ready { border-color: #9cf07a; box-shadow: 0 0 14px rgba(156,240,122,.5); }
.spell.poor .sicon { opacity: .55; }
.spell.targeting { border-color: #ffe066; box-shadow: 0 0 0 4px rgba(255,224,102,.5), 0 0 20px rgba(255,224,102,.7); animation: pulseText .8s infinite; }
.spell.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.passive { font-size: 11px; opacity: .75; }
.actions { justify-self: end; display: flex; gap: 8px; }
.actions button { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--glass); color: #fff; font-size: 24px; cursor: pointer; border: 2px solid rgba(255,255,255,.25); }
.emote-wheel { position: absolute; right: 12px; bottom: 76px; display: grid; grid-template-columns: repeat(4, 50px); gap: 6px; background: var(--glass); padding: 8px; border-radius: 16px; pointer-events: auto; animation: popIn .2s; }
.emote-wheel button { width: 50px; height: 50px; border-radius: 12px; border: 0; background: rgba(255,255,255,.12); font-size: 26px; cursor: pointer; }
.emote-wheel button:hover { background: rgba(255,255,255,.3); transform: scale(1.1); }
.pcard .emote-pop { top: auto; bottom: -46px; left: 40px; transform: scale(0); }
.pcard.opp .emote-pop { left: auto; right: 40px; }
.pcard .emote-pop.show { animation: emotePop2 2.4s ease forwards; }
@keyframes emotePop2 { 0% { transform: scale(.3); opacity: 0; } 10% { transform: scale(1.1); opacity: 1; } 15% { transform: scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }

.bmenu { position: absolute; z-index: 5; width: 240px; background: rgba(255, 248, 238, .97); color: var(--ink); border-radius: 16px; padding: 10px 12px; pointer-events: auto; box-shadow: 0 6px 0 rgba(0,0,0,.2), 0 12px 30px rgba(0,0,0,.35); animation: popIn .18s; }
.bm-h { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.bm-h .lv { font-size: 12px; background: var(--ink); color: #fff; padding: 1px 7px; border-radius: 8px; }
.bm-x { margin-left: auto; border: 0; background: #f0e2cf; width: 26px; height: 26px; border-radius: 50%; cursor: pointer; }
.bm-i { font-size: 13px; color: var(--ink2); margin: 4px 0 8px; }
.bm-up { width: 100%; border: 0; border-radius: 12px; padding: 9px; font-weight: 700; font-size: 16px; color: #fff; cursor: pointer; background: linear-gradient(#8fe0a8, var(--mint)); box-shadow: 0 4px 0 var(--mint-d); display: flex; justify-content: space-between; }
.bm-up.off, .bm-conv button.off { filter: grayscale(.8); opacity: .6; }
.bm-max { text-align: center; color: var(--gold-d); font-weight: 700; }
.bm-conv-l { font-size: 12px; margin: 8px 0 4px; color: var(--ink2); }
.bm-conv { display: flex; gap: 6px; }
.bm-conv button { flex: 1; border: 0; border-radius: 10px; background: #fff; padding: 6px 0; font-size: 22px; cursor: pointer; box-shadow: 0 3px 0 #e2cfb8; display: flex; flex-direction: column; align-items: center; }
.bm-conv button span { font-size: 11px; font-weight: 700; color: var(--ink2); }
.bm-tip { font-size: 11px; color: var(--ink2); margin-top: 8px; text-align: center; }
.spell-tip { position: absolute; width: 260px; background: rgba(255,248,238,.98); color: var(--ink); border-radius: 14px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.35); z-index: 6; }
.tt-h { font-weight: 700; font-size: 16px; }
.tt-d { font-size: 13px; margin: 4px 0; }
.tt-m { display: flex; gap: 10px; font-size: 12px; color: var(--ink2); flex-wrap: wrap; }
.toasts { position: absolute; top: 78px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(560px, 92vw); }
.toast { background: var(--glass); padding: 7px 14px; border-radius: 12px; font-size: 14px; border-left: 4px solid var(--tc, #fff); animation: toastIn .3s; backdrop-filter: blur(4px); text-align: center; }
.toast.warn { border-left-color: #ff8a8a; background: rgba(90, 20, 30, .8); }
.toast.out { opacity: 0; transition: .4s; }
.targeting-hint { position: absolute; bottom: 150px; left: 50%; transform: translateX(-50%); background: rgba(255, 224, 102, .95); color: #4a3200; padding: 8px 16px; border-radius: 14px; font-size: 15px; white-space: nowrap; animation: popIn .2s; }
.targeting-hint span { opacity: .7; font-size: 12px; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.cd-num { font-size: 160px; font-weight: 700; color: #fff; -webkit-text-stroke: 5px #3a1f4e; text-shadow: 0 10px 0 #3a1f4e; animation: cdPop .8s ease-out; }
@keyframes cdPop { 0% { transform: scale(2.2); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(.85); opacity: .9; } }
.banner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse, rgba(30,15,45,.35), rgba(30,15,45,.75)); animation: fadeIn .5s; }
.banner-t { font-size: clamp(64px, 13vw, 150px); font-weight: 700; color: #fff; -webkit-text-stroke: 4px #3a1f4e; text-shadow: 0 10px 0 #3a1f4e, 0 0 60px rgba(255,215,107,.7); animation: logoIn .8s cubic-bezier(.2,1.6,.4,1); }
.banner.win .banner-t { color: #ffd76b; }
.banner.lose .banner-t { color: #c9d4ff; text-shadow: 0 10px 0 #3a1f4e; }
.banner-s { font-size: 22px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
.pause { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20,10,30,.55); pointer-events: auto; backdrop-filter: blur(3px); }
.pause-card { background: var(--cream); color: var(--ink); padding: 22px; border-radius: 22px; width: min(420px, 92vw); display: flex; flex-direction: column; gap: 12px; text-align: center; box-shadow: 0 8px 0 rgba(0,0,0,.2); }
.pause-card h2 { margin: 0; }
.pause-card .row { justify-content: center; }
.help-mini { font-size: 13px; text-align: left; background: #fff; padding: 10px; border-radius: 12px; display: flex; flex-direction: column; gap: 4px; }
.ping { position: absolute; top: 74px; right: 14px; font-size: 12px; opacity: .7; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .lobby-cols, .setup, .res-cols { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .friend { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .home-grid { grid-template-columns: repeat(2, 1fr); }
  .home-me { position: static; }
  .settings-btn { position: absolute; top: 12px; right: 12px; bottom: auto; }
  .topbar { grid-template-columns: auto 1fr; }
  .topbar .screen-title { display: none; }
  .room-code span { width: 42px; height: 54px; font-size: 32px; }
  .vs-row { grid-template-columns: 1fr; }
  .vs-row .vs { display: none; }
  .hist-row { grid-template-columns: 50px 1fr 1fr; }
  .hist-row span:nth-child(4), .hist-row span:nth-child(5) { display: none; }
  .pcard { padding: 3px 8px 3px 3px; gap: 6px; border-width: 2px; }
  .pcard.opp { padding: 3px 3px 3px 8px; }
  .pcard .portrait { width: 34px; height: 34px; }
  .pname { font-size: 13px; max-width: 90px; }
  .phero { display: none; }
  .pmeta { font-size: 11px; gap: 4px; }
  .timer { font-size: 16px; min-width: 60px; padding: 1px 8px; }
  .armybar { width: 28vw; height: 14px; }
  .hud-bottom { grid-template-columns: auto 1fr auto; padding: 4px 6px 6px; gap: 6px; }
  .pct { flex-direction: column; padding: 4px; }
  .pct-label { display: none; }
  .pct-btn { min-width: 44px; padding: 4px; font-size: 12px; }
  .pct-btn kbd, .spell kbd { display: none; }
  .spellbar { justify-self: center; padding: 6px 8px 4px; }
  .catnip { min-width: 160px; height: 14px; }
  .spell { width: 54px; height: 54px; border-radius: 14px; }
  .spell .sicon { font-size: 26px; }
  .passive { display: none; }
  .actions { flex-direction: column; }
  .actions button { width: 42px; height: 42px; font-size: 20px; }
  .toasts { top: 56px; }
  .cd-num { font-size: 110px; }
}
@media (max-height: 520px) {
  .home { padding-top: 0; gap: 10px; }
  .logo-text span { font-size: 54px; }
  .logo-sub { display: none; }
  .btn.tile { padding: 8px; }
  .btn.tile .ti { font-size: 22px; }
}

/* fun modifiers */
.rules-row, .lobby-rules .rules-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.rules-l { font-weight: 600; width: 100%; }
.rule-icons { display: flex; gap: 4px; background: var(--glass); padding: 1px 8px; border-radius: 10px; font-size: 14px; pointer-events: auto; }
.setup > *, .lobby-cols > *, .res-cols > * { min-width: 0; }

.waiting { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20,10,30,.5); pointer-events: auto; z-index: 8; }
.waiting-card { background: var(--cream); color: var(--ink); padding: 22px 28px; border-radius: 20px; text-align: center; font-size: 18px; box-shadow: 0 8px 0 rgba(0,0,0,.2); }

/* version label, update banner, version panel */
.ver-badge { border: 0; background: rgba(0,0,0,.08); color: inherit; font: 600 12px var(--font); padding: 3px 9px; border-radius: 9px; cursor: pointer; }
.ver-badge.corner {
  position: fixed; z-index: 12; right: calc(env(safe-area-inset-right) + 8px); bottom: calc(env(safe-area-inset-bottom) + 8px);
  background: rgba(20, 10, 34, .6); color: #f3e9ff; font-size: 12px; padding: 4px 10px; backdrop-filter: blur(3px);
}
.ver-badge.corner:hover { background: rgba(20, 10, 34, .85); }
.update-banner {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 10px);
  border: 0; border-radius: 14px; padding: 9px 16px; cursor: pointer; font: 600 14px var(--font); color: #3b2600;
  background: linear-gradient(#ffe68a, #ffc94d); box-shadow: 0 5px 0 #c9971b, 0 10px 24px rgba(0,0,0,.35); max-width: 92vw; animation: fadeIn .3s;
}
.ver-modal { max-width: 380px; }
.ver-info h2 { margin: 0 0 10px; text-align: center; }
.ver-rows { display: flex; flex-direction: column; gap: 6px; background: #fff; border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.ver-rows div { display: flex; justify-content: space-between; gap: 12px; }
.ver-rows span { color: var(--ink2); }
.ver-rows b { text-align: right; }
.ver-warn { background: #fff1d6; border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.ver-status { margin: 10px 0; text-align: center; font-size: 14px; }
.ver-status .btn { margin-top: 6px; }
.ver-info .row { gap: 8px; }
