/* Admin-Oberfläche von Open Biosfear. Kein Framework; dunkel wie das Spiel. */
:root {
  --bg: #14161a;
  --panel: #1d2026;
  --panel-2: #262a32;
  --line: #343944;
  --text: #e6e3da;
  --dim: #9a9a94;
  --gold: #d9b45a;
  --green: #6fcf7a;
  --red: #e2604f;
  --blue: #7fc4ee;
  --purple: #ff73f2;
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.5rem; margin: 0 0 .25rem; color: var(--gold); }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; color: var(--gold); font-weight: 600; }
.card h2:not(:first-child) { margin-top: 1.2rem; }
p { margin: .4rem 0; }
.dim { color: var(--dim); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.error { color: var(--red); }

/* Eingaben */
input, select, textarea, button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .5rem .65rem;
  min-height: 2.4rem;
}
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
button { cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--gold); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: #5a4a1e; border-color: var(--gold); }
button.danger { border-color: #7a3a32; color: #ffb4a8; }
button.danger:hover { border-color: var(--red); }
label { display: block; margin: .6rem 0; color: var(--dim); font-size: .9rem; }
label > input, label > select, label > textarea { display: block; width: 100%; margin-top: .2rem; }
label.radio { display: inline-flex; align-items: center; gap: .4rem; color: var(--text); margin: .3rem .8rem .3rem 0; }
label.radio input { min-height: 0; width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: .6rem 0; padding: .4rem .7rem .7rem; }
legend { color: var(--dim); font-size: .9rem; padding: 0 .3rem; }
.inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .4rem 0; }
.inline label { margin: 0; display: inline-flex; align-items: center; gap: .4rem; }
.inline label > select { width: auto; margin: 0; }
.inline input[type=number] { width: 6.5rem; }
.inline input[type=search] { flex: 1 1 12rem; }

/* Anmeldung */
.login { min-height: 100%; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(24rem, 100%); }
.login-card button { width: 100%; margin-top: .6rem; }

/* Kopf und Navigation */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .5rem .9rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--gold); }
.nav { display: flex; gap: .3rem; flex: 1 1 auto; overflow-x: auto; }
.nav button { background: transparent; border-color: transparent; }
.nav button[aria-current=page] { background: var(--panel-2); border-color: var(--gold); color: var(--gold); }
.who { display: flex; align-items: center; gap: .6rem; margin-left: auto; }

main { padding: .9rem; max-width: 86rem; margin: 0 auto; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  margin-bottom: .9rem;
}
.columns { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); align-items: start; }
.columns > .card { margin-bottom: 0; }
.columns { margin-bottom: .9rem; }

/* Kennzahlen */
.cards { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); margin-bottom: .9rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; }
.stat .label { color: var(--dim); font-size: .82rem; }
.stat .value { font-size: 1.35rem; font-weight: 600; }
.stat .sub { color: var(--dim); font-size: .82rem; }

/* Tabellen */
.scroll { overflow-x: auto; }
.scroll.tall { max-height: 28rem; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--dim); font-weight: 500; position: sticky; top: 0; background: var(--panel); }
td.wrap { white-space: normal; min-width: 14rem; }
table.rows tbody tr { cursor: pointer; }
table.rows tbody tr:hover { background: var(--panel-2); }
table.rows.plain tbody tr { cursor: default; }
.empty { color: var(--dim); text-align: center; padding: 1rem; }

.badge { display: inline-block; padding: 0 .45rem; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: .8rem; color: var(--text); font-weight: 500; }
.tag { display: inline-block; padding: 0 .4rem; margin-right: .25rem; border-radius: 4px; font-size: .78rem; border: 1px solid var(--line); }
.tag.admin { color: var(--gold); border-color: var(--gold); }
.tag.ghost { color: var(--blue); border-color: var(--blue); }
.tag.peace { color: var(--green); border-color: var(--green); }
.tag.god { color: var(--purple); border-color: var(--purple); }
.tag.dead, .tag.off { color: var(--red); border-color: var(--red); }
.tag.on { color: var(--green); border-color: var(--green); }
#confirm-text { white-space: pre-line; }
#confirm-input { flex: 1 1 12rem; min-width: 0; }
.ok { color: var(--green); }
.bad { color: var(--red); }

/* Dialoge */
dialog.card { color: var(--text); width: min(34rem, calc(100% - 1.5rem)); max-height: calc(100% - 1.5rem); overflow: auto; margin: auto; }
#confirm-text { white-space: pre-line; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.dialog-head h2 { margin: 0; font-size: 1.25rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; }
.row-title { flex: 0 0 5.5rem; color: var(--dim); font-size: .9rem; }
.row input[type=number] { width: 5.5rem; }
.row input[name=item], .row select { flex: 1 1 10rem; min-width: 0; }

/* Karte */
.page-map { display: flex; flex-direction: column; }
.map-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; margin-bottom: .5rem; }
.map-wrap { position: relative; height: min(74vh, 60rem); min-height: 20rem; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #0c0d10; }
#map-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#map-canvas.dragging { cursor: grabbing; }
.map-menu { position: absolute; z-index: 3; margin: 0; padding: .6rem .7rem; width: 15.5rem; max-width: calc(100% - 1rem); box-shadow: 0 6px 24px rgba(0, 0, 0, .5); }
.map-menu select, .map-menu button { width: 100%; margin-top: .35rem; }
.map-menu .title { font-family: ui-monospace, Consolas, monospace; color: var(--gold); }

/* Protokoll */
.log { margin: 0; max-height: 26rem; overflow: auto; font: 12.5px/1.4 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; background: #0f1013; border: 1px solid var(--line); border-radius: 6px; padding: .6rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  max-width: calc(100% - 2rem); z-index: 20;
  background: var(--panel-2); border: 1px solid var(--green); border-radius: var(--radius);
  padding: .6rem 1rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
}
.toast.bad { border-color: var(--red); color: #ffb4a8; }

@media (max-width: 40rem) {
  main { padding: .6rem; }
  .who span { display: none; }
  .row-title { flex-basis: 100%; }
  th, td { padding: .35rem .45rem; }
}

/* Server: Einstellungen */
.settings-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1rem; align-items: start; }
.settings-card { margin: 0; padding: .6rem 1rem 1rem; }
.settings-card legend { color: var(--gold); font-size: 1rem; font-weight: 600; }
.settings-card[disabled] { opacity: .8; }
.setting { padding: .55rem 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.setting > label { margin: 0 0 .3rem; color: var(--text); font-size: .95rem; }
.setting-input { display: flex; align-items: center; gap: .5rem; }
.setting-input input[type=number] { width: 9rem; }
.setting-input input[type=checkbox] { min-height: 0; width: 1.3rem; height: 1.3rem; margin: 0; accent-color: var(--gold); }
.setting-input textarea { flex: 1 1 auto; }
.setting-hint { font-size: .82rem; margin: .3rem 0 0; }
.setting.changed > label::after { content: " · geändert"; color: var(--gold); font-size: .8rem; }
.settings-bar { position: sticky; bottom: .6rem; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: 1rem 0; }
.settings-bar #settings-changed { flex: 1 1 12rem; }
#restart-card { margin-top: 1rem; }
