/* Bugland – player client styles. Palette mirrors PALETTE in shared/constants.js */
:root {
  --bg-deep: #0f1a12;
  --bg-panel: #18281c;
  --bg-panel-a: rgba(18, 32, 22, 0.82);
  --moss: #3f6b3a;
  --leaf: #7bb661;
  --honey: #f5b82e;
  --amber: #e08a1e;
  --berry: #d8455b;
  --sky: #6fc3df;
  --text: #f2efe4;
  --text-dim: #a9b59f;
  --hp: #6cd46a;
  --xp: #f5b82e;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  --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);
  --font-head: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg-deep); color: var(--text);
  font-family: var(--font-body); font-weight: 700; -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
body { position: fixed; inset: 0; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
input, select { font: inherit; }

#game { position: fixed; inset: 0; display: block; touch-action: none; outline: none; }
body.state-join #game { visibility: hidden; }

/* ---------------------------------------------------------------- buttons & panels */
.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 10px 18px; cursor: pointer;
  background: #2a4230; color: var(--text); font-weight: 800; letter-spacing: 0.2px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); transition: transform 0.08s, filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.4); }
.btn-primary { background: linear-gradient(180deg, #ffd35a, var(--honey) 55%, var(--amber)); color: #2a1a06; box-shadow: inset 0 -4px 0 rgba(120, 60, 0, 0.35), 0 6px 18px rgba(245, 184, 46, 0.3); }
.btn-ghost { background: transparent; border: 1px solid rgba(255, 255, 255, 0.18); }
.btn-big { font-family: var(--font-head); font-size: 22px; padding: 14px 26px; border-radius: 16px; width: 100%; }

.panel {
  background: var(--bg-panel-a); border: 1px solid rgba(123, 182, 97, 0.25); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
  background: rgba(10, 18, 12, 0.7); border: 1px solid rgba(255, 255, 255, 0.1); font-size: 13px; font-weight: 800;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 18, 12, 0.65); font-size: 18px; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.icon-btn:active { transform: scale(0.94); }

/* ---------------------------------------------------------------- join screen */
.screen { position: fixed; inset: 0; z-index: 20; }
.join { overflow-y: auto; overflow-x: hidden; touch-action: pan-y; -webkit-overflow-scrolling: touch; user-select: auto; }
#join-bg { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.join-vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 40%, rgba(15, 26, 18, 0.15), rgba(15, 26, 18, 0.75) 75%); }
.join-wrap { position: relative; max-width: 980px; margin: 0 auto; padding: calc(18px + var(--safe-t)) 14px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; min-height: 100%; }
.logo { text-align: center; margin-top: 6px; }
.logo h1 {
  font-family: var(--font-head); font-weight: 700; margin: 0; font-size: clamp(48px, 11vw, 96px); line-height: 1;
  letter-spacing: 1px; color: var(--honey);
  background: linear-gradient(180deg, #fff1a8 0%, #ffd04a 40%, #e08a1e 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 #5a3206) drop-shadow(0 10px 18px rgba(0, 0, 0, 0.55));
}
.logo-bug { display: inline-block; -webkit-text-fill-color: initial; font-size: 0.7em; margin-right: 8px; animation: bugwiggle 2.4s ease-in-out infinite; transform-origin: 50% 80%; vertical-align: 6%; filter: none; }
@keyframes bugwiggle { 0%, 100% { transform: rotate(-8deg) translateY(0); } 50% { transform: rotate(10deg) translateY(-6px); } }
.tagline { margin: 8px 0 0; color: var(--text); opacity: 0.9; font-size: clamp(14px, 3.6vw, 18px); text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7); }

.join-card {
  background: rgba(16, 28, 19, 0.86); border: 1px solid rgba(123, 182, 97, 0.28); border-radius: 20px; padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; flex-direction: column; gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field label, .field .label { font-family: var(--font-head); font-size: 17px; color: var(--honey); }
#join-name, #join-code {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid rgba(123, 182, 97, 0.35); background: rgba(5, 12, 7, 0.65);
  color: var(--text); font-size: 18px; font-weight: 800; outline: none; transition: border-color 0.15s; user-select: text;
}
#join-name:focus, #join-code:focus { border-color: var(--honey); }
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.class-card {
  position: relative; border-radius: 14px; padding: 8px 8px 10px; cursor: pointer; text-align: center;
  background: linear-gradient(180deg, rgba(40, 64, 44, 0.75), rgba(20, 34, 24, 0.85));
  border: 2px solid rgba(255, 255, 255, 0.08); transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.class-card:hover { transform: translateY(-2px); }
.class-card.selected { border-color: var(--cls, var(--honey)); box-shadow: 0 0 0 3px rgba(245, 184, 46, 0.2), 0 8px 24px rgba(0, 0, 0, 0.4); background: linear-gradient(180deg, rgba(60, 84, 50, 0.85), rgba(26, 42, 28, 0.9)); }
.class-card canvas { width: 96px; height: 84px; display: block; }
.class-card .cc-name { font-family: var(--font-head); font-size: 16px; line-height: 1.1; }
.class-card .cc-role { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--cls, #444); color: #10120c; font-weight: 900; text-transform: uppercase; letter-spacing: 0.5px; }
.class-card .cc-fly { position: absolute; top: 6px; right: 8px; font-size: 12px; opacity: 0.85; }
.class-card .cc-skills { display: flex; gap: 3px; font-size: 14px; margin-top: 2px; }
.class-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 14px; background: rgba(5, 12, 7, 0.45); border-radius: 14px; padding: 12px 14px; border: 1px solid rgba(255, 255, 255, 0.06); }
.class-detail h3 { margin: 0 0 4px; font-family: var(--font-head); font-size: 20px; color: var(--cls, var(--honey)); }
.class-detail .desc { margin: 0 0 10px; color: var(--text-dim); font-weight: 700; font-size: 14px; }
.stat-row { display: grid; grid-template-columns: 62px 1fr 38px; align-items: center; gap: 8px; font-size: 12px; margin: 4px 0; }
.stat-row .sbar { height: 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.stat-row .sbar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--leaf), var(--honey)); }
.stat-row .val { text-align: right; color: var(--text-dim); }
.skill-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.skill-list li { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: start; font-size: 13px; }
.skill-list .s-ico { font-size: 20px; line-height: 1.2; text-align: center; }
.skill-list .s-name { font-weight: 900; }
.skill-list .s-key { font-size: 10px; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); margin-left: 6px; color: var(--text-dim); }
.skill-list .s-lvl { font-size: 10px; color: var(--honey); margin-left: 4px; }
.skill-list .s-desc { color: var(--text-dim); font-weight: 600; display: block; }
.joincode summary { cursor: pointer; color: var(--text-dim); font-size: 13px; }
.joincode input { margin-top: 8px; }
.join-error { min-height: 1.2em; margin: 0; color: #ff8a8a; text-align: center; font-weight: 900; }
.join-error.shake { animation: shake 0.4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.join-status { margin: -6px 0 0; text-align: center; font-size: 13px; color: var(--text-dim); display: flex; gap: 8px; justify-content: center; align-items: center; }
.join-status .dot, .net-status i { width: 8px; height: 8px; border-radius: 50%; background: #888; display: inline-block; }
.join-status.ok .dot { background: var(--leaf); box-shadow: 0 0 8px var(--leaf); }
.join-status.bad .dot { background: var(--berry); }
.join-help { text-align: center; font-size: 12px; color: var(--text-dim); text-shadow: 0 1px 3px #000; line-height: 1.6; }
.help-touch { display: none; }
body.touch .help-touch { display: block; }
body.touch .help-desktop { display: none; }
#join-btn.loading .btn-label::after { content: ' …'; }

@media (max-width: 640px) {
  .class-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .class-card canvas { width: 76px; height: 64px; }
  .class-card .cc-name { font-size: 14px; }
  .class-card .cc-skills { display: none; }
  .class-detail { grid-template-columns: 1fr; }
  .join-card { padding: 14px; border-radius: 18px; }
}

/* ---------------------------------------------------------------- HUD layout */
.game-ui { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.game-ui > *, .game-ui button, .game-ui .panel, .game-ui input, .game-ui select { pointer-events: auto; }
.game-ui .hud-tl, .game-ui .hud-tc, .game-ui .hud-tr, .game-ui .announce, .game-ui .event-banner, .game-ui .levelup, .game-ui .joy, .game-ui .rotate-hint { pointer-events: none; }
.game-ui .hud-tl > *, .game-ui .hud-tr > .mm-wrap, .game-ui .rotate-hint .x { pointer-events: auto; }

.hud-tl { z-index: 8; position: absolute; top: calc(10px + var(--safe-t)); left: calc(10px + var(--safe-l)); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.player-panel {
  display: flex; gap: 8px; align-items: center; padding: 6px 10px 6px 6px; border-radius: 16px;
  background: rgba(10, 18, 12, 0.72); border: 1px solid rgba(255, 255, 255, 0.08); box-shadow: var(--shadow);
}
#hud-portrait { width: 52px; height: 52px; border-radius: 12px; background: radial-gradient(circle at 40% 35%, #4b7a3c, #1c2e20); }
.pp-main { display: flex; flex-direction: column; gap: 4px; width: clamp(150px, 22vw, 230px); }
.pp-name { display: flex; align-items: center; gap: 6px; font-family: var(--font-head); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvl-badge { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 6px; border-radius: 8px; background: var(--honey); color: #2a1a06; font-size: 13px; font-weight: 700; }
.bar { position: relative; height: 14px; border-radius: 8px; background: rgba(0, 0, 0, 0.55); overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.08); }
.bar .fill { position: absolute; inset: 0; width: 0%; border-radius: 8px; transition: width 0.2s ease-out; }
.hp-bar .fill { background: linear-gradient(180deg, #8ef08a, #3fae3c); }
.hp-bar.mid .fill { background: linear-gradient(180deg, #ffd56a, #e0a01e); }
.hp-bar.low .fill { background: linear-gradient(180deg, #ff7a7a, #c82a2a); animation: pulse-low 0.8s infinite; }
@keyframes pulse-low { 50% { filter: brightness(1.4); } }
.xp-bar { height: 9px; }
.xp-bar .fill { background: linear-gradient(90deg, #f5b82e, #ffe27a); }
.bar-text { position: relative; display: block; text-align: center; font-size: 10px; line-height: 13px; font-weight: 900; text-shadow: 0 1px 2px #000; }
.xp-bar .bar-text { font-size: 8px; line-height: 8px; }
.buff-bar { display: flex; gap: 4px; flex-wrap: wrap; max-width: 280px; }
.buff { position: relative; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; background: rgba(10, 18, 12, 0.72); border: 1px solid rgba(255, 255, 255, 0.12); }
.buff.debuff { border-color: rgba(216, 69, 91, 0.7); }
.buff .ttl { position: absolute; bottom: -3px; right: -3px; font-size: 9px; background: #000; border-radius: 6px; padding: 0 3px; font-weight: 900; }
.stat-btn {
  border: 0; border-radius: 12px; padding: 7px 12px; cursor: pointer; font-weight: 900;
  background: linear-gradient(180deg, #ffd35a, var(--amber)); color: #2a1a06; box-shadow: 0 0 0 0 rgba(245, 184, 46, 0.6); animation: glowpulse 1.6s infinite;
}
@keyframes glowpulse { 0% { box-shadow: 0 0 0 0 rgba(245, 184, 46, 0.6); } 70% { box-shadow: 0 0 0 12px rgba(245, 184, 46, 0); } 100% { box-shadow: 0 0 0 0 rgba(245, 184, 46, 0); } }
.stat-panel { padding: 10px; width: 240px; display: flex; flex-direction: column; gap: 6px; }
.stat-panel h4 { margin: 0 0 2px; font-family: var(--font-head); color: var(--honey); font-size: 15px; }
.stat-line { display: grid; grid-template-columns: 22px 1fr auto 34px; gap: 6px; align-items: center; font-size: 13px; }
.stat-line .v { color: var(--text-dim); font-size: 12px; }
.stat-line button { width: 34px; height: 30px; border-radius: 9px; border: 0; background: var(--leaf); color: #10200c; font-weight: 900; font-size: 18px; cursor: pointer; }
.stat-line button:disabled { background: #444; color: #888; }

.hud-tc { position: absolute; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(460px, 46vw); }
.phase-row { display: flex; gap: 6px; }
.timer { font-family: var(--font-head); font-size: 16px; min-width: 66px; justify-content: center; }
.timer.urgent { color: #ff8a8a; animation: pulse-low 1s infinite; }
#phase-chip.running { background: rgba(63, 107, 58, 0.85); }
#phase-chip.lobby { background: rgba(70, 90, 140, 0.8); }
#phase-chip.paused { background: rgba(140, 110, 40, 0.85); }
#phase-chip.ended { background: rgba(140, 50, 60, 0.85); }
.event-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.event-chips .chip { background: rgba(80, 50, 120, 0.75); font-size: 12px; }
.boss-bar { width: 100%; padding: 6px 10px 8px; border-radius: 14px; background: rgba(30, 8, 12, 0.78); border: 1px solid rgba(216, 69, 91, 0.6); box-shadow: 0 0 24px rgba(216, 69, 91, 0.25); }
.boss-name { font-family: var(--font-head); font-size: 15px; text-align: center; margin-bottom: 4px; color: #ffd0d6; }
.boss-bar .bar { height: 14px; }
.boss-bar .fill { background: linear-gradient(180deg, #ff6a7e, #a8202e); }
.lobby-banner { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; padding: 8px 14px; border-radius: 14px; background: rgba(20, 32, 60, 0.78); border: 1px solid rgba(111, 195, 223, 0.45); font-size: 13px; }
.lobby-banner b { font-family: var(--font-head); font-size: 16px; color: var(--sky); font-weight: 600; }
.lobby-banner span { color: var(--text-dim); }

.hud-tr { position: absolute; top: calc(10px + var(--safe-t)); right: calc(10px + var(--safe-r)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.mm-wrap { position: relative; }
#minimap { width: 150px; height: 150px; border-radius: 14px; border: 2px solid rgba(255, 255, 255, 0.15); background: #1c2e20; box-shadow: var(--shadow); display: block; }
.net-status { position: absolute; left: 6px; bottom: 6px; display: flex; align-items: center; gap: 4px; font-size: 10px; background: rgba(0, 0, 0, 0.55); padding: 1px 6px; border-radius: 8px; }
.net-status.good i { background: var(--leaf); }
.net-status.ok i { background: var(--honey); }
.net-status.bad i { background: var(--berry); }
.mini-lb { list-style: none; margin: 0; padding: 6px 8px; min-width: 170px; border-radius: 12px; background: rgba(10, 18, 12, 0.65); font-size: 12px; }
.mini-lb:empty { display: none; }
.mini-lb li { display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; padding: 1px 0; white-space: nowrap; }
.mini-lb li .n { overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.mini-lb li .s { color: var(--honey); }
.mini-lb li.me { color: var(--honey); }
.mini-lb li.sep { border-top: 1px dashed rgba(255, 255, 255, 0.15); margin-top: 2px; padding-top: 3px; }
.killfeed { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; max-width: 300px; }
.kf { display: flex; gap: 6px; align-items: center; padding: 3px 10px; border-radius: 10px; background: rgba(10, 18, 12, 0.7); font-size: 12px; animation: kfin 0.25s ease-out; transition: opacity 0.6s; white-space: nowrap; }
.kf.me { background: rgba(90, 60, 10, 0.8); border: 1px solid rgba(245, 184, 46, 0.5); }
.kf.boss { background: rgba(110, 20, 40, 0.85); }
.kf.fade { opacity: 0; }
.kf .k { color: var(--honey); }
.kf .v { color: #ffb0b8; }
@keyframes kfin { from { transform: translateX(30px); opacity: 0; } }

.hud-buttons { position: absolute; right: calc(168px + var(--safe-r)); top: calc(10px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; }
.touch-only { display: none !important; }
body.touch .touch-only { display: grid !important; }
.emote-menu { position: absolute; right: calc(214px + var(--safe-r)); top: calc(10px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 14px; background: rgba(10, 18, 12, 0.85); }
.emote-menu button { width: 44px; height: 40px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, 0.08); font-size: 20px; font-weight: 900; cursor: pointer; }
.settings-panel { position: absolute; top: calc(60px + var(--safe-t)); right: calc(170px + var(--safe-r)); width: 290px; padding: 14px; display: flex; flex-direction: column; gap: 10px; z-index: 30; }
.settings-panel h3 { margin: 0; font-family: var(--font-head); color: var(--honey); }
.settings-panel .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.settings-panel .row.buttons { justify-content: flex-end; margin-top: 4px; }
.settings-panel select { background: #0b140d; color: var(--text); border: 1px solid #3f6b3a; border-radius: 8px; padding: 4px 6px; max-width: 170px; }
.settings-panel input[type=range] { width: 140px; accent-color: var(--honey); }
.settings-panel input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--honey); }

/* ---------------------------------------------------------------- skill bar */
.skillbar { position: absolute; bottom: calc(14px + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; gap: 10px; }
.skill {
  position: relative; width: 62px; height: 62px; border-radius: 16px; cursor: pointer; padding: 0; overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.16); background: radial-gradient(circle at 40% 30%, #3d5f3c, #15241a 80%);
  box-shadow: var(--shadow), inset 0 -3px 0 rgba(0, 0, 0, 0.3); display: grid; place-items: center; touch-action: none;
}
.skill .ico { font-size: 28px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5)); }
.skill .key { position: absolute; left: 4px; top: 2px; font-size: 10px; font-weight: 900; color: var(--text-dim); }
.skill .cd { position: absolute; inset: 0; background: conic-gradient(rgba(0, 0, 0, 0.68) calc(var(--p, 0) * 360deg), transparent 0); pointer-events: none; }
.skill .cd-t { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-size: 18px; text-shadow: 0 2px 3px #000; pointer-events: none; }
.skill .lock { white-space: pre-line; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.66); font-size: 11px; font-weight: 900; text-align: center; line-height: 1.1; color: var(--text-dim); pointer-events: none; }
.skill.ready { border-color: rgba(245, 184, 46, 0.6); }
.skill.ready.just { animation: readyflash 0.5s; }
@keyframes readyflash { 0% { box-shadow: 0 0 0 0 rgba(245, 184, 46, 0.9); } 100% { box-shadow: 0 0 0 14px rgba(245, 184, 46, 0); } }
.skill.pressed { transform: scale(0.93); filter: brightness(1.25); }
.skill.primary { width: 70px; height: 70px; border-radius: 50%; }
.skill .name { display: none; }
.skill:hover .name { display: block; position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 11px; background: #000; padding: 2px 8px; border-radius: 6px; }

/* touch layout: action cluster bottom-right */
body.touch .skillbar { left: auto; transform: none; right: calc(14px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); width: 210px; height: 200px; display: block; }
body.touch .skill { position: absolute; width: 64px; height: 64px; border-radius: 50%; }
body.touch .skill .key { display: none; }
body.touch .skill.primary { width: 96px; height: 96px; right: 0; bottom: 0; }
body.touch .skill.primary .ico { font-size: 40px; }
body.touch .skill[data-slot="1"] { right: 104px; bottom: 6px; }
body.touch .skill[data-slot="2"] { right: 86px; bottom: 92px; }
body.touch .skill[data-slot="3"] { right: 14px; bottom: 116px; }

/* joystick */
.joy-zone { z-index: -1; position: absolute; left: 0; bottom: 0; width: 55%; height: 72%; touch-action: none; display: none; }
body.touch .joy-zone { display: block; }
.joy { position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.14)); border: 2px solid rgba(255, 255, 255, 0.25); pointer-events: none; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ffe27a, var(--amber)); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }

/* ---------------------------------------------------------------- banners */
.announce { position: absolute; top: calc(150px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 720px); }
.ann { padding: 12px 22px; border-radius: 16px; text-align: center; font-family: var(--font-head); font-size: clamp(16px, 2.6vw, 22px); font-weight: 600; background: rgba(10, 18, 12, 0.82); border: 2px solid rgba(255, 255, 255, 0.18); box-shadow: var(--shadow); animation: annin 0.4s cubic-bezier(0.2, 1.6, 0.4, 1); transition: opacity 0.5s, transform 0.5s; }
.ann.warning { background: rgba(80, 30, 10, 0.88); border-color: #ff8a3a; color: #ffd8b0; }
.ann.epic { background: linear-gradient(135deg, rgba(90, 40, 120, 0.92), rgba(160, 90, 20, 0.92)); border-color: var(--honey); color: #fff6d0; font-size: clamp(18px, 3.4vw, 28px); text-shadow: 0 2px 0 #3a1a00; }
.ann.out { opacity: 0; transform: translateY(-14px); }
@keyframes annin { from { opacity: 0; transform: scale(0.6); } }
.event-banner { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); padding: 10px 24px; border-radius: 18px; background: linear-gradient(135deg, rgba(30, 50, 90, 0.92), rgba(70, 30, 90, 0.92)); border: 2px solid rgba(111, 195, 223, 0.6); text-align: center; box-shadow: var(--shadow); animation: annin 0.4s; }
.event-banner .ev-ico { font-size: 34px; }
.event-banner .ev-name { font-family: var(--font-head); font-size: 24px; }
.event-banner .ev-desc { font-size: 13px; color: var(--text-dim); }
.event-banner.end { border-color: rgba(255, 255, 255, 0.3); background: rgba(20, 28, 22, 0.88); }
.levelup { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
.levelup .lv-big { font-family: var(--font-head); font-size: clamp(44px, 10vw, 84px); font-weight: 700; color: #ffe27a; text-shadow: 0 4px 0 #6a3a00, 0 0 30px rgba(255, 210, 80, 0.8); animation: lvpop 1.8s ease-out forwards; }
.levelup .lv-sub { font-size: 16px; margin-top: 4px; animation: lvpop 1.8s ease-out forwards; }
@keyframes lvpop { 0% { transform: scale(0.3); opacity: 0; } 15% { transform: scale(1.15); opacity: 1; } 25% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }

/* ---------------------------------------------------------------- vote */
.vote-widget { position: absolute; left: calc(10px + var(--safe-l)); bottom: calc(110px + var(--safe-b)); width: 260px; padding: 10px; border-radius: 16px; background: rgba(16, 20, 40, 0.86); border: 1px solid rgba(111, 195, 223, 0.5); box-shadow: var(--shadow); }
.vote-head { display: flex; gap: 6px; align-items: center; font-size: 14px; margin-bottom: 8px; font-family: var(--font-head); }
.vote-head #vote-q { flex: 1; }
.vote-time { font-size: 12px; color: var(--sky); }
.vote-options { display: flex; flex-direction: column; gap: 6px; }
.vote-opt { position: relative; display: flex; gap: 8px; align-items: center; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px; padding: 7px 10px; background: rgba(255, 255, 255, 0.06); cursor: pointer; overflow: hidden; text-align: left; font-size: 13px; }
.vote-opt .vbar { position: absolute; inset: 0; width: 0; background: rgba(111, 195, 223, 0.25); transition: width 0.3s; }
.vote-opt span { position: relative; }
.vote-opt .vl { flex: 1; }
.vote-opt .vn { color: var(--sky); font-size: 12px; }
.vote-opt.mine { border-color: var(--honey); }
.vote-opt.winner { border-color: var(--leaf); background: rgba(123, 182, 97, 0.25); }
.vote-opt:disabled { cursor: default; }
body.touch .vote-widget { bottom: auto; top: calc(150px + var(--safe-t)); width: 220px; }

/* ---------------------------------------------------------------- overlays */
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(5, 10, 6, 0.55); z-index: 15; padding: 16px; }
.center-card { padding: 22px 28px; text-align: center; max-width: 420px; }
.center-card h2, .death-card h2, .results-card h2, .lb-panel h2 { font-family: var(--font-head); margin: 6px 0; color: var(--honey); }
.big-ico { font-size: 52px; }
.death-screen { background: radial-gradient(ellipse at center, rgba(60, 0, 10, 0.35), rgba(20, 0, 4, 0.75)); }
.death-card { text-align: center; padding: 22px; max-width: 380px; }
.death-ico { font-size: 64px; animation: bugwiggle 2s infinite; }
.death-by { color: var(--text-dim); margin: 4px 0; }
.death-count { font-family: var(--font-head); font-size: clamp(20px, 5vw, 28px); margin: 8px 0 14px; white-space: nowrap; }
.lb-overlay { background: rgba(5, 10, 6, 0.45); }
.lb-panel, .results-card { padding: 16px 18px; width: min(560px, 94vw); max-height: 86vh; overflow: auto; }
.lb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lb-table th { text-align: left; font-size: 11px; color: var(--text-dim); text-transform: uppercase; padding: 4px 6px; }
.lb-table td { padding: 5px 6px; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.lb-table tr.me td { color: var(--honey); background: rgba(245, 184, 46, 0.08); }
.lb-table td.num { text-align: right; }
.lb-table td .ci { margin-right: 4px; }
.hint { color: var(--text-dim); font-size: 12px; text-align: center; }
.results-card { text-align: center; }
.results-card .lb-table { text-align: left; margin: 10px 0; }
.mvp { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px; border-radius: 14px; background: linear-gradient(135deg, rgba(245, 184, 46, 0.2), rgba(224, 138, 30, 0.1)); border: 1px solid rgba(245, 184, 46, 0.5); }
.mvp:empty { display: none; }
.mvp .crown { font-size: 34px; animation: bugwiggle 2.4s infinite; }
.mvp .mvp-name { font-family: var(--font-head); font-size: 24px; color: #ffe27a; }
.mvp .mvp-sub { font-size: 12px; color: var(--text-dim); }
.kicked { display: grid; place-items: center; background: rgba(5, 10, 6, 0.92); z-index: 50; }
.conn-banner { position: fixed; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 40; display: flex; gap: 10px; align-items: center; padding: 10px 18px; border-radius: 14px; background: rgba(80, 20, 20, 0.92); border: 1px solid #ff8a8a; box-shadow: var(--shadow); font-weight: 800; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rotate-hint { position: absolute; bottom: calc(230px + var(--safe-b)); left: 50%; transform: translateX(-50%); padding: 8px 12px; border-radius: 12px; background: rgba(10, 18, 12, 0.85); font-size: 12px; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.rotate-hint .x { background: none; border: 0; cursor: pointer; font-size: 14px; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; font-size: 20px; }

/* ---------------------------------------------------------------- responsive HUD */
@media (max-width: 900px) {
  .hud-tc { width: min(360px, 52vw); }
}
@media (max-width: 720px), (max-height: 520px) {
  #minimap { width: 108px; height: 108px; }
  .hud-buttons { right: calc(126px + var(--safe-r)); }
  .emote-menu { right: calc(172px + var(--safe-r)); }
  .settings-panel { right: calc(10px + var(--safe-r)); top: calc(130px + var(--safe-t)); }
  .mini-lb { min-width: 0; max-width: 150px; font-size: 11px; }
  .killfeed { max-width: 200px; }
  .kf { font-size: 11px; padding: 2px 8px; }
  #hud-portrait { width: 40px; height: 40px; }
  .pp-main { width: 130px; }
  .pp-name { font-size: 14px; }
  .hide-xs { display: none; }
}
/* phone portrait: compact top area, stack centre below the side columns */
/* phone portrait: buttons as a row under the minimap, killfeed on the left, centre column lower */
@media (max-width: 560px) {
  .hud-buttons { flex-direction: row; right: calc(10px + var(--safe-r)); top: calc(126px + var(--safe-t)); }
  .emote-menu { right: calc(10px + var(--safe-r)); top: calc(172px + var(--safe-t)); flex-direction: row; flex-wrap: wrap; width: 160px; }
  .settings-panel { top: calc(172px + var(--safe-t)); }
  .mini-lb { display: none; }
  .killfeed { position: fixed; left: calc(10px + var(--safe-l)); bottom: calc(14px + var(--safe-b)); top: auto; align-items: flex-start; max-width: 50vw; }
  .killfeed .kf:nth-child(n+4) { display: none; }
  .hud-tc { top: calc(176px + var(--safe-t)); width: 70vw; }
  .announce { top: calc(300px + var(--safe-t)); }
  .ann { padding: 8px 14px; }
  .event-banner { top: calc(232px + var(--safe-t)); width: 86vw; padding: 6px 14px; }
  .event-banner .ev-ico { font-size: 22px; }
  .event-banner .ev-name { font-size: 18px; }
  .event-banner .ev-desc { font-size: 11px; }
  .rotate-hint { bottom: calc(130px + var(--safe-b)); left: calc(10px + var(--safe-l)); transform: none; white-space: normal; max-width: 52vw; }
  .lobby-banner { font-size: 11px; padding: 6px 10px; }
  .lobby-banner b { font-size: 13px; }
  .buff { width: 26px; height: 26px; font-size: 14px; }
  .vote-widget, body.touch .vote-widget { top: auto; bottom: calc(236px + var(--safe-b)); right: calc(10px + var(--safe-r)); left: auto; width: 46vw; padding: 8px; }
  .vote-head { font-size: 12px; }
  .vote-opt { padding: 5px 8px; font-size: 12px; }
}
/* phone landscape */
@media (max-height: 520px) {
  body.touch .skillbar { transform: scale(0.85); transform-origin: bottom right; }
  .hud-tc { width: min(300px, 34vw); }
  .hud-buttons { flex-direction: row; right: calc(124px + var(--safe-r)); }
  .hud-buttons .icon-btn { width: 34px; height: 34px; font-size: 16px; }
  .emote-menu { top: calc(52px + var(--safe-t)); right: calc(124px + var(--safe-r)); flex-direction: row; }
  .settings-panel { top: calc(52px + var(--safe-t)); right: calc(124px + var(--safe-r)); max-height: calc(100vh - 70px); overflow: auto; }
  .mini-lb { display: none; }
  .killfeed .kf:nth-child(n+3) { display: none; }
  .announce { top: 18%; }
  .lobby-banner span { display: none; }
  .levelup .lv-big { font-size: 44px; }
  .vote-widget, body.touch .vote-widget { width: 200px; padding: 8px; }
  .vote-opt { padding: 4px 8px; font-size: 12px; }
}
.skill.primary .key { left: 50%; transform: translateX(-50%); top: 4px; }
.game-ui, .game-ui * { touch-action: none; }
.settings-panel input[type=range] { touch-action: pan-x; }
