:root {
  --bg: #07140f;
  --panel: rgba(16, 28, 22, 0.92);
  --line: rgba(255,255,255,0.1);
  --teal: #00d4aa;
  --ink: #e8fff6;
  --muted: #8aa396;
  --danger: #ef4444;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  overflow: hidden;
  position: fixed;
  inset: 0;
  touch-action: manipulation;
}
.screen { display: none; position: fixed; inset: 0; }
.screen.active { display: block; }
.hidden { display: none !important; }

.menu-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(0,212,170,.16), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(124,58,237,.14), transparent 42%),
    #07140f;
}
.menu-content, .lobby-panel, .gameover-panel, .settings-panel, .augment-panel {
  position: relative; z-index: 1;
  max-width: 460px; margin: 8vh auto 0;
  padding: 28px 22px calc(24px + var(--safe-bot));
  text-align: center;
}
.eyebrow {
  text-transform: uppercase; letter-spacing: .28em;
  font-size: 11px; color: var(--teal); margin-bottom: 8px;
}
.game-title {
  font-size: 48px; line-height: .9; font-weight: 900; letter-spacing: -1px;
}
.game-title span { color: var(--teal); }
.tagline { color: var(--muted); margin: 14px 0 22px; line-height: 1.4; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; }
.menu-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--ink);
  border-radius: 12px;
  padding: 13px 18px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.menu-btn.primary {
  background: linear-gradient(135deg, #00d4aa, #00b894);
  color: #04110c; border: none; width: 100%;
}
.menu-btn.small { margin-top: 16px; width: auto; padding: 8px 16px; font-size: 13px; }
.menu-footer {
  margin-top: 20px; color: var(--muted); font-size: 12px;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.blood-toggle { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.blood-toggle input { width: 18px; height: 18px; }

.lobby-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; text-align: left; }
.lobby-panel h2 { text-align: center; margin-bottom: 6px; }
.lobby-mode { text-align: center; color: var(--teal); font-size: 13px; margin-bottom: 14px; }
.lobby-panel label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 6px; }
.lobby-input, #roomCodeInput, #playerName {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: #fff;
  font-size: 16px;
}
#roomCodeInput {
  text-transform: uppercase; letter-spacing: 3px; text-align: center; font-weight: 800;
  flex: 1 1 auto; width: auto; min-width: 140px;
}
.lobby-options { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.divider { text-align: center; color: #667; font-size: 12px; }
.join-row { display: flex; align-items: stretch; gap: 8px; }
.btn-join { flex: 0 0 auto; width: auto !important; white-space: nowrap; padding: 10px 20px; }
.lobby-info { margin-top: 16px; }
.player-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.player-chip { background: rgba(255,255,255,.05); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.room-code-big { font-size: 28px; letter-spacing: 6px; color: var(--teal); font-weight: 900; }
.wait-msg { color: var(--muted); font-size: 13px; text-align: center; }
.lobby-error { color: #f87171; min-height: 18px; font-size: 13px; margin-top: 8px; text-align: center; }

#gameScreen { background: #0a1a12; }
#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  padding: calc(8px + var(--safe-top)) 10px 8px;
  display: flex; justify-content: space-between; gap: 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent);
  pointer-events: none;
}
.hud-left, .hud-right, .hud-mid { display: flex; gap: 8px; align-items: center; }
.hud-mid { flex-direction: column; text-align: center; }
.hud-item, #hudPhase { font-size: 12px; color: #d1fae5; }
#hudAugmentEta { font-size: 11px; color: var(--teal); }
.hud-btn {
  pointer-events: auto;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
  color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 12px;
}
#elixirBar {
  position: absolute; left: 12px; right: 12px; bottom: calc(92px + var(--safe-bot));
  height: 14px; border-radius: 8px; background: rgba(0,0,0,.45);
  overflow: hidden; z-index: 6; border: 1px solid rgba(250,204,21,.35);
}
#elixirFill { height: 100%; width: 50%; background: linear-gradient(90deg, #f59e0b, #fde68a); }
#elixirText { position: absolute; inset: 0; text-align: center; font-size: 10px; font-weight: 800; color: #111; }
.hand {
  position: absolute; left: 0; right: 0; bottom: var(--safe-bot);
  height: 90px; display: flex; gap: 6px; justify-content: center;
  padding: 6px 8px 8px; z-index: 6;
  background: linear-gradient(to top, rgba(0,0,0,.65), transparent);
}
.card {
  width: 72px; min-width: 64px; border-radius: 10px;
  border: 2px solid rgba(255,255,255,.12);
  background: #13241b; color: #fff; padding: 6px 4px;
  font-size: 10px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.card.selected { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(0,212,170,.3); }
.card.disabled { opacity: .4; }
.card-cost { font-weight: 900; color: #fbbf24; }
.card-name { font-weight: 700; line-height: 1.1; }
.card-role { color: #94a3b8; text-transform: uppercase; font-size: 8px; }
.drop-hint {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,.55); padding: 8px 12px; border-radius: 8px; z-index: 7;
}

.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.62);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.augment-panel, .settings-panel, .gameover-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  width: min(560px, 100%); margin: 0;
}
.augment-choices { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 14px; }
@media (min-width: 640px) { .augment-choices { grid-template-columns: 1fr 1fr 1fr; } }
.aug-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px;
  background: #102018; cursor: pointer; text-align: center;
}
.aug-card:hover, .aug-card:focus { border-color: var(--teal); }
.aug-rare { color: #67e8f9; }
.aug-epic { color: #c4b5fd; }
.aug-common { color: #86efac; }

@media (max-width: 520px) {
  .game-title { font-size: 40px; }
  .card { width: 62px; font-size: 9px; }
  #elixirBar { bottom: calc(84px + var(--safe-bot)); }
}
