* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

:root {
  --bg-dark: rgba(13, 17, 23, 0.86);
  --bg-card: rgba(22, 27, 36, 0.92);
  --border: rgba(255, 255, 255, 0.12);
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --cyan: #38bdf8;
  --danger: #ef4444;
  --text: #f3f4f6;
  --muted: #9ca3af;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0e14;
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#overlay-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 12;
}

body.slowmo-active #hud::after {
  content: "";
  position: fixed;
  inset: 0;
  border: 3px solid rgba(56, 189, 248, 0.45);
  box-shadow: inset 0 0 60px rgba(56, 189, 248, 0.2);
  pointer-events: none;
}

body.photo-mode #hud,
body.photo-mode #overlay-canvas {
  opacity: 0;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 17, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 20px;
}

.lobby-panel {
  width: min(1020px, 96vw);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 30px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}

.lobby-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
  margin-bottom: 18px;
}

.brand-badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--accent);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.lobby-header h1 {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 2px;
}

.lobby-header h1 span {
  color: var(--accent);
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
}

.lobby-col h3 {
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.map-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.map-card {
  padding: 11px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}

.map-card:hover {
  background: rgba(255, 255, 255, 0.08);
}

.map-card.active {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.14);
}

.map-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 2px;
}

.map-desc {
  font-size: 12px;
  color: var(--muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.85);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--accent);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  transition: all 0.14s ease;
}

.btn-primary {
  width: 100%;
  padding: 12px 16px;
  background: var(--accent);
  color: #111827;
  font-size: 15px;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  padding: 10px 14px;
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: var(--cyan);
}
.btn-secondary:hover { background: rgba(56, 189, 248, 0.28); }

.btn-danger {
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.btn-ghost {
  padding: 5px 10px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.col-head h3 { margin-bottom: 0; }

.join-code-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.join-code-row input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.room-list {
  height: 185px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(10, 14, 20, 0.55);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.room-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-top: 66px;
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}
.room-item:hover { background: rgba(245, 158, 11, 0.15); }
.room-item-title { font-weight: 700; font-size: 14px; }
.room-item-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.badge {
  font-size: 11px;
  color: var(--accent);
  background: rgba(245, 158, 11, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}
.btn-small {
  padding: 6px 10px;
  background: var(--accent);
  color: #111827;
  font-size: 12px;
}

.controls-mini {
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.controls-mini b { color: var(--text); }

/* In-game HUD */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.88);
  font-size: 24px;
  font-weight: 300;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9);
}

.target-inspector {
  position: fixed;
  left: 50%;
  top: calc(50% + 22px);
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(11, 15, 23, 0.72);
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.14);
  letter-spacing: 0.4px;
}

.target-inspector.danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.65);
  background: rgba(127, 29, 29, 0.72);
}

.hud-top-left {
  position: fixed;
  top: 16px;
  left: 16px;
}

.telemetry-card {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 280px;
  backdrop-filter: blur(6px);
}

.telemetry-title {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.telemetry-row {
  display: flex;
  gap: 18px;
}

.label { font-size: 11px; color: var(--muted); }
.val { font-size: 18px; font-weight: 800; }
.val.gold { color: #facc15; }
.val.accent { color: var(--accent); }

.progress-track {
  margin-top: 8px;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  transition: width 0.25s ease;
}

.combo-popup {
  margin-top: 8px;
  display: inline-block;
  padding: 5px 12px;
  background: rgba(245, 158, 11, 0.92);
  color: #111827;
  font-weight: 900;
  font-size: 15px;
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(245, 158, 11, 0.45);
}

.ability-pills {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.ability-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--muted);
}

.ability-pill.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.14);
}

.blitz-banner {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.22);
  border: 1px solid rgba(239, 68, 68, 0.55);
  font-size: 13px;
}

.blitz-banner b {
  color: #fca5a5;
  font-size: 16px;
}

.scoreboard-panel {
  width: min(560px, 92vw);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.scoreboard-panel h3 {
  margin-bottom: 12px;
  color: var(--accent);
}

.scoreboard-panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.scoreboard-panel th, .scoreboard-panel td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.scoreboard-panel tr.me {
  background: rgba(245, 158, 11, 0.12);
}

.scoreboard-panel .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 7px;
}

.scoreboard-panel .gold { color: #facc15; font-weight: 700; }

.row-inline {
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
}

.row-inline input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.help-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.help-grid b {
  color: var(--text);
}

.hud-top-right {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.room-badge-card {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  text-align: right;
  pointer-events: auto;
}
.room-sub { font-size: 13px; margin-top: 2px; }
.room-sub b { color: var(--accent); cursor: pointer; letter-spacing: 1px; }
.btn-invite { margin-top: 5px; font-size: 11px; padding: 3px 8px; }

.minimap-wrap {
  background: var(--bg-dark);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}
#minimap-canvas {
  width: 148px;
  height: 148px;
  display: block;
  border-radius: 6px;
  image-rendering: pixelated;
}

.event-feed {
  position: fixed;
  left: 16px;
  top: 145px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feed-item {
  background: rgba(12, 16, 23, 0.72);
  border-left: 3px solid var(--cyan);
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 4px;
  transition: opacity 0.5s ease;
}
.feed-warn { border-left-color: var(--accent); color: #fde68a; }
.feed-good { border-left-color: #34d399; }
.feed-chat { border-left-color: #a78bfa; }

.interact-prompt {
  position: fixed;
  left: 50%;
  bottom: 122px;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 7px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
}

.chat-input-wrap {
  position: fixed;
  left: 16px;
  bottom: 110px;
  width: 360px;
  pointer-events: auto;
}

.hud-bottom {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tool-hint {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: #fde68a;
}

.hotbar {
  display: flex;
  gap: 5px;
  background: var(--bg-dark);
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  pointer-events: auto;
}

.hotbar-slot {
  width: 78px;
  padding: 6px 5px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  text-align: center;
  cursor: pointer;
}
.hotbar-slot.active {
  background: rgba(245, 158, 11, 0.24);
  border-color: var(--accent);
}
.slot-key {
  display: block;
  font-size: 10px;
  color: var(--accent);
  font-weight: 800;
}
.slot-name {
  display: block;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pause overlay */
.pause-panel {
  width: min(460px, 94vw);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pause-panel h2 {
  font-size: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.setting-row label { font-size: 13px; color: var(--muted); }

.btn-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.sky-btn {
  padding: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border: 1px solid var(--border);
}
.sky-btn.active {
  background: rgba(245, 158, 11, 0.24);
  border-color: var(--accent);
  color: var(--accent);
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

@media (max-width: 860px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .hotbar-slot { width: 58px; }
}
