:root {
  --bg: #0f0f12;
  --fg: #eaeaf0;
  --muted: #9aa0a6;
  --panel: #15161b;
  --accent: #6ee7ff;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

button,
select {
  cursor: pointer !important;
}
input[type="range"] {
  cursor: grab !important;
}
/* Menu */
#menu {
  max-width: 420px;
  margin: 6vh auto;
  background: var(--panel);
  padding: 20px;
  border-radius: 12px;
}
#menu h1 {
  margin: 0 0 12px;
  font-size: 22px;
}
.row-join {
  display: flex !important;
}
#joinBtn {
  width: 100%;
}
#menu .row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
}
#menu label {
  color: var(--muted);
}
#menu input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #2a2d35;
  background: #0d0f14;
  color: var(--fg);
}
#menu input.error {
  border-color: #ff4d4f;
  color: #ff4d4f;
}
#menu button {
  padding: 8px 12px;
  border: 1px solid #2a2d35;
  border-radius: 8px;
  background: #1e2028;
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease, transform 0.05s ease;
}
#menu button:hover {
  background: #242633;
  border-color: #3a3f4d;
  box-shadow: 0 0 0 1px rgba(110, 231, 255, 0.15) inset;
}
#menu button:active {
  transform: translateY(1px);
}
#menu button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#menu .hint {
  color: var(--muted);
  margin-top: 8px;
  font-size: 13px;
}

.board {
  display: flex;
  flex-direction: row;
  gap: 10px;
  width: 100%;
}

.score {
  display: flex;
  justify-content: space-between;
}
.rooms {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
}
.rooms th,
.rooms td {
  border-bottom: 1px solid #2a2d35;
  padding: 6px 8px;
  text-align: left;
}
.rooms td .lock {
  color: #ffd93b;
}

.hidden {
  display: none;
}

/* Game */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid #262a32;
}
.status {
  color: var(--muted);
}
.actions {
  display: flex;
  gap: 8px;
}
.actions select,
.actions button {
  padding: 6px 8px;
  border: 1px solid #2a2d35;
  border-radius: 8px;
  background: #1e2028;
  color: var(--fg);
  transition: background 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease, transform 0.05s ease;
}
.actions button:hover,
.audio-controls button:hover {
  background: #242633;
  border-color: #3a3f4d;
  box-shadow: 0 0 0 1px rgba(110, 231, 255, 0.15) inset;
}
.actions button:active,
.audio-controls button:active {
  transform: translateY(1px);
}
.actions button:focus-visible,
.audio-controls button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Modal close button hover */
.modal header button:hover {
  background: #272a36;
  border-color: #3a3f4d;
}
.audio-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}
.audio-controls input[type="range"] {
  width: 120px;
}

/* Start button glow when ready */
@keyframes btn-glow {
  0% {
    box-shadow: 0 0 0px rgba(110, 231, 255, 0), 0 0 0px rgba(48, 232, 122, 0);
  }
  50% {
    box-shadow: 0 0 16px rgba(110, 231, 255, 0.35),
      0 0 28px rgba(48, 232, 122, 0.25);
  }
  100% {
    box-shadow: 0 0 0px rgba(110, 231, 255, 0), 0 0 0px rgba(48, 232, 122, 0);
  }
}
#startBtn.glow {
  border-color: #30e87a;
  animation: btn-glow 1.6s ease-in-out infinite;
}

.boardwrap {
  display: flex;
  flex-direction: row;
  gap: 16px;
  padding: 16px;
}
#opponents {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.main {
  display: flex;
  gap: 14px;
  flex-direction: column;
  position: relative; /* needed for overlay positioning */
}
.hud {
  background: var(--panel);
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #262a32;
  font-size: 14px;
  height: fit-content;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
/* removed #inv: inventory display moved into powers panel */
.hud .powers {
  border: 1px solid #2a2d35;
  border-radius: 8px;
  padding: 8px;
  background: #101219;
}
.hud .powers-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.hud .powers-body {
  font-weight: 600;
}
/* Special inventory badges */
.hud .powers-body .sp-badge {
  display: inline-block;
  min-width: 22px;
  height: 26px;
  line-height: 22px;
  text-align: center;
  margin-right: 6px;
  margin-bottom: 4px;
  border: 1px solid #2a2d35;
  border-radius: 6px;
  background: #0d0f14;
  color: #eaeaf0;
  font-weight: 700;
}
.hud .powers-body .sp-badge.current {
  border-color: #ff4d4f;
  box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2) inset;
}
.hud .nextwrap {
  display: inline-block;
}
.hud .next-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.hud #next {
  background: #0d0f14;
  border: 1px solid #2a2d35;
  border-radius: 6px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.mini {
  background: var(--panel);
  border: 1px solid #262a32;
  border-radius: 10px;
  padding: 8px;
}
.mini.selected {
  border-color: #30e87a;
  box-shadow: 0 0 0 2px rgba(48, 232, 122, 0.25) inset;
}
.minihead {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dead player minis appear inactive */
.mini.dead {
  opacity: 0.55;
}
.mini.dead canvas {
  filter: grayscale(0.6);
  cursor: not-allowed !important;
}
.mini.dead .minihead {
  color: #555;
}

/* Chat */
.chat {
  border-top: 1px solid #262a32;
  display: grid;
  grid-template-columns: 1fr;
  padding: 10px 16px;
  gap: 8px;
}
#log {
  height: 120px;
  overflow: auto;
  font-size: 13px;
  background: #0d0f14;
  border: 1px solid #262a32;
  border-radius: 8px;
  padding: 8px;
}
#chatForm input {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #2a2d35;
  background: #0d0f14;
  color: var(--fg);
}

/* Canvas */
canvas {
  display: block;
  background: #000;
  border: 2px solid #333;
}
canvas.self-selected {
  border-color: #30e87a;
  box-shadow: 0 0 0 2px rgba(48, 232, 122, 0.25) inset;
}

/* Waiting overlay and pulse effect */
.wait-overlay {
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(1px);
}
.wait-overlay .pulse {
  color: #eaeaf0;
  font-weight: 700;
  background: rgba(13, 15, 20, 0.8);
  border: 1px solid #2a2d35;
  border-radius: 10px;
  padding: 10px 12px;
  animation: waiting-pulse 1.6s ease-in-out infinite;
}
@keyframes waiting-pulse {
  0% {
    box-shadow: 0 0 0 rgba(110, 231, 255, 0);
  }
  50% {
    box-shadow: 0 0 18px rgba(110, 231, 255, 0.25);
  }
  100% {
    box-shadow: 0 0 0 rgba(110, 231, 255, 0);
  }
}
canvas.waiting {
  animation: canvas-breathe 1.8s ease-in-out infinite;
}
@keyframes canvas-breathe {
  0% {
    box-shadow: 0 0 0 0 rgba(48, 232, 122, 0);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(48, 232, 122, 0.18) inset;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(48, 232, 122, 0);
  }
}
