/* ============================================================
   GOLF 3D -- Complete Visual Overhaul
   Color Scheme:
     Primary  #4ade80  (green)
     Accent   #22d3ee  (cyan)
     Warning  #fbbf24  (gold)
     Error    #f87171  (red)
     Birdie   #60a5fa  (blue)
   ============================================================ */

/* ----- CSS Custom Properties ----- */
:root {
  --clr-primary: #4ade80;
  --clr-primary-dark: #22c55e;
  --clr-accent: #22d3ee;
  --clr-accent-dark: #0ea5e9;
  --clr-warning: #fbbf24;
  --clr-error: #f87171;
  --clr-birdie: #60a5fa;
  --clr-par: #e2e8f0;
  --clr-bogey: #f87171;

  --bg-deep: #0b0f1a;
  --bg-surface: rgba(15, 23, 42, 0.65);
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-blur: 18px;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --shadow-glow-green: 0 0 30px rgba(74, 222, 128, 0.25);
  --shadow-glow-cyan: 0 0 30px rgba(34, 211, 238, 0.25);

  --font-main: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --transition-fast: 0.18s ease;
  --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background: var(--bg-deep);
  color: #fff;
  overflow: hidden;
  line-height: 1.5;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input {
  font-family: inherit;
}

/* ============================================================
   KEYFRAME ANIMATIONS
   ============================================================ */

/* --- Background gradient shift --- */
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* --- Floating shapes --- */
@keyframes floatShape1 {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  25%      { transform: translate(80px, -120px) rotate(90deg) scale(1.1); }
  50%      { transform: translate(-40px, -200px) rotate(180deg) scale(0.95); }
  75%      { transform: translate(60px, -80px) rotate(270deg) scale(1.05); }
}

@keyframes floatShape2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33%      { transform: translate(-100px, -150px) rotate(120deg); }
  66%      { transform: translate(50px, -250px) rotate(240deg); }
}

@keyframes floatShape3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(120px, -180px) scale(1.15); }
}

/* --- Golf ball spin --- */
@keyframes golfBallSpin {
  0%   { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes golfBallFloat {
  0%, 100% { top: 55%; }
  50%      { top: 45%; }
}

/* --- Entrance animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* --- Pulsing indicator --- */
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  50%      { box-shadow: 0 0 0 12px rgba(74, 222, 128, 0); }
}

@keyframes pulseText {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

/* --- Power bar glow --- */
@keyframes powerGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(74, 222, 128, 0.3), inset 0 0 6px rgba(74, 222, 128, 0.1); }
  50%      { box-shadow: 0 0 22px rgba(74, 222, 128, 0.6), inset 0 0 12px rgba(74, 222, 128, 0.2); }
}

/* --- Score flash --- */
@keyframes scoreFlash {
  0%   { background: rgba(74, 222, 128, 0.4); }
  100% { background: transparent; }
}

/* --- Spin loader --- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Shimmer --- */
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* --- Slide panel in from right --- */
@keyframes slideInPanel {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* --- Particle drift --- */
@keyframes particleDrift1 {
  0%   { transform: translate(0, 0); opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.6; }
  100% { transform: translate(250px, -600px); opacity: 0; }
}

@keyframes particleDrift2 {
  0%   { transform: translate(0, 0); opacity: 0; }
  10%  { opacity: 0.4; }
  90%  { opacity: 0.4; }
  100% { transform: translate(-180px, -550px); opacity: 0; }
}

@keyframes particleDrift3 {
  0%   { transform: translate(0, 0); opacity: 0; }
  10%  { opacity: 0.5; }
  90%  { opacity: 0.5; }
  100% { transform: translate(100px, -700px); opacity: 0; }
}

@keyframes particleDrift4 {
  0%   { transform: translate(0, 0); opacity: 0; }
  15%  { opacity: 0.35; }
  85%  { opacity: 0.35; }
  100% { transform: translate(-220px, -500px); opacity: 0; }
}

@keyframes emotePopIn {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  60%  { transform: scale(1.15) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}


/* ============================================================
   LOADING SCREEN
   ============================================================ */

#loadingScreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(-45deg, #0b0f1a, #0f2027, #132a13, #0b1a2e);
  background-size: 400% 400%;
  animation: gradientShift 18s ease infinite;
  transition: opacity 0.6s ease;
}

#loadingScreen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  animation: fadeInUp 0.8s ease both;
}

.loading-ball {
  width: 64px;
  height: 64px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, #e0e0e0 50%, #c0c0c0 70%, #a0a0a0);
  box-shadow:
    inset -8px -8px 16px rgba(0, 0, 0, 0.15),
    0 4px 20px rgba(74, 222, 128, 0.3),
    0 0 40px rgba(74, 222, 128, 0.15);
  animation: golfBallFloat 2s ease-in-out infinite, golfBallSpin 3s linear infinite;
  position: relative;
}

.loading-ball::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(180, 180, 180, 0.5);
  border-radius: 50%;
  top: 20%;
  left: 45%;
  box-shadow:
    8px 6px 0 rgba(180, 180, 180, 0.4),
    -4px 10px 0 rgba(180, 180, 180, 0.35),
    6px 16px 0 rgba(180, 180, 180, 0.3),
    -6px 22px 0 rgba(180, 180, 180, 0.25),
    10px 12px 0 rgba(180, 180, 180, 0.3);
}

.loading-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 28px;
}

.loading-bar-container {
  width: 220px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  margin: 0 auto 20px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--clr-primary), var(--clr-accent));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.loading-tip {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.45);
  max-width: 280px;
  margin: 0 auto;
  min-height: 2.6em;
  transition: opacity 0.3s ease;
}

/* ============================================================
   HOLE TRANSITION OVERLAY
   ============================================================ */

#holeTransitionOverlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

#holeTransitionOverlay.active {
  opacity: 1;
  pointer-events: auto;
}

#holeTransitionOverlay .hole-info-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s ease 0.3s;
}

#holeTransitionOverlay.active .hole-info-card {
  opacity: 1;
}

.hole-info-card h2 {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.hole-info-card p {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.7);
}

/* ============================================================
   LOBBY SCREEN
   ============================================================ */

#lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  position: relative;
  overflow: hidden;

  /* Animated gradient background */
  background: linear-gradient(
    -45deg,
    #0b0f1a,
    #0f2027,
    #132a13,
    #0b1a2e,
    #1a0b2e
  );
  background-size: 400% 400%;
  animation: gradientShift 18s ease infinite;
}

/* --- Floating CSS shapes / particles --- */
#lobby::before,
#lobby::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

#lobby::before {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(74, 222, 128, 0.08) 0%, transparent 70%);
  top: 10%;
  left: -5%;
  animation: floatShape1 20s ease-in-out infinite;
}

#lobby::after {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.07) 0%, transparent 70%);
  bottom: 5%;
  right: -3%;
  animation: floatShape2 25s ease-in-out infinite;
}

/* Extra floating shapes via lobby background shapes container */
.lobby-bg-shapes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.lobby-bg-shapes .shape {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
}

.lobby-bg-shapes .shape:nth-child(1) {
  width: 12px;
  height: 12px;
  background: var(--clr-primary);
  bottom: 15%;
  left: 20%;
  animation: particleDrift1 12s linear infinite;
}

.lobby-bg-shapes .shape:nth-child(2) {
  width: 8px;
  height: 8px;
  background: var(--clr-accent);
  bottom: 10%;
  left: 50%;
  animation: particleDrift2 15s linear infinite 2s;
}

.lobby-bg-shapes .shape:nth-child(3) {
  width: 10px;
  height: 10px;
  background: var(--clr-warning);
  bottom: 20%;
  left: 75%;
  animation: particleDrift3 10s linear infinite 4s;
}

.lobby-bg-shapes .shape:nth-child(4) {
  width: 6px;
  height: 6px;
  background: var(--clr-primary);
  bottom: 5%;
  left: 35%;
  animation: particleDrift4 18s linear infinite 1s;
}

.lobby-bg-shapes .shape:nth-child(5) {
  width: 14px;
  height: 14px;
  background: var(--clr-accent);
  bottom: 8%;
  left: 60%;
  animation: particleDrift1 14s linear infinite 6s;
}

.lobby-bg-shapes .shape:nth-child(6) {
  width: 5px;
  height: 5px;
  background: var(--clr-primary);
  bottom: 12%;
  left: 85%;
  animation: particleDrift3 16s linear infinite 3s;
}

/* Large decorative shape */
.lobby-bg-shapes .shape-diamond {
  position: absolute;
  width: 200px;
  height: 200px;
  border: 1px solid rgba(74, 222, 128, 0.06);
  border-radius: 30px;
  top: 15%;
  right: 10%;
  transform: rotate(45deg);
  animation: floatShape3 22s ease-in-out infinite;
}

.lobby-bg-shapes .shape-ring {
  position: absolute;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(34, 211, 238, 0.05);
  border-radius: 50%;
  bottom: 20%;
  left: 8%;
  animation: floatShape2 28s ease-in-out infinite;
}

/* --- Golf ball SVG decoration --- */
.lobby-golf-ball {
  position: absolute;
  width: 220px;
  height: 220px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.035;
  z-index: 0;
  pointer-events: none;
  animation: golfBallFloat 6s ease-in-out infinite;
}

.lobby-golf-ball svg {
  width: 100%;
  height: 100%;
  animation: golfBallSpin 30s linear infinite;
}

/* --- Glass-morphism lobby card --- */
.lobby-container {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 48px 44px 40px;
  min-width: 420px;
  max-width: 480px;
  width: 90vw;

  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));

  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.4),
    0 0 80px rgba(74, 222, 128, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);

  animation: fadeInUp 0.8s var(--transition-base) both;
}

.lobby-container h1 {
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
  animation: fadeInUp 0.8s var(--transition-base) 0.15s both;
}

.subtitle {
  color: #94a3b8;
  margin-bottom: 28px;
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.5px;
  animation: fadeInUp 0.8s var(--transition-base) 0.25s both;
}

/* --- Mode selector tabs: Solo vs IA / Multijoueur --- */
.mode-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.25);
  animation: fadeInUp 0.8s var(--transition-base) 0.3s both;
}

.mode-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: all var(--transition-base);
  position: relative;
}

.mode-tab:hover {
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.03);
}

.mode-tab.active {
  color: #fff;
  background: rgba(74, 222, 128, 0.12);
}

.mode-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  width: 80%;
  height: 2px;
  background: linear-gradient(90deg, var(--clr-primary), var(--clr-accent));
  border-radius: 2px;
}

/* --- Difficulty selector (AI mode) --- */
.difficulty-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
  animation: fadeInUp 0.8s var(--transition-base) 0.35s both;
}

.diff-btn {
  flex: 1;
  padding: 10px 8px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: all var(--transition-base);
}

.diff-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.04);
}

.diff-btn.active {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
  background: rgba(74, 222, 128, 0.08);
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.12);
}

.diff-btn.diff-easy.active {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
  background: rgba(74, 222, 128, 0.08);
}

.diff-btn.diff-medium.active {
  border-color: var(--clr-warning);
  color: var(--clr-warning);
  background: rgba(251, 191, 36, 0.08);
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.12);
}

.diff-btn.diff-hard.active {
  border-color: var(--clr-error);
  color: var(--clr-error);
  background: rgba(248, 113, 113, 0.08);
  box-shadow: 0 0 16px rgba(248, 113, 113, 0.12);
}

/* --- Floating label input groups --- */
.input-group {
  position: relative;
  margin-bottom: 22px;
  animation: fadeInUp 0.8s var(--transition-base) 0.35s both;
}

.input-group input {
  width: 100%;
  padding: 16px 18px 8px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.input-group input:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12);
}

.input-group label {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 0.95rem;
  pointer-events: none;
  transition: all var(--transition-fast);
}

.input-group input:focus ~ label,
.input-group input:not(:placeholder-shown) ~ label {
  top: 10px;
  transform: translateY(0);
  font-size: 0.7rem;
  color: var(--clr-primary);
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Keep original form inputs styled too (backward compat) */
#lobbyForm input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  margin-bottom: 20px;
}

#lobbyForm input:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12);
}

#lobbyForm input::placeholder {
  color: #64748b;
}

/* --- Lobby buttons --- */
.lobby-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeInUp 0.8s var(--transition-base) 0.45s both;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-base), background var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

.btn:hover::after {
  transform: translateX(100%);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-primary-dark));
  color: #0b0f1a;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-green);
}

.btn-secondary {
  background: linear-gradient(135deg, #38bdf8, var(--clr-accent-dark));
  color: #0b0f1a;
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-cyan);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: #94a3b8;
}

.btn-outline:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
  background: rgba(74, 222, 128, 0.06);
}

/* Legacy button IDs */
#createBtn,
#joinBtn {
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-base);
  position: relative;
  overflow: hidden;
}

#createBtn {
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-primary-dark));
  color: #0b0f1a;
  width: 100%;
}

#createBtn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-green);
}

#joinBtn {
  background: linear-gradient(135deg, #38bdf8, var(--clr-accent-dark));
  color: #0b0f1a;
  flex-shrink: 0;
}

#joinBtn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-cyan);
}

.separator {
  color: #475569;
  font-size: 0.85rem;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.separator::before,
.separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}

.join-row {
  display: flex;
  gap: 10px;
}

.join-row input {
  flex: 1;
  margin-bottom: 0 !important;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 4px;
  font-weight: 700;
  font-family: var(--font-mono);
}

/* --- Room Browser --- */
.room-browser {
  margin-top: 4px;
}

.room-browser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.room-browser-header span {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.refresh-btn {
  background: none;
  border: 1px solid var(--glass-border);
  color: rgba(255, 255, 255, 0.5);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.refresh-btn:hover {
  color: var(--clr-primary);
  border-color: var(--clr-primary);
}

.room-list {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.room-empty {
  text-align: center;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.35);
  padding: 12px 0;
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.room-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--clr-primary);
}

.room-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.room-item-host {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.room-item-status {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.4);
}

.room-join-btn {
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--clr-primary);
  background: transparent;
  color: var(--clr-primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.room-join-btn:hover {
  background: var(--clr-primary);
  color: #000;
}

/* --- Waiting state --- */
#waitingDiv {
  padding: 24px 0;
  animation: fadeIn 0.5s var(--transition-base) both;
}

#roomCodeDisplay {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 10px;
  font-family: var(--font-mono);
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 15px 0;
  user-select: all;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

#roomCodeDisplay:hover {
  transform: scale(1.05);
}

.waiting-text {
  color: #94a3b8;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.loader {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--clr-primary);
  border-right-color: var(--clr-accent);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.9s linear infinite;
}

#lobbyError {
  color: var(--clr-error);
  margin-top: 16px;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.15);
  animation: fadeIn 0.3s ease both;
}


/* ============================================================
   GAME SCREEN
   ============================================================ */

#game {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Allow pointer events on interactive HUD children */
#hud > * {
  pointer-events: auto;
}


/* ============================================================
   POWER BAR -- Wider, gradient glow, tick marks
   ============================================================ */

#powerBarContainer {
  position: absolute;
  left: 36px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: slideInLeft 0.6s var(--transition-base) both;
  pointer-events: none;
}

#powerBarBg {
  width: 36px;
  height: 280px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 18px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: box-shadow var(--transition-base);
}

/* Tick marks at 25%, 50%, 75%, 100% */
#powerBarBg::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(to right, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.2) 35%, transparent 35%) 0 0% / 100% 1px no-repeat,
    linear-gradient(to right, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0.25) 50%, transparent 50%) 0 25% / 100% 1.5px no-repeat,
    linear-gradient(to right, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.3) 60%, transparent 60%) 0 50% / 100% 2px no-repeat,
    linear-gradient(to right, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0.25) 50%, transparent 50%) 0 75% / 100% 1.5px no-repeat;
}

/* Tick labels */
.power-ticks {
  position: absolute;
  left: calc(100% + 8px);
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.power-tick {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.35);
  font-weight: 600;
  font-family: var(--font-mono);
  line-height: 1;
}

#powerBarFill {
  width: 100%;
  height: 0%;
  border-radius: 16px;
  background: linear-gradient(to top, var(--clr-primary), #facc15 50%, var(--clr-error));
  transition: height 0.05s linear, background-color 0.1s;
  position: relative;
  z-index: 1;
}

/* Glow when actively charging */
#powerBarContainer.charging #powerBarBg {
  animation: powerGlow 0.8s ease-in-out infinite;
  border-color: rgba(74, 222, 128, 0.4);
}

#powerBarContainer.charging #powerBarFill {
  box-shadow: 0 0 15px rgba(74, 222, 128, 0.4);
}

#powerLabel {
  font-size: 0.6rem;
  letter-spacing: 2.5px;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 700;
  text-transform: uppercase;
}

/* Power percentage readout */
.power-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--clr-primary);
  font-family: var(--font-mono);
  min-width: 36px;
  text-align: center;
}


/* ============================================================
   CLUB SELECTOR -- Horizontal bottom bar
   ============================================================ */

#clubSelector {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  pointer-events: auto;
  animation: fadeInUp 0.5s var(--transition-base) 0.2s both;
}

.club-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: all var(--transition-base);
  min-width: 72px;
}

.club-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
}

.club-item.active {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.3);
  color: var(--clr-primary);
  box-shadow: 0 0 20px rgba(74, 222, 128, 0.15);
}

.club-icon {
  font-size: 1.4rem;
  line-height: 1;
  transition: transform var(--transition-fast);
}

.club-item.active .club-icon {
  transform: scale(1.15);
}

.club-name {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.club-distance {
  font-size: 0.58rem;
  color: #64748b;
  font-family: var(--font-mono);
}

.club-item.active .club-distance {
  color: rgba(74, 222, 128, 0.7);
}


/* ============================================================
   TURN INDICATOR
   ============================================================ */

#turnInfo {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 28px;
  border-radius: var(--radius-lg);
  text-align: center;
  font-size: 0.9rem;
  border: 1px solid var(--glass-border);
  transition: all var(--transition-base);
  animation: fadeInUp 0.5s var(--transition-base) both;
  pointer-events: none;
}

/* Pulse when it is your turn */
#turnInfo.my-turn {
  border-color: rgba(74, 222, 128, 0.35);
  animation: pulse 2s ease-in-out infinite, fadeInUp 0.5s var(--transition-base) both;
  background: rgba(0, 0, 0, 0.6);
}

#turnInfo.my-turn .player-name {
  animation: pulseText 2s ease-in-out infinite;
}

/* Subtle when watching other player */
#turnInfo.watching {
  opacity: 0.7;
  border-color: rgba(255, 255, 255, 0.06);
}

#turnInfo .player-name {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--clr-primary);
  display: block;
}

#turnInfo .hole-info {
  color: #94a3b8;
  font-size: 0.78rem;
  margin-top: 2px;
}

#turnInfo .stroke-count {
  color: #64748b;
  font-size: 0.72rem;
  font-family: var(--font-mono);
}


/* ============================================================
   SCOREBOARD -- Glass-morphism, color coded
   ============================================================ */

#scoreBoard {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  font-size: 0.82rem;
  min-width: 200px;
  animation: slideInRight 0.5s var(--transition-base) 0.1s both;
  pointer-events: auto;
  transition: all var(--transition-base);
}

#scoreBoard:hover {
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 255, 255, 0.18);
}

.scoreboard-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 8px;
  text-align: center;
}

#scoreBoard table {
  width: 100%;
  border-collapse: collapse;
}

#scoreBoard th,
#scoreBoard td {
  padding: 5px 10px;
  text-align: center;
}

#scoreBoard th {
  color: #64748b;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

#scoreBoard td {
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

#scoreBoard .player-col {
  text-align: left;
  font-family: var(--font-main);
}

#scoreBoard .current {
  color: var(--clr-primary);
  font-weight: 700;
}

/* Score color coding */
#scoreBoard .score-birdie {
  color: var(--clr-birdie);
  font-weight: 700;
}

#scoreBoard .score-par {
  color: var(--clr-par);
}

#scoreBoard .score-bogey {
  color: var(--clr-bogey);
  font-weight: 600;
}

#scoreBoard .score-eagle {
  color: #a78bfa;
  font-weight: 700;
}

/* Score change flash */
#scoreBoard td.score-changed {
  animation: scoreFlash 0.8s ease both;
}

/* Row highlighting */
#scoreBoard tr.active-player td {
  background: rgba(74, 222, 128, 0.06);
}

#scoreBoard tbody tr {
  transition: background var(--transition-fast);
}

#scoreBoard tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}


/* ============================================================
   WIND INDICATOR
   ============================================================ */

#windIndicator {
  position: absolute;
  bottom: 100px;
  right: 20px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  text-align: center;
  min-width: 88px;
  animation: slideInRight 0.5s var(--transition-base) 0.2s both;
  transition: all var(--transition-base);
}

.wind-label {
  font-size: 0.65rem;
  color: #64748b;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
}

.wind-arrow {
  font-size: 2rem;
  line-height: 1;
  color: var(--clr-accent);
  display: inline-block;
  transition: transform 0.5s ease;
  filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.3));
}

.wind-speed {
  font-size: 0.82rem;
  color: #e2e8f0;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-weight: 600;
}


/* ============================================================
   HOLE INFO
   ============================================================ */

#holeInfo {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  pointer-events: none;
}

.hole-par {
  color: var(--clr-primary);
  font-weight: 700;
}

.hole-distance {
  font-family: var(--font-mono);
  color: var(--clr-accent);
}


/* ============================================================
   INSTRUCTIONS
   ============================================================ */

#instructions {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 8px 22px;
  border-radius: var(--radius-md);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: opacity var(--transition-base);
  pointer-events: none;
}

#instructions kbd {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  margin: 0 2px;
  color: rgba(255, 255, 255, 0.6);
}


/* ============================================================
   MINIMAP
   ============================================================ */

#minimapContainer {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 180px;
  height: 180px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: slideInLeft 0.5s var(--transition-base) 0.3s both;
  pointer-events: auto;
  transition: all var(--transition-base);
}

#minimapContainer:hover {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

#minimapContainer canvas,
#minimapContainer .minimap-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.minimap-label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  pointer-events: none;
}


/* ============================================================
   MESSAGE OVERLAY -- Scale-in animation
   ============================================================ */

#messageOverlay {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: 2.4rem;
  font-weight: 800;
  color: #fff;
  text-shadow:
    0 0 30px rgba(0, 0, 0, 0.9),
    0 0 60px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.6);
  text-align: center;
  display: none;
  pointer-events: none;
  z-index: 100;
  letter-spacing: 1px;
}

#messageOverlay.visible {
  display: block;
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#messageOverlay.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* Message variants */
#messageOverlay.msg-birdie {
  color: var(--clr-birdie);
  text-shadow: 0 0 40px rgba(96, 165, 250, 0.5), 0 4px 12px rgba(0,0,0,0.6);
}

#messageOverlay.msg-eagle {
  color: #a78bfa;
  text-shadow: 0 0 40px rgba(167, 139, 250, 0.5), 0 4px 12px rgba(0,0,0,0.6);
}

#messageOverlay.msg-bogey {
  color: var(--clr-error);
  text-shadow: 0 0 40px rgba(248, 113, 113, 0.3), 0 4px 12px rgba(0,0,0,0.6);
}

#messageOverlay.msg-hole-in-one {
  background: linear-gradient(135deg, var(--clr-warning), #f59e0b);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 30px rgba(251, 191, 36, 0.5));
  font-size: 3rem;
}


/* ============================================================
   FINAL SCORES PANEL
   ============================================================ */

#finalScores {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 15, 30, 0.9);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 44px 52px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(74, 222, 128, 0.2);
  text-align: center;
  z-index: 200;
  pointer-events: auto;
  min-width: 340px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 100px rgba(74, 222, 128, 0.06);
  animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#finalScores h2 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#finalScores .score-line {
  font-size: 1.15rem;
  margin: 12px 0;
  color: #e2e8f0;
  font-family: var(--font-mono);
}

#finalScores .winner {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--clr-warning);
  margin: 24px 0;
  text-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
}

#finalScores .trophy {
  font-size: 3rem;
  display: block;
  margin-bottom: 10px;
}

#finalScores button {
  padding: 14px 36px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-primary-dark));
  color: #0b0f1a;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 16px;
  transition: transform var(--transition-fast), box-shadow var(--transition-base);
  pointer-events: auto;
}

#finalScores button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-green);
}


/* ============================================================
   CHAT PANEL -- Right side slide-out
   ============================================================ */

#chatPanel {
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  height: 100%;
  background: rgba(10, 15, 30, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: 150;
  pointer-events: auto;
  animation: slideInPanel 0.4s var(--transition-base) both;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.3);
}

#chatPanel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #94a3b8;
  text-transform: uppercase;
}

.chat-close-btn {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.chat-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.chat-message {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.82rem;
  line-height: 1.45;
  animation: fadeIn 0.3s ease both;
}

.chat-message .msg-author {
  font-weight: 700;
  font-size: 0.75rem;
  margin-bottom: 2px;
  display: block;
}

.chat-message .msg-author.player-1 {
  color: var(--clr-primary);
}

.chat-message .msg-author.player-2 {
  color: var(--clr-accent);
}

.chat-message .msg-author.player-3 {
  color: var(--clr-warning);
}

.chat-message .msg-author.player-4 {
  color: #c084fc;
}

.chat-message .msg-text {
  color: #cbd5e1;
}

.chat-message.system-msg {
  color: #64748b;
  font-style: italic;
  font-size: 0.75rem;
  background: none;
  padding: 4px 0;
}

/* --- Quick emote buttons --- */
.chat-emotes {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  flex-wrap: wrap;
}

.emote-btn {
  flex: 1;
  min-width: 42px;
  padding: 8px 4px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  color: #e2e8f0;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.emote-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  transform: scale(1.08);
}

.emote-btn:active {
  transform: scale(0.95);
}

/* Emote pop-in animation above player */
.emote-bubble {
  position: absolute;
  font-size: 2rem;
  animation: emotePopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  pointer-events: none;
  z-index: 120;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}

/* --- Chat input --- */
.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 0.82rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.chat-input-row input:focus {
  border-color: var(--clr-primary);
}

.chat-input-row input::placeholder {
  color: #475569;
}

.chat-send-btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--clr-primary);
  color: #0b0f1a;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chat-send-btn:hover {
  background: var(--clr-primary-dark);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.3);
}

/* --- Chat toggle button (when panel is closed) --- */
.chat-toggle-btn {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  color: #94a3b8;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transition: all var(--transition-base);
  z-index: 140;
}

.chat-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border-color: var(--clr-primary);
}

.chat-toggle-btn .unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--clr-error);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
}

.text-gradient {
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Hide / show */
.hidden {
  display: none !important;
}

.invisible {
  visibility: hidden;
  pointer-events: none;
}

/* Animate entrance classes for JS use */
.anim-fade-in     { animation: fadeIn 0.4s ease both; }
.anim-fade-in-up  { animation: fadeInUp 0.5s var(--transition-base) both; }
.anim-slide-left  { animation: slideInLeft 0.5s var(--transition-base) both; }
.anim-slide-right { animation: slideInRight 0.5s var(--transition-base) both; }
.anim-scale-in    { animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }


/* ============================================================
   NOTIFICATIONS / TOASTS
   ============================================================ */

.toast-container {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}

.toast {
  padding: 12px 24px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  animation: fadeInUp 0.35s ease both;
  pointer-events: auto;
}

.toast.toast-success {
  border-color: rgba(74, 222, 128, 0.3);
  color: var(--clr-primary);
}

.toast.toast-error {
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--clr-error);
}


/* ============================================================
   LOADING / TRANSITION SCREEN
   ============================================================ */

.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: 1000;
}

.loading-screen .loading-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 2px;
}

.loading-bar {
  width: 200px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--clr-primary), var(--clr-accent));
  transition: width 0.3s ease;
}

.loading-shimmer {
  width: 200px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.03) 25%,
    rgba(74,222,128,0.2) 50%,
    rgba(255,255,255,0.03) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s linear infinite;
}


/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */

/* --- Tablets and small laptops (768px - 1024px) --- */
@media (max-width: 1024px) {
  .lobby-container {
    min-width: 360px;
    padding: 36px 32px 32px;
  }

  .lobby-container h1 {
    font-size: 2.6rem;
  }

  #powerBarBg {
    height: 220px;
    width: 30px;
  }

  #clubSelector {
    gap: 4px;
    padding: 6px 10px;
  }

  .club-item {
    padding: 8px 12px;
    min-width: 60px;
  }

  .club-icon {
    font-size: 1.2rem;
  }

  .club-name {
    font-size: 0.58rem;
  }

  #chatPanel {
    width: 280px;
  }

  #minimapContainer {
    width: 150px;
    height: 150px;
  }

  #scoreBoard {
    font-size: 0.75rem;
    min-width: 170px;
  }
}

/* --- Mobile landscape / small tablets (768px) --- */
@media (max-width: 768px) {
  .lobby-container {
    min-width: 0;
    max-width: 95vw;
    padding: 28px 24px 24px;
  }

  .lobby-container h1 {
    font-size: 2.2rem;
  }

  .subtitle {
    font-size: 0.95rem;
    margin-bottom: 20px;
  }

  .mode-tabs {
    margin-bottom: 18px;
  }

  .mode-tab {
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  .difficulty-selector {
    gap: 8px;
    margin-bottom: 18px;
  }

  .diff-btn {
    padding: 8px 6px;
    font-size: 0.75rem;
  }

  #powerBarContainer {
    left: 14px;
  }

  #powerBarBg {
    height: 180px;
    width: 26px;
  }

  #clubSelector {
    bottom: 16px;
    gap: 2px;
    padding: 5px 8px;
  }

  .club-item {
    padding: 6px 10px;
    min-width: 52px;
  }

  .club-icon {
    font-size: 1rem;
  }

  .club-name {
    font-size: 0.52rem;
  }

  .club-distance {
    display: none;
  }

  #turnInfo {
    top: 12px;
    padding: 8px 18px;
    font-size: 0.8rem;
  }

  #turnInfo .player-name {
    font-size: 0.95rem;
  }

  #scoreBoard {
    top: 12px;
    right: 12px;
    padding: 10px 12px;
    font-size: 0.7rem;
    min-width: 140px;
  }

  #windIndicator {
    bottom: 80px;
    right: 12px;
    padding: 10px 14px;
    min-width: 70px;
  }

  .wind-arrow {
    font-size: 1.5rem;
  }

  #minimapContainer {
    width: 120px;
    height: 120px;
    bottom: 12px;
    left: 12px;
  }

  #chatPanel {
    width: 100%;
    max-width: 320px;
  }

  #holeInfo {
    bottom: 70px;
    font-size: 0.75rem;
    padding: 6px 16px;
  }

  #instructions {
    bottom: 4px;
    font-size: 0.65rem;
    padding: 5px 14px;
  }

  #messageOverlay {
    font-size: 1.8rem;
  }

  #finalScores {
    padding: 30px 28px;
    min-width: 280px;
    max-width: 92vw;
  }

  #finalScores h2 {
    font-size: 1.7rem;
  }
}

/* --- Large screens / 2K+ --- */
@media (min-width: 1600px) {
  .lobby-container {
    min-width: 460px;
    max-width: 520px;
    padding: 56px 52px 48px;
  }

  .lobby-container h1 {
    font-size: 3.6rem;
  }

  #powerBarBg {
    width: 40px;
    height: 320px;
  }

  #clubSelector {
    gap: 8px;
    padding: 10px 16px;
  }

  .club-item {
    padding: 12px 22px;
    min-width: 84px;
  }

  #minimapContainer {
    width: 200px;
    height: 200px;
  }

  #scoreBoard {
    min-width: 240px;
    font-size: 0.88rem;
    padding: 18px 22px;
  }
}

/* --- 4K displays --- */
@media (min-width: 2560px) {
  :root {
    font-size: 18px;
  }

  .lobby-container {
    min-width: 520px;
    max-width: 600px;
    padding: 64px 60px 56px;
  }

  .lobby-container h1 {
    font-size: 4rem;
  }

  #powerBarBg {
    width: 48px;
    height: 380px;
    border-radius: 24px;
  }

  #clubSelector {
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius-xl);
  }

  .club-item {
    padding: 14px 26px;
    min-width: 96px;
  }

  #minimapContainer {
    width: 240px;
    height: 240px;
  }

  #scoreBoard {
    min-width: 280px;
    padding: 22px 26px;
    border-radius: var(--radius-xl);
  }

  #turnInfo {
    padding: 16px 36px;
    border-radius: var(--radius-xl);
  }

  #chatPanel {
    width: 400px;
  }
}

/* ============================================================
   SPIN WIDGET
   ============================================================ */

.spin-widget {
  position: fixed;
  left: 80px;
  bottom: 120px;
  z-index: 500;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0.8;
  transition: opacity var(--transition-fast);
}

.spin-widget:hover {
  opacity: 1;
}

.spin-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.spin-bar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.spin-end-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.3);
  width: 16px;
  text-align: center;
}

.spin-bar {
  width: 12px;
  height: 80px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.spin-center {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.3);
}

.spin-fill {
  position: absolute;
  left: 1px;
  right: 1px;
  background: var(--clr-primary);
  border-radius: 4px;
  transition: all 0.15s ease;
}

.spin-value-label {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.5);
}

/* ============================================================
   SETTINGS PANEL
   ============================================================ */

.settings-gear-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 700;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.settings-gear-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--clr-primary);
  transform: rotate(45deg);
}

.settings-panel {
  position: fixed;
  top: 66px;
  right: 16px;
  z-index: 700;
  width: 280px;
  background: var(--glass-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: fadeInUp 0.25s ease both;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--glass-border);
}

.settings-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--clr-primary);
  letter-spacing: 0.04em;
}

.settings-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition-fast);
}

.settings-close-btn:hover {
  color: var(--clr-error);
}

.settings-body {
  padding: 12px 18px 18px;
}

.settings-section {
  margin-bottom: 16px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.settings-select {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
}

.settings-select:focus {
  border-color: var(--clr-primary);
}

.settings-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  cursor: pointer;
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--clr-primary);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}

.settings-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--clr-primary);
  cursor: pointer;
  border: none;
}

.settings-slider-value {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.6);
  min-width: 38px;
  text-align: right;
}

.settings-mute-btn {
  width: 100%;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.settings-mute-btn:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

/* --- Preference: reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  #lobby {
    animation: none;
    background-size: 100% 100%;
  }
}

/* --- Preference: high contrast --- */
@media (prefers-contrast: high) {
  :root {
    --glass-bg: rgba(0, 0, 0, 0.8);
    --glass-border: rgba(255, 255, 255, 0.3);
  }

  #scoreBoard,
  #turnInfo,
  #windIndicator,
  #clubSelector {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
  }
}

/* ── Practice Mode Controls ──────────────── */
#practiceControls {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 20;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 8px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.practice-btn {
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-primary-dark));
  color: #0b0f1a;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.practice-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-green);
}

.practice-back {
  background: linear-gradient(135deg, var(--clr-error), #b91c1c);
  color: #fff;
}

.practice-back:hover {
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.3);
}

.practice-select {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border: 1px solid var(--glass-border);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
}

.practice-select:focus {
  border-color: var(--clr-primary);
}

.practice-select option {
  background: #1e293b;
  color: #e2e8f0;
}

/* ── Leaderboard Panel ───────────────────── */
.leaderboard-toggle-btn {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 25;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #e2e8f0;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.leaderboard-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

.leaderboard-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  width: min(440px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  animation: fadeInUp 0.25s ease both;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--glass-border);
}

.leaderboard-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--clr-warning);
  letter-spacing: 0.04em;
}

.leaderboard-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition-fast);
}

.leaderboard-close-btn:hover {
  color: var(--clr-error);
}

.leaderboard-body {
  padding: 12px 18px 18px;
  overflow-y: auto;
  max-height: 60vh;
}

.leaderboard-empty {
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  padding: 20px 0;
  font-size: 0.85rem;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.leaderboard-table th {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.leaderboard-table td {
  padding: 8px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
}

.leaderboard-top td {
  color: var(--clr-warning);
  font-weight: 600;
}

.par-under { color: var(--clr-primary) !important; }
.par-even { color: #94a3b8 !important; }
.par-over { color: var(--clr-error) !important; }

/* ── Stats Panel ─────────────────────────── */
.stats-toggle-btn {
  position: fixed;
  top: 108px;
  right: 16px;
  z-index: 25;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #e2e8f0;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stats-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

.stats-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  width: min(380px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  animation: fadeInUp 0.25s ease both;
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--glass-border);
}

.stats-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--clr-accent);
  letter-spacing: 0.04em;
}

.stats-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition-fast);
}

.stats-close-btn:hover {
  color: var(--clr-error);
}

.stats-body {
  padding: 12px 18px 18px;
  overflow-y: auto;
  max-height: 60vh;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-row:last-child {
  border-bottom: none;
}

.stats-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.82rem;
}

.stats-value {
  color: #e2e8f0;
  font-weight: 700;
  font-size: 0.9rem;
}

.stats-highlight .stats-value {
  color: var(--clr-warning);
}

/* ── Lobby Leaderboard & Stats Buttons ───── */
.lobby-extras {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: center;
}

.lobby-extras button {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: #94a3b8;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.lobby-extras button:hover {
  color: #e2e8f0;
  border-color: var(--clr-primary);
}

/* ============================================================
   TUTORIAL GUIDE
   ============================================================ */

@keyframes tutorialFadeIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes tutorialPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.3); }
  50%      { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0.15), 0 0 30px rgba(74, 222, 128, 0.1); }
}

@keyframes tutorialOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes tutorialOverlayOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: tutorialOverlayIn 0.4s ease both;
}

.tutorial-overlay.tutorial-exiting {
  animation: tutorialOverlayOut 0.4s ease both;
  pointer-events: none;
}

.tutorial-highlight {
  position: fixed;
  border: 2px solid var(--clr-primary);
  animation: tutorialPulse 2s ease-in-out infinite;
  pointer-events: none;
  z-index: 100001;
  display: none;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.tutorial-tooltip {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 100002;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: var(--radius-lg);
  padding: 28px 32px 20px;
  max-width: 400px;
  width: 90vw;
  box-shadow:
    0 0 40px rgba(74, 222, 128, 0.1),
    0 20px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.tutorial-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: #64748b;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.tutorial-close:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
}

.tutorial-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.tutorial-icon svg {
  filter: drop-shadow(0 0 8px rgba(74, 222, 128, 0.3));
}

.tutorial-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f1f5f9;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.tutorial-text {
  font-size: 0.88rem;
  color: #94a3b8;
  text-align: center;
  line-height: 1.6;
  margin-bottom: 14px;
}

.tutorial-anim {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.tutorial-anim-canvas {
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.tutorial-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.tutorial-btn {
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.25);
  color: var(--clr-primary);
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 100px;
}

.tutorial-btn:hover {
  background: rgba(74, 222, 128, 0.22);
  border-color: var(--clr-primary);
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.15);
}

.tutorial-next {
  background: var(--clr-primary);
  color: #0b0f1a;
  border-color: var(--clr-primary);
}

.tutorial-next:hover {
  background: var(--clr-primary-dark);
  border-color: var(--clr-primary-dark);
  box-shadow: 0 0 20px rgba(74, 222, 128, 0.3);
}

.tutorial-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.tutorial-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: all 0.3s ease;
}

.tutorial-dot.active {
  background: var(--clr-primary);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
  transform: scale(1.3);
}

.tutorial-dot.done {
  background: rgba(74, 222, 128, 0.4);
}

.tutorial-skip {
  display: block;
  margin: 0 auto;
  background: none;
  border: none;
  color: #475569;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 8px;
  transition: color var(--transition-fast);
}

.tutorial-skip:hover {
  color: #94a3b8;
}

/* Responsive adjustments for tooltip positioning with targets */
.tutorial-tooltip.pos-center {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Small screens: always center */
@media (max-width: 768px) {
  .tutorial-tooltip {
    max-width: calc(100vw - 32px);
    padding: 22px 20px 16px;
  }

  .tutorial-tooltip.pos-right,
  .tutorial-tooltip.pos-left,
  .tutorial-tooltip.pos-top,
  .tutorial-tooltip.pos-bottom {
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
  }
}
