* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #222240;
  --bg-input: #16162b;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --accent2: #ec4899;
  --accent3: #10b981;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-bright: #ffffff;
  --border: #2d2d4a;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: rgba(15, 15, 26, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 1px;
}

.logo-icon { font-size: 1.5rem; }
.accent { color: var(--accent); }

.header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-auth {
  display: flex;
  gap: 0.5rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: white;
}

.user-points {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--warning);
}

.hidden { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn:hover { background: var(--bg-card-hover); border-color: var(--accent); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: #5558e6;
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 1.05rem;
  border-radius: var(--radius);
}

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
  transition: color 0.2s;
}
.btn-icon:hover { color: var(--text); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-success { background: var(--accent3); border-color: var(--accent3); color: white; }
.btn-success:hover { background: #059669; }

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

/* Main */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.card-hover { cursor: pointer; transition: all 0.25s; }
.card-hover:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Page layouts */
.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.auth-card p {
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.auth-card .auth-footer {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.auth-card .auth-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

/* Home page */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-dim);
  max-width: 500px;
  margin: 0 auto;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}

.game-card {
  position: relative;
  overflow: hidden;
}

.game-card .game-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.game-card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.game-card p {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.game-card .game-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.game-card .game-meta span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.game-card .badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-live {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent3);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-soon {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Section titles */
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Leaderboard */
.leaderboard {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard th {
  text-align: left;
  padding: 0.6rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.leaderboard td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(45, 45, 74, 0.5);
  font-size: 0.9rem;
}

.leaderboard tr:hover td { background: rgba(99, 102, 241, 0.05); }

.rank { font-weight: 700; color: var(--text-dim); width: 40px; }
.rank-1 { color: #fbbf24; }
.rank-2 { color: #94a3b8; }
.rank-3 { color: #cd7f32; }

.lb-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.lb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.7rem;
  color: white;
  flex-shrink: 0;
}

.lb-points {
  font-weight: 700;
  color: var(--warning);
}

/* Game page - Number Duel */
.game-page {
  max-width: 600px;
  margin: 0 auto;
}

.game-status {
  text-align: center;
  padding: 2rem 0;
}

.game-status h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.game-status p {
  color: var(--text-dim);
}

.vs-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.vs-player {
  text-align: center;
  flex: 1;
}

.vs-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
}

.vs-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.vs-guesses {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

.vs-text {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent2);
}

/* Number picker */
.number-input-area {
  text-align: center;
  margin: 2rem 0;
}

.number-input-area h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.number-input-wrap {
  display: flex;
  gap: 0.75rem;
  max-width: 300px;
  margin: 0 auto;
}

.number-input-wrap input {
  flex: 1;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  padding: 0.8rem;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  width: 100%;
}

.number-input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Round history */
.round-history {
  margin-top: 1.5rem;
}

.round-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.round-num {
  font-weight: 700;
  color: var(--text-dim);
  min-width: 60px;
}

.round-guess {
  font-weight: 600;
}

.hint-higher { color: #ef4444; }
.hint-lower { color: #3b82f6; }
.hint-correct { color: var(--accent3); font-weight: 700; }

.heat-indicator {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-weight: 600;
}

.heat-burning { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.heat-hot { background: rgba(249, 115, 22, 0.2); color: #f97316; }
.heat-warm { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.heat-cool { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.heat-cold { background: rgba(99, 102, 241, 0.2); color: #6366f1; }

/* Game result overlay */
.game-result {
  text-align: center;
  padding: 2rem;
  margin-top: 1rem;
}

.result-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.result-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.result-win { color: var(--accent3); }
.result-loss { color: var(--danger); }
.result-draw { color: var(--warning); }

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1.5rem 0;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.result-stat {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.result-stat .stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.result-stat .stat-value {
  font-size: 1.3rem;
  font-weight: 700;
}

/* Waiting/Queue animation */
.pulse-ring {
  display: inline-block;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
  margin: 2rem auto;
}

.pulse-ring::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  animation: pulse 1.5s ease-out infinite;
}

.pulse-ring::after {
  content: '';
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  animation: pulse 1.5s ease-out infinite 0.5s;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}

.searching-text {
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Timer bar */
.timer-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 1rem 0;
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 1s linear;
}

.timer-bar-fill.urgent {
  background: var(--danger);
}

/* Profile */
.profile-card {
  max-width: 500px;
  margin: 0 auto;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
}

.profile-info h2 { font-size: 1.3rem; }
.profile-info p { color: var(--text-dim); font-size: 0.85rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-input);
  padding: 1rem;
  border-radius: var(--radius-sm);
  text-align: center;
}

.stat-card .stat-num {
  font-size: 1.5rem;
  font-weight: 800;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.2rem;
}

/* Responsive */
@media (max-width: 640px) {
  .header-inner { padding: 0.65rem 1rem; }
  main { padding: 1rem; }
  .hero h1 { font-size: 1.8rem; }
  .hero p { font-size: 0.95rem; }
  .games-grid { grid-template-columns: 1fr; }
  .vs-display { gap: 1rem; }
  .vs-avatar { width: 44px; height: 44px; font-size: 1rem; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .stat-card .stat-num { font-size: 1.2rem; }
  .result-title { font-size: 1.5rem; }
}

/* Countdown */
.countdown {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  animation: countPop 0.5s ease;
}

@keyframes countPop {
  0% { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  z-index: 1000;
  transition: transform 0.3s ease;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

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

/* Opponent indicator */
.opponent-status {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 0.5rem;
}

.opponent-status.guessed {
  color: var(--accent3);
}
