:root {
  --ink: #2b2340;
  --ink-soft: #5b5577;
  --bg: #eef2f9;
  --card: #fff;
  --line: rgba(43, 35, 64, 0.1);
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --danger: #e11d48;
  font-family: 'Fredoka', 'Nunito', system-ui, sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 26px;
  font-weight: 700;
  color: #34d399;
  text-decoration: none;
}

.brand span {
  color: #a78bfa;
}

.brand small {
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 600;
  margin-left: 4px;
}

#who {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 600;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: 0 4px 18px rgba(40, 40, 90, 0.07);
  overflow-x: auto;
}

#gate {
  max-width: 380px;
  margin: 40px auto;
}

#gate form,
#gate label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#gate form {
  gap: 12px;
}

h1,
h2,
h3 {
  margin: 0 0 10px;
}

h2 {
  font-size: 18px;
}

h2:not(:first-child) {
  margin-top: 18px;
}

h3 {
  font-size: 14px;
  color: var(--ink-soft);
}

.count {
  font-size: 14px;
  color: var(--ink-soft);
}

.muted {
  color: var(--ink-soft);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.stat {
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 4px 18px rgba(40, 40, 90, 0.07);
}

.stat b {
  display: block;
  font-size: 24px;
}

.stat span {
  font-size: 13px;
  color: var(--ink-soft);
}

.grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td.num {
  font-variant-numeric: tabular-nums;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

input {
  font: inherit;
  font-size: 15px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 2px solid var(--line);
  flex: 1;
  min-width: 160px;
  outline: none;
}

select {
  font: inherit;
  font-size: 15px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: #fff;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 10px;
  cursor: pointer;
}

.check input {
  flex: none;
  min-width: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.skill {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 13px;
}

.meter {
  flex: 1;
  max-width: 240px;
  height: 10px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #4ade80, #facc15, #f43f5e);
  background-size: 240px 100%;
  transition: width 0.4s;
}

input:focus {
  border-color: var(--accent);
}

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  background: rgba(43, 35, 64, 0.07);
  color: var(--ink);
  cursor: pointer;
}

.btn:hover {
  filter: brightness(0.96);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.danger {
  background: rgba(225, 29, 72, 0.1);
  color: var(--danger);
}

.btn.small {
  font-size: 12px;
  padding: 4px 10px;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(43, 35, 64, 0.07);
}

.badge.ok {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-dark);
}

.badge.bad {
  background: rgba(225, 29, 72, 0.12);
  color: var(--danger);
}

.badge.admin {
  background: rgba(167, 139, 250, 0.2);
  color: #6d28d9;
}

.records {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: 14px;
}

.records ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.error {
  color: var(--danger);
  font-weight: 600;
  min-height: 1.2em;
  margin: 0;
}

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(43, 35, 64, 0.92);
  color: #fff;
  font-weight: 500;
}

.mode-status {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(14, 116, 144, 0.08);
  font-size: 15px;
}

.modes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 28px;
  margin-top: 8px;
}

.slots {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slots li {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
}

.slots li.now {
  font-weight: 700;
}

.slots li .grow {
  flex: 1;
}

.mins {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--ink-soft);
}

.mins input,
.slots input[type='number'] {
  flex: none;
  width: 76px;
  min-width: 0;
}

input[type='datetime-local'] {
  flex: 0 1 auto;
  min-width: 0;
}

.small-note {
  font-size: 12px;
  margin: 8px 0 0;
}

/* Space between the dashboard's sections (stats, players/broadcast, accounts). */
#dash {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Phones: each table row becomes a small labelled card instead of scrolling sideways. */
@media (max-width: 640px) {
  header {
    padding: 12px 16px;
  }
  main {
    padding: 14px 12px 32px;
  }
  .card {
    padding: 14px;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat b {
    font-size: 20px;
  }
  .records,
  .modes-grid {
    grid-template-columns: 1fr;
  }
  .slots li {
    gap: 6px;
  }
  .slots li select {
    flex: 1 1 0;
    min-width: 0;
  }
  .slots input[type='number'] {
    width: 58px;
  }
  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }
  thead {
    display: none;
  }
  tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 12px;
    background: rgba(43, 35, 64, 0.04);
  }
  td {
    padding: 0;
    border: none;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-soft);
  }
  /* Name across the top; action buttons across the bottom, no label. */
  td:first-child {
    grid-column: 1 / -1;
    font-weight: 700;
    font-size: 15px;
  }
  td:first-child::before,
  td:last-child::before {
    content: none;
  }
  td:last-child {
    grid-column: 1 / -1;
  }
  td:last-child .btn {
    width: 100%;
    padding: 8px;
  }
}
