:root {
  color-scheme: light;
  --bg: #142116;
  --ink: #f4f0dd;
  --muted: #b8c3a9;
  --line: #46523f;
  --panel: #243124;
  --panel2: #1b261d;
  --accent: #4fa34d;
  --accent2: #7c72d8;
  --gold: #e0b849;
  --danger: #b9483f;
  --stone: #6d716c;
  --shadow: rgba(0, 0, 0, .42);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(16, 31, 19, .86), rgba(12, 18, 14, .96)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(255,255,255,.035) 31px 32px),
    repeating-linear-gradient(90deg, #1d3920 0 31px, #244525 31px 32px);
  color: var(--ink);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, #426b32 0 8%, #3a5d2d 8% 16%, #5a452e 16% 24%, #6f5234 24% 32%, transparent 32%),
    linear-gradient(180deg, transparent 0 64%, rgba(18, 13, 10, .45) 64%);
  opacity: .45;
  image-rendering: pixelated;
}
button, input, textarea, select { font: inherit; }
button {
  border: 2px solid #1a2618;
  background: linear-gradient(#67bd5e, #34873f);
  color: white;
  padding: 10px 14px;
  border-radius: 3px;
  cursor: pointer;
  min-height: 42px;
  box-shadow: inset 0 2px rgba(255,255,255,.25), inset 0 -3px rgba(0,0,0,.25), 0 3px 0 #101710;
  text-shadow: 0 1px 0 rgba(0,0,0,.55);
  font-weight: 700;
}
button:hover { filter: brightness(1.08); transform: translateY(-1px); }
button:active { transform: translateY(2px); box-shadow: inset 0 2px rgba(0,0,0,.28); }
button.ghost { background: linear-gradient(#3c453d, #242c27); color: var(--ink); border-color: #6a7569; }
button.danger { background: linear-gradient(#d06458, #9f342e); }
input, textarea, select {
  width: 100%;
  border: 2px solid #111812;
  border-radius: 3px;
  padding: 10px;
  background: #131b16;
  color: var(--ink);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.06), inset 0 -2px 0 rgba(0,0,0,.28);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { resize: vertical; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 4px solid #111812;
  background:
    linear-gradient(180deg, rgba(56, 82, 49, .95), rgba(30, 45, 31, .98)),
    repeating-linear-gradient(90deg, transparent 0 23px, rgba(255,255,255,.05) 23px 24px);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 12px 24px var(--shadow);
}
.topbar h1 { font-size: 24px; margin: 0; letter-spacing: 0; text-shadow: 0 3px 0 #0b130d; }
.topbar p { margin: 3px 0 0; color: #d5dfc7; font-weight: 700; }
.layout { max-width: 1280px; margin: 0 auto; padding: 20px; }
.band { padding: 14px 0; }
.metrics { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 12px; }
.metrics div {
  background:
    linear-gradient(180deg, rgba(255,255,255,.05), transparent),
    repeating-linear-gradient(135deg, rgba(255,255,255,.035) 0 8px, transparent 8px 16px),
    var(--panel);
  border: 3px solid #111812;
  border-top-color: #4d6048;
  border-left-color: #4d6048;
  border-radius: 4px;
  padding: 12px;
  box-shadow: 0 5px 0 rgba(0,0,0,.32);
  min-height: 84px;
}
.metrics span { display: block; color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; }
.metrics strong { display: block; font-size: 20px; margin-top: 4px; overflow-wrap: anywhere; color: #fff8d8; }
#status[data-state="running"] { color: #74e06d; }
#status[data-state="starting"] { color: #f0d55f; }
#status[data-state="stopping"] { color: #ffad5d; }
#status[data-state="failed"] { color: #ff7770; }
#status[data-state="stopped"] { color: #d0d0c0; }
.connection-panel {
  display: grid;
  grid-template-columns: minmax(240px, .8fr) minmax(0, 1.8fr);
  gap: 16px;
  margin-top: 16px;
  background:
    linear-gradient(135deg, rgba(124, 114, 216, .22), rgba(79, 163, 77, .13)),
    rgba(10, 17, 14, .72);
  border: 3px solid #111812;
  border-top-color: #66735e;
  border-left-color: #66735e;
  border-radius: 5px;
  padding: 16px;
  box-shadow: 0 8px 0 rgba(0,0,0,.34);
}
.connection-hero {
  display: grid;
  align-content: center;
  gap: 6px;
  min-height: 150px;
}
.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.connection-hero h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  color: #fff8d8;
  text-shadow: 0 3px 0 #0b130d;
  overflow-wrap: anywhere;
}
.connection-hero p {
  margin: 0;
  color: #d5dfc7;
}
.connection-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.connection-cards article {
  background: rgba(7, 16, 11, .78);
  border: 2px solid #111812;
  border-top-color: #4e5d4b;
  border-left-color: #4e5d4b;
  border-radius: 4px;
  padding: 14px;
  min-height: 104px;
}
.connection-cards span,
.connection-cards small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}
.connection-cards strong {
  display: block;
  margin: 5px 0;
  font-size: 20px;
  color: #fff8d8;
  overflow-wrap: anywhere;
}
#crossplayStatus[data-state="ok"] { color: #74e06d; }
#crossplayStatus[data-state="warn"] { color: #f0d55f; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), rgba(0,0,0,.06)),
    var(--panel2);
  border: 3px solid #111812;
  border-top-color: #536452;
  border-left-color: #536452;
  border-radius: 4px;
  padding: 16px;
  margin-top: 16px;
  box-shadow: 0 8px 0 rgba(0,0,0,.34);
}
.panel h2 {
  margin: -2px 0 14px;
  font-size: 18px;
  color: #ffe68a;
  text-shadow: 0 2px 0 #0d120e;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.row { display: flex; gap: 10px; align-items: stretch; }
.row input { min-width: 0; }
.memory-row label { flex: 1; display: grid; gap: 6px; color: var(--muted); font-weight: 800; }
.memory-row label span { font-size: 12px; text-transform: uppercase; }
.memory-row button { align-self: end; }
.muted { color: var(--muted); }
.players { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.players li {
  border: 2px solid #111812;
  border-radius: 3px;
  padding: 7px 10px;
  background: linear-gradient(#3e6f3d, #244b2a);
  color: #f7ffe7;
  box-shadow: inset 0 2px rgba(255,255,255,.12), 0 3px 0 rgba(0,0,0,.24);
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background:
    radial-gradient(circle at 12px 12px, rgba(91, 231, 133, .09) 0 2px, transparent 3px),
    #07100b;
  background-size: 24px 24px;
  color: #bfffbf;
  border: 3px solid #111812;
  border-top-color: #303a32;
  border-left-color: #303a32;
  border-radius: 4px;
  padding: 12px;
  min-height: 80px;
  max-height: 520px;
  overflow: auto;
}
.logs { font-size: 13px; line-height: 1.45; }
.compact-log { max-height: 240px; min-height: 160px; }
.list-board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.list-board section {
  border: 2px solid #111812;
  border-top-color: #4e5d4b;
  border-left-color: #4e5d4b;
  border-radius: 3px;
  background: rgba(0,0,0,.18);
  padding: 10px;
  min-height: 120px;
}
.list-board h3 { margin: 0 0 8px; font-size: 14px; color: #ffe68a; }
.mini-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.mini-list li {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(15, 24, 17, .82);
  border-radius: 3px;
  padding: 7px 8px;
  overflow-wrap: anywhere;
}
.mini-list span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.mini-empty { margin: 0; }
.properties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tabs button { background: linear-gradient(#5d645a, #343c35); color: var(--ink); border-color: #111812; min-height: 38px; }
.tabs button.active { background: linear-gradient(#d6b74f, #9d792d); color: #171308; border-color: #111812; text-shadow: none; }
.field label { display: flex; justify-content: space-between; gap: 10px; font-weight: 650; margin-bottom: 4px; }
.field label span { color: var(--muted); font-size: 12px; font-weight: 500; align-self: center; overflow-wrap: anywhere; }
.field small { display: block; color: var(--muted); margin-top: 4px; min-height: 34px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.toolbar button { background: var(--accent2); padding: 8px 10px; min-height: 36px; }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(26, 63, 31, .65), rgba(19, 20, 15, .95)),
    repeating-linear-gradient(0deg, #31592f 0 32px, #654b31 32px 64px, #514235 64px 96px);
}
.login-shell { width: min(420px, calc(100vw - 32px)); }
.login-panel {
  background: linear-gradient(180deg, rgba(255,255,255,.05), transparent), var(--panel2);
  border: 4px solid #111812;
  border-top-color: #566755;
  border-left-color: #566755;
  border-radius: 4px;
  padding: 28px;
  box-shadow: 0 12px 0 rgba(0,0,0,.38);
}
.login-panel h1 { margin: 0 0 20px; text-shadow: 0 3px 0 #0b130d; }
.login-panel button { width: 100%; margin-top: 14px; }
.error { color: var(--danger); }
[data-role="admin"] .participant-only { display: none; }
[data-role="participant"] .admin-only { display: none; }
@media (max-width: 820px) {
  .topbar { align-items: flex-start; padding: 14px 16px; }
  .topbar h1 { font-size: 20px; }
  .layout { padding: 12px; }
  .metrics, .grid, .properties, .list-board, .connection-panel, .connection-cards { grid-template-columns: 1fr; }
  .row { flex-direction: column; }
}

.participant-page {
  color-scheme: dark;
  background:
    linear-gradient(180deg, rgba(16, 20, 19, .72), rgba(6, 9, 10, .96)),
    radial-gradient(circle at top left, rgba(96, 150, 112, .28), transparent 36%),
    linear-gradient(135deg, #12181a, #090c0d);
  background-size: cover, auto;
  background-attachment: fixed;
}
.participant-page::before {
  opacity: .16;
  background:
    linear-gradient(120deg, rgba(121, 164, 117, .22), transparent 42%),
    linear-gradient(180deg, transparent 0, rgba(0, 0, 0, .5) 100%);
}
.player-hero {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(28, 35, 36, .82);
  box-shadow: 0 22px 70px rgba(0,0,0,.42);
  backdrop-filter: blur(18px);
}
.player-hero h1 {
  margin: 4px 0 2px;
  font-size: clamp(32px, 6vw, 58px);
  line-height: 1;
  color: #fff;
  text-shadow: none;
}
.player-hero p { margin: 0; color: #cbd8c7; font-weight: 800; }
.player-status {
  min-width: 180px;
  display: grid;
  gap: 4px;
  justify-items: end;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(12, 17, 18, .72);
}
.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #a8adbd;
  box-shadow: 0 0 0 6px rgba(168, 173, 189, .12);
}
.status-dot[data-state="on"] { background: #57e68c; box-shadow: 0 0 0 6px rgba(87, 230, 140, .14); }
.status-dot[data-state="off"] { background: #ff6972; box-shadow: 0 0 0 6px rgba(255, 105, 114, .14); }
.player-status strong { color: #fff; font-size: 22px; }
.player-status small { color: #aab9aa; }
.player-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 18px auto 40px;
}
.player-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.player-card {
  padding: 18px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.11);
  background: linear-gradient(180deg, rgba(42, 50, 49, .84), rgba(24, 31, 32, .84));
  box-shadow: 0 18px 54px rgba(0,0,0,.32);
  backdrop-filter: blur(18px);
}
.player-card p {
  line-height: 1.55;
}
.wide-card { grid-column: span 2; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head span,
.player-card label span,
.soft-line {
  color: #abb9aa;
  font-size: 13px;
  font-weight: 800;
}
.card-head strong { color: #fff; font-size: 22px; }
.participant-page input,
.participant-page textarea,
.participant-page select {
  margin-top: 6px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  background: rgba(12, 16, 17, .82);
  color: #f8fbff;
  box-shadow: none;
}
.participant-page button {
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #79b978, #4c8754);
  color: #07110a;
  box-shadow: 0 10px 26px rgba(61, 111, 70, .25);
  text-shadow: none;
}
.participant-page button.ghost {
  background: rgba(255,255,255,.1);
  color: #f8fbff;
  box-shadow: none;
}
.participant-page button.danger {
  background: linear-gradient(180deg, #d79a61, #a35d3e);
  color: #180d07;
  box-shadow: 0 10px 26px rgba(163, 93, 62, .25);
}
.participant-page button:disabled {
  cursor: wait;
  opacity: .72;
  transform: none;
}
.control-stack { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.split-row { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 12px; align-items: end; }
.warning-text {
  margin: 12px 0 0;
  color: #ffdcb5;
  line-height: 1.55;
}
.confirm-dialog {
  max-width: 440px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  color: #f8fbff;
  background: rgba(24, 31, 32, .97);
  box-shadow: 0 26px 90px rgba(0,0,0,.55);
}
.confirm-dialog::backdrop { background: rgba(5, 8, 16, .72); backdrop-filter: blur(4px); }
.confirm-dialog h2 { margin: 8px 0; }
.confirm-dialog label { display: block; margin-top: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  min-width: 240px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 14px;
  border-radius: 8px;
  background: rgba(34, 58, 43, .96);
  color: #fff;
  box-shadow: 0 18px 52px rgba(0,0,0,.4);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast[data-kind="bad"] { background: rgba(103, 55, 40, .96); }
.mini-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 820px) {
  .player-hero { align-items: stretch; flex-direction: column; margin-top: 12px; }
  .player-status { justify-items: start; }
  .player-grid, .split-row { grid-template-columns: 1fr; }
  .wide-card { grid-column: auto; }
  .control-stack { grid-template-columns: 1fr; }
}
