/* Core variables */
:root {
  color-scheme: dark;
  --bg: radial-gradient(circle at 8% 12%, rgba(120, 90, 255, 0.18), transparent 45%),
    radial-gradient(circle at 85% 8%, rgba(64, 192, 255, 0.18), transparent 50%),
    #050815;
  --panel: rgba(14, 18, 34, 0.9);
  --panel-strong: rgba(18, 22, 42, 0.95);
  --border: rgba(140, 110, 255, 0.45);
  --text: #eef1ff;
  --muted: #98a1c7;
  --accent: #7d5af0;
  --accent-rose: #ff70b9;
  --accent-cyan: #39cfda;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --radius: 18px;
  --radius-lg: 26px;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-strong: rgba(255, 255, 255, 0.08);
  --font-display: "Space Grotesk", "Rajdhani", "Inter", "SF Pro Display", system-ui, sans-serif;
  --font-body: "Inter", "Space Grotesk", system-ui, sans-serif;
}

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

body.dashboard {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  padding: 0;
}

.hidden {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  transition: top 0.3s ease;
  z-index: 999;
}

.skip-link:focus {
  top: 1rem;
}

/* Header */
.command-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  padding: 18px clamp(16px, 3vw, 30px);
  gap: 1.2rem;
  background: linear-gradient(120deg, rgba(8, 10, 24, 0.9), rgba(12, 14, 28, 0.8));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45), 0 0 22px rgba(125, 90, 240, 0.35);
  backdrop-filter: blur(10px);
}

.command-bar__side {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.command-bar__side--right {
  margin-left: auto;
}

.branding-stack {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.command-bar__logo {
  font-family: var(--font-display);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 700;
  color: #fff;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  background: linear-gradient(120deg, rgba(125, 90, 240, 0.85), rgba(57, 207, 218, 0.75));
  box-shadow: 0 8px 24px rgba(125, 90, 240, 0.4);
}

.command-bar__titles h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.08em;
}

.round-panel {
  padding: 0.8rem 1.2rem;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(125, 90, 240, 0.25), rgba(57, 207, 218, 0.25));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 30px rgba(125, 90, 240, 0.35);
}

.round-counter {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.round-counter__label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.75);
}

.round-counter__value {
  font-size: 1.05rem;
  font-weight: 700;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 14px;
  padding: 0.75rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(130deg, #7d5af0, #39cfda);
  box-shadow: 0 12px 30px rgba(125, 90, 240, 0.4);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 16px 36px rgba(125, 90, 240, 0.5);
  filter: brightness(1.05);
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: linear-gradient(130deg, #6d5aff, #5ce6ff);
}

.btn--outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.actions-grid {
  display: grid;
  gap: 0.4rem;
}

.action-row {
  display: flex;
  gap: 0.4rem;
  flex-direction: column;
  align-items: stretch;
}

.action-row--secondary .btn {
  background: linear-gradient(120deg, #ff70b9, #7d5af0);
}

.action-row--table .btn {
  background: linear-gradient(120deg, #39cfda, #7d5af0);
}

/* Layout */
.grid--dashboard {
  display: grid;
  grid-template-columns: minmax(520px, 1.6fr) minmax(320px, 0.8fr);
  gap: 1.2rem;
  padding: clamp(16px, 3vw, 28px);
  max-width: 1400px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow);
  padding: 1.6rem;
  backdrop-filter: blur(8px);
}

.panel__head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.panel__hints {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel--agents {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel--intel {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 0.8rem;
}

.intel-card {
  background: var(--panel-strong);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.intel-card--chart,
.intel-card--timer {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.timer-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.timer-option {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  padding: 0.45rem 0.9rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.timer-option.is-active {
  background: linear-gradient(120deg, #7d5af0, #39cfda);
  border-color: rgba(125, 90, 240, 0.8);
  box-shadow: 0 12px 24px rgba(125, 90, 240, 0.45);
}

.timer-readout {
  font-size: 2.2rem;
  font-weight: 700;
}

.agents-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.4rem;
  scroll-snap-type: x mandatory;
}
.agents-grid::-webkit-scrollbar {
  height: 8px;
}
.agents-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.agent-card {
  position: relative;
  padding: 1rem;
  border-radius: 16px;
  background: linear-gradient(150deg, rgba(14, 18, 34, 0.95), rgba(18, 22, 42, 0.85));
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.45), 0 0 18px rgba(125, 90, 240, 0.25);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  min-width: 260px;
  scroll-snap-align: start;
}

.agent-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.55), 0 0 24px rgba(125, 90, 240, 0.35);
}

.agent-card.active-player {
  border-color: var(--border);
  box-shadow: 0 0 18px rgba(125, 90, 240, 0.7);
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.player-meta__avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: radial-gradient(circle, rgba(125, 90, 240, 0.4), rgba(57, 207, 218, 0.3));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.player-meta__info {
  display: flex;
  flex-direction: column;
}

.player-meta__name {
  font-weight: 700;
}

.player-meta__job {
  color: var(--muted);
  font-size: 0.88rem;
}

/* Ranking overlay */
#ranking-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.65);
  z-index: 9999;
}

#ranking-overlay.hidden {
  display: none;
}

.ranking-card {
  width: min(960px, 94vw);
  background: var(--panel-strong);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.6), 0 0 24px rgba(125, 90, 240, 0.35);
  padding: 1.6rem;
  position: relative;
}

.ranking-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
}

.ranking-header h2 {
  margin: 0;
  letter-spacing: 0.18em;
}

.ranking-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.ranking-table thead th {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
  color: var(--muted);
}

.ranking-table tbody tr {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
  border-radius: 12px;
}

.ranking-table td {
  padding: 0.9rem 1rem;
}

/* Startplayer popup */
.startplayer-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.startplayer-popup.show {
  opacity: 1;
  pointer-events: auto;
}

.startplayer-popup-content {
  padding: 28px 42px;
  border-radius: 18px;
  background: rgba(12, 14, 30, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 28px rgba(125, 90, 240, 0.9);
}

#startplayer-popup-text {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.08em;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  padding: 0.85rem 1.2rem;
  border-radius: 12px;
  background: rgba(6, 8, 16, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

/* End overlay */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9500;
}

.overlay__content {
  background: rgba(10, 12, 22, 0.92);
  border-radius: 18px;
  padding: 1.6rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 22px rgba(125, 90, 240, 0.3);
}

.overlay__content img {
  max-width: 120px;
  display: block;
  margin: 0 auto 0.8rem;
}

/* End-round popup removed */

/* Utilities */
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.78rem;
  color: var(--muted);
}

@media (max-width: 1024px) {
  .grid--dashboard {
    grid-template-columns: 1fr;
  }

  .command-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .action-row {
    justify-content: flex-start;
    flex-direction: row;
    align-items: center;
  }
}

@media (max-width: 640px) {
  .command-bar__logo {
    font-size: 0.9rem;
  }

  .command-bar__titles h1 {
    font-size: 1.1rem;
  }
}
