/* SnakQ .io rewrite — neon cyber theme. */

:root {
  --bg: #05060a;
  --panel: rgba(13, 17, 28, 0.85);
  --panel-strong: rgba(13, 17, 28, 0.95);
  --border: rgba(125, 244, 255, 0.25);
  --text: #f0fbff;
  --text-muted: #8aa5b3;
  --primary: #00E5FF;
  --primary-glow: #7df4ff;
  --accent: #fff7a0;
  --danger: #ff5252;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: crosshair;
  touch-action: none;
  outline: none; /* Suppress focus ring even though tabindex=0 — iframe focus only. */
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─────── Overlay screens ─────── */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  pointer-events: auto;
  z-index: 10;
  background: radial-gradient(circle at center, rgba(0, 229, 255, 0.05), rgba(0, 0, 0, 0.85) 60%);
}
.overlay.active { display: flex; }
.hidden { display: none !important; }

.brand {
  text-align: center;
  margin-bottom: 16px;
}
.logo {
  margin: 0;
  font-size: 4.2rem;
  font-weight: 900;
  letter-spacing: -2.5px;
  line-height: 1;
  background: linear-gradient(180deg, #fff 0%, #b8e8f4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(0, 229, 255, 0.5);
}
.logo-q {
  color: var(--primary);
  -webkit-text-fill-color: var(--primary);
  text-shadow: 0 0 24px var(--primary);
}
.tagline {
  margin: 8px 0 0;
  color: var(--primary-glow);
  font-size: 1.05rem;
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* ─────── Cards ─────── */
.card {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 380px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
input[type="text"] {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.15);
}

/* ─────── Skin picker ─────── */
.skin-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.skin-chip {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--c, #00E5FF);
  box-shadow: 0 0 16px var(--c, #00E5FF), inset 0 0 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s, border-color 0.1s;
  padding: 0;
}
.skin-chip:hover { transform: scale(1.05); }
.skin-chip.active {
  border-color: var(--text);
  transform: scale(1.1);
}

/* ─────── Buttons ─────── */
.btn {
  border: none;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: transform 0.05s, box-shadow 0.15s, background 0.15s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #001417;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-glow);
  box-shadow: 0 0 28px rgba(0, 229, 255, 0.7);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); }

.hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* ─────── Death card ─────── */
.died-card { text-align: center; gap: 14px; }
.died-card h2 {
  margin: 0;
  font-size: 2rem;
  color: var(--danger);
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(255, 82, 82, 0.5);
}
.died-killer {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.died-killer strong { color: #fff7a0; font-weight: 600; }
.end-scores {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}
.end-scores td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.end-scores td:last-child {
  text-align: right;
  font-weight: 700;
  color: var(--primary-glow);
}

/* ─────── HUD ─────── */
.hud-top {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  pointer-events: none;
  z-index: 5;
}
.hud-latency {
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

/* ─────── On-screen BOOST button (touch devices only) ─────── */
.btn-mute {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(125, 244, 255, 0.25);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-muted);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  z-index: 30;
  opacity: 0.65;
  transition: opacity 0.15s, background 0.15s;
}
.btn-mute:hover { opacity: 1; }
.btn-mute.muted { color: #ff7878; }

.btn-mobile-boost {
  display: none;
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(24px, calc(24px + env(safe-area-inset-bottom)));
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid rgba(0, 229, 255, 0.55);
  background: rgba(0, 229, 255, 0.18);
  color: var(--text);
  font-size: 2.4rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), inset 0 0 18px rgba(0, 229, 255, 0.25);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.7);
  transition: transform 0.05s, background 0.05s;
}
.btn-mobile-boost:active {
  background: rgba(0, 229, 255, 0.45);
  transform: scale(0.94);
}
/* SHOCK button — sits above BOOST. Pulses when charge is full (class added by JS). */
.btn-mobile-shock {
  display: none;
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(132px, calc(132px + env(safe-area-inset-bottom)));
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid rgba(255, 247, 160, 0.55);
  background: rgba(255, 247, 160, 0.12);
  color: var(--text);
  font-size: 2.1rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), inset 0 0 14px rgba(255, 247, 160, 0.2);
  text-shadow: 0 0 12px rgba(255, 247, 160, 0.7);
  opacity: 0.55;
  transition: opacity 0.2s, transform 0.05s, background 0.05s;
}
.btn-mobile-shock.ready {
  opacity: 1;
  border-color: rgba(255, 247, 160, 0.95);
  background: rgba(255, 247, 160, 0.28);
  animation: shock-pulse 0.9s ease-in-out infinite;
}
.btn-mobile-shock:active {
  background: rgba(255, 247, 160, 0.5);
  transform: scale(0.92);
}
@keyframes shock-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(0,0,0,0.6), 0 0 0 rgba(255,247,160,0); }
  50%      { box-shadow: 0 4px 16px rgba(0,0,0,0.6), 0 0 28px rgba(255,247,160,0.6); }
}

@media (pointer: coarse), (max-width: 767px) {
  .btn-mobile-boost,
  .btn-mobile-shock { display: flex; }
}
/* Hide while overlay screens are active. */
.overlay.active ~ .btn-mobile-boost,
.overlay.active ~ .btn-mobile-shock { display: none; }

.footer {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}
.footer a { color: var(--text-muted); }
.footer-brand { display: block; margin-top: 4px; opacity: 0.6; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
