:root {
  --bg-0: #02060d;
  --bg-1: #05121f;
  --panel: rgba(3, 19, 32, 0.86);
  --line: rgba(0, 255, 204, 0.25);
  --accent: #00ffcc;
  --accent-2: #ff9d4d;
  --text: #dff6ff;
  --muted: rgba(223, 246, 255, 0.72);
  --danger: #ff5454;
  --ready: #80ffe6;
  --warn: #ffd4a8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--text);
  font-family: "Share Tech Mono", "Consolas", monospace;
  background: radial-gradient(circle at 20% 10%, #08334d 0%, var(--bg-0) 45%, #01040a 100%);
}

.game-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  padding: 8px;
}

.hud-top {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, auto) minmax(220px, 1fr);
  gap: 8px;
  align-items: stretch;
}

.hp-card,
.status {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  backdrop-filter: blur(4px);
}

.status {
  min-width: 240px;
  display: grid;
  gap: 2px;
  align-content: center;
}

.status p,
.controls p {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
}

.slot-summary {
  color: var(--muted);
}

.role-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.hud-action {
  border: 1px solid rgba(0, 255, 204, 0.36);
  border-radius: 8px;
  color: var(--text);
  background: rgba(0, 255, 204, 0.08);
  padding: 7px 9px;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  text-align: center;
}

.hud-action.quit {
  border-color: rgba(255, 157, 77, 0.42);
  background: rgba(255, 157, 77, 0.1);
}

.hud-action.hidden {
  display: none;
}

.hud-action:hover {
  filter: brightness(1.12);
}

.hud-action:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  filter: none;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hp-card .label {
  margin: 0 0 4px 0;
  font-size: 12px;
  letter-spacing: 0.4px;
}

.hp-card .value {
  margin: 4px 0 0 0;
  font-size: 12px;
}

.slot-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid rgba(128, 255, 230, 0.35);
  padding: 2px 7px;
  color: var(--ready);
  background: rgba(0, 255, 204, 0.08);
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}

.slot-pill.taken {
  border-color: rgba(255, 157, 77, 0.35);
  color: var(--warn);
  background: rgba(255, 157, 77, 0.08);
}

.slot-pill.ai {
  border-color: rgba(144, 225, 255, 0.35);
  color: #bdefff;
  background: rgba(144, 225, 255, 0.08);
}

.bar-wrap {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.bar {
  width: 0%;
  height: 100%;
  transition: width 100ms linear;
}

.boss .bar {
  background: linear-gradient(90deg, #2dffb8, #00ffcc);
  box-shadow: 0 0 10px rgba(0, 255, 204, 0.6);
}

.human .bar {
  background: linear-gradient(90deg, #ffc28f, #ff9d4d);
  box-shadow: 0 0 10px rgba(255, 157, 77, 0.6);
}

.shield-wrap {
  width: 100%;
  height: 7px;
  margin-top: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.shield {
  width: 0%;
  height: 100%;
  transition: width 120ms linear;
  background: linear-gradient(90deg, rgba(144, 225, 255, 0.28), #9befff);
  box-shadow: 0 0 8px rgba(120, 230, 255, 0.52);
}

.shield-value {
  color: var(--muted);
  font-size: 10px;
}

.power-row {
  display: grid;
  grid-template-columns: auto minmax(58px, 1fr) auto;
  gap: 7px;
  align-items: center;
  margin-top: 6px;
}

.special-row {
  opacity: 0.92;
}

.power-chip,
.cooldown-text {
  font-size: 10px;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
}

.power-chip.ready,
.cooldown-text.ready {
  color: var(--ready);
}

.power-chip.active,
.cooldown-text.active {
  color: #ffffff;
  text-shadow: 0 0 8px rgba(0, 255, 204, 0.75);
}

.human-chip.active,
.human .cooldown-text.active {
  text-shadow: 0 0 8px rgba(255, 157, 77, 0.75);
}

.cooldown-wrap {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.cooldown-fill {
  width: 0%;
  height: 100%;
  transition: width 120ms linear, filter 120ms linear;
}

.boss-fill {
  color: #00ffcc;
  background: linear-gradient(90deg, rgba(0, 255, 204, 0.22), #00ffcc);
}

.human-fill {
  color: #ff9d4d;
  background: linear-gradient(90deg, rgba(255, 157, 77, 0.24), #ff9d4d);
}

.cooldown-fill.ready,
.cooldown-fill.active {
  filter: drop-shadow(0 0 6px currentColor);
}

.arena-wrap {
  position: relative;
  min-height: 0;
  border-radius: 8px;
  border: 1px solid rgba(0, 255, 204, 0.25);
  background: #020913;
  overflow: hidden;
}

#arena {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay-message {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 255, 204, 0.4);
  text-align: center;
  pointer-events: none;
  max-width: min(92vw, 620px);
  z-index: 3;
}

.toast-message {
  position: absolute;
  right: 14px;
  bottom: 14px;
  max-width: min(88vw, 360px);
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0, 255, 204, 0.36);
  color: var(--text);
  background: rgba(0, 7, 14, 0.72);
  box-shadow: 0 0 18px rgba(0, 255, 204, 0.12);
  font-size: 12px;
  line-height: 1.3;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
  z-index: 4;
}

.toast-message.show {
  opacity: 1;
  transform: translateY(0);
}

.controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(0, 255, 204, 0.22);
  background: var(--panel);
}

.controls p {
  color: var(--muted);
}

.controls span {
  display: inline-block;
  margin-right: 5px;
  color: var(--text);
}

.role-picker {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(1, 5, 10, 0.8);
  z-index: 50;
}

.role-picker.hidden {
  display: none;
}

.role-picker .panel {
  width: min(92vw, 540px);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid rgba(0, 255, 204, 0.45);
  background: linear-gradient(180deg, rgba(4, 20, 34, 0.95), rgba(2, 11, 20, 0.95));
  box-shadow: 0 0 34px rgba(0, 255, 204, 0.14);
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.role-picker h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1;
}

.role-picker p {
  margin: 0 0 12px 0;
  font-size: 13px;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.mode-btn {
  border: 1px solid rgba(0, 255, 204, 0.38);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(0, 12, 22, 0.72);
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  text-align: center;
}

.mode-btn.active {
  color: var(--text);
  border-color: rgba(255, 157, 77, 0.68);
  background: linear-gradient(90deg, rgba(255, 157, 77, 0.24), rgba(0, 255, 204, 0.1));
  box-shadow: 0 0 16px rgba(255, 157, 77, 0.12);
}

.role-picker .buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.role-picker button {
  display: grid;
  gap: 3px;
  text-align: left;
  border: 1px solid rgba(0, 255, 204, 0.45);
  border-radius: 8px;
  color: var(--text);
  background: linear-gradient(90deg, rgba(0, 255, 204, 0.2), rgba(0, 255, 204, 0.05));
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
}

.role-picker button small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.role-picker button:hover {
  filter: brightness(1.12);
}

.role-picker button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  filter: none;
}

.role-picker button.is-owned {
  border-color: rgba(255, 157, 77, 0.72);
  background: linear-gradient(90deg, rgba(255, 157, 77, 0.24), rgba(0, 255, 204, 0.08));
}

.role-picker button.is-taken {
  border-color: rgba(255, 157, 77, 0.38);
  color: rgba(223, 246, 255, 0.78);
  background: rgba(255, 157, 77, 0.08);
}

.role-picker button.is-pending {
  border-color: rgba(255, 212, 168, 0.72);
  background: linear-gradient(90deg, rgba(255, 212, 168, 0.2), rgba(0, 255, 204, 0.06));
}

.role-picker .mode-btn {
  display: block;
  text-align: center;
  border: 1px solid rgba(0, 255, 204, 0.38);
  color: var(--muted);
  background: rgba(0, 12, 22, 0.72);
}

.role-picker .mode-btn.active {
  color: var(--text);
  border-color: rgba(255, 157, 77, 0.68);
  background: linear-gradient(90deg, rgba(255, 157, 77, 0.24), rgba(0, 255, 204, 0.1));
}

.role-picker button.has-ai:not(:disabled) {
  border-color: rgba(144, 225, 255, 0.5);
}

.role-picker .close-picker {
  flex: 0 0 auto;
  display: block;
  width: auto;
  border-color: rgba(223, 246, 255, 0.22);
  color: var(--muted);
  background: rgba(0, 9, 18, 0.45);
  padding: 7px 9px;
  text-align: center;
  font-size: 11px;
}

.role-picker button.spectator-link {
  margin-top: 4px;
  border-color: rgba(223, 246, 255, 0.18);
  color: var(--muted);
  background: rgba(0, 9, 18, 0.45);
  padding: 8px 12px;
}

.role-picker .error {
  min-height: 18px;
  color: #ffc8a1;
}

.mobile-controls {
  position: fixed;
  inset: auto 8px 8px 8px;
  display: none;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.dpad {
  position: relative;
  width: 150px;
  height: 150px;
  pointer-events: auto;
}

.pad {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid rgba(0, 255, 204, 0.4);
  color: var(--text);
  background: rgba(0, 9, 18, 0.65);
  font: inherit;
  font-size: 18px;
}

.pad.up { left: 51px; top: 0; }
.pad.left { left: 0; top: 51px; }
.pad.down { left: 51px; top: 102px; }
.pad.right { left: 102px; top: 51px; }

.action-stack {
  display: grid;
  gap: 8px;
  justify-items: end;
  pointer-events: auto;
}

.fire-btn,
.special-btn {
  pointer-events: auto;
  border-radius: 999px;
  font: inherit;
}

.fire-btn {
  width: 96px;
  height: 96px;
  border: 1px solid rgba(255, 157, 77, 0.65);
  color: #ffe5d0;
  background: radial-gradient(circle at 35% 30%, rgba(255, 190, 132, 0.45), rgba(255, 130, 45, 0.28), rgba(30, 5, 0, 0.6));
}

.special-btn {
  width: 74px;
  height: 54px;
  border: 1px solid rgba(0, 255, 204, 0.62);
  color: #dff6ff;
  background: radial-gradient(circle at 35% 30%, rgba(0, 255, 204, 0.28), rgba(0, 70, 82, 0.52), rgba(0, 7, 14, 0.72));
}

@media (max-width: 900px) {
  .hud-top {
    grid-template-columns: 1fr;
  }

  .status {
    min-width: 0;
  }

  .game-shell {
    padding: 6px;
    gap: 6px;
  }

  .controls {
    justify-content: flex-start;
  }
}

@media (pointer: coarse) {
  .game-shell {
    padding-bottom: 116px;
  }

  .mobile-controls {
    display: flex;
  }

  .controls {
    display: none;
  }
}

@media (max-width: 520px) {
  .power-row {
    grid-template-columns: 1fr auto;
  }

  .power-row .cooldown-wrap {
    grid-column: 1 / -1;
    order: 3;
  }

  .role-picker .panel {
    padding: 16px;
  }

  .role-picker .buttons {
    grid-template-columns: 1fr;
  }
}
