/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #06000f;
  --cyan:    #00f5ff;
  --pink:    #ff44bb;
  --purple:  #a020f0;
  --gold:    #ffd700;
  --text:    rgba(255,255,255,0.85);
  --muted:   rgba(255,255,255,0.35);
  --card-bg: rgba(10,2,24,0.92);
  --radius:  14px;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  overflow: hidden;
  user-select: none;
}

/* ── Screens ───────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* animated bg canvas (landing & room) */
#bg-canvas, #bg-canvas-room {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ── Landing ───────────────────────────────────────────────────── */
.landing-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo-img {
  width: 64px; height: 64px;
  border-radius: 50%;
  box-shadow: 0 0 22px var(--pink);
  animation: bobble 2.5s ease-in-out infinite;
}
.logo-img:last-child { animation-delay: 0.8s; }

@keyframes bobble {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.title-main {
  font-size: clamp(32px, 6vw, 72px);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-shadow: 0 0 40px var(--cyan), 0 0 80px var(--cyan);
  color: #fff;
}

.title-sub {
  font-size: clamp(12px, 2vw, 18px);
  letter-spacing: 0.4em;
  color: var(--pink);
  text-shadow: 0 0 12px var(--pink);
  margin-top: 4px;
}

/* ── Card ──────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1.5px solid rgba(160, 32, 240, 0.4);
  border-radius: var(--radius);
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-width: 340px;
  box-shadow: 0 0 40px rgba(160,32,240,0.15), inset 0 0 40px rgba(0,0,0,0.3);
}

.landing-card { max-width: 400px; width: 90vw; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  border: none;
  border-radius: 10px;
  padding: 14px 28px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
  width: 100%;
}
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-cyan {
  background: linear-gradient(135deg, #00b4cc 0%, #00f5ff 100%);
  color: #000;
  box-shadow: 0 0 22px rgba(0,245,255,0.5);
}
.btn-cyan:hover:not(:disabled) { box-shadow: 0 0 36px rgba(0,245,255,0.8); transform: translateY(-2px); }

.btn-pink {
  background: linear-gradient(135deg, #c2006e 0%, #ff44bb 100%);
  color: #fff;
  box-shadow: 0 0 22px rgba(255,68,187,0.5);
}
.btn-pink:hover:not(:disabled) { box-shadow: 0 0 36px rgba(255,68,187,0.8); transform: translateY(-2px); }

.btn-start {
  background: linear-gradient(135deg, #7c00d0 0%, #a020f0 50%, #c060ff 100%);
  color: #fff;
  box-shadow: 0 0 28px rgba(160,32,240,0.6);
  font-size: 17px;
  padding: 16px 36px;
}
.btn-start:hover:not(:disabled) { box-shadow: 0 0 50px rgba(160,32,240,0.9); transform: translateY(-2px); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid rgba(255,255,255,0.15);
  font-size: 13px;
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.35); }

.btn-icon { font-size: 18px; line-height: 1; }

/* ── Divider ───────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.2em;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.12);
}

/* ── Join row ──────────────────────────────────────────────────── */
.join-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.input-code {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  padding: 13px 16px;
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-code::placeholder { letter-spacing: 0.2em; color: rgba(255,255,255,0.25); font-size: 14px; }
.input-code:focus {
  border-color: var(--pink);
  box-shadow: 0 0 16px rgba(255,68,187,0.35);
}

.join-row .btn-pink { flex: 0 0 auto; width: auto; padding: 13px 22px; }

/* ── Error message ─────────────────────────────────────────────── */
.error-msg {
  color: #ff6060;
  font-size: 13px;
  letter-spacing: 0.05em;
  min-height: 18px;
  text-align: center;
}

/* ── Room screen ───────────────────────────────────────────────── */
.room-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 90vw;
  max-width: 700px;
}

.room-title {
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 800;
  letter-spacing: 0.3em;
  color: var(--muted);
}

/* Room code display */
.code-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(0,0,0,0.5);
  border: 2px solid var(--purple);
  border-radius: 14px;
  padding: 16px 28px;
  box-shadow: 0 0 30px rgba(160,32,240,0.3);
}
.code-label {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--muted);
}
.code-value {
  font-family: 'Courier New', monospace;
  font-size: clamp(32px, 6vw, 52px);
  font-weight: 900;
  letter-spacing: 0.3em;
  color: #fff;
  text-shadow: 0 0 20px var(--cyan);
}
.btn-copy {
  background: none;
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 18px;
  padding: 6px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-copy:hover { color: #fff; border-color: var(--cyan); }

.code-hint {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* Player slots grid */
.players-grid {
  display: flex;
  align-items: center;
  gap: 24px;
  width: 100%;
}

.player-slot {
  flex: 1;
  background: var(--card-bg);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}
.player-slot:hover { transform: translateY(-3px); }
.player-slot.selected-by-me  { border-color: currentColor; }
.player-slot.taken-by-other  { cursor: not-allowed; opacity: 0.7; }

.slot-color-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  border-radius: 4px 4px 0 0;
}

.slot-face {
  width: 60px; height: 60px;
  border-radius: 50%;
  opacity: 0.5;
  transition: opacity 0.2s, box-shadow 0.2s;
}
.player-slot.selected-by-me .slot-face,
.player-slot.taken-by-other .slot-face { opacity: 1; }

.slot-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.15em;
}
.slot-keys {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.1em;
  font-family: monospace;
}
.slot-status {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 4px 10px;
}
.player-slot.selected-by-me .slot-status { color: #fff; background: rgba(255,255,255,0.12); }

/* VS badge */
.vs-badge {
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 900;
  color: var(--muted);
  letter-spacing: 0.15em;
  flex: 0 0 auto;
}

/* Start area */
.start-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 340px;
}
.btn-start { width: 100%; }
.start-hint {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-align: center;
}

/* ── Game screen ───────────────────────────────────────────────── */
#screen-game { background: #06000f; }

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

/* Corner leave button */
.corner-btn {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 10;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.corner-btn:hover { color: #fff; border-color: rgba(255,255,255,0.4); }

/* ── Solo section ──────────────────────────────────────────────── */
.solo-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.diff-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.btn-diff {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--muted);
  padding: 9px 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-diff:hover { color: #fff; border-color: rgba(255,255,255,0.35); }
.btn-diff.active {
  color: #fff;
  border-color: var(--purple);
  background: rgba(160,32,240,0.2);
  box-shadow: 0 0 12px rgba(160,32,240,0.4);
}

/* ── Profile section ───────────────────────────────────────────── */
.profile-section {
  width: 100%;
  background: rgba(0,0,0,0.35);
  border: 1.5px solid rgba(160,32,240,0.25);
  border-radius: 12px;
  padding: 14px 18px;
}

.profile-section-title {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin-bottom: 12px;
}

.profile-editor {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Avatar */
.avatar-wrap {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.15);
  transition: border-color 0.2s;
}
.avatar-wrap:hover { border-color: var(--cyan); }
.avatar-wrap:hover .avatar-overlay { opacity: 1; }

.avatar-large {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  color: var(--cyan);
  font-size: 22px;
  opacity: 0;
  transition: opacity 0.15s;
}

/* Profile fields */
.profile-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.name-input {
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 9px 13px;
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.05em;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.name-input::placeholder { color: rgba(255,255,255,0.25); font-weight: 400; }
.name-input:focus { border-color: var(--cyan); box-shadow: 0 0 10px rgba(0,245,255,0.2); }

/* Saved profiles */
.saved-profiles-label {
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--muted);
}

.saved-profiles-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.saved-thumb {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.15);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
.saved-thumb:hover { border-color: var(--cyan); transform: scale(1.1); box-shadow: 0 0 10px rgba(0,245,255,0.4); }
.saved-thumb.active { border-color: var(--cyan); box-shadow: 0 0 14px rgba(0,245,255,0.6); }

.btn-upload-new {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 2px dashed rgba(255,255,255,0.25);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.btn-upload-new:hover { border-color: var(--cyan); color: var(--cyan); }

/* ── Game overlays ─────────────────────────────────────────────── */
.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(4px);
}
.game-overlay.hidden { display: none; }

.overlay-card {
  background: var(--card-bg);
  border: 2px solid rgba(160,32,240,0.5);
  border-radius: 20px;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 0 60px rgba(160,32,240,0.3);
  text-align: center;
}

.overlay-icon {
  font-size: 52px;
  line-height: 1;
}

.overlay-title {
  font-size: clamp(22px, 4vw, 36px);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-shadow: 0 0 24px var(--cyan);
}

.overlay-btns {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-width: 240px;
}
