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

:root {
  --bg-dark: #0a0a0f;
  --bg-panel: #1a1a2e;
  --bg-panel-alt: #16213e;
  --accent-green: #00ff88;
  --accent-blue: #00d4ff;
  --accent-red: #ff4444;
  --text-white: #ffffff;
  --text-gray: #a0a0b0;
  --border-color: rgba(255, 255, 255, 0.08);
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  --radius-card: 10px;
  --radius-btn: 6px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-white);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  user-select: none;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

/* ===== Screens ===== */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  z-index: 10;
  padding: 24px;
}

.screen.active {
  display: flex;
  animation: slideIn 0.3s ease-out;
}

.screen__title {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: -1px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.screen__subtitle {
  font-size: 0.85rem;
  color: var(--text-gray);
  text-align: center;
  margin-bottom: 24px;
}

.screen__content {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 24px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-white);
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.btn:hover {
  border-color: var(--accent-green);
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.25);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-primary {
  background: var(--accent-green);
  color: #0a0a0f;
  border-color: var(--accent-green);
  font-weight: 700;
}

.btn-primary:hover {
  background: #00e67a;
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
}

.btn-danger {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.btn-danger:hover {
  background: var(--accent-red);
  color: var(--text-white);
}

.btn-sm {
  min-height: 32px;
  padding: 6px 16px;
  font-size: 0.85rem;
  width: auto;
}

/* ===== Menu ===== */
.menu {
  gap: 14px;
}

.menu__input {
  width: 100%;
  max-width: 320px;
  min-height: 44px;
  padding: 10px 16px;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text-white);
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-btn);
  outline: none;
  text-align: center;
}

.menu__input::placeholder {
  color: var(--text-gray);
}

.menu__input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}

/* ===== Settings ===== */
.settings {
  gap: 20px;
}

.settings__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}

.settings__toggle {
  display: flex;
  gap: 4px;
}

.lang-btn {
  width: 48px !important;
  min-height: 36px !important;
}

.lang-btn.active {
  background: var(--accent-green);
  color: #0a0a0f;
  border-color: var(--accent-green);
}

/* ===== Lobby ===== */
.lobby {
  gap: 16px;
  max-height: 70vh;
  overflow-y: auto;
  width: 100%;
  max-width: 500px;
}

.lobby__list {
  width: 100%;
}

.lobby__list-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

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

.lobby__list-items li:hover {
  border-color: var(--accent-blue);
}

.lobby__empty {
  color: var(--text-gray);
  text-align: center;
  padding: 20px;
}

.lobby__create {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.lobby__active {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.lobby__player-count {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-gray);
}

.lobby__players {
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lobby__players li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-radius: var(--radius-btn);
  font-size: 0.9rem;
}

.lobby__quests {
  width: 100%;
}

.lobby__quests h3 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-blue);
  margin-bottom: 8px;
}

.lobby__quest-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lobby__quest-list li {
  font-size: 0.8rem;
  color: var(--text-gray);
  padding: 4px 0;
}

/* ===== Game Screen ===== */
#screen-game {
  padding: 0;
  z-index: 5;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== HUD ===== */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(to bottom, rgba(10, 10, 15, 0.85) 0%, transparent 100%);
  z-index: 20;
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
}

.hud__left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hud__score {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-white);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hud__score span:first-child {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hud__combo {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-green);
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.hud__coins {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: #ffd700;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hud__coins span:first-child {
  font-size: 0.65rem;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hud__lives {
  font-size: 1rem;
}

.hud__pause-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-white);
  cursor: pointer;
  transition: all 0.2s ease;
}

.hud__pause-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--accent-blue);
}

.hud__quests {
  position: absolute;
  top: 60px;
  right: 16px;
  width: 200px;
  background: rgba(26, 26, 46, 0.9);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 10px;
  z-index: 20;
  font-size: 0.75rem;
}

.quest-mini {
  padding: 3px 0;
  color: var(--text-gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combo-pop {
  animation: pulse 0.3s ease;
}

/* ===== Game Over ===== */
.gameover {
  gap: 16px;
  text-align: center;
}

.gameover__stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}

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

.gameover__stat span:first-child {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-gray);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 900;
  color: var(--text-white);
}

/* ===== Shop ===== */
.shop {
  gap: 14px;
  max-height: 80vh;
}

.shop__coins {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: #ffd700;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.shop__coins span:first-child {
  font-size: 0.75rem;
  color: var(--text-gray);
}

.shop__tabs {
  display: flex;
  gap: 4px;
  width: 100%;
}

.shop-tab-btn {
  flex: 1;
}

.shop-tab-btn.active {
  background: var(--accent-green);
  color: #0a0a0f;
  border-color: var(--accent-green);
}

.shop__items {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
}

.shop-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 16px 10px;
  text-align: center;
  transition: all 0.2s ease;
  position: relative;
}

.shop-item:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.shop-item__icon {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel-alt);
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.shop-item__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shop-item__name {
  font-size: 0.85rem;
  font-weight: 600;
}

.shop-item__desc {
  font-size: 0.7rem;
  color: var(--text-gray);
}

.shop-item__price {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #ffd700;
  font-weight: 700;
  margin-top: 4px;
}

.shop-item__badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 10px;
  border-radius: 20px;
  position: absolute;
  top: 8px;
  right: 8px;
}

.shop-item__badge--equipped {
  color: #0a0a0f;
  background: var(--accent-green);
}

/* ===== Animations ===== */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

@keyframes slideIn {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 3px; }

/* ===== Mobile ===== */
@media (max-width: 600px) {
  .screen__title { font-size: 1.8rem; }
  .screen__content { max-width: 100%; }
  .hud { padding: 8px 12px; }
  .hud__score { font-size: 1.2rem; }
  .hud__quests { display: none; }
  .shop__items { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 1.5rem; }
}
