:root {
  --bg: #12151c;
  --panel: #1b2030;
  --panel-2: #262d42;
  --text: #e8ebf3;
  --muted: #9aa3b8;
  --accent: #ffb300;
  --danger: #ff6b6b;
  --ball: 42px;
  --peg: 13px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at top, #1d2438 0%, var(--bg) 60%) fixed;
}

/* ---------- Kopf ---------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  max-width: 900px;
  margin: 0 auto;
}
h1 { margin: 0; font-size: 1.9rem; letter-spacing: .02em; }
h1 span { color: var(--accent); }
h2 { margin: 0 0 8px; font-size: 1.15rem; }
h3 { margin: 16px 0 6px; font-size: 1rem; color: var(--accent); }
.top-actions { display: flex; gap: 8px; }

/* ---------- Buttons ---------- */
button { font: inherit; color: inherit; }
.primary, .ghost {
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid transparent;
}
.primary { background: var(--accent); color: #1b1300; font-weight: 700; }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.ghost { background: transparent; border-color: #3a435c; }
.ghost:hover:not(:disabled) { background: var(--panel-2); }
button:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: auto minmax(280px, 360px);
  gap: 24px;
  justify-content: center;
  align-items: start;
  padding: 8px 24px 40px;
}

/* ---------- Brett ---------- */
.board {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(160deg, #6b4423, #3f2814);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .55), inset 0 0 0 2px rgba(255, 255, 255, .06);
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px 6px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .2);
}
.row.current {
  background: rgba(255, 179, 0, .16);
  outline: 2px solid rgba(255, 179, 0, .55);
}
.code-row {
  background: rgba(0, 0, 0, .42);
  margin-bottom: 6px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .08);
}
.rownum {
  width: 20px;
  text-align: center;
  font-size: .8rem;
  color: rgba(255, 255, 255, .5);
}
.slots { display: flex; gap: 8px; }
.slot {
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: default;
}
.slot.editable { cursor: pointer; }
.slot.active .ball { box-shadow: 0 0 0 3px var(--accent); }

/* ---------- Kugeln ---------- */
.ball {
  display: inline-grid;
  place-items: center;
  width: var(--ball);
  height: var(--ball);
  border-radius: 50%;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  background: radial-gradient(circle at 32% 28%,
    color-mix(in srgb, var(--c) 50%, white) 0%,
    var(--c) 45%,
    color-mix(in srgb, var(--c) 65%, black) 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .5);
}
.ball.empty {
  background: radial-gradient(circle at 50% 40%, #1a1109, #2d1c0e);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, .75);
}
.ball.hidden {
  background: radial-gradient(circle at 32% 28%, #4a526b, #232839);
  color: var(--muted);
  text-shadow: none;
}

/* ---------- Feedback-Pegs ---------- */
.fb {
  display: grid;
  grid-template-columns: repeat(2, var(--peg));
  gap: 4px;
  margin-left: auto;
}
.board.positional .fb { grid-template-columns: repeat(4, var(--peg)); }
.peg {
  display: inline-block;
  width: var(--peg);
  height: var(--peg);
  padding: 0;
  border-radius: 50%;
  border: 0;
  vertical-align: middle;
}
.peg.none { background: #1a1109; box-shadow: inset 0 2px 3px rgba(0, 0, 0, .8); }
.peg.black { background: radial-gradient(circle at 35% 30%, #555, #050505); box-shadow: 0 0 0 1px #8b8b8b; }
.peg.white { background: radial-gradient(circle at 35% 30%, #fff, #c9c9c9); box-shadow: 0 0 0 1px #fff; }
button.peg { cursor: pointer; }
button.peg:hover { transform: scale(1.25); }

/* ---------- Seitenpanel ---------- */
.panel { display: flex; flex-direction: column; gap: 12px; }
.card {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}
.card p { margin: 6px 0; }
.hint { color: var(--muted); font-size: .82rem; }
.error { color: var(--danger); font-weight: 600; }
.legend { line-height: 1.9; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.score { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.score .num { font-size: 2rem; font-weight: 800; }
.score .num.lead { color: var(--accent); }
.score .who { font-size: .85rem; color: var(--muted); }
.score .mid { text-align: center; }
.meta { margin-top: 8px; font-size: .85rem; color: var(--muted); text-align: center; }

.status h2 { color: var(--accent); }

.palette { display: flex; flex-wrap: wrap; gap: 8px; }
.pal {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--panel-2);
  cursor: pointer;
}
.pal:hover:not(:disabled) { border-color: var(--accent); }
.pal small { color: var(--muted); font-size: .72rem; }

.over { border: 2px solid var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 10px;
  background: #000d;
  border: 1px solid #444;
  z-index: 50;
}

/* ---------- Dialoge ---------- */
dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 22px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid #3a435c;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .7);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.field { display: grid; gap: 4px; margin: 10px 0; }
.field span { font-size: .85rem; color: var(--muted); }
select {
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid #3a435c;
  font: inherit;
}
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; cursor: pointer; }
.check em { color: var(--muted); font-size: .85rem; }
.rules ul, .rules ol { margin: 6px 0; padding-left: 22px; }
.rules li { margin: 4px 0; line-height: 1.4; }
.rules p { line-height: 1.5; }

/* ---------- Mobil ---------- */
@media (max-width: 760px) {
  :root { --ball: 36px; --peg: 11px; }
  .layout { grid-template-columns: 1fr; padding: 8px 12px 32px; justify-items: center; }
  .panel { width: 100%; max-width: 420px; }
  .top { padding: 12px; }
  .slots { gap: 6px; }
  .row { gap: 8px; }
}
