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

:root {
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-sidebar: #0f3460;
  --accent: #e94560;
  --accent2: #533483;
  --text: #ffffff;
  --text-dim: #a0a0b0;
  --green: #00d474;
  --gold: #ffd700;
  --blue: #00b0ff;
  --radius: 12px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.screen { display: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; }
.screen.active { display: flex; }

/* ===== AUTH SCREEN ===== */
#auth-screen {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
}

.auth-bg-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

.auth-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.logo-section { text-align: center; }

.game-title {
  font-size: 4rem;
  font-weight: 900;
  background: linear-gradient(135deg, #00b0ff, #e94560, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 4px;
  text-shadow: none;
  margin-top: 10px;
}

.game-subtitle {
  color: var(--text-dim);
  font-size: 1.2rem;
  margin-top: 5px;
  letter-spacing: 2px;
}

.auth-box {
  background: rgba(22, 33, 62, 0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 30px;
  width: 380px;
  backdrop-filter: blur(20px);
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}

.auth-tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s;
}

.auth-tab.active {
  background: var(--accent);
  color: white;
}

.auth-form { display: none; flex-direction: column; gap: 12px; }
.auth-form.active { display: flex; }

.auth-form input {
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.3);
  color: white;
  font-size: 1rem;
  outline: none;
  transition: border 0.3s;
}

.auth-form input:focus {
  border-color: var(--blue);
}

.btn-primary {
  padding: 14px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(233,69,96,0.4);
}

.btn-guest {
  width: 100%;
  padding: 12px;
  margin-top: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-guest:hover {
  border-color: var(--blue);
  color: white;
}

.error-msg {
  color: var(--accent);
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 20px;
  text-align: center;
}

/* ===== TOP BAR ===== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: rgba(15, 52, 96, 0.95);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.logo-small {
  font-weight: 900;
  font-size: 1.3rem;
  background: linear-gradient(135deg, #00b0ff, #e94560);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

.search-bar input {
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.3);
  color: white;
  width: 300px;
  font-size: 0.9rem;
  outline: none;
}

.search-bar input:focus { border-color: var(--blue); }

.top-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.user-stats {
  display: flex;
  gap: 15px;
  font-weight: 600;
}

.coins-display { color: var(--gold); }
.level-display { color: var(--blue); }

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
  padding: 4px 12px;
  border-radius: 8px;
  transition: background 0.2s;
}

.user-menu:hover { background: rgba(255,255,255,0.1); }

.avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
}

.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  overflow: hidden;
  min-width: 150px;
  z-index: 200;
}

.dropdown.show { display: block; }

.dropdown button {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
}

.dropdown button:hover { background: rgba(255,255,255,0.1); }

/* ===== HUB LAYOUT ===== */
#hub-screen {
  flex-direction: column;
}

.hub-content {
  display: flex;
  margin-top: 56px;
  height: calc(100vh - 56px);
}

.sidebar {
  width: 200px;
  background: rgba(15, 52, 96, 0.5);
  padding: 15px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid rgba(255,255,255,0.05);
  overflow-y: auto;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.95rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.sidebar-btn:hover { background: rgba(255,255,255,0.08); color: white; }
.sidebar-btn.active { background: var(--accent); color: white; }

.sidebar-icon { font-size: 1.2rem; }

/* ===== GAMES AREA ===== */
.games-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.featured-banner {
  position: relative;
  height: 280px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 30px;
  background: linear-gradient(135deg, #1a0a2e, #2d1b69);
}

.featured-3d {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.featured-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 30px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
}

.featured-tag {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.featured-info h2 { font-size: 2rem; margin-bottom: 5px; }
.featured-info p { color: var(--text-dim); margin-bottom: 15px; }

.btn-play {
  padding: 12px 40px;
  border-radius: 8px;
  border: none;
  background: var(--green);
  color: #000;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-play:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(0,212,116,0.4);
}

.section-title {
  font-size: 1.3rem;
  margin-bottom: 15px;
  font-weight: 700;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding-bottom: 30px;
}

.game-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid rgba(255,255,255,0.05);
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.game-card-thumb {
  height: 150px;
  position: relative;
  overflow: hidden;
}

.game-card-thumb canvas {
  width: 100%;
  height: 100%;
}

.game-card-info {
  padding: 12px;
}

.game-card-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
}

.game-card-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.game-card-tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.player-count { color: var(--green); }

/* ===== GAME SCREEN ===== */
#game-screen {
  flex-direction: column;
  background: #000;
}

.game-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 48px;
  background: rgba(0,0,0,0.8);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.btn-back {
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-back:hover { background: rgba(255,255,255,0.1); }

.game-name {
  font-weight: 700;
  font-size: 1.1rem;
}

.game-hud {
  font-weight: 600;
  color: var(--gold);
}

#game-canvas {
  flex: 1;
  margin-top: 48px;
  width: 100%;
  display: block;
}

#game-ui-overlay {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  pointer-events: none;
}

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

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 30px;
  width: 450px;
  max-width: 90vw;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 15px; right: 15px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
}

.profile-body {
  display: flex;
  gap: 30px;
  margin-top: 20px;
}

.avatar-preview {
  width: 100px;
  height: 100px;
  border-radius: 16px;
  background: var(--blue);
}

.color-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.color-opt {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s;
}

.color-opt:hover { transform: scale(1.2); }
.color-opt.active { border-color: white; }

.profile-stats { flex: 1; }

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.xp-bar {
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
  border-radius: 4px;
  transition: width 0.5s;
}

.gameover-content { text-align: center; }

.gameover-score {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--gold);
  margin: 15px 0;
}

.gameover-rewards {
  display: flex;
  justify-content: center;
  gap: 30px;
  font-size: 1.2rem;
  color: var(--green);
  margin-bottom: 20px;
}

.gameover-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-secondary {
  padding: 12px 30px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.btn-secondary:hover { background: rgba(255,255,255,0.1); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .search-bar input { width: 150px; }
  .game-title { font-size: 2.5rem; }
  .featured-banner { height: 200px; }
  .games-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
