:root {
  --bg: #0b0f17;
  --panel: rgba(18, 24, 38, 0.92);
  --text: #e8ecf4;
  --muted: #8a94a8;
  --accent: #ff4d6d;
  --accent2: #4dabf7;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

.panel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 400px); padding: 28px 24px; border-radius: 18px;
  background: var(--panel); backdrop-filter: blur(6px);
  box-shadow: 0 12px 40px rgba(0,0,0,.5); text-align: center; z-index: 10;
}
.panel.compact { width: auto; min-width: 240px; padding: 20px 28px; }
.panel.bottom { top: auto; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 18px 20px; }
h1 { margin: 0 0 6px; font-size: 44px; letter-spacing: -1px; font-weight: 800; }
h1 span { color: var(--accent); margin-left: 6px; }
h2 { margin: 0 0 8px; font-size: 26px; }
.tag { margin: 0 0 22px; color: var(--muted); }
.small { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
input {
  width: 100%; padding: 14px 16px; font-size: 18px; border-radius: 12px;
  border: 2px solid #2a3348; background: #0f1522; color: var(--text); outline: none;
  text-align: center; user-select: text; -webkit-user-select: text;
}
input:focus { border-color: var(--accent2); }
button {
  margin-top: 14px; width: 100%; padding: 16px; font-size: 22px; font-weight: 800;
  border: 0; border-radius: 12px; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, #ff4d6d, #ff922b); letter-spacing: 1px;
  touch-action: manipulation;
}
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: #263049; }
#menu { padding-top: 40px; }
button.icon-btn { position: absolute; top: 6px; right: 6px; width: 38px; height: 38px; margin: 0; padding: 0; font-size: 20px; background: transparent; border-radius: 50%; }
button.icon-btn:hover { background: #263049; }
button.slim { font-size: 16px; padding: 11px; font-weight: 700; }

#me { margin: 14px 0 8px; font-size: 14px; color: var(--muted); }
#me b { color: var(--text); }
.xpbar { height: 6px; margin: 6px 0 4px; border-radius: 3px; background: #263049; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, #4dabf7, #51cf66); transition: width .8s; }

.tabs { display: flex; gap: 6px; margin: 4px 0 8px; }
.tabs button { margin: 0; padding: 8px 4px; font-size: 14px; font-weight: 700; background: #263049; }
.tabs button.on { background: linear-gradient(135deg, #ff4d6d, #ff922b); }
#lb-list { text-align: left; min-height: 0; max-height: 46vh; overflow: auto; margin: 6px 0 0; padding-left: 34px; font-size: 15px; line-height: 1.65; }
#lb-list li.me { color: #ffd43b; font-weight: 700; }
#lb-list .k { color: var(--muted); float: right; }
#lb-list .lv { color: var(--muted); font-size: 12px; margin-left: 4px; }
#lb-list .empty { list-style: none; margin-left: -34px; text-align: center; color: var(--muted); }

.result { font-size: 15px; margin: 0 0 6px; }
.result .pts { font-size: 20px; font-weight: 800; color: #51cf66; }
.result .up { color: #ffd43b; font-weight: 800; font-size: 18px; }
.row { display: flex; gap: 10px; }
.row button { margin-top: 6px; font-size: 18px; padding: 12px; }
.row button.slim { font-size: 15px; padding: 11px 4px; white-space: nowrap; letter-spacing: 0; }
#lobby-room .row button.slim { white-space: normal; }
#lobby { width: min(92vw, 360px); }
#room-info { color: #ffd43b; margin-bottom: 8px; }
.missions { margin: 12px 0 8px; padding: 8px 12px; border-radius: 12px; background: #0f1522; text-align: left; font-size: 13px; color: var(--muted); }
.missions .mt { font-weight: 700; color: var(--text); margin-bottom: 2px; }
.missions .m { display: flex; gap: 8px; align-items: baseline; line-height: 1.7; }
.missions .m span { flex: 1; }
.missions .m b { color: var(--text); font-variant-numeric: tabular-nums; }
.missions .m i { font-style: normal; color: #51cf66; white-space: nowrap; }
.missions .m.done span { text-decoration: line-through; }
.missions .m.done b { color: #51cf66; }
.missions .m.done i { color: var(--muted); }
.account { margin: 4px 0 10px; }
.account #gbtn { display: flex; justify-content: center; min-height: 44px; }
.account .small { margin-top: 4px; }
.account a { color: var(--accent2); margin-left: 4px; padding: 12px 10px; margin: -6px 0 -6px 4px; display: inline-block; cursor: pointer; text-decoration: underline; }
.mdone { color: #51cf66; font-weight: 700; font-size: 14px; margin: 2px 0; }
.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 8px 0 4px; }
.swatches button { margin: 0; padding: 0; aspect-ratio: 1; border-radius: 50%; font-size: 13px; border: 3px solid transparent; background: #263049; }
.swatches button.on { border-color: #fff; }
.swatches button.locked { box-shadow: inset 0 0 0 40px rgba(11,15,23,.6); color: #fff; text-shadow: 0 1px 3px #000; }
.swatches button.locked.on { box-shadow: inset 0 0 0 40px rgba(11,15,23,.6); }
#styles button { white-space: nowrap; letter-spacing: 0; font-size: 12px; padding: 8px 5px; }
#styles .lk { font-size: 10px; margin-left: 3px; opacity: .9; }
.swatches .lk { font-size: 11px; }
#styles button.locked { opacity: .45; }
#room-info a { color: var(--accent2); margin: -6px 0 -6px 4px; padding: 12px 10px; display: inline-block; font-size: inherit; cursor: pointer; text-decoration: underline; }
#lobby-room { margin-top: 10px; }
#lobby.compact { max-width: min(92vw, 400px); }
.names { margin-top: 6px; color: var(--text); font-size: 14px; line-height: 1.5; white-space: normal; }
.howto { margin-top: 20px; font-size: 14px; color: var(--muted); line-height: 1.7; }
#menu .tag, .panel .small, #me { text-wrap: balance; }
.howto b { color: var(--text); font-weight: 600; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud-left { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.pill { background: rgba(10,14,22,.7); padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 15px; }
#zone-info { position: absolute; left: 50%; transform: translateX(-50%); top: max(12px, env(safe-area-inset-top)); white-space: nowrap; }
#zone-info.warn { color: #ff8095; }
#effects { position: absolute; left: 50%; transform: translateX(-50%); top: calc(max(12px, env(safe-area-inset-top)) + 40px); display: flex; gap: 6px; }
.fx { position: relative; overflow: hidden; background: rgba(10,14,22,.75); border-radius: 999px; padding: 5px 12px 7px; font-weight: 800; font-size: 14px; white-space: nowrap; }
.fx.good { color: #2ecc71; } .fx.bad { color: #ff6b81; }
.fx.pending { opacity: .6; }
.fx i { position: absolute; left: 0; bottom: 0; height: 3px; background: currentColor; }
#minimap { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); width: 120px; height: 120px; }
#kills { pointer-events: auto; cursor: pointer; }
#net {
  position: absolute; right: max(12px, env(safe-area-inset-right)); top: calc(max(12px, env(safe-area-inset-top)) + 132px);
  background: rgba(10,14,22,.85); border-radius: 10px; padding: 8px 12px; font: 12px/1.55 ui-monospace, Menlo, monospace;
  white-space: pre; color: #c9d1e0; pointer-events: none;
}
#net b { color: #fff; }
#net .bad { color: #ff6b6b; font-weight: 700; }
#net .ok { color: #69db7c; }
#feed { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
body:has(#dead:not([hidden])) #feed { display: none; }
#feed div { background: rgba(10,14,22,.6); padding: 4px 10px; border-radius: 8px; transition: opacity .5s; }
#feed b { font-weight: 700; }
#feed .tag { color: #ffd43b; font-weight: 900; margin-left: 6px; letter-spacing: .5px; }
.tip {
  position: absolute; left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 34%); transform: translateX(-50%);
  background: rgba(77,171,247,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700;
  font-size: 15px; max-width: min(86vw, 420px); text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}

#center-msg {
  position: fixed; left: 50%; top: 24%; transform: translate(-50%, -50%);
  font-size: 96px; font-weight: 900; pointer-events: none; z-index: 6;
  text-shadow: 0 4px 24px rgba(0,0,0,.6); text-align: center; white-space: nowrap;
}
#center-msg small { display: block; font-size: 22px; font-weight: 700; color: var(--muted); }

.touch-ind {
  position: fixed; bottom: 0; width: 50%; height: 30%; z-index: 4; pointer-events: none;
  display: flex; align-items: flex-end; padding: 0 0 max(28px, env(safe-area-inset-bottom));
  font-size: 34px; color: rgba(255,255,255,.18); transition: color .08s;
}
#touch-left { left: 0; justify-content: flex-start; padding-left: 28px; }
#touch-right { right: 0; justify-content: flex-end; padding-right: 28px; }
.touch-ind.on { color: rgba(255,255,255,.55); }

#ranking { font-variant-numeric: tabular-nums; text-align: left; max-height: 40vh; overflow: auto; margin: 10px 0 0; padding-left: 34px; font-size: 15px; line-height: 1.6; }
#ranking li.me { color: #ffd43b; font-weight: 700; }
#ranking .k { color: var(--muted); float: right; }

.spinner { width: 28px; height: 28px; margin: 0 auto 10px; border-radius: 50%; border: 3px solid #2a3348; border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  h1 { font-size: 36px; }
  #minimap { width: 92px; height: 92px; }
  .pill { font-size: 13px; padding: 5px 10px; }
  #center-msg { font-size: 72px; }
  #zone-info { left: max(12px, env(safe-area-inset-left)); transform: none; top: calc(max(12px, env(safe-area-inset-top)) + 64px); }
  #effects { left: max(12px, env(safe-area-inset-left)); transform: none; top: calc(max(12px, env(safe-area-inset-top)) + 100px); flex-direction: column; align-items: flex-start; }
  .fx { font-size: 12px; padding: 4px 10px 6px; }
  #feed { font-size: 12px; }
  #net { top: calc(max(12px, env(safe-area-inset-top)) + 104px); font-size: 10.5px; padding: 6px 9px; }
}
