/* ==================== CSS VARIABLES ==================== */
:root {
  /* Dark Cyber Theme (Default) */
  --bg-primary: #0a0a0f;
  --bg-secondary: #16161f;
  --bg-card: #1e1e2e;
  --bg-card-hover: #252535;

  --text-primary: #e0e0ff;
  --text-secondary: #a0a0c0;
  --text-muted: #6a6a8a;

  --accent-purple: #a855f7;
  --accent-yellow: #fbbf24;
  --accent-magenta: #ec4899;

  --border-color: #2a2a3a;
  --shadow: rgba(168, 85, 247, 0.2);
}

body[data-theme="kawaii"] {
  /* Kawaii Theme */
  --bg-primary: #fff0f6;
  --bg-secondary: #ffe4f0;
  --bg-card: #ffd4e8;
  --bg-card-hover: #ffc4de;

  --text-primary: #5a0a3a;
  --text-secondary: #8a3a6a;
  --text-muted: #b86a9a;

  --accent-purple: #d946ef;
  --accent-yellow: #fde047;
  --accent-magenta: #f472b6;

  --border-color: #ffc0e0;
  --shadow: rgba(236, 72, 153, 0.2);
}

/* ==================== RESET & BASE ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

/* ==================== LAYOUT ==================== */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

/* ==================== AUTH SCREEN ==================== */
.auth-container {
  margin: auto;
  padding: 2rem;
  text-align: center;
  max-width: 400px;
}

.logo {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 3rem;
  font-size: 1.1rem;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-magenta));
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 20px var(--shadow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px var(--shadow);
}

.btn-primary:active {
  transform: translateY(0);
}

.error-msg {
  color: #ff6b6b;
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* ==================== LOBBY SCREEN ==================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h2 {
  font-size: 1.3rem;
}

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

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  transform: scale(1.05);
}

.lobby-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.section {
  margin-bottom: 2rem;
}

.section h3 {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ==================== PLAYERS GRID ==================== */
.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.player-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.player-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.player-status {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.player-status.online {
  background: #10b981;
}

.player-status.in-game {
  background: var(--accent-yellow);
}

.player-name {
  font-weight: 600;
  color: var(--text-primary);
}

/* CPU opponent card styling */
.cpu-card {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-magenta));
  border-color: var(--accent-purple);
}

.cpu-card .player-name {
  color: white;
  font-size: 1.1rem;
}

/* ==================== GAMES LIST ==================== */
.games-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.game-card:hover {
  background: var(--bg-card-hover);
}

.game-info {
  flex: 1;
}

.game-type {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

.game-players {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.btn-secondary {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-card);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-style: italic;
}

/* ==================== MODAL ==================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
  margin-bottom: 1.5rem;
  text-align: center;
}

.game-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.game-option {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem 1rem;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
}

.game-option:hover {
  border-color: var(--accent-purple);
  background: var(--bg-card);
  transform: scale(1.05);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 640px) {
  .logo {
    font-size: 2rem;
  }

  .players-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .modal-content {
    padding: 1.5rem;
  }
}

/* ==================== UTILITIES ==================== */
.tap-target {
  min-width: 48px;
  min-height: 48px;
}