:root {
  --bg: #060914;
  --bg-soft: #0b1120;
  --panel: #101827;
  --panel-2: #111d2f;
  --line: rgba(104, 240, 255, 0.22);
  --line-strong: rgba(104, 240, 255, 0.5);
  --text: #edf7ff;
  --muted: #9ab0c8;
  --cyan: #68f0ff;
  --blue: #4c8dff;
  --lime: #a7ff5f;
  --magenta: #ff5fd2;
  --danger: #ff657c;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(104, 240, 255, 0.13), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(255, 95, 210, 0.1), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family: "Kanit", sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--cyan);
}

.app-shell {
  color: var(--text);
}

.admin-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 28px 20px;
  background: rgba(8, 13, 27, 0.92);
  border-right: 1px solid var(--line);
}

.brand-block {
  display: grid;
  gap: 4px;
  padding: 12px 10px 28px;
}

.brand-name {
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 700;
}

.brand-subtitle,
.eyebrow,
.hint-text,
.muted-cell {
  color: var(--muted);
}

.brand-subtitle,
.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
}

.side-nav {
  display: grid;
  gap: 10px;
}

.side-link {
  display: block;
  padding: 13px 14px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
}

.side-link:hover,
.side-link.active {
  color: var(--text);
  background: rgba(104, 240, 255, 0.08);
  border-color: var(--line);
  box-shadow: inset 0 0 18px rgba(104, 240, 255, 0.08);
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.admin-name {
  color: var(--muted);
}

.main-panel {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 34px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 9, 20, 0.74);
  backdrop-filter: blur(12px);
}

.topbar h1,
.section-head h2,
.panel h3,
.player-header h1,
.login-copy h1,
.player-card h1,
.game-hero h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0;
}

.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--lime);
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--lime);
  box-shadow: 0 0 18px rgba(167, 255, 95, 0.85);
}

.content-wrap {
  width: min(1440px, 100%);
  padding: 34px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 34px;
}

.metric-card,
.panel,
.form-panel,
.table-shell,
.login-panel,
.player-card,
.score-stage,
.game-hero {
  background: linear-gradient(180deg, rgba(16, 24, 39, 0.96), rgba(9, 16, 31, 0.96));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 22px;
}

.metric-card span {
  color: var(--muted);
}

.metric-card strong {
  color: var(--cyan);
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1;
  text-shadow: 0 0 18px rgba(104, 240, 255, 0.38);
}

.section-head,
.panel-head,
.control-row,
.hero-meta,
.form-actions,
.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-head {
  margin-bottom: 18px;
}

.btn {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 600;
}

.btn-neon {
  color: #03111b;
  background: linear-gradient(135deg, var(--cyan), var(--lime));
  border: 0;
  box-shadow: 0 0 22px rgba(104, 240, 255, 0.28);
}

.btn-neon:hover,
.btn-neon:focus {
  color: #03111b;
  filter: brightness(1.08);
}

.btn-outline-neon {
  color: var(--cyan);
  border-color: var(--line-strong);
  background: rgba(104, 240, 255, 0.04);
}

.btn-outline-neon:hover,
.btn-outline-neon:focus {
  color: var(--text);
  border-color: var(--cyan);
  background: rgba(104, 240, 255, 0.14);
}

.btn-outline-danger-neon {
  color: var(--danger);
  border-color: rgba(255, 101, 124, 0.5);
  background: rgba(255, 101, 124, 0.04);
}

.btn-outline-danger-neon:hover,
.btn-outline-danger-neon:focus {
  color: var(--text);
  border-color: var(--danger);
  background: rgba(255, 101, 124, 0.14);
}

.table-shell {
  overflow: hidden;
}

.table-shell.embedded {
  box-shadow: none;
}

.neon-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--line);
  color: var(--text);
}

.neon-table th {
  color: var(--muted);
  font-weight: 500;
}

.neon-table td,
.neon-table th {
  padding: 15px 18px;
}

.code-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.code-pill {
  color: var(--cyan);
  background: rgba(104, 240, 255, 0.09);
  border: 1px solid var(--line);
}

.status-pill {
  color: var(--muted);
  background: rgba(154, 176, 200, 0.1);
  border: 1px solid rgba(154, 176, 200, 0.24);
}

.status-open {
  color: var(--lime);
  background: rgba(167, 255, 95, 0.1);
  border-color: rgba(167, 255, 95, 0.35);
}

.status-closed {
  color: var(--danger);
  background: rgba(255, 101, 124, 0.1);
  border-color: rgba(255, 101, 124, 0.35);
}

.status-draft {
  color: var(--cyan);
  background: rgba(104, 240, 255, 0.08);
  border-color: var(--line);
}

.auth-wrap,
.player-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 34px;
  width: min(980px, 100%);
  padding: 36px;
}

.login-copy {
  align-self: center;
}

.login-copy h1 {
  margin-bottom: 14px;
  font-size: clamp(2.2rem, 7vw, 4.8rem);
}

.login-copy p:last-child {
  max-width: 560px;
  color: var(--muted);
  font-size: 1.1rem;
}

.neon-form .form-label {
  color: var(--text);
}

.form-control,
.form-select {
  min-height: 46px;
  color: var(--text);
  background-color: rgba(5, 11, 24, 0.84);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.form-control:focus,
.form-select:focus {
  color: var(--text);
  background-color: rgba(5, 11, 24, 0.96);
  border-color: var(--cyan);
  box-shadow: 0 0 0 0.2rem rgba(104, 240, 255, 0.12);
}

.form-control::placeholder {
  color: rgba(154, 176, 200, 0.72);
}

.form-panel {
  padding: 26px;
}

.wide-form {
  width: 100%;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 24px;
}

.game-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 24px;
  padding: 26px;
  margin-bottom: 18px;
}

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

.qr-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  color: var(--muted);
}

.qr-panel img {
  width: 180px;
  height: 180px;
  padding: 10px;
  background: white;
  border-radius: 8px;
}

.control-row {
  justify-content: flex-start;
  margin-bottom: 18px;
}

.dashboard-columns,
.api-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.4fr);
  gap: 18px;
}

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

.panel {
  padding: 22px;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head span {
  color: var(--muted);
}

.leaderboard-list {
  display: grid;
  gap: 10px;
}

.leader-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px;
  background: rgba(104, 240, 255, 0.045);
  border: 1px solid rgba(104, 240, 255, 0.14);
  border-radius: 8px;
}

.leader-row:first-child {
  border-color: rgba(167, 255, 95, 0.42);
  box-shadow: inset 0 0 20px rgba(167, 255, 95, 0.08);
}

.leader-row.is-me {
  border-color: rgba(255, 95, 210, 0.5);
  background: rgba(255, 95, 210, 0.08);
}

.rank {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--bg);
  background: var(--cyan);
  border-radius: 999px;
  font-weight: 700;
}

.name {
  overflow-wrap: anywhere;
}

.score {
  color: var(--lime);
  font-size: 1.25rem;
}

.info-list {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
}

.info-list dt {
  color: var(--muted);
  font-weight: 500;
}

.info-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.code-block {
  margin: 0;
  padding: 16px;
  color: var(--cyan);
  background: rgba(5, 11, 24, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
}

.player-card {
  width: min(680px, 100%);
  padding: 28px;
}

.join-card {
  text-align: center;
}

.player-copy {
  color: var(--muted);
}

.big-input {
  min-height: 58px;
  text-align: center;
  font-size: 1.2rem;
}

.player-game {
  display: grid;
  gap: 18px;
  width: min(760px, 100%);
}

.player-header {
  width: 100%;
}

.score-stage {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
}

.score-label {
  color: var(--muted);
  font-size: 1.1rem;
}

.score-number {
  color: var(--cyan);
  font-size: clamp(4rem, 18vw, 8rem);
  line-height: 0.95;
  text-shadow: 0 0 30px rgba(104, 240, 255, 0.35);
}

.tap-button {
  width: min(360px, 100%);
  min-height: 118px;
  color: #03111b;
  background: linear-gradient(135deg, var(--cyan), var(--lime));
  border: 0;
  border-radius: 8px;
  box-shadow: 0 0 28px rgba(104, 240, 255, 0.34);
  font-family: inherit;
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 700;
  transition: transform 120ms ease, filter 120ms ease;
}

.tap-button:not(:disabled):active,
.tap-button.is-pressing {
  transform: scale(0.97);
  filter: brightness(1.08);
}

.tap-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.7) brightness(0.72);
}

.leaderboard-card {
  width: 100%;
}

.empty-state {
  display: grid;
  gap: 12px;
  justify-items: start;
  width: min(720px, 100%);
  padding: 28px;
  background: rgba(16, 24, 39, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.alert-danger {
  color: #ffdbe2;
  background: rgba(255, 101, 124, 0.12);
  border-color: rgba(255, 101, 124, 0.4);
}

.alert-success,
.neon-alert {
  color: #edffd9;
  background: rgba(167, 255, 95, 0.1);
  border-color: rgba(167, 255, 95, 0.36);
}

.table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.table-actions form {
  margin: 0;
}

.delete-panel {
  max-width: 760px;
}

.delete-summary {
  display: grid;
  gap: 8px;
  padding: 18px;
  background: rgba(255, 101, 124, 0.06);
  border: 1px solid rgba(255, 101, 124, 0.28);
  border-radius: 8px;
}

.delete-summary h3 {
  margin: 0 0 10px;
}

@media (max-width: 1100px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

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

@media (max-width: 760px) {
  .content-wrap,
  .topbar,
  .sidebar {
    padding: 20px;
  }

  .topbar,
  .section-head,
  .player-header,
  .game-hero,
  .login-panel {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head,
  .player-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .api-grid {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 24px;
  }

  .game-hero {
    display: grid;
  }

  .hero-meta,
  .control-row,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .control-row form,
  .control-row button,
  .form-actions .btn {
    width: 100%;
  }

  .table-shell {
    overflow-x: auto;
  }

  .neon-table {
    min-width: 680px;
  }

  .info-list {
    grid-template-columns: 1fr;
  }
}
