:root {
  --bg: #0e0f13;
  --panel: #171920;
  --panel-2: #1f222b;
  --line: #2a2e39;
  --text: #f2f3f5;
  --muted: #8b90a0;
  --accent: #ff4d2e;
  --accent-2: #ffb020;
  --down: #2ee59d;
  --up: #ff5c6c;
  --gold: #ffcf3f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  font-variant-numeric: tabular-nums;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 13px; margin: -4px 0 10px; }

/* Kopf */
.top { padding: calc(10px + env(safe-area-inset-top)) 16px 4px; }
.brand { display: flex; align-items: center; gap: 8px; }
.logo { width: 34px; height: 34px; border-radius: 9px; display: block; }
h1 { margin: 0; font-size: 20px; letter-spacing: 1.5px; font-weight: 800; font-style: italic; }
h1 b { color: var(--accent); }
.icon-btn.plus { font-size: 24px; font-weight: 300; line-height: 1; color: #fff; background: var(--accent); border-color: var(--accent); }
.icon-btn { margin-left: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; font-size: 18px; }

/* Rangliste */
.board { margin-top: 12px; background: linear-gradient(135deg, #22140f, var(--panel) 60%); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.champ { display: flex; align-items: center; gap: 12px; }
.champ .crown { font-size: 34px; filter: drop-shadow(0 2px 8px rgba(255, 207, 63, .4)); }
.champ .label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.champ .name { font-size: 24px; font-weight: 800; line-height: 1.1; }
.champ .val { margin-left: auto; font-size: 26px; font-weight: 800; color: var(--down); }
.champ.none .name { font-size: 16px; font-weight: 600; color: var(--muted); }

.toggles { display: flex; gap: 8px; margin: 12px 0 6px; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--panel-2); color: var(--text); font-weight: 600; }
.seg:last-child { margin-left: auto; }

.ranking { list-style: none; margin: 0; padding: 0; }
.ranking li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 15px; }
.ranking .pos { width: 22px; color: var(--muted); font-weight: 700; }
.ranking .dot, .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.ranking .who { font-weight: 600; }
.ranking .bar { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.ranking .bar i { display: block; height: 100%; border-radius: 3px; }
.ranking .v { min-width: 72px; text-align: right; font-weight: 700; }
.v.good { color: var(--down); }
.v.bad { color: var(--up); }

/* Tabelle */
main { padding: 12px 16px 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 100%; }
th, td { border-bottom: 1px solid var(--line); text-align: center; height: 52px; padding: 0 4px; }
th { position: sticky; top: 0; background: var(--panel-2); font-size: 15px; font-weight: 800; height: 46px; }
th .crown { font-size: 13px; }
th.date, td.date { width: 76px; color: var(--muted); font-weight: 600; background: rgba(255, 255, 255, .02); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
th.date { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
td.cell { padding: 0; }
td.cell button {
  display: block; width: 100%; height: 52px; border: 0; background: none; cursor: pointer;
  font-size: 18px; font-weight: 600; touch-action: manipulation;
}
td.cell button:active { background: var(--panel-2); }
td.cell .d { display: block; font-size: 11px; font-weight: 700; margin-top: 1px; }
td.cell .d.good { color: var(--down); }
td.cell .d.bad { color: var(--up); }
td.cell .d.same { color: var(--muted); }
td.cell.me { background: rgba(255, 77, 46, .05); }
tr.today td { background: rgba(255, 77, 46, .1); }
tr.today td.date { color: var(--accent); font-weight: 800; }
tr.today td.empty button::after { content: "＋"; color: var(--accent); font-size: 22px; font-weight: 400; }
td.empty { color: var(--line); }
tr:last-child td { border-bottom: 0; }
.hint { color: var(--muted); font-size: 13px; text-align: center; margin: 12px 0; }

.quick {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  border: 0; border-radius: 14px; padding: 16px; font-size: 17px; font-weight: 800;
  background: linear-gradient(90deg, var(--accent), #ff7a2e); color: #fff;
  box-shadow: 0 8px 24px rgba(255, 77, 46, .35);
}

/* Bottom-Sheets */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; z-index: 10; }
.sheet-bg[hidden] { display: none; }
.sheet {
  width: 100%; max-height: 88vh; overflow-y: auto; background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 600px) {
  .sheet-bg { align-items: center; justify-content: center; }
  .sheet { max-width: 420px; border-radius: 20px; border: 1px solid var(--line); }
}
.sheet h2 { font-size: 15px; margin: 18px 0 10px; }
.sheet h2:first-child { margin-top: 0; }
.sheet-head { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.sheet-head .muted { margin-left: auto; font-size: 15px; }
.kg-input { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 18px 0 6px; }
.kg-input input {
  width: 180px; font-size: 52px; font-weight: 800; text-align: center; background: var(--bg);
  border: 2px solid var(--line); border-radius: 14px; padding: 6px 0; outline: none;
}
.kg-input input:focus { border-color: var(--accent); }
.kg-input span { font-size: 22px; color: var(--muted); }
.err { color: var(--up); text-align: center; min-height: 20px; margin: 0 0 8px; font-size: 14px; }
.row { display: flex; gap: 8px; margin-top: 16px; }
.row .primary { flex: 1; }
.primary { background: var(--accent); border: 0; color: #fff; font-weight: 700; border-radius: 12px; padding: 13px 16px; }
.ghost { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; }
.ghost.wide { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }
.chip.on { border-color: var(--accent); background: rgba(255, 77, 46, .15); font-weight: 700; }
.add { display: flex; gap: 8px; }
.add input, .add select { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.add input { flex: 1; }
.add .primary { padding: 12px 16px; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; z-index: 20;
  font-size: 14px; white-space: nowrap;
}
.toast[hidden] { display: none; }

.keyform { display: grid; gap: 10px; max-width: 360px; margin: 8px auto; color: var(--text); font-size: 15px; }
.keyform p { margin: 0; }
.keyform input { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }

/* Pixel-Arena unter der Tabelle */
.arena { margin: 8px auto 0; max-width: 520px; }
.arena img { display: block; width: 100%; height: auto; image-rendering: pixelated; border-radius: 14px; }

/* Beweisfoto */
td.cell button { position: relative; }
td.cell .cam { position: absolute; top: 3px; right: 5px; font-size: 13px; }
.proof { margin: 4px 0 6px; display: grid; gap: 8px; }
.proof-view { position: relative; justify-self: center; }
.proof-view img { display: block; max-width: 100%; max-height: 200px; border-radius: 12px; border: 1px solid var(--line); cursor: zoom-in; }
.proof-del { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .7); color: #fff; font-size: 14px; }
.lightbox { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .92); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.proof[hidden] { display: none; }
.proof-hint { font-size: 12px; text-align: center; margin: -2px 0 0; }
.fightend { margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--accent-2); }
.add input[type="date"] { color-scheme: dark; }
