:root {
  --bg: #1a1a1b;
  --bg-2: #111112;
  --panel: rgba(26, 26, 27, 0.92);
  --border: #343536;
  --text: #d7dadc;
  --muted: #818384;
  --accent: #ff4500;       /* hive orange */
  --accent-blue: #0079d3;
  --ok: #46d160;
  --danger: #ff585b;
  --radius: 8px;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

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

html, body {
  height: 100%;
  width: 100%;
  font-family: "IBM Plex Sans", "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: #0f0f10;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Fullscreen canvas viewport ---------- */
#canvas-viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    repeating-conic-gradient(#1a1a1b 0 25%, #141415 0 50%) 50% / 32px 32px;
  cursor: crosshair;
  touch-action: none;
}
#canvas-viewport.pan { cursor: grab; }
#canvas-viewport.panning { cursor: grabbing; }
#canvas-viewport.censor { cursor: crosshair; }

#canvas {
  position: absolute;
  top: 0; left: 0;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  transform-origin: 0 0;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 12px 40px rgba(0, 0, 0, 0.5);
}

.sel-rect {
  position: absolute;
  border: 1.5px dashed var(--danger);
  background: rgba(255, 88, 91, 0.15);
  pointer-events: none;
  z-index: 4;
}

.reticle {
  position: absolute;
  pointer-events: none;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #000, inset 0 0 0 1px #000;
  z-index: 3;
}

/* ---------- HUD (floating overlays) ---------- */
.hud { position: fixed; z-index: 10; }
.hud-topright { top: 12px; right: 12px; }
.hud-zoom {
  right: 12px; bottom: 90px;
  display: flex; flex-direction: column; gap: 6px;
  align-items: flex-end;
}

/* ---------- Language toggle ---------- */
.lang-toggle-pill {
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.3px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}
.lang-toggle-pill:hover { color: var(--accent); }
/* Floating variant used on auth pages (no topbar). */
.lang-toggle {
  position: fixed; top: 14px; right: 14px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow);
  z-index: 50;
}
.lang-toggle:hover { color: var(--accent); }

/* ---------- Top bar: account · nav · status ---------- */
.topbar {
  top: 12px; left: 12px;
  /* Stop short of the ranking card on the right (max-width 220px + 12px gap). */
  right: 248px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 12px;
  pointer-events: none; /* let canvas receive events outside the children */
}
.topbar > * { pointer-events: auto; }
.topbar-zone { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.topbar-left   { justify-content: flex-start; }
.topbar-center { justify-content: center; }
.topbar-right  { justify-content: flex-end; }

.topbar-nav {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow);
}
.topbar-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: background 120ms, color 120ms;
}
.topbar-link:hover { background: rgba(255, 255, 255, 0.08); color: var(--accent); }
.topbar-link.hidden { display: none; }

.topbar-admin {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  box-shadow: var(--shadow);
}
.topbar-sep {
  width: 1px; align-self: stretch;
  background: var(--border);
  margin: 2px 4px;
}

/* Cursor-info pills sit directly above the zoom buttons. */
.cursor-info {
  display: flex; flex-direction: column; gap: 4px;
  align-items: flex-end;
  margin-bottom: 4px;
}

@media (max-width: 880px) {
  .topbar { right: 12px; grid-template-columns: 1fr; gap: 6px; }
  .topbar-zone { justify-content: flex-start; }
  .topbar-link-text { display: none; } /* icon-only on tight screens */
  .hud-topright { display: none; }     /* free up space — link in topbar still works */
}

.pill {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
}
.pill-sm { font-size: 12px; padding: 4px 10px; }
.pill-link { color: var(--text); text-decoration: none; font-weight: 600; }
.pill-link:hover { color: var(--accent); }
.pill-sep { color: var(--muted); }
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.admin-tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  padding: 1px 5px; border-radius: 3px;
  background: rgba(255, 69, 0, 0.2); color: var(--accent);
  border: 1px solid rgba(255, 69, 0, 0.4);
}

/* Tool chips */
.tool-chip {
  width: 36px; height: 36px;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms;
}
.tool-chip svg { width: 18px; height: 18px; fill: currentColor; }
.tool-chip:hover { background: rgba(255, 255, 255, 0.08); }
.tool-chip.active { background: var(--accent); color: #fff; }
.admin-hint { font-size: 12px; color: var(--muted); padding: 0 8px 0 4px; }

/* Ranking */
.rank-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  min-width: 180px;
  max-width: 220px;
}
.rank-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rank-title-link {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--accent, #3690ea);
  text-decoration: none;
  opacity: 0.85;
}
.rank-title-link:hover { opacity: 1; text-decoration: underline; }
.rank-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rank-list li {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 8px;
  font-size: 12px;
  padding: 3px 0;
  align-items: center;
}
.rank-pos { color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-list li.top1 .rank-pos { color: #ffd94a; }
.rank-list li.top2 .rank-pos { color: #d9d9d9; }
.rank-list li.top3 .rank-pos { color: #e8a365; }
.rank-user {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: inherit; text-decoration: none;
  border-bottom: 1px dashed transparent;
  cursor: pointer;
}
.rank-user:hover { border-bottom-color: rgba(150, 175, 255, 0.55); }
.rank-user .admin-tag { margin-left: 4px; font-size: 8px; padding: 0 3px; }
.rank-count { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Zoom buttons */
.zoom-btn {
  width: 36px; height: 36px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  box-shadow: var(--shadow);
}
.zoom-btn:hover { background: rgba(255, 255, 255, 0.08); }
.zoom-btn[aria-pressed="true"] {
  background: rgba(105, 130, 255, 0.22);
  border-color: rgba(150, 175, 255, 0.55);
  box-shadow: 0 0 10px rgba(120, 150, 255, 0.35);
}

/* ---------- Online pill ---------- */
.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
  animation: online-pulse 1.6s ease-in-out infinite;
}
.online-label { opacity: 0.7; margin-left: 1px; }
@keyframes online-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}

/* ---------- Minimap (bottom-left) ---------- */
.hud-minimap {
  left: 12px; bottom: 14px;
  width: 120px; height: 120px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: crosshair;
  overflow: hidden;
}
.minimap-canvas {
  display: block;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.minimap-view {
  position: absolute;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  background: rgba(255, 255, 255, 0.05);
}

/* Night mode dimming is handled inside the canvas render — no CSS overlay
   needed. The body class is kept only as a state hook. */

/* ---------- Recent colors (inline section in palette-bar) ---------- */
.recents {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  padding-right: 4px;
}
.recents[hidden] { display: none; }
.recents-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--muted); font-weight: 700;
}
.recents-swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}
.recents-swatches .swatch {
  width: 22px; height: 22px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 80ms, border-color 80ms;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.recents-swatches .swatch:hover { transform: scale(1.12); }
.recents-swatches .swatch.selected {
  border-color: #fff;
  transform: scale(1.15);
}
.recents-sep[hidden] { display: none; }

@media (max-width: 700px) {
  .recents-swatches { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Jump input ---------- */
.hud-jump {
  position: fixed;
  left: 144px;  /* right of minimap (120 + gaps) */
  bottom: 14px;
}
.jump-form {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  box-shadow: var(--shadow);
  gap: 4px;
}
.jump-form input {
  width: 70px; background: transparent; border: none; color: var(--text);
  font-size: 12px; padding: 4px 6px; outline: none;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.jump-form button {
  background: rgba(255,255,255,0.08); border: none; color: var(--text);
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.jump-form button:hover { background: rgba(255,255,255,0.18); }

/* ---------- Trending overlay (over minimap) ---------- */
.trending-overlay { position: absolute; inset: 0; pointer-events: none; }
.trending-dot {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,180,40,0.9), rgba(255,80,0,0.4) 60%, transparent 75%);
  transform: translate(-50%, -50%);
  animation: trend-pulse 1.4s ease-in-out infinite;
  mix-blend-mode: screen;
}
@keyframes trend-pulse {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(0.7); }
  50%      { opacity: 1;   transform: translate(-50%, -50%) scale(1.1); }
}

/* ---------- Mention in chat ---------- */
.chat-mention {
  background: rgba(106, 92, 255, 0.2);
  color: #c5cdff;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 3px;
  text-decoration: none;
}
.chat-messages .chat-self.chat-mentioned-me {
  background: rgba(255, 214, 53, 0.08);
  border-left: 2px solid #ffd635;
  padding-left: 6px;
}

/* ---------- Chat panel ---------- */
.chat-panel {
  position: fixed;
  right: 12px;
  top: 220px;
  width: 300px;
  max-height: 360px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 12;
  overflow: hidden;
}
.chat-panel[data-collapsed="true"] { max-height: 38px; }
.chat-panel[data-collapsed="true"] .chat-body { display: none; }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.chat-title { font-size: 13px; font-weight: 600; letter-spacing: 0.3px; }
.chat-toggle {
  background: none; border: none; color: var(--text);
  cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px;
  opacity: 0.7;
}
.chat-toggle:hover { opacity: 1; }

.chat-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.chat-messages {
  list-style: none;
  margin: 0; padding: 8px 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
  font-size: 13px;
  line-height: 1.4;
  scrollbar-width: thin;
}
.chat-messages li {
  padding: 3px 0;
  word-wrap: break-word;
  word-break: break-word;
}
.chat-messages .chat-user {
  font-weight: 600;
  margin-right: 4px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed transparent;
}
.chat-messages .chat-user:hover {
  border-bottom-color: rgba(150, 175, 255, 0.5);
}
.chat-messages .chat-time {
  color: var(--muted);
  font-size: 10px;
  margin-left: 4px;
}
.chat-messages .chat-self .chat-user { color: #6a5cff; }
.chat-messages .chat-system {
  text-align: center;
  font-style: italic;
  color: var(--muted);
  font-size: 11px;
  padding: 6px 0;
  letter-spacing: 0.3px;
}
.chat-messages .chat-announcement {
  background: linear-gradient(135deg, rgba(255,69,0,0.18), rgba(106,92,255,0.18));
  border: 1px solid rgba(255,214,53,0.4);
  border-left: 3px solid #ffd635;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 6px 0;
  list-style: none;
}
.chat-ann-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffd635;
  margin-bottom: 4px;
}
.chat-ann-text {
  font-size: 13px;
  font-weight: 500;
  word-wrap: break-word;
  word-break: break-word;
}

.chat-form {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
}
.chat-form input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  outline: none;
}
.chat-form input:focus { border-color: rgba(150,175,255,0.5); }
.chat-form input:disabled { opacity: 0.55; cursor: not-allowed; }
.chat-send {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
}
.chat-send:hover:not(:disabled) { background: rgba(255,255,255,0.1); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Pixel history popup ---------- */
.history-pop {
  position: fixed;
  z-index: 30;
  width: 240px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  font-size: 12px;
}
.history-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 4px;
}
.history-close {
  background: none; border: none; color: var(--text);
  cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px;
  opacity: 0.7;
}
.history-close:hover { opacity: 1; }
.history-meta {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}
.history-list {
  list-style: none;
  margin: 0; padding: 0;
  max-height: 220px;
  overflow-y: auto;
}
.history-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.06);
}
.history-list li:last-child { border-bottom: none; }
.history-swatch {
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.5);
  flex-shrink: 0;
}
.history-user {
  font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: inherit; text-decoration: none;
  border-bottom: 1px dashed transparent;
}
.history-user:hover { border-bottom-color: rgba(150, 175, 255, 0.55); }
.history-when { color: var(--muted); font-size: 10px; }
.history-empty { color: var(--muted); font-style: italic; padding: 4px 0; }

@media (max-width: 720px) {
  .chat-panel { width: calc(100vw - 24px); right: 12px; top: auto; bottom: 150px; max-height: 240px; }
}

/* ---------- Achievement toast ---------- */
.achievement-toast {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, #1f1230 0%, #2a1f4a 50%, #3a1f3f 100%);
  border: 1px solid #6a5cff;
  border-left: 4px solid #ffd635;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 8px;
  min-width: 280px;
  max-width: 360px;
  box-shadow: 0 4px 24px rgba(106, 92, 255, 0.4), 0 0 60px rgba(255, 214, 53, 0.15);
  animation: ach-in 360ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
  transition: opacity 400ms, transform 400ms;
  color: #fff;
}
.ach-icon {
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(255, 214, 53, 0.6));
}
.ach-body { flex: 1; min-width: 0; }
.ach-label {
  font-size: 9px;
  letter-spacing: 1.4px;
  font-weight: 700;
  color: #ffd635;
  margin-bottom: 2px;
}
.ach-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}
.ach-desc {
  font-size: 12px;
  color: #c5cad4;
  line-height: 1.3;
}
@keyframes ach-in {
  0%   { opacity: 0; transform: translateX(80px) scale(0.9); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}


/* ---------- Palette bar (bottom) ---------- */
.palette-bar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}
.palette-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  opacity: 0.7;
  margin: 4px 0;
}

/* ---------- Items panel ---------- */
.items {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 260px;
}
.item-chip {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: linear-gradient(135deg, #1f2530, #2a323e);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 80ms, border-color 80ms, box-shadow 120ms;
  padding: 0;
  overflow: hidden;
}
.item-chip:hover { transform: scale(1.06); }
.item-chip.selected {
  border-color: #ff4500;
  box-shadow: 0 0 0 1px #000, 0 0 14px rgba(255,69,0,0.55);
  transform: scale(1.08);
}
.item-chip.cooling { cursor: not-allowed; opacity: 0.55; }
.item-chip-cd {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
body.item-armed #canvas-viewport { cursor: crosshair; }

/* ---------- Explosion FX ---------- */
.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 20;
}
.fx-particle {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 2px;
  --dx: 0px;
  --dy: 0px;
  --rot: 0deg;
  animation: fx-explode 700ms cubic-bezier(0.2, 0.65, 0.3, 1) forwards;
  will-change: transform, opacity;
}
.fx-flash {
  position: absolute;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,220,90,0.95) 0%, rgba(255,90,0,0.6) 40%, rgba(255,0,0,0) 70%);
  animation: fx-flash 380ms ease-out forwards;
  transform: translate(-50%, -50%);
  mix-blend-mode: screen;
}
.fx-flash--mega {
  width: 140px; height: 140px;
  background: radial-gradient(circle,
    rgba(255,255,255,0.95) 0%,
    rgba(150,180,255,0.85) 18%,
    rgba(180,74,192,0.6) 45%,
    rgba(73,58,193,0.25) 70%,
    rgba(0,0,0,0) 80%);
  animation: fx-flash 600ms cubic-bezier(0.2, 0.65, 0.3, 1) forwards;
}
.fx-flash--nuke {
  width: 260px; height: 260px;
  background: radial-gradient(circle,
    rgba(255,255,255,1) 0%,
    rgba(255,255,200,0.95) 12%,
    rgba(255,200,80,0.85) 28%,
    rgba(255,120,0,0.7) 48%,
    rgba(190,0,57,0.45) 65%,
    rgba(60,30,20,0.25) 80%,
    rgba(0,0,0,0) 92%);
  animation: fx-flash-nuke 1100ms cubic-bezier(0.18, 0.7, 0.25, 1) forwards;
}
@keyframes fx-flash-nuke {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  20%  { opacity: 1; }
  60%  { opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(3.4); opacity: 0; }
}
.fx-flash--mirror {
  width: 36px; height: 36px;
  background: radial-gradient(circle,
    rgba(255,255,255,0.95) 0%,
    rgba(180,230,255,0.7) 35%,
    rgba(120,200,255,0.3) 65%,
    rgba(0,0,0,0) 80%);
  animation: fx-flash 500ms ease-out forwards;
}
.fx-flash--apocalypse {
  width: 380px; height: 380px;
  background:
    radial-gradient(circle,
      rgba(255,255,255,1)    0%,
      rgba(255,235,150,0.95) 10%,
      rgba(255,150,40,0.85)  22%,
      rgba(220,20,80,0.75)   38%,
      rgba(120,40,180,0.6)   55%,
      rgba(40,90,200,0.45)   70%,
      rgba(80,200,220,0.25)  82%,
      rgba(0,0,0,0)          93%);
  animation: fx-flash-apocalypse 1800ms cubic-bezier(0.18, 0.7, 0.22, 1) forwards;
}
@keyframes fx-flash-apocalypse {
  0%   { transform: translate(-50%, -50%) scale(0.2)  rotate(0deg);   opacity: 1; }
  10%  { transform: translate(-50%, -50%) scale(1.0)  rotate(20deg);  opacity: 1; }
  35%  { transform: translate(-50%, -50%) scale(1.8)  rotate(60deg);  opacity: 0.9; }
  70%  { transform: translate(-50%, -50%) scale(3.6)  rotate(160deg); opacity: 0.55; }
  100% { transform: translate(-50%, -50%) scale(5.8)  rotate(260deg); opacity: 0; }
}
@keyframes fx-explode {
  0%   { transform: translate(0,0) scale(1) rotate(0deg); opacity: 1; }
  60%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2) rotate(var(--rot)); opacity: 0; }
}
@keyframes fx-flash {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0.9; }
  60%  { opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
}
.palette {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 4px;
  max-width: 92vw;
}
.swatch {
  width: 26px; height: 26px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 80ms, border-color 80ms;
}
.swatch:hover { transform: scale(1.12); }
.swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 1px #000;
  transform: scale(1.18);
}

/* ---------- Placer (confirm to place) ---------- */
.placer {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.placer-preview { display: flex; align-items: center; gap: 8px; }
.placer-swatch {
  width: 22px; height: 22px;
  border-radius: 4px;
  box-shadow: 0 0 0 1px #000, inset 0 0 0 2px #fff;
}
.placer-coord { font-size: 12px; color: var(--muted); }
.placer-btn {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
.placer-btn-ghost { background: transparent; color: var(--text); }
.placer-btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.placer-btn-primary { background: var(--accent); color: #fff; }
.placer-btn-primary:hover { background: #ff5b1a; }

/* ---------- Cooldown ---------- */
.cooldown {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--muted);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cooldown-bar {
  width: 80px; height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
#cooldown-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 80ms linear;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  top: 60px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  box-shadow: var(--shadow);
  animation: slide-in 160ms ease-out;
  min-width: 200px;
}
.toast.success { border-color: var(--ok); }
.toast.error { border-color: var(--danger); }
@keyframes slide-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- Auth pages ---------- */
body.auth {
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(800px 400px at 50% -10%, rgba(255, 69, 0, 0.18), transparent 60%),
    #0f0f10;
  overflow: auto;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.auth-hero { padding: 22px 24px 14px; border-bottom: 1px solid var(--border); text-align: center; }
.auth-hero h1 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.auth-hero p { color: var(--muted); font-size: 13px; }
.auth-body { padding: 18px 24px 22px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); }
.field input {
  background: #0f0f10;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.auth-btn {
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.auth-btn:hover { background: #ff5b1a; }
.auth-footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 6px; }
.auth-footer a { color: var(--accent-blue); text-decoration: none; font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }
.msg { border-radius: 4px; padding: 8px 10px; font-size: 12px; }
.msg.error { background: rgba(255, 88, 91, 0.15); color: var(--danger); border: 1px solid rgba(255, 88, 91, 0.3); }
.msg.success { background: rgba(70, 209, 96, 0.15); color: var(--ok); border: 1px solid rgba(70, 209, 96, 0.3); }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .palette { grid-template-columns: repeat(10, 1fr); }
  .rank-card { min-width: 140px; max-width: 180px; }
  .hud-zoom { bottom: 120px; }
}
