:root {
  --accent-a: #667eea;
  --accent-b: #764ba2;
  --success: #4caf50;
  --danger: #f44336;
  --warning: #ff9800;
  --ink: #333;
  --muted: #666;
  --soft: #f7f7fb;
  --line: #e8e8ef;
  --card: rgba(255, 255, 255, 0.96);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--accent-a) 0%, var(--accent-b) 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none !important;
  box-shadow: none !important;
}

a {
  color: inherit;
}

.admin-shell {
  width: min(1200px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 36px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding: 18px 20px;
  border-radius: 15px;
  background: var(--card);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.16);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-a) 0%, var(--accent-b) 100%);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.muted {
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions a,
.top-actions button,
.secondary-button,
.primary-button,
.warning-button,
.danger-button,
.ghost-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font-weight: 800;
  text-decoration: none;
}

.top-actions a,
.top-actions button,
.secondary-button,
.ghost-button {
  background: #f0f0f0;
  color: var(--ink);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent-a) 0%, var(--accent-b) 100%);
  color: #fff;
}

.warning-button {
  background: var(--warning);
  color: #fff;
}

.danger-button {
  background: var(--danger);
  color: #fff;
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.warning-button:hover:not(:disabled),
.danger-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled),
.top-actions a:hover,
.top-actions button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.28);
}

.login-card,
.dashboard {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.login-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 30px;
  align-items: center;
  padding: 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-a);
  font-weight: 900;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.05;
}

.login-card p {
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 22px;
  border-radius: 16px;
  background: var(--soft);
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

input,
textarea {
  width: 100%;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  padding: 14px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent-a);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.form-message,
.status-line {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.dashboard {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.dashboard-head,
.section-head,
.room-title-row,
.room-actions,
.broadcast-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.dashboard-head h1 {
  margin-bottom: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: 14px;
  background: var(--soft);
}

.tab {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.tab.is-active {
  background: #fff;
  color: var(--accent-a);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.tab-panel {
  display: grid;
  gap: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card,
.admin-card,
.room-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.stat-card {
  display: grid;
  gap: 7px;
  padding: 18px;
}

.stat-card strong {
  color: var(--accent-a);
  font-size: 32px;
}

.stat-card span {
  color: var(--muted);
  font-weight: 800;
}

.admin-card {
  padding: 18px;
}

.rooms-list {
  display: grid;
  gap: 14px;
}

.room-item {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.room-item.playing {
  border-color: rgba(76, 175, 80, 0.5);
  background: #f1f8e9;
}

.room-item.waiting {
  border-color: rgba(33, 150, 243, 0.45);
}

.room-name {
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 900;
}

.status-badge {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-badge.waiting {
  background: #e3f2fd;
  color: #1976d2;
}

.status-badge.playing {
  background: #e8f5e9;
  color: #388e3c;
}

.status-badge.finished {
  background: #f5f5f5;
  color: #666;
}

.room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.players-list {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--soft);
}

.player-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.player-item:last-child {
  border-bottom: 0;
}

.player-name {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.player-id,
.room-id {
  color: #999;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.room-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.empty-state {
  padding: 36px;
  border-radius: 14px;
  background: var(--soft);
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

@media (max-width: 900px) {
  .admin-shell {
    width: min(100% - 24px, 760px);
  }

  .admin-topbar,
  .dashboard-head,
  .section-head,
  .broadcast-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .login-card {
    grid-template-columns: 1fr;
    padding: 22px;
  }

  .dashboard {
    padding: 16px;
  }

  .tabs {
    overflow-x: auto;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .top-actions,
  .room-actions {
    width: 100%;
  }

  .top-actions a,
  .top-actions button,
  .room-actions button {
    flex: 1;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
