:root {
  --paper: #fbf8ef;
  --ink: #1d1b2e;
  --line: rgba(80, 140, 220, 0.22);
  --accent: #e63946;
  --card: #ffffff;
  --font-hand: "Patrick Hand", "Comic Sans MS", "Comic Neue", cursive;
  --font-comic: "Bangers", Impact, "Arial Black", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 18px;
  background-color: var(--paper);
  background-image: linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 32px;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 10px 14px 9px 13px;
  padding: 6px 12px;
  cursor: pointer;
  box-shadow: 2px 3px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s;
}
button:hover { transform: translate(-1px, -1px); box-shadow: 3px 4px 0 var(--ink); }
button:active { transform: translate(2px, 3px); box-shadow: 0 0 0 var(--ink); }
button.active { background: #ffe066; }
button.big {
  font-family: var(--font-comic);
  font-size: 30px;
  letter-spacing: 1px;
  padding: 8px 28px;
  background: var(--accent);
  color: #fff;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 5px;
  border: 1.5px solid var(--ink);
  border-radius: 5px;
  background: #fff;
  font-family: inherit;
  text-align: center;
  line-height: 1.3;
}

.screen { padding-inline: 16px; }

.title { text-align: center; padding-block: 12px 4px; }
.title h1 {
  margin: 0;
  font-family: var(--font-comic);
  font-size: clamp(40px, 7vw, 72px);
  letter-spacing: 2px;
  color: #ffd60a;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-2deg);
}
.title p { margin: 4px 0 0; font-size: 20px; }

.card {
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 18px 12px 20px 14px;
  box-shadow: 4px 5px 0 var(--ink);
  padding: 16px;
}

.player-tabs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-block: 14px;
  flex-wrap: wrap;
}
.player-tab { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.player-tab .dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--ink);
}

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  gap: 20px;
  max-width: 900px;
  margin-inline: auto;
}
@media (max-width: 760px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
}

.draw-panel { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.part-tabs { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.part-group { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; align-items: center; }
.part-group .label { margin: 0 4px 0 0; }
.hint { margin: 0; text-align: center; min-height: 2.6em; max-width: 440px; line-height: 1.3; }

#draw-canvas {
  width: min(100%, 420px);
  aspect-ratio: 1;
  background: #fff;
  border: 2.5px dashed var(--ink);
  border-radius: 12px;
  cursor: crosshair;
  touch-action: none;
}

.tools { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.swatch {
  width: 30px; height: 30px;
  padding: 0;
  border-radius: 50%;
  box-shadow: 1px 2px 0 var(--ink);
}
.swatch.active { outline: 3px solid var(--ink); outline-offset: 2px; }
.swatch input[type="color"] {
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}
.swatch.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); position: relative; overflow: hidden; }

.brush-sizes { display: flex; gap: 8px; }
.brush-size { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
.brush-size span { display: block; background: var(--ink); border-radius: 50%; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.preview-panel { display: flex; flex-direction: column; gap: 12px; }
.name-field { display: flex; flex-direction: column; font-size: 16px; }
.name-field input {
  font: inherit;
  font-size: 22px;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
}
.label { font-size: 16px; display: block; margin-bottom: 4px; }
#body-colors { justify-content: flex-start; }

#preview-canvas {
  width: 100%;
  max-width: 260px;
  align-self: center;
  background: repeating-linear-gradient(transparent 0 31px, var(--line) 31px 32px), var(--paper);
  border: 2px solid var(--ink);
  border-radius: 12px;
}

.stats { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 17px; }
.stats li { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 8px; }
.stats .bar {
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.stats .bar i { display: block; height: 100%; background: var(--accent); }
.stats small { opacity: 0.7; }
.stats li.stats-title { display: block; font-weight: bold; margin-top: 4px; }

.start-panel {
  max-width: 900px;
  margin: 22px auto;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 24px;
  align-items: center;
  justify-content: center;
}
.picker-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.picker-row .label { margin: 0; }
.picker { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.picker button.active { background: #ffadc0; }

#net-overlay { position: fixed; z-index: 20; }
#net-overlay p { font-size: 20px; max-width: 460px; margin: 0 auto 18px; }

/* Admin-Ansicht */
body.admin .tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: 1700px;
  margin: 0 auto 30px;
}
@media (max-width: 1100px) { body.admin .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { body.admin .tiles { grid-template-columns: minmax(0, 1fr); } }
.tile { padding: 10px; }
.tile header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.tile .dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  margin: 0 4px;
  vertical-align: middle;
}
.tile canvas { width: 100%; height: auto; aspect-ratio: 16 / 9; display: block; border-radius: 8px; border: 2px solid var(--ink); }
.tile.ended { opacity: 0.5; }
.login { max-width: 420px; margin: 20px auto; display: flex; flex-direction: column; gap: 12px; }
.empty { text-align: center; font-size: 20px; }
.cpu-toggle { font-size: 20px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.cpu-toggle input { width: 20px; height: 20px; }

.controls-help { max-width: 900px; margin: 0 auto 30px; }
.controls-help h2 { margin: 0 0 8px; font-family: var(--font-comic); letter-spacing: 1px; font-weight: normal; }
.controls-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.controls-grid p { margin: 4px 0 0; line-height: 1.6; }

#game-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #2b2d42;
  padding: 0;
}
#game-canvas {
  width: min(100vw, calc(100vh * 16 / 9));
  height: auto;
  aspect-ratio: 16 / 9;
  display: block;
}
#game-canvas.mouse-aim { cursor: none; }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(29, 27, 46, 0.35);
  padding-inline: 16px;
}
.overlay .card { text-align: center; padding: 24px 32px; }
.overlay h2 {
  font-family: var(--font-comic);
  font-weight: normal;
  font-size: 48px;
  letter-spacing: 1px;
  margin: 0 0 18px;
}
.overlay-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; align-items: center; }
