/* ============================================================
   HUỆ DRINKING GAME — Cyberpunk / Nightclub Theme
   ============================================================ */

/* ---------- DESIGN TOKENS ---------- */
:root {
  --bg-deep: #0a0e1a;
  --bg-base: #0f172a;
  --bg-surface: rgba(255, 255, 255, 0.06);
  --glass-bg: rgba(15, 23, 42, 0.65);
  --glass-border: rgba(255, 255, 255, 0.12);

  --neon-magenta: #ff2d95;
  --neon-cyan: #00f0ff;
  --neon-purple: #a855f7;
  --neon-yellow: #facc15;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --radius-full: 999px;

  --font: 'Poppins', sans-serif;
  --transition-fast: 0.2s ease;
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}

/* ---------- ANIMATED BACKGROUND ORBS ---------- */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.45;
  will-change: transform;
}

.orb-1 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, var(--neon-magenta), transparent 70%);
  top: -80px;
  left: -60px;
  animation: float-1 12s ease-in-out infinite alternate;
}

.orb-2 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--neon-cyan), transparent 70%);
  bottom: -60px;
  right: -50px;
  animation: float-2 14s ease-in-out infinite alternate;
}

.orb-3 {
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, var(--neon-purple), transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: float-3 10s ease-in-out infinite alternate;
}

@keyframes float-1 {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(80px, 120px) scale(1.15);
  }
}

@keyframes float-2 {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(-90px, -100px) scale(1.2);
  }
}

@keyframes float-3 {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.3;
  }

  100% {
    transform: translate(-30%, -60%) scale(1.1);
    opacity: 0.55;
  }
}

/* ---------- APP SHELL ---------- */
.app-shell {
  position: relative;
  z-index: 1;
  max-width: 500px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- SCREEN MANAGEMENT ---------- */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  padding: 20px 16px;
  animation: fadeIn 0.5s ease;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- GLASS CARD ---------- */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ============================================================
   LOBBY SCREEN
   ============================================================ */
.lobby-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 28px;
  padding: 24px 0;
}

/* --- Logo --- */
.logo-wrapper {
  text-align: center;
}

.glow-title {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 2px;
  text-transform: uppercase;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  text-shadow:
    0 0 10px rgba(255, 45, 149, 0.6),
    0 0 40px rgba(255, 45, 149, 0.3),
    0 0 80px rgba(0, 240, 255, 0.15);
}

.title-icon {
  display: block;
  width: 100%;
  font-size: 2.8rem;
  margin-bottom: 4px;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

.title-accent {
  background: linear-gradient(90deg, var(--neon-magenta), var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* --- Lobby Form --- */
.lobby-form {
  width: 100%;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-group input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.input-group input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.15), 0 0 20px rgba(0, 240, 255, 0.1);
}

/* --- Buttons --- */
.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn-icon {
  font-size: 1.1em;
}

/* Primary — Magenta */
.btn-primary {
  background: linear-gradient(135deg, var(--neon-magenta), #d6006f);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 45, 149, 0.35);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 30px rgba(255, 45, 149, 0.55);
  transform: scale(1.03);
}

/* Secondary — Outlined Cyan */
.btn-secondary {
  background: transparent;
  color: var(--neon-cyan);
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.15);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(0, 240, 255, 0.1);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.3);
  transform: scale(1.03);
}

/* Accent — Cyan Filled */
.btn-accent {
  background: linear-gradient(135deg, var(--neon-cyan), #009db8);
  color: #0f172a;
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.3);
}

.btn-accent:hover:not(:disabled) {
  box-shadow: 0 6px 30px rgba(0, 240, 255, 0.5);
  transform: scale(1.03);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 10px 16px;
}

.btn-ghost:hover {
  color: var(--text-primary);
}

.btn-lg {
  padding: 16px 24px;
  font-size: 1.05rem;
  border-radius: var(--radius);
}

.btn-sm {
  padding: 10px 16px;
  font-size: 0.8rem;
}

.footer-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ============================================================
   GAME ROOM SCREEN
   ============================================================ */
#game-screen {
  padding-bottom: 200px;
  /* space for fixed controls */
}

/* --- Header --- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  margin-bottom: 20px;
}

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

.room-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.room-code {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 3px;
  background: linear-gradient(90deg, var(--neon-magenta), var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Players --- */
.players-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.player-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.player-badge .avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-magenta), var(--neon-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: #fff;
  font-weight: 700;
}

.player-badge.is-host .avatar {
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple));
}

.player-badge.is-you {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}

.player-badge.has-flipped {
  border-color: #22c55e;
}

/* --- Game Status Bar --- */
.game-status {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.status-pill .status-icon {
  font-size: 0.85rem;
}

.status-pill.all-flipped {
  border-color: #22c55e;
  color: #4ade80;
}

.status-pill.deck-empty {
  border-color: var(--neon-magenta);
  color: var(--neon-magenta);
}

/* --- Controls bottom row --- */
.controls-bottom-row {
  width: 100%;
  display: flex;
  justify-content: center;
}

.controls .btn-secondary {
  flex: 1;
}

/* ============================================================
   3D CARD
   ============================================================ */
.card-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

.card-container {
  perspective: 1000px;
  width: 260px;
  height: 380px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.card-inner.is-flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  overflow: hidden;
}

/* --- FRONT (Face-Down) --- */
.card-front {
  background: linear-gradient(160deg, #1a1035, #0d1b2a 40%, #132743);
  border: 2px solid rgba(168, 85, 247, 0.3);
  box-shadow:
    0 0 30px rgba(168, 85, 247, 0.15),
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.card-front-design {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  position: relative;
}

/* Decorative corner lines */
.card-front-design::before,
.card-front-design::after {
  content: '';
  position: absolute;
  border: 1.5px solid rgba(168, 85, 247, 0.25);
  border-radius: 8px;
}

.card-front-design::before {
  inset: 14px;
}

.card-front-design::after {
  inset: 22px;
  border-color: rgba(0, 240, 255, 0.12);
}

.card-logo-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid rgba(168, 85, 247, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  animation: pulse-ring 3s ease-in-out infinite;
}

@keyframes pulse-ring {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.3);
  }

  50% {
    box-shadow: 0 0 0 12px rgba(168, 85, 247, 0);
  }
}

.card-logo-icon {
  font-size: 2.2rem;
}

.card-brand {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 8px;
  background: linear-gradient(90deg, var(--neon-magenta), var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card-front-lines {
  display: flex;
  gap: 6px;
}

.card-front-lines span {
  width: 20px;
  height: 3px;
  border-radius: 2px;
  background: rgba(168, 85, 247, 0.3);
}

.card-front-lines span:nth-child(2) {
  width: 30px;
  background: rgba(0, 240, 255, 0.3);
}

/* --- BACK (Challenge) --- */
.card-back {
  background: linear-gradient(160deg, #0f172a, #1e1b4b 50%, #0f172a);
  border: 2px solid rgba(0, 240, 255, 0.3);
  transform: rotateY(180deg);
  box-shadow:
    0 0 40px rgba(0, 240, 255, 0.15),
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.card-back-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
  gap: 12px;
}

.challenge-emoji {
  font-size: 3.5rem;
  animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop {
  0% {
    transform: scale(0);
  }

  100% {
    transform: scale(1);
  }
}

.challenge-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--neon-cyan);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.challenge-text {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-primary);
}

/* ============================================================
   CONTROLS (Fixed Bottom)
   ============================================================ */
.controls {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 10;
}

.controls .btn-primary,
.controls .btn-accent {
  flex: 1;
  min-width: 0;
}

.controls .btn-ghost {
  width: 100%;
  text-align: center;
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  z-index: 100;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 90%;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 8px 30px rgba(239, 68, 68, 0.35);
}

.toast.success {
  background: linear-gradient(135deg, #22c55e, #15803d);
  box-shadow: 0 8px 30px rgba(34, 197, 94, 0.3);
}

.toast.info {
  background: linear-gradient(135deg, var(--neon-cyan), #0284c7);
  box-shadow: 0 8px 30px rgba(0, 240, 255, 0.3);
}

/* ============================================================
   RESPONSIVE / UTILITY
   ============================================================ */
@media (min-width: 501px) {
  body {
    display: flex;
    justify-content: center;
  }
}

/* Subtle scanline overlay for extra cyberpunk feel */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.03) 2px,
      rgba(0, 0, 0, 0.03) 4px);
  pointer-events: none;
  z-index: 999;
}