:root {
  color-scheme: dark;
  --bg: #14171c;
  --card: #1c2028;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --text-dim: #9aa3b2;
  --accent: #5aa9e6;
  --good: #4caf6f;
  --bad: #e0554f;
  --warn: #e0a64f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.brand-block { display: flex; flex-direction: column; gap: .1rem; }
.brand { color: var(--text); font-weight: 600; text-decoration: none; font-size: 1.1rem; }
.brand-subtitle { color: var(--text-dim); text-decoration: none; font-size: .75rem; }
.brand-subtitle:hover { color: var(--accent); text-decoration: underline; }
.topbar nav a, .topbar nav .link-button { color: var(--text-dim); text-decoration: none; margin-left: 1rem; }
.topbar nav a:hover, .topbar nav .link-button:hover { color: var(--accent); }
.inline-form { display: inline; }
.link-button {
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
}

main { max-width: 1800px; margin: 0 auto; padding: 1.5rem 2rem; }

.layout-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 900px) {
  .layout-3col { grid-template-columns: 1fr; }
}
.col-right:empty { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.card.narrow { max-width: 360px; margin: 3rem auto; }

h1 { font-size: 1.3rem; margin-top: 0; }
h2 { font-size: 1rem; margin-top: 0; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
h3 { font-size: .85rem; color: var(--text-dim); margin-bottom: .4rem; }

.status-row { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.event-status-row { flex-wrap: wrap; }
.event-start-tonight-btn { margin-left: auto; }

.badge {
  display: inline-block;
  padding: .3rem .7rem;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  background: var(--border);
  color: var(--text-dim);
}
.badge.online { background: rgba(76,175,111,.15); color: var(--good); }
.badge.offline { background: rgba(224,85,79,.15); color: var(--bad); }

.metric { color: var(--text-dim); font-size: .95rem; }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .6rem;
  margin-top: .75rem;
}

.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem .8rem;
  min-width: 0;
}

.stat-label { font-size: .75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; }
.stat-value {
  font-size: 1rem;
  margin-top: .25rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.stat-value.fresh { color: var(--good); }
.stat-value.stale { color: var(--warn); }
.stat-value.unknown, .stat-value.never-checked { color: var(--text-dim); }

.stat-value-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.stat-value-row .stat-value { margin-top: 0; }
.copy-field-btn {
  flex: none;
  background: var(--border);
  color: var(--text-dim);
  padding: .2rem .55rem;
  font-size: .72rem;
  font-weight: 500;
}
.copy-field-btn:hover { background: #333a48; color: var(--text); }

.player-bubbles {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
}
.player-bubbles li { display: contents; }

button.player-pick {
  border: none;
  cursor: pointer;
  font: inherit;
}
button.player-pick.selected { background: var(--accent); color: #0b1420; }

.total-players-badge {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-dim);
}

.players-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
@media (max-width: 560px) { .players-row { grid-template-columns: 1fr; } }

.player-actions-col .button-row { margin-top: .25rem; }

.player-actions-col .button-row { margin-top: .25rem; }

#player-action-log {
  background: #0e1116;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .6rem .75rem;
  max-height: 140px;
  overflow-y: auto;
  font-size: .78rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 1rem;
}

.hint { color: var(--text-dim); font-size: .85rem; margin-bottom: 0; }
.error { color: var(--bad); }
.notice { color: var(--good); }

.button-row { display: flex; gap: .6rem; flex-wrap: wrap; }

button, input[type="submit"] {
  background: var(--accent);
  color: #0b1420;
  border: none;
  border-radius: 6px;
  padding: .5rem 1rem;
  font-weight: 600;
  cursor: pointer;
}
button.danger { background: var(--bad); color: #fff; }
button:disabled { opacity: .6; cursor: default; }

.admin-form {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: .6rem;
}
.admin-form:last-child { margin-bottom: 0; }

input[type="text"], input[type="password"], select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: .5rem .6rem;
  font-size: .9rem;
}
select, textarea {
  width: 100%;
  box-sizing: border-box;
}
textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem;
  resize: vertical;
  line-height: 1.5;
}

label { display: block; font-size: .85rem; color: var(--text-dim); margin-bottom: .3rem; }
form label { margin-top: .75rem; }
.checkbox { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text-dim); }
.checkbox input { width: auto; }

.content-editor-select { margin-bottom: .75rem; }
.content-editor-field { margin-bottom: .75rem; }
.content-editor-field:last-child { margin-bottom: 0; }
.content-editor-field input[type="text"] { width: 100%; box-sizing: border-box; }
#content-editor-overridden { color: var(--accent); margin-bottom: .5rem; }
.content-editor-actions { margin-top: .75rem; }

#connect-ip, #connect-port, #connect-password { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.connect-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}
.connect-actions .faq-details,
.connect-actions .steam-button {
  flex: 1 1 calc(50% - .5rem);
  box-sizing: border-box;
}
.connect-actions .faq-details[open] { flex-basis: 100%; }

.steam-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1.3rem;
  background: linear-gradient(135deg, #1b2838, #2a475e);
  color: #66c0f4;
  border: 1px solid #2a475e;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
}
.steam-button:hover { background: linear-gradient(135deg, #2a475e, #1b2838); color: #a6d8f7; }

.faq-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1.3rem;
  background: var(--border);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.faq-toggle::-webkit-details-marker { display: none; }
.faq-toggle::before {
  content: "\25B8";
  transition: transform .15s ease;
}
.faq-details[open] .faq-toggle::before { transform: rotate(90deg); }
.faq-toggle:hover { background: #333a48; }
.faq-content { margin-top: 1rem; }

#event-remaining { color: var(--accent); font-weight: 600; margin: .5rem 0 0; }
.admin-only-note {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px dashed var(--border);
  color: var(--warn);
}
.admin-only-note p { margin: .3rem 0; }
.admin-only-note p:first-child { margin-top: 0; }
.event-overrides {
  list-style: none;
  margin: .3rem 0 0;
  padding: 0;
  display: grid;
  gap: .25rem;
  font-size: .8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.event-divider {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.hint + .admin-form { margin-top: .75rem; }

.blurb {
  line-height: 1.6;
}
.blurb h1, .blurb h2:not(.card-title), .blurb h3 {
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  margin: 1.2rem 0 .5rem;
}
.blurb h1:first-child, .blurb h2:not(.card-title):first-child, .blurb h3:first-child { margin-top: 0; }
.blurb p { margin: .6rem 0; }
.blurb ul { padding-left: 1.2rem; }
.blurb li { margin: .3rem 0; }
.blurb hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.blurb code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1rem .35rem;
  font-size: .9em;
}
.blurb strong { color: var(--text); }
.blurb em { color: var(--text-dim); }
.blurb a { color: var(--accent); }
.blurb a:hover { text-decoration: none; }

.lore-details {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.lore-details summary {
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
  list-style: none;
}
.lore-details summary::-webkit-details-marker { display: none; }
.lore-details summary::before {
  content: "\25B8";
  display: inline-block;
  margin-right: .5rem;
  transition: transform .15s ease;
}
.lore-details[open] summary::before { transform: rotate(90deg); }
.lore-details summary:hover { color: var(--accent); }
.lore-content { margin-top: .75rem; }

#rcon-output, #console-output {
  background: #0e1116;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .75rem;
  max-height: 260px;
  overflow-y: auto;
  font-size: .82rem;
  white-space: pre-wrap;
  word-break: break-word;
}
#console-output { max-height: 320px; margin-bottom: .6rem; font-size: .74rem; }

.console-filter-row { margin-bottom: .6rem; }

.button-secondary {
  background: var(--border);
  color: var(--text);
  font-weight: 500;
}
.button-secondary:hover { background: #333a48; }
.console-filter.active {
  background: var(--accent);
  color: #0b1420;
  font-weight: 600;
}

.collapsible summary {
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
  list-style: none;
}
.collapsible summary::-webkit-details-marker { display: none; }
.collapsible summary::before {
  content: "\25B8";
  display: inline-block;
  margin-right: .5rem;
  transition: transform .15s ease;
}
.collapsible[open] summary::before { transform: rotate(90deg); }
.collapsible summary:hover { color: var(--accent); }
.collapsible-body { margin-top: .9rem; }
pre + .collapsible { margin-top: 1rem; }

/* Used when a <details> replaces a card's own <h2> (e.g. "Site content")
   rather than acting as a sub-section toggle -- same size/weight as h2. */
.collapsible-heading summary { font-size: 1rem; font-weight: 700; }

.rcon-help {
  list-style: none;
  margin: .5rem 0 1rem;
  padding: 0;
  display: grid;
  gap: .35rem;
  font-size: .8rem;
  color: var(--text-dim);
}
.rcon-help code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .05rem .35rem;
  color: var(--text);
  font-size: .85em;
}
