/* ─── Bomberman-specific styles ──────────────────────────── */
/* All CSS variables (--bg, --surface, --border, --accent, --danger, --good, --text, --muted) */
/* are inherited from ../style.css — do NOT redefine them here */

:root {
  --hud-h: 44px;
}

/* ─── Page layout ─── */
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ─── Spinner (from style.css base, repeated for portability) ─── */
.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 16px auto 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── HUD strip ─── */
#hud {
  height: var(--hud-h);
  background: rgba(0, 0, 0, 0.6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 13px;
  z-index: 10;
  flex-shrink: 0;
}
#hud.hidden { display: none; }

#hudLeft   { color: var(--text);   font-weight: 600; }
#hudCenter { color: #ffd700;       font-size: 15px; font-weight: 700; }
#hudRight  { color: var(--muted);  font-size: 11px; }

/* ─── Canvas wrap ─── */
#canvasWrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

#gameCanvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* Responsive: scale canvas to fit available area while keeping aspect ratio */
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ─── Lobby card ─── */
.lobby-card {
  max-width: 480px;
  width: 90vw;
  max-height: 90dvh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ─── Name input ─── */
.name-input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  box-sizing: border-box;
}
.name-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ─── Primary action button ─── */
.btn-primary {
  width: 100%;
  padding: 12px 20px;
  background: var(--good);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary:hover  { background: #81c784; }
.btn-primary:active { background: #4caf50; }
.btn-primary.hidden { display: none !important; }

/* ─── Player list ─── */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  max-height: 220px;
  overflow-y: auto;
}

.player-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.player-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-badge {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ─── Lobby settings ─── */
.lobby-settings {
  margin-bottom: 16px;
}

.settings-label {
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  display: block;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  gap: 12px;
}

.settings-row .settings-label {
  margin-bottom: 0;
}

/* ─── Map select dropdown ─── */
.map-select {
  padding: 6px 12px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  min-width: 120px;
}
.map-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ─── Toggle row ─── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.9rem;
}

/* ─── Toggle button ─── */
.toggle-btn {
  padding: 6px 18px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  min-width: 52px;
}
.toggle-btn.active {
  border-color: var(--good);
  background: rgba(102, 187, 106, 0.15);
  color: var(--good);
}

/* ─── Waiting text ─── */
.waiting-text {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
  margin-top: 12px;
}

/* ─── Utility: host-only / non-host-only ─── */
/* Controlled entirely via JS .style.display — no CSS needed */

/* ─── Countdown overlay ─── */
.countdown-number {
  font-size: 160px;
  font-weight: 900;
  color: #ffd700;
  text-shadow:
    0 0 20px rgba(255, 215, 0, 0.8),
    0 0 60px rgba(255, 215, 0, 0.4);
  animation: countdownPulse 1s ease-in-out infinite;
  user-select: none;
}

@keyframes countdownPulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.2); opacity: 0.75; }
}

/* ─── Scoreboard / Game Over card ─── */
.scoreboard-card {
  max-width: 480px;
  width: 90vw;
  max-height: 90dvh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ─── Winner text ─── */
.winner-text {
  font-size: 1.4rem;
  color: var(--accent);
  margin: 12px 0 20px;
  font-weight: 700;
}

/* ─── Rankings table ─── */
.rankings-section {
  margin: 12px 0 20px;
  width: 100%;
}

.rankings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.rankings-table th {
  padding: 8px 12px;
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.rankings-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.rank-num { text-align: center; font-weight: 700; }
.rank-1   { color: #ffd700; }
.rank-2   { color: #c0c0c0; }
.rank-3   { color: #cd7f32; }

.rank-1-row {
  background: rgba(255, 215, 0, 0.06);
}

/* ─── Mobile: lobby overlay scrolls vertically ─── */
@media (pointer: coarse), (max-width: 600px) {
  #lobbyOverlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: 16px 0 24px;
  }

  .overlay-card {
    padding: 20px 16px;
  }

  .lobby-card {
    width: 94vw;
    max-height: none;
  }

  .lobby-card .logo { font-size: 2rem; }
  .lobby-card h1    { font-size: 1.3rem; margin: 4px 0 6px; }

  .toggle-row   { padding: 6px 0; font-size: 0.85rem; }
  .settings-row { padding: 6px 0; font-size: 0.85rem; }

  .player-list {
    max-height: 140px;
  }
}

/* ─── Responsive canvas: scale to fit viewport on small screens ─── */
@media (max-width: 740px) {
  #gameCanvas {
    width: 100vw;
    height: auto;
  }
}

@media (max-height: 680px) {
  #gameCanvas {
    height: calc(100dvh - var(--hud-h));
    width: auto;
  }
}

/* ─── Score columns in rankings table ─── */
.rank-score {
  font-weight: 700;
  color: #ffd700;
}

.rankings-table td {
  text-align: center;
  font-size: 0.82rem;
}

.rankings-table td.rank-name {
  text-align: left;
}

/* ─── Fun stats awards ─── */
.awards-section {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.award-badge {
  padding: 8px 12px;
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: 8px;
  font-size: 0.85rem;
}

.award-icon {
  font-size: 1.1rem;
}

.award-title {
  font-weight: 700;
  color: #ffd700;
}

.award-player {
  color: var(--text);
}

.award-value {
  color: var(--muted);
  font-size: 0.8rem;
}

/* ─── Mobile controls ─── */
.bm-mobile-controls {
  position: fixed;
  bottom: 16px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 24px;
  z-index: 100;
  pointer-events: none;
}

.bm-mobile-controls > * {
  pointer-events: auto;
}

/* D-pad */
.bm-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.bm-dpad-row {
  display: flex;
  gap: 2px;
}

.bm-dpad-mid {
  align-items: center;
}

.bm-dpad-center {
  width: 48px;
  height: 48px;
}

.bm-dpad-btn {
  width: 48px;
  height: 48px;
  background: rgba(30, 30, 50, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.bm-dpad-btn:active {
  background: rgba(80, 80, 120, 0.9);
  border-color: var(--accent);
}

/* Bomb button */
.bm-bomb-btn {
  width: 80px;
  height: 80px;
  background: rgba(180, 20, 20, 0.85);
  border: 3px solid #ef5350;
  border-radius: 50%;
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  line-height: 1.2;
}

.bm-bomb-btn:active {
  background: rgba(220, 40, 40, 0.95);
}

/* ─── Audio control buttons ─── */
#bmSfxBtn, #bmMusicBtn, #bmSkipBtn {
  position: fixed;
  top: 8px;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  color: #fff;
  font-size: 0.85rem;
  padding: 4px 8px;
  cursor: pointer;
}

#bmSfxBtn { right: 8px; }
.bm-volume-slider { position: fixed; top: 12px; z-index: 1000; width: 60px; height: 20px; cursor: pointer; accent-color: #4caf50; }
#bmSfxVolSlider { right: 68px; }
#bmMusicBtn { right: 140px; }
#bmMusicVolSlider { right: 220px; }
#bmSkipBtn { right: 290px; }

/* Hide audio controls on very small screens where they overlap mobile controls */
@media (max-width: 400px) {
  #bmSkipBtn, #bmMusicVolSlider { display: none; }
}

/* Spectator banner — shown at top of screen when watching */
.spectator-banner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 180, 0, 0.92);
  color: #000;
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 0 0 8px 8px;
  font-size: 14px;
  letter-spacing: 1px;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.spectator-banner.hidden {
  display: none;
}
