:root {
  --bg: #0b0b0d;
  --bg-2: #141418;
  --card: #1a1a20;
  --line: #2c2c35;
  --text: #f2efe9;
  --muted: #a19d96;
  --red: #e0313b;
  --red-dark: #8f1a21;
  --gold: #e8b84a;
  --green: #4fbf7a;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(224, 49, 59, 0.18), transparent 60%),
    var(--bg);
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.wrap.wide { max-width: 1000px; }

header.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

header.brand svg { width: 30px; height: 30px; color: var(--red); flex: none; }

header.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

header.brand .spacer { flex: 1; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

h2 { margin: 0 0 12px; font-size: 1.3rem; }
h3 { margin: 0 0 10px; font-size: 1.05rem; color: var(--muted); font-weight: 600; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.center { text-align: center; }
.hidden { display: none !important; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  outline: none;
}

input:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(224, 49, 59, 0.25); }

input.code {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.4rem;
}

textarea { min-height: 220px; resize: vertical; line-height: 1.5; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 12px;
  padding: 14px 18px;
  cursor: pointer;
  color: var(--text);
  background: #2b2b33;
  text-decoration: none;
  touch-action: manipulation;
}

button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--red); color: #fff; }
button.primary:active { background: var(--red-dark); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
button.danger { background: transparent; border: 1px solid var(--red); color: var(--red); }
button.block { width: 100%; margin-top: 18px; padding: 18px; font-size: 1.1rem; }
button.sm { padding: 8px 12px; font-size: 0.85rem; border-radius: 9px; }

.error {
  background: rgba(224, 49, 59, 0.12);
  border: 1px solid rgba(224, 49, 59, 0.5);
  color: #ffb3b8;
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 14px;
}

.notice {
  background: rgba(232, 184, 74, 0.1);
  border: 1px solid rgba(232, 184, 74, 0.4);
  color: var(--gold);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

/* Spieleransicht */

.hello { color: var(--muted); margin-bottom: 4px; }

.target-card {
  text-align: center;
  padding: 34px 20px 30px;
  border-color: rgba(224, 49, 59, 0.45);
  background:
    radial-gradient(circle at 50% 30%, rgba(224, 49, 59, 0.16), transparent 70%),
    var(--card);
}

.target-label {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.8rem;
  color: var(--red);
  font-weight: 800;
}

.target-name {
  font-size: clamp(2.3rem, 11vw, 3.6rem);
  font-weight: 900;
  line-height: 1.1;
  margin: 14px 0 6px;
  word-break: break-word;
}

.crosshair { width: 64px; height: 64px; color: var(--red); margin: 0 auto 6px; display: block; }

.flash { animation: flash 1.2s ease-out; }
@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(224, 49, 59, 0.9); transform: scale(1.03); }
  100% { box-shadow: 0 0 0 30px rgba(224, 49, 59, 0); transform: scale(1); }
}

.stat {
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: baseline;
  color: var(--muted);
}
.stat strong { color: var(--text); font-size: 1.6rem; }

.big-state { text-align: center; padding: 40px 20px; }
.big-state .icon { font-size: 4rem; line-height: 1; margin-bottom: 12px; }
.big-state h2 { font-size: 2rem; }
.big-state.dead h2 { color: var(--red); }
.big-state.win h2 { color: var(--gold); font-size: 2.3rem; }
.winner-name { font-size: 2.4rem; font-weight: 900; color: var(--gold); margin: 6px 0 14px; word-break: break-word; }

.rules { color: var(--muted); font-size: 0.92rem; }
.rules summary { cursor: pointer; font-weight: 600; color: var(--text); }
.rules ol { padding-left: 1.2em; margin: 10px 0 0; }

footer.foot { margin-top: 24px; text-align: center; }

/* Dialog */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.dialog {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px 20px 20px;
}

.dialog h2 { color: var(--red); }
.dialog .row { display: flex; gap: 10px; margin-top: 20px; }
.dialog .row button { flex: 1; padding: 16px; }

@media (min-width: 600px) {
  .overlay { align-items: center; }
}

/* Admin */

.grid-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.grid-stats .card { margin: 0; text-align: center; padding: 14px 8px; }
.grid-stats strong { display: block; font-size: 1.7rem; }
.grid-stats span { color: var(--muted); font-size: 0.85rem; }

.players { display: grid; gap: 10px; }

.player-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.player-row.dead { opacity: 0.55; }
.player-row .pname { font-weight: 700; }
.player-row .meta { color: var(--muted); font-size: 0.88rem; }
.player-row .actions { display: flex; flex-wrap: wrap; gap: 8px; order: 3; }
.player-row .actions button { flex: 1 1 auto; }

.codebadge {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.15em;
  background: #000;
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--gold);
}

.tag { font-size: 0.75rem; padding: 2px 8px; border-radius: 99px; font-weight: 700; margin-left: 6px; }
.tag.alive { background: rgba(79, 191, 122, 0.15); color: var(--green); }
.tag.dead { background: rgba(224, 49, 59, 0.15); color: var(--red); }

.circle { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.circle .node { background: var(--bg-2); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-weight: 600; }
.circle .arrow { color: var(--red); }

.log { list-style: none; margin: 0; padding: 0; }
.log li {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.log li:last-child { border-bottom: 0; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }

.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 0; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--red); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 99px;
  font-weight: 700;
  z-index: 20;
  max-width: calc(100% - 32px);
  text-align: center;
}

@media (min-width: 760px) {
  .admin-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
}
