/* ───────────────────────────────────────────────────────────────
   Glückstopf – Lotto-Look: Tippschein-Papier, Kugeln, Rot & Gelb
   ─────────────────────────────────────────────────────────────── */
:root {
  --red: #e30613;
  --red-dark: #b4000c;
  --yellow: #ffd500;
  --yellow-soft: #fff1a6;
  --paper: #fff8dc;
  --card: #fffef7;
  --ink: #1b1b1b;
  --ink-2: #4a4a4a;
  --muted: #7a7466;
  --line: #f0c9cc;
  --grid: #ead9a4;
  --good: #1e7b3c;
  --series-1: #d6452b; /* Einsatz */
  --series-2: #2a62c9; /* Gewinne */
  --radius: 14px;
  --shadow: 0 1px 0 rgba(0,0,0,.04), 0 8px 24px -12px rgba(120,60,0,.25);
  --display: "Arial Black", "Helvetica Neue", Impact, system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--body);
  color: var(--ink);
  background:
    radial-gradient(circle at 1px 1px, rgba(227,6,19,.08) 1px, transparent 0) 0 0 / 18px 18px,
    var(--paper);
  min-height: 100vh;
}
a { color: var(--red-dark); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; line-height: 1.15; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: .2em 0 .6em; }
h2 { font-size: 1.25rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }

/* ── Kopf ──────────────────────────────────────────────────── */
.topbar {
  background: var(--red);
  color: #fff;
  border-bottom: 6px solid var(--yellow);
  position: sticky; top: 0; z-index: 10;
}
.topbar .inner { display: flex; align-items: center; gap: 1rem; max-width: 1120px; margin: 0 auto; padding: .7rem 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-family: var(--display); font-size: 1.25rem; }
.brand .ball { width: 34px; height: 34px; font-size: .9rem; }
.nav { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.nav a, .nav button {
  color: #fff; text-decoration: none; padding: .4rem .75rem; border-radius: 999px; font-weight: 600; font-size: .92rem;
  background: none; border: 0; cursor: pointer; font-family: inherit;
}
.nav a:hover, .nav button:hover { background: rgba(255,255,255,.15); }
.nav a.active { background: var(--yellow); color: var(--ink); }
.nav form { margin: 0; }

main { max-width: 1120px; margin: 0 auto; padding: 1.4rem 1rem 4rem; }

/* ── Karten ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.25rem;
  position: relative;
}
.card.ticket { border-top: 8px solid var(--red); }
.card.ticket::after { /* Abriss-Perforation */
  content: ""; position: absolute; left: 12px; right: 12px; top: -1px; height: 0;
  border-top: 2px dashed rgba(255,255,255,.7);
}
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stack > * + * { margin-top: 1rem; }
.section { margin-top: 1.6rem; }
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ── Kennzahlen ────────────────────────────────────────────── */
.kpi { padding: 1rem 1.1rem; }
.kpi .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.kpi .value { font-family: var(--display); font-size: 1.6rem; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .85rem; color: var(--ink-2); }
.kpi.hero { background: linear-gradient(135deg, var(--yellow) 0%, #ffe766 100%); border-color: #e7c600; }
.kpi.hero .value { font-size: 2.3rem; color: var(--red-dark); }
.pos { color: var(--good); }
.neg { color: var(--red-dark); }

/* ── Kugeln ────────────────────────────────────────────────── */
.balls { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.ball {
  --c1: #fff; --c2: #e9e9e9;
  width: 46px; height: 46px; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-family: var(--display); font-size: 1.05rem; color: var(--ink);
  background: radial-gradient(circle at 32% 28%, #fff 0 14%, var(--c1) 34%, var(--c2) 100%);
  box-shadow: inset -4px -6px 10px rgba(0,0,0,.18), 0 3px 6px rgba(0,0,0,.18);
  position: relative; flex: none;
}
.ball > span { /* weißer Zahlen-Spiegel wie bei echten Kugeln */
  background: rgba(255,255,255,.92); border-radius: 50%; width: 62%; height: 62%;
  display: grid; place-items: center; box-shadow: inset 0 1px 2px rgba(0,0,0,.15);
}
.ball.t-a { --c1: #ffe14d; --c2: #e6b800; }
.ball.t-b { --c1: #ff6b6b; --c2: #c9000c; }
.ball.t-c { --c1: #6aa8ff; --c2: #1d4fb8; }
.ball.t-d { --c1: #6fe08f; --c2: #158a3c; }
.ball.t-e { --c1: #c48bff; --c2: #6b2bc0; }
.ball.sz  { --c1: #3a3a3a; --c2: #0d0d0d; color: var(--ink); }
.ball.sm { width: 32px; height: 32px; font-size: .78rem; }
.ball.xs { width: 26px; height: 26px; font-size: .68rem; }
.ball.dim { filter: grayscale(1) opacity(.45); }
.ball.hit { outline: 3px solid var(--yellow); outline-offset: 2px; animation: pop .6s ease-out both; }
.ball-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-right: .2rem; }
@keyframes pop { 0% { transform: scale(.6) rotate(-40deg); } 70% { transform: scale(1.12) rotate(6deg); } 100% { transform: none; } }
.balls.roll .ball { animation: roll .7s cubic-bezier(.2,.8,.2,1.2) both; }
.balls.roll .ball:nth-child(2) { animation-delay: .07s } .balls.roll .ball:nth-child(3) { animation-delay: .14s }
.balls.roll .ball:nth-child(4) { animation-delay: .21s } .balls.roll .ball:nth-child(5) { animation-delay: .28s }
.balls.roll .ball:nth-child(6) { animation-delay: .35s } .balls.roll .ball:nth-child(7) { animation-delay: .42s }
.balls.roll .ball:nth-child(8) { animation-delay: .49s }
@keyframes roll { from { transform: translateX(-60px) rotate(-360deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Tippfeld (7×7 wie auf dem Schein) ─────────────────────── */
.tippfelder { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem; }
.tippfeld { border: 1.5px solid var(--red); border-radius: 8px; padding: .4rem; background: #fff; }
.tippfeld .head { display: flex; justify-content: space-between; align-items: baseline; font-size: .74rem; font-weight: 800; color: var(--red); padding: 0 .1rem .3rem; text-transform: uppercase; letter-spacing: .05em; }
.tippfeld .cells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.tippfeld .c {
  aspect-ratio: 1; display: grid; place-items: center; font-size: .66rem; color: #d77f86;
  border: 1px solid #f6c7cb; border-radius: 3px; position: relative; font-variant-numeric: tabular-nums;
}
.tippfeld .c.x { color: var(--ink); font-weight: 800; }
.tippfeld .c.x::after { /* Kreuz */
  content: ""; position: absolute; inset: 2px;
  background:
    linear-gradient(45deg, transparent 44%, rgba(20,20,20,.75) 44% 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, rgba(20,20,20,.75) 44% 56%, transparent 56%);
}
.tippfeld .c.d { background: var(--yellow-soft); }               /* gezogen */
.tippfeld .c.x.d { background: var(--yellow); border-color: #c9a400; } /* Treffer */
.tippfeld .c.x.d::after { background:
    linear-gradient(45deg, transparent 44%, var(--red) 44% 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--red) 44% 56%, transparent 56%); }
.hitbadge { display: inline-block; background: var(--ink); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .7rem; }
.hitbadge.h3 { background: var(--red); }
.hitbadge.h4 { background: var(--good); }

/* ── Tabellen ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .45rem .5rem; border-bottom: 2px solid var(--red); }
td { padding: .5rem; border-bottom: 1px dashed var(--grid); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Badges, Pillen ────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #f3ede0; color: var(--ink-2); }
.pill.red { background: var(--red); color: #fff; }
.pill.yellow { background: var(--yellow); color: var(--ink); }
.pill.green { background: #d9f2df; color: var(--good); }
.pill.warn { background: #fff0c2; color: #7a5600; }

/* ── Formulare ─────────────────────────────────────────────── */
label { display: block; font-size: .82rem; font-weight: 700; color: var(--ink-2); margin-bottom: .25rem; }
input, select, textarea {
  font: inherit; width: 100%; padding: .55rem .7rem; border-radius: 10px;
  border: 1.5px solid #e6d8b4; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--yellow); border-color: var(--red); }
input[type=checkbox] { width: auto; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.form-row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--red); color: #fff; border: 0; border-radius: 999px; padding: .6rem 1.15rem;
  font: 700 .95rem var(--body); cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: 0 3px 0 var(--red-dark);
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--red-dark); }
.btn.yellow { background: var(--yellow); color: var(--ink); box-shadow: 0 3px 0 #c9a400; }
.btn.ghost { background: transparent; color: var(--red-dark); box-shadow: none; border: 1.5px solid var(--line); }
.btn.sm { padding: .32rem .7rem; font-size: .82rem; }
.inline { display: inline; margin: 0; }

.flash { padding: .75rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 600; background: #d9f2df; color: var(--good); border: 1.5px solid #a9dcb6; }
.flash.err { background: #ffe1e3; color: var(--red-dark); border-color: var(--line); }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .4rem .9rem; border-radius: 999px; text-decoration: none; background: #fff; border: 1.5px solid var(--line); color: var(--ink); font-weight: 700; font-size: .9rem; }
.tabs a.active { background: var(--red); color: #fff; border-color: var(--red); }

/* ── Charts ────────────────────────────────────────────────── */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #ecdcae; stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--body); }
.chart .label { fill: var(--ink); font-size: 12px; font-weight: 700; font-family: var(--body); }
.chart .value { fill: var(--ink-2); font-size: 12px; font-family: var(--body); font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1 { stroke: var(--series-1); }
.chart .line.s2 { stroke: var(--series-2); }
.chart .dot { stroke: var(--card); stroke-width: 2; }
.chart .dot.s1 { fill: var(--series-1); }
.chart .dot.s2 { fill: var(--series-2); }
.chart .bar.s2 { fill: var(--series-2); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: rgba(255,213,0,.15); }
.legend { display: flex; gap: 1rem; font-size: .85rem; color: var(--ink-2); margin-bottom: .5rem; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: .35rem; }

/* Heatmap 1–49 als Tippschein */
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; max-width: 360px; }
.heat .h {
  aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center; font-weight: 800; font-size: .8rem;
  border: 1.5px solid #f6c7cb; background: #fff; color: var(--ink); position: relative;
}
.heat .l1 { background: #ffeef0; } .heat .l2 { background: #ffc9ce; } .heat .l3 { background: #ff8f99; } .heat .l4 { background: var(--red); color: #fff; }
.heat .ours { outline: 2.5px solid var(--ink); outline-offset: -1px; }

/* Login */
.login-wrap { min-height: calc(100vh - 80px); display: grid; place-items: center; }
.login-card { max-width: 420px; width: 100%; text-align: center; }
.login-card .balls { justify-content: center; margin-bottom: 1rem; }

/* Konfetti-Canvas */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

@media (max-width: 640px) {
  .topbar .inner { flex-wrap: wrap; }
  .nav { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .ball { width: 37px; height: 37px; font-size: .88rem; }
  .balls { gap: .3rem; }
  .kpi .value { font-size: 1.35rem; }
  .kpi.hero .value { font-size: 1.9rem; }
}
@media (prefers-reduced-motion: reduce) {
  .ball, .balls.roll .ball { animation: none !important; }
}
@media print {
  .topbar, .btn, form { display: none !important; }
  body { background: #fff; }
}
