/* ═══════════════════════════════════════════════════
   GUDDION GAMES — ПОДБОР КОДА
   Liquid Glass Design System
════════════════════════════════════════════════════ */

:root {
  --purple: #7C3AED;
  --blue: #3B82F6;
  --purple-light: #d2bbff;
  --bg-dark: #0a0a1a;
  --bg-mid: #1a0a2e;
  --surface: #15121b;
  --surface-card: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.15);
  --border-light: rgba(255,255,255,0.08);
  --text: #e8dfee;
  --text-muted: #ccc3d8;
  --text-dim: rgba(255,255,255,0.4);
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --font-main: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; }

/* ── PRELOADER ── */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a1a;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
#preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.preloader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
.preloader-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.preloader-brand {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #d2bbff, #7C3AED);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.preloader-sub {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-top: 2px;
}
.preloader-spinner {
  position: relative;
  width: 48px;
  height: 48px;
}
.spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px solid transparent;
  border-top-color: #7C3AED;
  animation: spin 1s linear infinite;
}
.spinner-ring-2 {
  inset: 7px;
  border-top-color: #3B82F6;
  animation-duration: 0.7s;
  animation-direction: reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }
.preloader-hint {
  font-size: 13px;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.04em;
}

body {
  font-family: var(--font-main);
  background: var(--bg-dark);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* ── ANIMATED BACKGROUND CANVAS ── */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ── HEADER ── */
/* ── FLOATING HEADER PILL ── */
#app-header {
  position: fixed;
  top: 10px;
  left: 16px;
  right: 16px;
  z-index: 100;
  max-width: 448px;
  margin: 0 auto;
  pointer-events: none;
}
.header-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 18px;
  padding: 9px 12px;
  box-shadow: 0 4px 28px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06);
  pointer-events: all;
}
.header-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.header-btn:active { background: rgba(255,255,255,0.15); color: var(--text); }
.header-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  overflow: hidden;
}
.header-brand {
  font-size: 9px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.header-game-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--purple-light);
  letter-spacing: -.01em;
  white-space: nowrap;
}

/* ── SCREENS ── */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
  opacity: 0;
}
.screen.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease forwards;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 74px 20px 32px;
  min-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* ── GLASS CARD ── */
.glass-card {
  width: 100%;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
}

.glass-card-sm {
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 12px 16px;
}

/* ── TYPOGRAPHY ── */
.field-label {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-left: 4px;
}
.field-group { display: flex; flex-direction: column; gap: 8px; }

/* ── INPUTS ── */
.glass-input {
  width: 100%;
  height: 52px;
  border-radius: 14px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 16px;
  padding: 0 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.glass-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15), inset 0 0 10px rgba(59,130,246,0.1);
}
.glass-input::placeholder { color: var(--text-dim); }
.input-wrap { position: relative; }
.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 20px;
  pointer-events: none;
}
.input-wrap .glass-input { padding-left: 44px; }

/* ── STEPPER ── */
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  border-radius: 14px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 6px 8px;
}
.stepper-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.stepper-btn:active { background: rgba(255,255,255,0.15); transform: scale(0.95); }
.stepper-val {
  font-family: var(--font-main);
  font-size: 22px;
  font-weight: 700;
  color: var(--purple-light);
}

/* ── BUTTONS ── */
.btn-primary {
  width: 100%;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--purple) 0%, var(--blue) 100%);
  border: none;
  color: #fff;
  font-family: var(--font-main);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: box-shadow 0.2s, transform 0.15s, opacity 0.2s;
  box-shadow: 0 0 20px rgba(124,58,237,0.35);
}
.btn-primary:hover { box-shadow: 0 0 28px rgba(124,58,237,0.55); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled {
  opacity: 0.45;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-ghost {
  width: 100%;
  height: 44px;
  border-radius: 22px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, transform 0.15s;
}
.btn-ghost:active { background: rgba(255,255,255,0.1); transform: scale(0.97); }

/* Bot mode button */
.btn-secondary {
  width: 100%;
  height: 52px;
  border-radius: 26px;
  background: rgba(59,130,246,0.12);
  border: 1px solid rgba(59,130,246,0.35);
  color: #93c5fd;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.btn-secondary:active {
  background: rgba(59,130,246,0.2);
  transform: scale(0.97);
  box-shadow: 0 0 18px rgba(59,130,246,0.3);
}

.bot-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.bot-row .btn-secondary { flex: 1; }
.diff-tabs {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 4px;
  flex-shrink: 0;
}
.diff-tab {
  width: 34px;
  height: 28px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}
.diff-tab:hover { background: rgba(255,255,255,0.08); }
.diff-tab.active { background: rgba(124,58,237,0.25); }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.08); }

.icon-btn-sm {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icon-primary {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(124,58,237,0.3);
  transition: transform 0.15s;
}
.btn-icon-primary:active { transform: scale(0.95); }

/* ── DIVIDER ── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 13px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.12);
}

/* ── JOIN ROW ── */
.join-row { display: flex; gap: 10px; }
.join-input { flex: 1; text-align: center; letter-spacing: 0.15em; text-transform: uppercase; font-family: var(--font-mono); font-size: 18px; }

/* ── LOBBY SCREEN ── */
.lobby-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
}
.lobby-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}
.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 8px var(--purple);
  animation: pulseDot 1.5s ease-in-out infinite;
}
.pulse-dot.blue { background: var(--blue); box-shadow: 0 0 8px var(--blue); }
.pulse-dot.green { background: var(--green); box-shadow: 0 0 8px var(--green); animation: none; }
@keyframes pulseDot {
  0%, 100% { opacity: 0.6; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

.player-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.player-row:last-child { border-bottom: none; }
.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.player-avatar.ghost {
  background: rgba(255,255,255,0.05);
  border: 2px dashed rgba(255,255,255,0.2);
  color: var(--text-dim);
}
.player-avatar.sm {
  width: 34px;
  height: 34px;
}
.player-info { display: flex; flex-direction: column; gap: 3px; }
.player-name { font-size: 15px; font-weight: 600; }
.player-status {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.player-status.green { color: var(--green); }

.invite-section { display: flex; flex-direction: column; gap: 10px; }
.invite-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 10px 14px;
}
.invite-url {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── SETUP SCREEN ── */
.setup-content {
  padding-top: 70px;
  gap: 20px;
  padding-bottom: 24px;
  justify-content: flex-start;
}

.back-btn {
  position: absolute;
  top: 16px;
  left: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.setup-title {
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}

.opponent-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── CODE SLOTS ── */
.code-slots {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}
.code-slot {
  width: 48px;
  height: 60px;
  border-radius: 12px;
  background: rgba(0,0,0,0.25);
  border: 1.5px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}
.code-slot.active {
  border-color: var(--purple);
  box-shadow: 0 0 12px rgba(124,58,237,0.3), inset 0 0 8px rgba(124,58,237,0.1);
}
.code-slot.filled {
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.06);
}
.cursor-blink {
  width: 2px;
  height: 28px;
  background: var(--purple);
  border-radius: 1px;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.setup-waiting {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -8px;
}

/* ── DIALPAD ── */
.dialpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 280px;
}
.dial-btn {
  height: 62px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  -webkit-user-select: none;
  user-select: none;
}
.dial-btn:active { background: rgba(255,255,255,0.14); transform: scale(0.93); }
.dial-empty { height: 62px; }

/* GAME DIALPAD — same beautiful circles as setup */
.dialpad-game {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  gap: 10px;
  justify-content: center;
  width: 100%;
}
.dialpad-game .dial-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 22px;
}
.dial-send {
  background: linear-gradient(135deg, var(--purple), var(--blue)) !important;
  box-shadow: 0 0 16px rgba(124,58,237,0.5);
}
.dial-send:not(:disabled):active {
  box-shadow: 0 0 24px rgba(124,58,237,0.7);
}
.dial-send:disabled {
  background: rgba(255,255,255,0.06) !important;
  box-shadow: none !important;
  opacity: 0.4;
}

/* Rematch button state */
.btn-rematch-waiting {
  opacity: 0.6;
  pointer-events: none;
}

/* Floating chat button */
.chat-fab {
  position: absolute;
  bottom: 180px;
  right: 16px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(124,58,237,0.4);
  transition: transform 0.2s;
  z-index: 50;
}
.chat-fab:active { transform: scale(0.92); }
.hint-fab {
  position: absolute;
  bottom: 240px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(251,191,36,0.15);
  border: 1px solid rgba(251,191,36,0.4);
  color: #fbbf24;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(251,191,36,0.2);
  transition: transform 0.2s, opacity 0.2s;
  z-index: 50;
}
.hint-fab:active { transform: scale(0.92); }
.hint-fab:disabled { opacity: 0.3; pointer-events: none; }
.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--surface);
}

/* Invite URL as input */
.invite-url-input {
  flex: 1;
  height: 40px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 10px;
  cursor: text;
  min-width: 0;
}
.invite-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── GAME SCREEN ── */
#screen-game {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  inset: 0;
  max-width: 480px;
  margin: 0 auto;
}

.game-top {
  flex-shrink: 0;
  padding: 70px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-bottom {
  flex-shrink: 0;
  padding: 6px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border-light);
  background: rgba(10,10,26,0.6);
  backdrop-filter: blur(12px);
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 20px;
  padding: 7px 14px;
  align-self: center;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s;
  box-shadow: 0 0 10px rgba(124,58,237,0.15);
}
.turn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 6px var(--purple);
  animation: pulseDot 1.2s ease-in-out infinite;
}
.turn-timer {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  min-width: 20px;
  text-align: right;
}
.turn-timer.urgent { color: var(--red); font-weight: 700; }
.turn-indicator.opponent {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.1);
  box-shadow: none;
}
.turn-indicator.opponent .turn-dot { background: var(--text-dim); box-shadow: none; animation: none; }

/* Opponent best score badge */
.opponent-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.opp-best-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.opp-score-badge {
  display: flex;
  align-items: baseline;
  gap: 1px;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-muted);
  transition: color 0.3s, transform 0.2s;
  flex-shrink: 0;
  padding: 0 8px;
}
.opp-score-badge span:first-child {
  font-size: 26px;
  line-height: 1;
}
.opp-score-badge .opp-denom {
  font-size: 13px;
  color: var(--text-dim);
}
.opp-score-badge.has-score { color: var(--yellow); }
.opp-score-badge.near-win  { color: var(--red); }
@keyframes scorePop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.opp-score-badge.pop { animation: scorePop 0.35s ease; }

.opponent-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.opponent-name { font-size: 15px; font-weight: 600; }
.opponent-code { display: flex; gap: 4px; flex-wrap: wrap; }

/* Opponent note slots — interactive */
.opp-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}
.opp-code-hint {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
  flex-shrink: 0;
}
.opp-code-slot {
  width: 32px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  user-select: none;
  -webkit-user-select: none;
}
.opp-code-slot:active { transform: scale(0.92); }
.opp-code-slot.opp-active {
  border-color: var(--purple);
  background: rgba(124,58,237,0.15);
  color: var(--purple-light);
  box-shadow: 0 0 8px rgba(124,58,237,0.3);
}
.opp-code-slot.noted {
  color: var(--purple-light);
  border-color: rgba(124,58,237,0.4);
  background: rgba(124,58,237,0.1);
}

/* My code display */
.my-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}
.my-code-hint {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
  flex-shrink: 0;
}
.my-code-slots { display: flex; gap: 4px; flex-wrap: wrap; }
.my-code-slot {
  width: 32px;
  height: 36px;
  border-radius: 8px;
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: rgba(134,239,172,0.8);
}

/* ── GUESS HISTORY ── */
.guess-history {
  flex: 1 1 0;
  min-height: 0;          /* critical — prevents flex child from overflowing */
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 14px;
  scrollbar-width: none;
}
.guess-history::-webkit-scrollbar { display: none; }

.guess-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 8px 12px;
  flex-shrink: 0;             /* prevent row from collapsing */
  opacity: 1;
  transform: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
/* CSS-only entrance animation — no GSAP x-shift that can clip */
.guess-row-enter {
  opacity: 0;
  transform: translateY(8px);
}
.guess-row-enter.guess-row-visible {
  opacity: 1;
  transform: translateY(0);
}
.guess-num {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  min-width: 32px;
}
.guess-digits {
  display: flex;
  gap: 4px;
  flex: 1;
}
.guess-digit {
  width: 26px;
  height: 30px;
  border-radius: 7px;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
}
.score-badge {
  min-width: 56px;
  height: 26px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 0 8px;
}
.score-0  { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.score-partial { background: rgba(245,158,11,0.15); border: 1px solid rgba(245,158,11,0.3); color: #fcd34d; }
.score-win { background: rgba(34,197,94,0.2); border: 1px solid rgba(34,197,94,0.4); color: #86efac; }

.guess-slots {
  flex-shrink: 0;
  gap: 5px;
}
.guess-slots .code-slot {
  width: 40px;
  height: 48px;
  font-size: 20px;
  border-radius: 10px;
}

/* ── RESULT SCREEN ── */
.result-card { text-align: center; gap: 12px; }
.result-trophy { font-size: 64px; animation: bounceIn 0.6s cubic-bezier(.36,.07,.19,.97); }
@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}
.result-title { font-size: 32px; font-weight: 700; }
.result-subtitle { font-size: 14px; color: var(--text-muted); }
.result-stats {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 12px 0 4px;
}
.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 8px 14px;
  min-width: 64px;
}
.stat-val { font-size: 20px; font-weight: 700; color: var(--purple-light); font-family: var(--font-mono); }
.stat-lbl { font-size: 10px; color: var(--text-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: .05em; }

.result-opp-status {
  font-size: 13px;
  color: var(--green);
  margin-top: 8px;
  min-height: 18px;
  text-align: center;
}
.result-code-display {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0 4px;
}
.result-digit {
  width: 52px;
  height: 64px;
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
}
.result-code-label { font-size: 12px; color: var(--text-dim); font-family: var(--font-mono); letter-spacing: 0.05em; }

/* ── DISCONNECT OVERLAY ── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay-card {
  text-align: center;
  gap: 14px;
  max-width: 320px;
}
.countdown-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid rgba(245,158,11,0.4);
  box-shadow: 0 0 20px rgba(245,158,11,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}
#countdown-num {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--yellow);
}

/* ── CHAT DRAWER ── */
.chat-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: rgba(21,18,27,0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  height: 50vh;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
  max-width: 480px;
  margin: 0 auto;
}
.chat-drawer.open { transform: translateY(0); }

.chat-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.2);
  align-self: center;
  margin: 10px 0 0;
  flex-shrink: 0;
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  flex-shrink: 0;
}
.chat-title { font-size: 16px; font-weight: 700; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: none;
}
.chat-messages::-webkit-scrollbar { display: none; }

.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.chat-msg.self { flex-direction: row-reverse; }
.chat-bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
}
.chat-msg.self .chat-bubble {
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg:not(.self) .chat-bubble {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-light);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-msg-name { font-size: 11px; color: var(--text-dim); margin-bottom: 3px; }
.chat-msg-wrap { display: flex; flex-direction: column; }
.chat-msg.self .chat-msg-wrap { align-items: flex-end; }

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 10px 16px 20px;
  flex-shrink: 0;
  border-top: 1px solid var(--border-light);
}
.chat-text-input { flex: 1; height: 44px; }
.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 149;
  background: transparent;
}

/* ── TUTORIAL ── */
.tutorial-modal { display: flex; flex-direction: column; }
.tutorial-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}
.tut-icon {
  width: 64px; height: 64px; border-radius: 20px;
  background: rgba(124,58,237,0.18); border: 1px solid rgba(124,58,237,0.3);
  display: flex; align-items: center; justify-content: center;
  color: var(--purple-light); font-size: 32px;
}
.tut-text { font-size: 14px; color: var(--text-muted); line-height: 1.65; max-width: 280px; }
.tut-text strong { color: var(--text); }
.tut-example {
  display: flex; gap: 6px; align-items: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 10px 16px;
}
.tut-example .faq-digits span { width: 32px; height: 36px; border-radius: 10px; font-size: 16px; }
.tut-arrow { color: var(--text-dim); font-size: 20px; }
.tut-badge { background: rgba(251,191,36,0.15); border: 1px solid rgba(251,191,36,0.35); color: #fbbf24; border-radius: 20px; padding: 4px 12px; font-size: 13px; font-weight: 700; }
.tutorial-footer {
  display: flex; gap: 10px; padding: 12px 16px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.tut-step-counter { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ── FAQ MODAL ── */
.faq-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.faq-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 201;
  width: min(92vw, 420px);
  background: rgba(22,17,34,0.92);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 24px;
  overflow: hidden;
  transition: transform 0.28s cubic-bezier(.34,1.56,.64,1), opacity 0.22s ease;
  opacity: 0;
}
.faq-modal.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.faq-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.faq-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.faq-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0 16px;
  max-height: calc(82dvh - 56px);
}
.faq-body::-webkit-scrollbar { width: 3px; }
.faq-body::-webkit-scrollbar-track { background: transparent; }
.faq-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

.faq-section {
  padding: 16px 20px;
}
.faq-section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(124,58,237,0.18);
  border: 1px solid rgba(124,58,237,0.3);
  color: var(--purple-light);
  margin-bottom: 10px;
}
.faq-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.faq-text {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}
.faq-text strong { color: var(--purple-light); font-weight: 600; }

.faq-divider {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 0 20px;
}

.faq-example {
  margin-top: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.faq-ex-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.faq-label {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.faq-digits {
  display: flex;
  gap: 4px;
}
.faq-digits span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.faq-ex-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.faq-badge-example {
  background: rgba(251,191,36,0.15);
  border: 1px solid rgba(251,191,36,0.35);
  color: #fbbf24;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}
.faq-ex-note {
  font-size: 12px;
  color: var(--text-dim);
}

.faq-tips {
  margin: 6px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.faq-tips li {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.faq-tips li strong { color: var(--purple-light); font-weight: 600; }

/* ── MATERIAL SYMBOLS ── */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 22px;
  line-height: 1;
  user-select: none;
}

/* ── RESPONSIVE ── */
@media (max-height: 700px) {
  .screen-content { padding-top: 68px; }
  .setup-content { gap: 14px; }
  .code-slot { width: 42px; height: 52px; font-size: 22px; }
  .dial-btn { height: 54px; font-size: 20px; }
  .dialpad { gap: 8px; }
}
@media (max-width: 360px) {
  .code-slot { width: 40px; height: 54px; }
  .dialpad { max-width: 260px; }
}
