@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Share+Tech+Mono&display=swap');

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

:root {
  --bg: #0d0d1a;
  --panel: #1a1a2e;
  --border: #2a2a4a;
  --accent: #7c3aed;
  --accent2: #06b6d4;
  --cyan: #06b6d4;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #fbbf24;
  --text: #e2e8f0;
  --muted: #64748b;
  --r: 10px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ─── Screens ──────────────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  transition: opacity 0.25s;
}
.screen.hidden { display: none; }

/* ─── Panel ────────────────────────────────────────────────────────────────── */
.panel {
  background: linear-gradient(160deg, #1e1e38 0%, #16162a 100%);
  border: 1px solid rgba(124,58,237,0.28);
  box-shadow: 0 0 32px rgba(124,58,237,0.1), inset 0 1px 0 rgba(255,255,255,0.05);
  border-radius: var(--r);
  padding: 1.5rem;
  width: 100%;
  max-width: 460px;
}

/* ─── Typography ────────────────────────────────────────────────────────────── */
.title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1rem, 5vw, 1.6rem);
  text-align: center;
  margin-bottom: 0.3em;
  line-height: 1.4;
}
.title.rainbow {
  background: linear-gradient(90deg, #f72585, #7209b7, #3a86ff, #06d6a0, #ffd166);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 1.8rem;
  letter-spacing: 0.1em;
}

h3 {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.6rem;
}

/* ─── Inputs ────────────────────────────────────────────────────────────────── */
.input-group { margin-bottom: 1rem; }
.input-group label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  letter-spacing: 0.08em;
}
input[type=text], input[type=password], input[type=number], select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }
select option { background: var(--panel); }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.55rem, 2vw, 0.72rem);
  border: none;
  border-radius: 8px;
  padding: 0.8em 1.4em;
  cursor: pointer;
  transition: transform 0.08s, filter 0.1s;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  width: 100%;
  margin-bottom: 0.6rem;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, #8b45ff, #6020d0);
  color: #fff;
  box-shadow: 0 4px 15px rgba(124,58,237,0.4);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.15); box-shadow: 0 4px 20px rgba(124,58,237,0.6); }
.btn-cyan {
  background: linear-gradient(135deg, #0cd4f5, #0590b8);
  color: #0d0d1a;
  box-shadow: 0 4px 12px rgba(6,182,212,0.35);
}
.btn-cyan:hover:not(:disabled) { filter: brightness(1.1); }
.btn-green {
  background: linear-gradient(135deg, #22d48a, #0d9560);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16,185,129,0.35);
}
.btn-green:hover:not(:disabled) { filter: brightness(1.1); }
.btn-red { background: var(--red); color: #fff; }
.btn-ghost {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--muted);
}
.btn-ghost:hover { border-color: var(--accent2); color: var(--accent2); background: rgba(6,182,212,0.06); }
.btn-sm { font-size: 0.55rem; padding: 0.55em 1em; margin-bottom: 0; width: auto; }
.btn-invite {
  background: rgba(99,179,237,0.12);
  border: 1px solid rgba(99,179,237,0.45);
  color: #90cdf4;
  font-size: 0.6rem;
  margin-bottom: 0.6rem;
}
.btn-invite:hover { background: rgba(99,179,237,0.22); border-color: #90cdf4; }
.btn-invite.copied { background: rgba(72,187,120,0.2); border-color: #68d391; color: #9ae6b4; }

.btn-row {
  display: flex;
  gap: 0.5rem;
}
.btn-row .btn { flex: 1; margin-bottom: 0; }

/* ─── Welcome screen ────────────────────────────────────────────────────────── */
#screen-welcome .logo {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1.1rem, 6vw, 2rem);
  text-align: center;
  background: linear-gradient(135deg, #f72585 0%, #7209b7 50%, #3a86ff 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.2em;
  line-height: 1.4;
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{filter:brightness(1)} 50%{filter:brightness(1.2)} }
#screen-welcome .tagline {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 2.5rem;
  letter-spacing: 0.15em;
}
.name-input-wrap {
  display: flex; gap: 0.5rem;
}
.name-input-wrap input { flex: 1; font-size: 1rem; }
.name-input-wrap .btn { width: auto; margin-bottom: 0; min-width: 50px; }

/* ─── Customize screen ──────────────────────────────────────────────────────── */
#screen-customize {
  padding: 0.5rem 0.5rem 1rem;
  overflow-y: auto;
  align-items: stretch;
  justify-content: flex-start;
}
.cust-wrap {
  display: flex;
  gap: 0.75rem;
  max-width: 580px;
  margin: 0 auto;
  width: 100%;
  align-items: flex-start;
}
.cust-preview {
  flex: 0 0 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  position: sticky;
  top: 0;
}
#previewCanvas {
  border-radius: 12px;
  border: 2px solid var(--border);
  background: linear-gradient(180deg, #1a1a2e, #16213e);
  width: 120px; height: 160px;
}
.char-name-input {
  text-align: center;
  font-size: 0.82rem;
  width: 120px;
}
.cust-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.cust-tabs {
  display: flex;
  gap: 4px;
}
.cust-tab {
  flex: 1;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.38rem, 1.5vw, 0.5rem);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px 7px 0 0;
  color: var(--muted);
  padding: 0.5em 0.3em;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.cust-tab:hover { border-color: var(--accent2); color: var(--accent2); }
.cust-tab.active {
  background: var(--panel);
  border-color: var(--accent);
  border-bottom-color: var(--panel);
  color: var(--text);
  position: relative;
  z-index: 1;
}
.cust-panel {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 0 8px 8px 8px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
}
.cust-panel.hidden { display: none; }

.section-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.52rem;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.45rem;
}

/* Type grid with mini-canvas cards */
.type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
.type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 6px 4px 5px;
  cursor: pointer;
  transition: all 0.12s;
}
.type-card:hover { border-color: var(--accent2); }
.type-card.selected {
  border-color: var(--accent);
  background: rgba(124,58,237,0.18);
  box-shadow: 0 0 10px rgba(124,58,237,0.35);
}
.type-card canvas { border-radius: 6px; display: block; }
.type-card-label {
  font-size: 0.48rem;
  color: var(--muted);
  font-family: 'Share Tech Mono', monospace;
  text-align: center;
  line-height: 1.2;
}
.type-card.selected .type-card-label { color: var(--text); }

/* Color swatches */
.color-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}
.color-swatch {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
  min-width: 0;
}
.color-swatch:hover { transform: scale(1.18); }
.color-swatch.selected { border-color: #fff; transform: scale(1.1); }

/* Option buttons (hats, faces, extras) */
.option-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
.option-btn {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.2rem;
  cursor: pointer;
  text-align: center;
  font-size: 0.58rem;
  color: var(--muted);
  font-family: 'Share Tech Mono', monospace;
  transition: all 0.1s;
  line-height: 1.3;
}
.option-btn .emoji { font-size: 1.3rem; display: block; margin-bottom: 2px; }
.option-btn:hover { border-color: var(--accent2); color: var(--text); }
.option-btn.selected {
  border-color: var(--accent);
  background: rgba(124,58,237,0.2);
  color: var(--text);
}

/* ─── Lobby ─────────────────────────────────────────────────────────────────── */
.room-info {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  align-items: center;
}
.room-info span { color: var(--text); font-weight: bold; }
.room-info-badge {
  background: rgba(124,58,237,0.2);
  border: 1px solid rgba(124,58,237,0.4);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 0.62rem;
  color: #c4b5fd;
}

.lobby-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}
.lobby-actions .btn { flex: 1; margin-bottom: 0; }

.players-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  max-height: 280px;
  overflow-y: auto;
}
.player-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  transition: background 0.12s;
}
.player-item:hover { background: rgba(255,255,255,0.07); }
.player-avatar {
  flex-shrink: 0;
  width: 52px; height: 52px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.12);
}
.player-item.me .player-avatar { border-color: rgba(6,182,212,0.6); }
.player-item.me { border-color: rgba(6,182,212,0.25); background: rgba(6,182,212,0.06); }
.player-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.player-item .player-name {
  font-size: 0.8rem;
  font-weight: bold;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-badges { display: flex; gap: 4px; }
.badge {
  font-size: 0.52rem;
  font-family: 'Press Start 2P', monospace;
  padding: 3px 7px;
  border-radius: 5px;
  background: linear-gradient(135deg,#f59e0b,#d97706);
  color: #000;
}
.badge.you {
  background: linear-gradient(135deg,#0cd4f5,#0590b8);
  color: #000;
}

/* ─── Rooms list ─────────────────────────────────────────────────────────────── */
.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  max-height: 280px;
  overflow-y: auto;
}
.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.1s;
}
.room-item:hover { border-color: var(--accent2); }
.room-item .name { font-weight: bold; font-size: 0.85rem; }
.room-item .meta { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }
.room-item .join-btn { font-size: 0.55rem; }
.room-empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
  font-size: 0.75rem;
}

/* ─── Countdown ─────────────────────────────────────────────────────────────── */
#screen-countdown {
  background: rgba(0,0,0,0.85);
  z-index: 50;
}
.countdown-num {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(4rem, 20vw, 8rem);
  background: linear-gradient(135deg, #f72585, #7209b7);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: countPop 0.8s ease-out;
}
@keyframes countPop { from{transform:scale(2);opacity:0} to{transform:scale(1);opacity:1} }

/* ─── Game screen ───────────────────────────────────────────────────────────── */
#screen-game {
  padding: 0;
  background: #000;
}
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Touch controls — split-zone: left half / right half */
#touch-controls {
  position: fixed;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 10;
  touch-action: none;
}
#touch-left, #touch-right {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 48%;
  pointer-events: all;
  touch-action: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: max(env(safe-area-inset-bottom, 0px) + 1.8rem, 2.2rem);
  /* subtle side gradient — shows user where to tap */
  transition: background 0.08s, opacity 0.08s;
}
#touch-left  { left: 0;  background: radial-gradient(ellipse at 20% 90%, rgba(255,255,255,0.04) 0%, transparent 70%); }
#touch-right { right: 0; background: radial-gradient(ellipse at 80% 90%, rgba(255,255,255,0.04) 0%, transparent 70%); }
#touch-left.active  { background: radial-gradient(ellipse at 20% 90%, rgba(100,200,255,0.18) 0%, transparent 65%); }
#touch-right.active { background: radial-gradient(ellipse at 80% 90%, rgba(100,200,255,0.18) 0%, transparent 65%); }
/* Arrow badge — always visible at low opacity, brighter when active */
.touch-arrow {
  font-size: 3rem;
  opacity: 0.22;
  transition: opacity 0.08s, transform 0.08s;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
  user-select: none;
  pointer-events: none;
}
#touch-left.active  .touch-arrow,
#touch-right.active .touch-arrow {
  opacity: 0.9;
  transform: scale(1.15);
  filter: drop-shadow(0 0 12px rgba(120,200,255,0.8));
}
.touch-show #touch-controls { display: flex; }

/* ─── Volume control (menú) ───────────────────────────────────────────────── */
.volume-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
  padding: 0.5rem 0.8rem;
  background: rgba(255,255,255,0.07);
  border-radius: 8px;
}
.volume-row span { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
#volume-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--cyan) 0%, var(--cyan) 100%);
  outline: none;
  cursor: pointer;
}
#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
  cursor: pointer;
}

/* ─── Mute button in-game ─────────────────────────────────────────────────── */
#game-mute-btn {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 0.8rem;
  padding: 4px 8px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
}
#game-mute-btn:hover { opacity: 1; }

/* ─── Spectator bar ───────────────────────────────────────────────────────── */
#spectator-bar {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.75);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 8px 14px;
  backdrop-filter: blur(4px);
}
#spectator-bar.hidden { display: none !important; }
#spectator-bar:not(.hidden) { display: flex; }
.is-dead #touch-controls { display: none !important; }
.spec-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.spec-label {
  font-size: 0.72rem;
  color: #ddd;
  letter-spacing: 0.05em;
  min-width: 120px;
  text-align: center;
}
.spec-label strong { color: #fff; }
#death-rank-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  color: #fff;
  background: rgba(239,68,68,0.5);
  border: 1px solid rgba(255,100,100,0.6);
  border-radius: 8px;
  padding: 4px 10px;
  text-align: center;
  animation: rankFadeOut 3.5s forwards;
}
#death-rank-badge.hidden { display: none; }
@keyframes rankFadeOut {
  0%   { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}
.spec-power-btn {
  font-size: 0.72rem;
  font-family: 'Press Start 2P', monospace;
  border-radius: 8px;
  border: 2px solid;
  padding: 5px 12px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}
.spec-power-btn:active { transform: scale(0.93); }
.spec-power-btn.help { background: rgba(40,180,80,0.25); border-color: #44ee88; color: #88ffaa; }
.spec-power-btn.harm { background: rgba(200,40,40,0.25); border-color: #ff5544; color: #ffaaaa; }

/* Indicador de powerup activo (solo lectura, no interactivo) */
#boost-indicator {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  min-width: 64px; height: 64px;
  padding: 0 10px;
  border-radius: 32px;
  background: rgba(0,0,0,0.55);
  border: 2px solid rgba(255,200,0,0.6);
  box-shadow: 0 0 12px rgba(255,200,0,0.4);
  font-size: 1.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  pointer-events: none;
}
#boost-indicator.hidden { display: none !important; }
.boost-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.45rem;
  color: #ffcc44;
  line-height: 1;
  letter-spacing: 0.02em;
}

/* Dead overlay */
#dead-overlay {
  position: fixed;
  inset: 0;
  background: rgba(239,68,68,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
  animation: deadOverlayFade 1.4s ease-out forwards;
}
#dead-overlay.hidden { display: none; }
#dead-overlay .dead-msg {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1rem, 5vw, 2rem);
  color: #fff;
  text-shadow: 0 0 20px #ef4444;
  animation: fadeInDown 0.5s ease-out;
  text-align: center;
  padding: 0 1rem;
}
@keyframes fadeInDown { from{opacity:0;transform:translateY(-20px)} to{opacity:1;transform:translateY(0)} }
@keyframes deadOverlayFade {
  0%   { opacity: 1; }
  60%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ─── Rankings ───────────────────────────────────────────────────────────────── */
.rank-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.rank-tab {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 12px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.52rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.rank-tab.active {
  background: rgba(255,200,50,0.18);
  border-color: #ffd700;
  color: #ffd700;
}
.rankings-list {
  width: 100%;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 8px 12px;
}
.rank-row.top1 { border-color: rgba(255,215,0,0.5); background: rgba(255,215,0,0.08); }
.rank-row.top2 { border-color: rgba(192,192,192,0.4); background: rgba(192,192,192,0.06); }
.rank-row.top3 { border-color: rgba(205,127,50,0.4); background: rgba(205,127,50,0.06); }
.rank-pos {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  min-width: 28px;
  text-align: center;
  color: var(--muted);
}
.rank-row.top1 .rank-pos { color: #ffd700; }
.rank-row.top2 .rank-pos { color: #c0c0c0; }
.rank-row.top3 .rank-pos { color: #cd7f32; }
.rank-name {
  flex: 1;
  font-size: 0.7rem;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-score {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  color: #4ecdc4;
  white-space: nowrap;
}
.rank-date {
  font-size: 0.55rem;
  color: var(--muted);
  white-space: nowrap;
}
.rank-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.65rem;
  padding: 2rem 0;
}
.rank-loading {
  text-align: center;
  color: var(--muted);
  font-size: 0.65rem;
  padding: 1.5rem 0;
}

/* ─── Results ───────────────────────────────────────────────────────────────── */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}
.result-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(255,255,255,0.08);
  transition: background 0.12s;
}
.result-item.first {
  border-color: rgba(251,191,36,0.5);
  background: rgba(251,191,36,0.07);
}
.result-item.second {
  border-color: rgba(148,163,184,0.4);
  background: rgba(148,163,184,0.04);
}
.result-item.third {
  border-color: rgba(205,124,46,0.4);
  background: rgba(205,124,46,0.04);
}
.rank-medal {
  font-size: 1.5rem;
  width: 2rem;
  text-align: center;
  flex-shrink: 0;
}
.result-avatar {
  width: 44px; height: 44px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.12);
  flex-shrink: 0;
}
.result-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.result-name { font-size: 0.82rem; font-weight: bold; }
.result-alt { font-size: 0.62rem; color: var(--accent2); letter-spacing: 0.05em; }

/* ─── Notifications ─────────────────────────────────────────────────────────── */
#notifications {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  pointer-events: none;
}
.notif {
  background: rgba(0,0,0,0.85);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  color: #fff;
  text-align: center;
  animation: notifIn 0.3s ease-out, notifOut 0.4s ease-in 2.6s forwards;
  white-space: nowrap;
}
@keyframes notifIn { from{opacity:0;transform:translateY(-10px)} to{opacity:1;transform:translateY(0)} }
@keyframes notifOut { to{opacity:0;transform:translateY(-8px)} }

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 400px) {
  .panel { padding: 1rem; }
  .color-grid { grid-template-columns: repeat(8, 1fr); gap: 4px; }
  .option-grid { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .option-btn .emoji { font-size: 1.1rem; }
  .cust-wrap { flex-direction: column; align-items: center; }
  .cust-preview { flex-direction: row; flex: none; gap: 0.5rem; flex-wrap: wrap; justify-content: center; position: static; }
  .cust-main { width: 100%; }
  .type-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 600px) {
  #touch-controls { display: none !important; }
}

/* ─── Settings panel ──────────────────────────────────────────────────────── */
.settings-slider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.settings-slider-row input[type=range] {
  flex: 1;
  accent-color: var(--accent);
}
.settings-slider-label-min {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}
.settings-slider-value {
  font-size: 0.75rem;
  font-family: 'Press Start 2P', monospace;
  color: var(--accent);
  min-width: 3.5rem;
  text-align: right;
}
.settings-hint {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.5rem;
  line-height: 1.5;
}
