/* ============================================================
   SquadPad - Game Controller Theme
   Palette inspired by BombSquad bomb: golden yellow, iridescent
   purple-violet, teal-cyan, warm pink, deep indigo background.
   ============================================================ */

/* --- Palette Variables --- */
:root {
  --bg-deep:       #0d0b1a;
  --bg-card:       rgba(255,255,255,0.04);
  --gold:          #E8C840;
  --gold-dim:      #C4A830;
  --purple:        #9B6BBE;
  --purple-deep:   #6A3B8A;
  --teal:          #5CC4B0;
  --teal-deep:     #3A9A88;
  --pink:          #C878A8;
  --pink-deep:     #A05080;
  --blue:          #6B8BD0;
  --blue-deep:     #4868A8;
  --text:          #e8e0f0;
  --text-dim:      #9088a0;
  --accent:        var(--gold);
  --danger:        #E85448;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  touch-action: none;            /* prevent browser gestures */
  -webkit-touch-callout: none;   /* no iOS callout */
  -webkit-user-select: none;     /* no text selection */
  user-select: none;
}
body {
  font-family: 'Outfit', system-ui, sans-serif;
  background:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E"),
    var(--bg-deep);
  color: var(--text);
}

#app {
  height: 100%;
  width: 100%;
  position: relative;
}

/* ============================================================
   Connect Screen
   ============================================================ */
#connect-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(155,107,190,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 30% 70%, rgba(92,196,176,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 60%, rgba(232,200,64,0.05) 0%, transparent 50%),
    var(--bg-deep);
}

.connect-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 40px 36px;
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  width: 460px;
  max-width: 92vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: fadeInUp 0.5s ease-out;
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: -2px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--purple) 45%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
}

.brand-subtitle {
  font-size: 1rem;
  color: var(--text-dim);
  margin-top: -8px;
}

/* --- Bento Grid (Player / Host cards) --- */
.bento-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.bento-card {
  padding: 28px 20px;
  border-radius: 14px;
  border: 1.5px solid rgba(255,255,255,0.08);
  text-align: center;
  cursor: pointer;
  background: none;
  font-family: inherit;
  transition: transform 0.2s ease, border-color 0.25s, box-shadow 0.25s, background 0.25s;
  outline: none;
}
.bento-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.bento-card:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 0.08s;
}

.bento-player {
  background: rgba(92,196,176,0.06);
  border-color: rgba(92,196,176,0.12);
}
.bento-player:hover {
  background: rgba(92,196,176,0.12);
  border-color: rgba(92,196,176,0.35);
  box-shadow: 0 8px 30px rgba(92,196,176,0.15);
}

.bento-host {
  background: rgba(155,107,190,0.06);
  border-color: rgba(155,107,190,0.12);
}
.bento-host:hover {
  background: rgba(155,107,190,0.12);
  border-color: rgba(155,107,190,0.35);
  box-shadow: 0 8px 30px rgba(155,107,190,0.15);
}

.bento-icon {
  font-size: 2rem;
  margin-bottom: 10px;
  transition: transform 0.2s ease;
}
.bento-card:hover .bento-icon {
  transform: scale(1.15);
}

.bento-player .bento-icon { color: var(--teal); }
.bento-host .bento-icon { color: var(--purple); }

.bento-card h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 6px;
}

.bento-card p {
  font-size: 0.85rem;
  color: #999;
  line-height: 1.4;
}

.bento-card a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
}
.bento-card a:hover {
  text-decoration: underline;
}

/* --- Join Row (input + button side by side) --- */
.join-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.join-row .btn-primary {
  width: auto;
  padding: 14px 28px;
  white-space: nowrap;
}

/* --- Credits Footer --- */
.connect-credits {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  text-align: center;
  width: 100%;
}

.connect-credits p {
  font-size: 0.75rem;
  color: #555;
  line-height: 1.7;
}

.connect-credits a {
  color: #777;
  text-decoration: none;
  transition: color 0.2s;
}
.connect-credits a:hover {
  color: var(--teal);
}

/* --- Role Picker Flows --- */
.back-link {
  -webkit-appearance: none;
  appearance: none;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  color: #666;
  background: none;
  border: none;
  cursor: pointer;
  margin-bottom: 12px;
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 4px;
  transition: color 0.2s, gap 0.2s;
  outline: none;
}
.back-link:hover {
  color: var(--text);
  gap: 6px;
}
.back-link:active {
  opacity: 0.7;
}
.back-link i {
  font-size: 0.9em;
  transition: transform 0.2s;
}
.back-link:hover i {
  transform: translateX(-3px);
}

.flow-desc {
  font-size: 1rem;
  color: #ccc;
  margin-bottom: 14px;
  text-align: center;
}

#player-flow, #host-flow {
  width: 100%;
  animation: slideIn 0.3s ease-out;
}

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

/* --- Host Steps --- */
.host-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.host-step {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.2s;
}
.host-step:hover {
  background: rgba(255,255,255,0.03);
}

.host-step-num {
  width: 32px;
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(155,107,190,0.15);
  color: var(--purple);
  font-size: 0.9rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(155,107,190,0.25);
  transition: background 0.2s, transform 0.2s;
}

.host-step:hover .host-step-num {
  background: rgba(155,107,190,0.25);
  transform: scale(1.1);
}

.host-step p {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  color: #ccc;
  line-height: 1.5;
  padding-top: 4px;
  margin: 0;
}

.host-step a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}
.host-step a:hover {
  color: #7DDCC8;
  text-decoration: underline;
}

/* Staggered entrance for host steps */
.host-step {
  animation: slideIn 0.3s ease-out both;
}
.host-step:nth-child(1) { animation-delay: 0s; }
.host-step:nth-child(2) { animation-delay: 0.08s; }
.host-step:nth-child(3) { animation-delay: 0.16s; }

.room-word {
  flex: 1;
  min-width: 0;
  padding: 14px 12px;
  font-size: 1.1rem;
  font-family: 'Outfit', sans-serif;
  text-align: center;
  text-transform: lowercase;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}
.room-word::placeholder {
  font-size: 0.8rem;
  text-transform: none;
  color: #555;
}
.room-word:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(155,107,190,0.2);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #B080D0, var(--purple));
  box-shadow: 0 4px 20px rgba(155,107,190,0.4);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: scale(0.97) translateY(0);
  box-shadow: 0 0 12px rgba(155,107,190,0.5);
}

.connect-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  width: 100%;
  justify-content: center;
}

.btn-link {
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: none;
  transition: color 0.2s;
}
.btn-link:hover {
  color: var(--text-dim);
}

#connection-status {
  font-size: 0.8rem;
  color: var(--danger);
  min-height: 1.2em;
  text-align: center;
}

/* ============================================================
   Controller Screen
   ============================================================ */
#controller-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(92,196,176,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(155,107,190,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 20%, rgba(232,200,64,0.03) 0%, transparent 40%),
    var(--bg-deep);
}

/* --- HUD Bar --- */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(0,0,0,0.4);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
  z-index: 10;
}

#menu-btn {
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
#menu-btn:active {
  background: rgba(255,255,255,0.1);
}

#game-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #aaa;
}

.connect-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--teal);
  opacity: 0.7;
}

#lag-display {
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  font-size: 0.75rem;
  color: var(--teal);            /* default teal = good */
  min-width: 50px;
  text-align: right;
}
#lag-display.lag-warn  { color: var(--gold); }
#lag-display.lag-bad   { color: var(--danger); }

/* --- Controls Area --- */
#controls {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  overflow: hidden;
  position: relative;
}

/* --- Joystick Zone (left half) --- */
#joystick-zone {
  width: 50%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#joystick-base {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid rgba(155,107,190,0.15);
  background: rgba(155,107,190,0.03);
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#joystick-thumb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(155,107,190,0.35), rgba(92,196,176,0.15));
  border: 2px solid rgba(155,107,190,0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  position: absolute;
  pointer-events: none;
  transition: transform 0.05s linear;
}

.kbd-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: #444;
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  pointer-events: none;
}
/* Hide keyboard hints on touch devices */
@media (hover: none) and (pointer: coarse) {
  .kbd-hint { display: none; }
}

/* --- Button Zone (right half) --- */
#button-zone {
  width: 50%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Diamond layout using CSS grid */
.btn-diamond {
  display: grid;
  grid-template-columns: 70px 70px 70px;
  grid-template-rows: 70px 70px 70px;
  gap: 6px;
  justify-items: center;
  align-items: center;
}

/* Position: throw=top, punch=left, bomb=right, jump=bottom */
.btn-throw { grid-column: 2; grid-row: 1; }
.btn-punch { grid-column: 1; grid-row: 2; }
.btn-bomb  { grid-column: 3; grid-row: 2; }
.btn-jump  { grid-column: 2; grid-row: 3; }

/* Action buttons: shared styles */
.action-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  /* Larger touch target via padding trick - actual tap zone is bigger */
  position: relative;
  transition: transform 0.08s ease-out, filter 0.08s, box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
}
/* Invisible touch-target expander */
.action-btn::after {
  content: '';
  position: absolute;
  top: -10px;
  right: -10px;
  bottom: -10px;
  left: -10px;
}

.action-btn:active,
.action-btn.pressed {
  transform: scale(0.82);
  filter: brightness(1.8) saturate(1.5);
  border-color: rgba(255,255,255,0.6);
}

/* Color-coded buttons — BombSquad bomb palette */
.btn-jump {
  background: radial-gradient(circle at 40% 35%, var(--teal), var(--teal-deep));
  box-shadow: 0 2px 8px rgba(92,196,176,0.3);
}
.btn-jump:active, .btn-jump.pressed {
  box-shadow: 0 0 30px rgba(92,196,176,0.9), 0 0 60px rgba(92,196,176,0.4), inset 0 0 12px rgba(255,255,255,0.15);
}

.btn-punch {
  background: radial-gradient(circle at 40% 35%, var(--pink), var(--pink-deep));
  box-shadow: 0 2px 8px rgba(200,120,168,0.3);
}
.btn-punch:active, .btn-punch.pressed {
  box-shadow: 0 0 30px rgba(200,120,168,0.9), 0 0 60px rgba(200,120,168,0.4), inset 0 0 12px rgba(255,255,255,0.15);
}

.btn-bomb {
  background: radial-gradient(circle at 40% 35%, var(--gold), var(--gold-dim));
  box-shadow: 0 2px 8px rgba(232,200,64,0.3);
}
.btn-bomb:active, .btn-bomb.pressed {
  box-shadow: 0 0 30px rgba(232,200,64,0.9), 0 0 60px rgba(232,200,64,0.4), inset 0 0 12px rgba(255,255,255,0.15);
}

.btn-throw {
  background: radial-gradient(circle at 40% 35%, var(--blue), var(--blue-deep));
  box-shadow: 0 2px 8px rgba(107,139,208,0.3);
}
.btn-throw:active, .btn-throw.pressed {
  box-shadow: 0 0 30px rgba(107,139,208,0.9), 0 0 60px rgba(107,139,208,0.4), inset 0 0 12px rgba(255,255,255,0.15);
}

/* ============================================================
   Responsive: Portrait
   ============================================================ */
@media (orientation: portrait) {
  #controls {
    align-items: flex-end;
    padding-bottom: 20px;
  }
  #joystick-zone {
    width: 45%;
  }
  #button-zone {
    width: 45%;
  }
  #joystick-base {
    width: 100px;
    height: 100px;
  }
  #joystick-thumb {
    width: 42px;
    height: 42px;
  }
  .action-btn {
    width: 50px;
    height: 50px;
    font-size: 1.1rem;
  }
  .btn-diamond {
    grid-template-columns: 54px 54px 54px;
    grid-template-rows: 54px 54px 54px;
    gap: 2px;
  }
}

/* ============================================================
   Responsive: Desktop (wide screens) - SCALE EVERYTHING UP
   ============================================================ */
@media (min-width: 768px) and (hover: hover) {
  #controls {
    padding: 24px 48px;
  }

  #joystick-base {
    width: 200px;
    height: 200px;
  }

  #joystick-thumb {
    width: 80px;
    height: 80px;
  }

  .action-btn {
    width: 90px;
    height: 90px;
    font-size: 2rem;
    border-width: 3px;
  }

  .btn-diamond {
    grid-template-columns: 100px 100px 100px;
    grid-template-rows: 100px 100px 100px;
    gap: 8px;
  }

  .key-tag {
    font-size: 0.8rem;
    padding: 3px 8px;
    bottom: -8px;
    right: -8px;
  }

  #hud {
    padding: 10px 24px;
  }

  #menu-btn {
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
  }

  #game-name {
    font-size: 1.2rem;
  }

  #lag-display {
    font-size: 0.9rem;
  }

  #settings-btn {
    padding: 8px 16px;
    font-size: 0.95rem;
  }

  .kbd-hint {
    font-size: 0.9rem;
  }

  /* Joystick needs larger radius for desktop */
  #joystick-zone {
    cursor: crosshair;
  }
}

/* ============================================================
   Host Dashboard
   ============================================================ */

/* --- Dashboard Body Override --- */
#dashboard {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-user-select: text;
  user-select: text;
}

/* --- Dashboard Header --- */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(0,0,0,0.5);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.dash-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--teal), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Dashboard Nav --- */
.dash-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #888;
  text-decoration: none;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.nav-link:hover {
  color: #ccc;
  border-color: rgba(255,255,255,0.1);
}

.nav-link.active {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
}

.nav-back {
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}

/* Spacer to balance the back button so title stays centered */
.dash-header-spacer {
  width: 70px; /* roughly matches nav-back width */
}

/* --- Dashboard Guided Flow --- */
.dash-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 20px;
  max-width: 640px;
  margin: 0 auto;
  flex: 1;
}

.dash-step {
  display: flex;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.dash-step:last-child {
  border-bottom: none;
}

.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(155,107,190,0.15);
  color: var(--purple);
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(155,107,190,0.25);
}

.step-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-content h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #e0e0e0;
}

.step-desc {
  font-size: 0.85rem;
  color: #888;
}

.step-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.or-divider {
  font-size: 0.75rem;
  color: #555;
  font-style: italic;
}

.input-inline input {
  padding: 8px 12px;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #e0e0e0;
  outline: none;
  width: 150px;
  transition: border-color 0.2s;
}

.input-inline input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 2px rgba(155,107,190,0.15);
}

.step-hint {
  font-size: 0.78rem;
  color: #777;
  line-height: 1.5;
}

.step-hint i {
  color: var(--teal);
  margin-right: 2px;
}

.step-result {
  margin-top: 4px;
  padding: 12px 14px;
  background: rgba(92,196,176,0.06);
  border: 1px solid rgba(92,196,176,0.12);
  border-radius: 8px;
}

.step-result p {
  font-size: 0.85rem;
  color: var(--teal);
  margin-bottom: 6px;
}

.step-result i.ph-check-circle {
  margin-right: 4px;
}

/* --- Share Box --- */
.share-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
}

.share-step-mini {
  display: flex;
  align-items: center;
  gap: 10px;
}

.share-label {
  font-size: 0.8rem;
  color: #888;
  min-width: 80px;
}

.share-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: #e0e0e0;
}

.share-instructions {
  font-weight: 600;
}

/* --- Share Layout: QR left, details right --- */
.share-layout {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
}

.share-layout canvas {
  flex-shrink: 0;
  border-radius: 10px;
}

.share-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.zoom-btn {
  font-size: 0.8rem;
  padding: 8px 16px;
  border-color: rgba(155,107,190,0.25);
  color: var(--purple);
  background: rgba(155,107,190,0.08);
  white-space: nowrap;
  margin-top: 6px;
  align-self: flex-start;
}
.zoom-btn:hover:not(:disabled) {
  background: rgba(155,107,190,0.18);
  border-color: rgba(155,107,190,0.4);
  color: #c8a0e8;
}

@media (max-width: 500px) {
  .dash-flow {
    padding: 12px;
  }
  .dash-step {
    padding: 14px 0;
  }
  .step-actions {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --- Browser Notice (when dashboard opened in browser) --- */
.browser-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 60px 20px;
  color: #aaa;
}

.browser-notice h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #e0e0e0;
}

.browser-notice p {
  font-size: 0.9rem;
  max-width: 400px;
  line-height: 1.5;
}

/* --- Dashboard Buttons --- */
.dash-btn {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: #ccc;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  align-self: flex-start;
}

.dash-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: #fff;
}

.dash-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.dash-btn.primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  border-color: transparent;
  color: #fff;
}

.dash-btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #B080D0, var(--purple));
}

.dash-btn.danger {
  background: linear-gradient(135deg, var(--danger), #C03030);
  border-color: transparent;
  color: #fff;
}

.dash-btn.danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #F06058, var(--danger));
}

/* --- Status Badge --- */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 10px;
}

.status-badge.online {
  background: rgba(92,196,176,0.15);
  color: var(--teal);
  border: 1px solid rgba(92,196,176,0.3);
}

.status-badge.offline {
  background: rgba(232,84,72,0.15);
  color: var(--danger);
  border: 1px solid rgba(232,84,72,0.3);
}


/* --- URL Display --- */
.url-display {
  display: block;
  padding: 10px 14px;
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  color: var(--teal);
  word-break: break-all;
}

.room-code {
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#qr-canvas {
  border-radius: 8px;
  margin-top: 8px;
}

/* --- Players List --- */
.players-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  transition: background 0.15s;
}

.player-row:hover {
  background: rgba(255,255,255,0.05);
}

.player-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e0e0e0;
}

.player-lag {
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  font-size: 0.75rem;
  min-width: 48px;
  text-align: right;
}

.lag-good { color: var(--teal); }
.lag-ok   { color: var(--gold); }
.lag-bad  { color: var(--danger); }

.kick-btn {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
  border: 1px solid rgba(232,84,72,0.2);
  border-radius: 6px;
  background: rgba(232,84,72,0.08);
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.kick-btn:hover {
  background: rgba(232,84,72,0.2);
  border-color: rgba(232,84,72,0.4);
}

/* --- Games List --- */
.games-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.game-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.game-row:hover {
  background: rgba(155,107,190,0.08);
  border-color: rgba(155,107,190,0.2);
}

.game-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e0e0e0;
}

.game-addr {
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  font-size: 0.75rem;
  color: #888;
}

/* --- Empty State --- */
.empty-state {
  font-size: 0.8rem;
  color: #555;
  font-style: italic;
  padding: 8px 0;
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(155,107,190,0.15);
  color: var(--purple);
  border-radius: 11px;
  border: 1px solid rgba(155,107,190,0.25);
}

/* --- Dashboard Link (Tauri-only) --- */
#dashboard-link {
  display: none;
}

body.is-tauri #dashboard-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
   Animations
   ============================================================ */

/* Page load animation */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Subtle pulse on joystick base when active */
@keyframes joyPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(155,107,190,0.2); }
  50% { box-shadow: 0 0 30px rgba(92,196,176,0.25); }
}

#joystick-base.active {
  animation: joyPulse 1.5s ease-in-out infinite;
  border-color: rgba(155,107,190,0.5);
}

/* Button press ripple effect */
@keyframes btnPulse {
  0% { box-shadow: 0 0 0 0 rgba(255,255,255,0.5); }
  50% { box-shadow: 0 0 0 8px rgba(255,255,255,0.2); }
  100% { box-shadow: 0 0 0 18px rgba(255,255,255,0); }
}

@keyframes btnPop {
  0% { transform: scale(1); }
  30% { transform: scale(0.78); }
  60% { transform: scale(0.85); }
  100% { transform: scale(0.82); }
}

.action-btn.pressed {
  animation: btnPulse 0.35s ease-out, btnPop 0.15s ease-out;
}

/* Smooth screen transitions */
#connect-screen, #controller-screen {
  transition: opacity 0.3s ease;
}

/* Button hover states for desktop */
@media (hover: hover) {
  .action-btn:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
  }
}

/* --- HUD Right Group --- */
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#settings-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  color: #bbb;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s, background 0.2s;
}
#settings-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* --- Key Tags on Buttons (desktop only) --- */
.key-tag {
  position: absolute;
  bottom: -6px;
  right: -6px;
  font-size: 0.7rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.3;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.2);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Hide key tags on touch devices */
@media (hover: none) and (pointer: coarse) {
  .key-tag { display: none; }
}

/* --- Settings Panel --- */
#settings-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}

.settings-card {
  background: rgba(30,25,50,0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 20px;
  width: 320px;
  max-width: 90vw;
  margin: auto;
}

.settings-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 12px 0;
}

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

.settings-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.settings-desc {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 16px;
}

.key-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.key-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.key-label {
  font-size: 0.85rem;
  color: #ccc;
}

.key-bind {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  min-width: 60px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.key-bind:hover {
  border-color: var(--purple);
  background: rgba(155,107,190,0.1);
}

.key-bind.listening {
  border-color: var(--gold);
  background: rgba(232,200,64,0.1);
  color: var(--gold);
}

.key-bind.listening::after {
  content: '...';
}

#reset-keys {
  display: block;
  margin: 0 auto;
  font-size: 0.75rem;
}

/* Icon inside buttons */
.action-btn i,
.btn-primary i,
.btn-demo i,
.dash-btn i,
.nav-link i,
.dash-card h2 i {
  vertical-align: middle;
}

.btn-primary i,
.btn-demo i {
  font-size: 1.1em;
  margin-right: 4px;
}

.dash-btn i {
  margin-right: 4px;
}

.nav-link i {
  margin-right: 2px;
}

/* ============================================================
   Player Name Input
   ============================================================ */
.name-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}
.name-input:focus {
  border-color: rgba(92,196,176,0.4);
}

/* ============================================================
   Connection History Chips
   ============================================================ */
.history-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.history-chip {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.history-chip:hover {
  border-color: rgba(92,196,176,0.3);
  background: rgba(92,196,176,0.08);
  color: var(--text);
}
.chip-time {
  color: #666;
  margin-left: 4px;
}

/* ============================================================
   Permission hint (scan network)
   ============================================================ */
.permission-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(232,200,64,0.06);
  border: 1px solid rgba(232,200,64,0.12);
}
.permission-hint strong {
  color: var(--gold);
}
.permission-hint em {
  color: var(--text);
  font-style: normal;
}

/* ============================================================
   Haptics Toggle
   ============================================================ */
.toggle-btn {
  padding: 6px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  cursor: pointer;
  min-width: 60px;
  text-align: center;
  transition: all 0.2s;
}
.toggle-btn.on {
  background: rgba(92,196,176,0.15);
  color: var(--teal);
  border-color: rgba(92,196,176,0.3);
}
.toggle-btn.off {
  background: rgba(255,255,255,0.04);
  color: #888;
  border-color: rgba(255,255,255,0.1);
}

/* ============================================================
   Connect Screen — landscape fit
   ============================================================ */
@media (orientation: landscape) and (max-height: 500px) {
  .connect-card {
    padding: 20px 28px;
    gap: 10px;
    max-height: 98vh;
    overflow-y: auto;
  }
  .brand-title { font-size: 2rem; }
  .brand-subtitle { font-size: 0.85rem; margin-top: -4px; }
  .bento-card { padding: 16px 14px; }
  .bento-icon { font-size: 1.4rem; margin-bottom: 4px; }
  .bento-card h3 { font-size: 0.95rem; }
  .bento-card p { font-size: 0.75rem; }
}

/* ============================================================
   Connect Tabs (Online / LAN)
   ============================================================ */
.connect-tabs {
  display: flex;
  gap: 0;
  width: 100%;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
}
.connect-tab {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  color: #888;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: color 0.2s, background 0.2s;
}
.connect-tab:hover {
  color: #bbb;
}
.connect-tab.active {
  color: #fff;
  background: rgba(155,107,190,0.2);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.connect-tab i {
  font-size: 1em;
}
.tab-content {
  width: 100%;
  animation: slideIn 0.25s ease-out;
}

#lan-address {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.1rem;
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  text-align: center;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}
#lan-address::placeholder {
  font-size: 0.85rem;
  color: #555;
}
#lan-address:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(92,196,176,0.2);
}

/* LAN hint tooltip in connect card */
#tab-lan .step-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(92,196,176,0.06);
  border: 1px solid rgba(92,196,176,0.12);
  border-radius: 10px;
  color: #888;
  font-size: 0.78rem;
  line-height: 1.5;
}
#tab-lan .step-hint i {
  color: var(--teal);
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ============================================================
   Share Zoom Overlay (host dashboard)
   ============================================================ */
#share-zoom-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-deep);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInUp 0.3s ease-out;
}
.zoom-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: #aaa;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.zoom-close-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.zoom-content {
  display: flex;
  align-items: center;
  gap: 48px;
  padding: 40px;
}
.zoom-content canvas {
  flex-shrink: 0;
  border-radius: 16px;
}
.zoom-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.zoom-title {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}
.zoom-url {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--teal);
  margin-top: 8px;
}
.zoom-code-label {
  font-size: 1rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-top: 16px;
}
.zoom-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 5rem;
  font-weight: 800;
  letter-spacing: 6px;
  background: linear-gradient(135deg, var(--teal), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

/* Zoom overlay responsive: stack on small screens */
@media (max-width: 700px) {
  .zoom-content {
    flex-direction: column;
    gap: 24px;
    padding: 20px;
  }
  .zoom-title { font-size: 2rem; }
  .zoom-url { font-size: 1.4rem; }
  .zoom-code { font-size: 3rem; }
}

/* ============================================================
   Utility: hidden attribute override
   ============================================================ */
[hidden] {
  display: none !important;
}
