/* ── Reset / base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e0d8ff;
}

/* ── Canvas ─────────────────────────────────────────────────────────────── */
#arcade-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* ── Loading Screen ──────────────────────────────────────────────────────── */
.loading-screen {
  position: fixed; inset: 0;
  background: #000010;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  transition: opacity 0.4s;
}
.loading-screen.fade-out { opacity: 0; pointer-events: none; }
.loading-content { text-align: center; }
.loading-logo { font-size: 4rem; margin-bottom: 1.5rem; animation: pulse 1.2s infinite; }
.loading-bar {
  width: 240px; height: 6px;
  background: #1a0044;
  border-radius: 3px;
  margin: 0 auto 1rem;
  overflow: hidden;
}
.loading-fill {
  height: 100%;
  background: linear-gradient(90deg, #6600ff, #00ccff);
  border-radius: 3px;
  animation: load-anim 1.5s ease-in forwards;
}
@keyframes load-anim {
  from { width: 0; }
  to   { width: 100%; }
}
.loading-text { color: #8866ff; font-size: 0.9rem; letter-spacing: 0.12em; text-transform: uppercase; }

/* ── Overlays ────────────────────────────────────────────────────────────── */
.arcade-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 20, 0.82);
  backdrop-filter: blur(12px);
  z-index: 50;
}
.arcade-overlay[hidden] { display: none; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.arcade-modal {
  background: rgba(8, 4, 28, 0.95);
  border: 1px solid #3300aa;
  border-radius: 16px;
  padding: 2.5rem 2.8rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow:
    0 0 0 1px #5500ff33,
    0 0 40px #3300aa55,
    inset 0 0 60px #0a003322;
  position: relative;
}

.modal-logo { font-size: 3rem; margin-bottom: 0.5rem; }

/* ── Neon titles ─────────────────────────────────────────────────────────── */
.neon-title {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.2;
  color: #e0d8ff;
  text-shadow: 0 0 12px #aa66ff, 0 0 28px #7700ff55;
  margin-bottom: 0.3rem;
}
.neon-title span {
  color: #00ccff;
  text-shadow: 0 0 12px #00ccff, 0 0 28px #0088ff55;
}
.neon-title-sm {
  font-size: 1.4rem;
  font-weight: 700;
  color: #e0d8ff;
  text-shadow: 0 0 10px #aa66ff;
  margin: 0;
}

.modal-sub {
  color: #8877bb;
  font-size: 0.9rem;
  margin-bottom: 1.6rem;
}

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.arcade-input {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: #0b0620;
  border: 1px solid #4400aa;
  border-radius: 8px;
  color: #e0d8ff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.arcade-input:focus {
  border-color: #7744ff;
  box-shadow: 0 0 0 3px #5500ff33;
}
.arcade-input::placeholder { color: #553388; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.arcade-btn {
  display: inline-block;
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.04em;
}
.arcade-btn.primary {
  display: block;
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, #5500ff, #3300cc);
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 0 20px #5500ff55;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.arcade-btn.primary:hover {
  background: linear-gradient(135deg, #7722ff, #5500ee);
  box-shadow: 0 0 28px #7722ff88;
  transform: translateY(-1px);
}
.arcade-btn.join {
  background: linear-gradient(135deg, #0055cc, #003399);
  color: #fff;
  box-shadow: 0 0 10px #0055cc44;
}
.arcade-btn.join:hover {
  background: linear-gradient(135deg, #0077ff, #0055cc);
  box-shadow: 0 0 16px #0077ff66;
}
.arcade-btn.leave-slot {
  background: rgba(80, 0, 0, 0.6);
  color: #ff6666;
  border: 1px solid #aa0000;
}
.arcade-btn.leave-slot:hover {
  background: rgba(160, 0, 0, 0.7);
}
.arcade-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.arcade-btn.small { padding: 0.4rem 0.9rem; font-size: 0.82rem; }

.back-link {
  display: block;
  margin-top: 1.1rem;
  color: #553388;
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s;
}
.back-link:hover { color: #aa88ff; }

/* ── Machine modal ───────────────────────────────────────────────────────── */
.machine-modal { max-width: 460px; text-align: left; }

.close-btn {
  position: absolute;
  top: 1rem; right: 1.2rem;
  background: none;
  border: none;
  color: #553388;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}
.close-btn:hover { color: #cc88ff; }

.machine-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #2a0066;
}
.machine-icon { font-size: 2.8rem; flex-shrink: 0; }
.machine-desc { color: #8877bb; font-size: 0.85rem; margin-top: 0.2rem; }

.machine-slots { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.2rem; }

.slot-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: #0d0630;
  border: 1px solid #2a0066;
  border-radius: 8px;
}
.slot-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #6644aa;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-width: 24px;
}
.slot-name {
  flex: 1;
  font-size: 0.9rem;
}
.slot-name.open { color: #553388; font-style: italic; }
.slot-name.taken { color: #e0d8ff; font-weight: 600; }
.slot-name.mine  { color: #00ccff; font-weight: 600; }

.machine-hint { color: #443366; font-size: 0.78rem; text-align: center; }

/* ── Proximity prompt ────────────────────────────────────────────────────── */
.arcade-prompt {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 4, 28, 0.88);
  border: 1px solid #5500ff;
  border-radius: 10px;
  padding: 0.6rem 1.4rem;
  font-size: 0.92rem;
  color: #c8b8ff;
  pointer-events: none;
  animation: prompt-bob 2s ease-in-out infinite;
  box-shadow: 0 0 16px #5500ff44;
}
.arcade-prompt[hidden] { display: none; }
.arcade-prompt kbd {
  display: inline-block;
  background: #3300aa;
  border: 1px solid #6644cc;
  border-radius: 4px;
  padding: 0 6px;
  font-family: inherit;
  font-size: 0.9em;
  color: #e0d8ff;
  margin: 0 2px;
}
@keyframes prompt-bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%       { transform: translateX(-50%) translateY(-4px); }
}

/* ── Toast notification ────────────────────────────────────────────────────── */
.arcade-toast {
  position: fixed;
  bottom: 8.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(0, 18, 14, 0.92);
  border: 1px solid #00ffcc;
  border-radius: 10px;
  padding: 0.55rem 1.5rem;
  font-size: 0.95rem;
  color: #00ffee;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 0 22px #00ffcc55;
  white-space: nowrap;
  z-index: 600;
}

.points-pop {
  position: fixed;
  left: 50%;
  bottom: 12rem;
  transform: translateX(-50%) translateY(8px) scale(0.92);
  color: #ffe77a;
  font: 700 28px/1.1 "Segoe UI", system-ui, sans-serif;
  text-shadow: 0 0 12px rgba(255, 235, 120, 0.9), 0 0 22px rgba(255, 160, 60, 0.7);
  opacity: 0;
  pointer-events: none;
  z-index: 620;
}

.points-pop.show {
  animation: points-pop-rise 0.9s ease-out;
}

@keyframes points-pop-rise {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(8px) scale(0.92);
  }
  20% {
    opacity: 1;
    transform: translateX(-50%) translateY(-6px) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-34px) scale(1.0);
  }
}

/* ── HUD ─────────────────────────────────────────────────────────────────── */
.controls-hint {
  position: fixed;
  top: 0.9rem; left: 50%;
  transform: translateX(-50%);
  color: #443366;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  pointer-events: none;
  transition: opacity 0.4s;
}
.controls-hint[hidden] { display: none; }

.player-count {
  position: fixed;
  top: 0.9rem; right: 1.2rem;
  color: #443366;
  font-size: 0.78rem;
  pointer-events: none;
}
.player-count[hidden] { display: none; }

/* ── Mobile FPS Touch Controls ───────────────────────────────────────────── */
.fps-touch-toggle {
  position: fixed;
  bottom: 60px;
  right: 10px;
  z-index: 210;
  background: rgba(8, 20, 26, 0.85);
  color: #9deaf2;
  border: 1px solid rgba(80, 180, 190, 0.7);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  touch-action: none;
}

.fps-touch-overlay {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 205;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 10px 12px 14px;
  background: linear-gradient(to top, rgba(2, 6, 12, 0.75), rgba(2, 6, 12, 0));
}

.fps-touch-left,
.fps-touch-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.fps-stick {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid rgba(90, 170, 190, 0.65);
  background: radial-gradient(circle at 50% 35%, rgba(10, 42, 56, 0.65), rgba(6, 20, 28, 0.72));
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.fps-stick-knob {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(120, 220, 235, 0.75);
  background: radial-gradient(circle at 36% 35%, rgba(160, 245, 255, 0.95), rgba(40, 125, 150, 0.85));
  pointer-events: none;
  position: absolute;
}

.fps-stick-label {
  color: rgba(150, 230, 240, 0.75);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.fps-face-grid {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(3, 40px);
  gap: 4px;
}

.fps-btn {
  border: 1px solid rgba(120, 170, 190, 0.65);
  border-radius: 50%;
  background: rgba(18, 48, 60, 0.8);
  color: rgba(180, 238, 246, 0.95);
  font-size: 13px;
  font-weight: 700;
  touch-action: none;
}

.fps-btn:active,
.fps-btn.pressed {
  background: rgba(70, 180, 200, 0.88);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(90, 220, 240, 0.7);
}

.fps-btn-a { border-color: rgba(55, 190, 125, 0.8); color: #8affc3; }
.fps-btn-b { border-color: rgba(225, 90, 85, 0.8); color: #ffb1ac; }
.fps-btn-x { border-color: rgba(80, 130, 225, 0.8); color: #b8d2ff; }
.fps-btn-y { border-color: rgba(220, 180, 80, 0.8); color: #ffe9a7; }

@media (min-width: 901px) {
  .fps-touch-toggle,
  .fps-touch-overlay {
    display: none;
  }
}

/* ── CSS2D labels (player names, cabinet signs) ─────────────────────────── */
.player-label {
  background: rgba(8, 4, 28, 0.8);
  color: #c8b8ff;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #3300aa44;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}
.cabinet-label {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow: 0 0 8px currentColor;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

/* ── Avatar picker ───────────────────────────────────────────────────────── */
.avatar-section {
  margin-bottom: 1.4rem;
  border: 1px solid #2a0066;
  border-radius: 10px;
  padding: 1rem 1rem 0.7rem;
  background: #07031a;
  text-align: left;
}
.avatar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}
.avatar-preview {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid #5500ff;
  object-fit: cover;
  background: #0d0430;
  flex-shrink: 0;
  box-shadow: 0 0 12px #5500ff44;
}
.avatar-sets {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1;
}
.avatar-set-btn {
  padding: 0.3rem 0.55rem;
  background: #0d0430;
  border: 1px solid #3300aa;
  border-radius: 6px;
  color: #7766aa;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  line-height: 1.5;
}
.avatar-set-btn:hover { border-color: #6644cc; color: #c8b8ff; }
.avatar-set-btn.active {
  background: #1a0066;
  border-color: #7744ff;
  color: #e0d8ff;
  box-shadow: 0 0 8px #5500ff44;
}
.avatar-seed-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.avatar-seed-row .arcade-input {
  margin-bottom: 0;
  flex: 1;
  padding: 0.55rem 0.8rem;
  font-size: 0.88rem;
}
.avatar-rnd-btn {
  padding: 0.55rem 0.75rem;
  background: #1a0066;
  border: 1px solid #4400cc;
  border-radius: 8px;
  color: #aa88ff;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
  flex-shrink: 0;
}
.avatar-rnd-btn:hover {
  background: #2a0088;
  border-color: #7744ff;
  color: #e0d8ff;
}
.avatar-hint {
  color: #443366;
  font-size: 0.7rem;
  margin-top: 0.55rem;
  text-align: center;
}

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.95); }
}

/* ── Virtual Gamepad ─────────────────────────────────────────────────────── */
#vpad-toggle {
  position: fixed;
  bottom: 6px; right: 10px;
  z-index: 201;
  background: rgba(0,0,0,0.75);
  color: #888;
  border: 1px solid #444;
  border-radius: 5px;
  padding: 3px 10px;
  font-size: 10px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#vpad-toggle:active { color: #fff; border-color: #aa44ff; }
.vpad-overlay {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  pointer-events: none;
}
.vpad-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 10px;
  background: linear-gradient(to top, rgba(2,2,13,0.93) 0%, rgba(2,2,13,0.55) 100%);
  border-top: 1px solid rgba(120,60,220,0.35);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}
.vpad-shoulders {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 420px;
  gap: 8px;
}
.vpad-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.vpad-left-col, .vpad-right-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.vpad-center-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.vpad-stick-area {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  border: 2px solid rgba(100,50,200,0.45);
  position: relative;
  touch-action: none;
  cursor: grab;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.vpad-stick-area:active { cursor: grabbing; }
.vpad-stick-knob {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(160,100,255,0.9), rgba(60,10,160,0.85));
  border: 1px solid rgba(160,100,255,0.55);
  pointer-events: none;
  position: absolute;
}
.vpad-dpad {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  grid-template-rows: repeat(3, 32px);
  gap: 2px;
}
.vpad-dp-ctr {
  background: rgba(255,255,255,0.03);
  border-radius: 3px;
}
.vpad-face-grid {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(3, 40px);
  gap: 3px;
}
/* Shared button base */
.vpad-btn {
  border: 1px solid rgba(120,70,200,0.5);
  border-radius: 6px;
  background: rgba(60,30,100,0.6);
  color: rgba(200,160,255,0.9);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.07s, box-shadow 0.07s, color 0.07s;
  -webkit-tap-highlight-color: transparent;
}
.vpad-btn:active, .vpad-btn.pressed {
  background: rgba(130,70,220,0.85);
  box-shadow: 0 0 10px rgba(150,80,255,0.7);
  color: #fff;
}
.vpad-dp   { border-radius: 4px; font-size: 10px; }
.vpad-face { border-radius: 50%; width: 40px; height: 40px; font-size: 13px; }
.vpad-a {
  background: rgba(0,110,40,0.65);
  color: #88ffaa;
  border-color: rgba(0,180,60,0.5);
  font-size: 15px;
  border-radius: 50%;
}
.vpad-a:active, .vpad-a.pressed {
  background: rgba(0,200,60,0.85);
  box-shadow: 0 0 14px rgba(0,255,80,0.7);
}
.vpad-shoulder {
  flex: 1;
  height: 34px;
  border-radius: 8px;
  font-size: 13px;
  letter-spacing: 1px;
}
.vpad-sm { width: 46px; height: 28px; border-radius: 14px; font-size: 11px; }
.vpad-start-btn { width: 60px; font-size: 10px; letter-spacing: 0.8px; }
.vpad-hint {
  font-size: 10px;
  color: rgba(170,140,255,0.45);
  text-align: center;
  letter-spacing: 0.3px;
}

/* ── Back button (shown when zoomed into machine screen) ──────────────────── */
.back-btn {
  position: fixed;
  top: 14px; left: 14px;
  z-index: 45;
  background: rgba(2,2,13,0.75);
  color: rgba(200,160,255,0.9);
  border: 1px solid rgba(120,70,200,0.5);
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.back-btn:hover {
  background: rgba(80,40,130,0.9);
  color: #fff;
  border-color: rgba(160,90,255,0.75);
}
