:root {
  --bg: #0b0b0c;
  --surface: #151517;
  --surface-2: #1d1d20;
  --line: #2a2a2e;
  --text: #f4f4ef;
  --muted: #8b8b86;
  --accent: #c6ff3d;
  --accent-ink: #0b0b0c;
  --hot: #ff5c3d;
  --r: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
#app {
  max-width: 560px; margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { font: inherit; color: inherit; }

.brand { font-weight: 900; letter-spacing: -.04em; font-size: 20px; text-decoration: none; }
.brand a { text-decoration: none; }
.brand span { color: var(--accent); }

.mega {
  font-size: clamp(44px, 13vw, 76px); line-height: .92; letter-spacing: -.05em;
  font-weight: 900; margin: 36px 0 18px;
}
.mega em { font-style: normal; color: var(--accent); }
.mega.small { font-size: clamp(34px, 10vw, 54px); margin-top: 8px; overflow-wrap: anywhere; }
.lead { color: var(--muted); font-size: 18px; max-width: 30em; margin: 0 0 28px; }
.kicker { color: var(--accent); font-weight: 700; margin: 36px 0 0; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
.hint { color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); font-size: 14px; }
.label { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; margin: 0; }

.card { background: var(--surface); border-radius: var(--r); padding: 20px; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.form input:not([type=number]), .custom-add input, .fix-row input {
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: 12px;
  padding: 14px; font-size: 17px; outline: none; width: 100%;
}
.form input:focus, .custom-add input:focus, .fix-row input:focus { border-color: var(--accent); }
.goal-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); font-weight: 600; }
.stepper { display: flex; align-items: center; background: var(--surface-2); border-radius: 12px; }
.stepper button { width: 44px; height: 46px; border: 0; background: none; font-size: 22px; }
.stepper input {
  width: 56px; text-align: center; background: none; border: 0; outline: none;
  font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.btn {
  border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 800;
  background: var(--surface-2); text-decoration: none; display: inline-flex; justify-content: center; align-items: center;
  transition: transform .12s, filter .12s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.big { padding: 17px; font-size: 18px; width: 100%; }
.btn:disabled { opacity: .5; }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 14px; padding: 8px 0; text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger { color: #ff7a7a; }
.err { color: #ff7a7a; font-size: 14px; margin: 0; min-height: 0; }
.err:empty { display: none; }

.duel-list { display: grid; gap: 8px; margin-top: 10px; }
.duel-list a { display: flex; justify-content: space-between; background: var(--surface); padding: 16px 18px; border-radius: 14px; text-decoration: none; font-weight: 700; }
.duel-list a span { color: var(--accent); }
#myDuels { margin-top: 32px; }

.join-players { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.join-players span { background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 700; }
.join-players i { font-style: normal; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* Arena */
.topbar { display: flex; justify-content: space-between; align-items: center; }
.top-actions { display: flex; gap: 8px; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--surface); display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.duel-title { margin: 22px 0 16px; }
.duel-title h1 { font-size: clamp(28px, 8vw, 40px); letter-spacing: -.04em; line-height: 1; margin: 8px 0 0; font-weight: 900; overflow-wrap: anywhere; }
.pill { display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; background: var(--surface); color: var(--accent); padding: 5px 10px; border-radius: 999px; }

.hero { display: grid; gap: 18px; padding-top: 26px; }
.ring-wrap { position: relative; width: min(240px, 66vw); aspect-ratio: 1; margin: 0 auto; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; stroke-width: 14; }
.ring-bg { stroke: var(--surface-2); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2,.9,.25,1), stroke .4s; }
.ring-wrap.done .ring-fg { filter: drop-shadow(0 0 10px rgba(198,255,61,.55)); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.today-num { font-size: clamp(56px, 18vw, 84px); font-weight: 900; letter-spacing: -.06em; line-height: 1; font-variant-numeric: tabular-nums; }
.today-num.bump { animation: bump .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes bump { 40% { transform: scale(1.13); } }
.today-sub { color: var(--muted); font-size: 14px; font-weight: 600; margin-top: 4px; }
.hero-meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--surface-2); border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 700; }
.chip.hot { background: rgba(255,92,61,.16); color: #ff9a7a; }

.level-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin-bottom: 7px; gap: 8px; }
.level-top span:last-child { color: var(--muted); font-weight: 600; text-align: right; }
.xp { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #7dffb2); border-radius: 999px; transition: width 1s cubic-bezier(.2,.9,.25,1); }

.adds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.add {
  border: 0; border-radius: 14px; background: var(--surface-2); padding: 18px 0; font-size: 20px; font-weight: 900;
  letter-spacing: -.03em; transition: transform .1s, background .2s; position: relative;
}
.add:active { transform: scale(.92); background: var(--accent); color: var(--accent-ink); }
.custom-add { display: flex; gap: 8px; }
.custom-add input { flex: 1; min-width: 0; }
#fixBtn { justify-self: center; }
.card-inner { background: var(--surface-2); border-radius: 14px; padding: 12px; display: grid; gap: 10px; }
.fix-row { display: flex; gap: 8px; }
.fix-row input { background: var(--bg); flex: 1; min-width: 0; }

.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 8px; padding: 8px 10px; font-size: 14px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--text); color: var(--bg); }
.seg.small { background: var(--surface); }
.seg.small button { padding: 5px 9px; font-size: 13px; }

.block { margin-top: 34px; }
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.block > .label { margin-bottom: 14px; }

/* Rennbahn */
.lanes { display: grid; gap: 10px; }
.lane { background: var(--surface); border-radius: 14px; padding: 12px 14px 14px; will-change: transform; }
.lane.me { box-shadow: inset 0 0 0 1.5px var(--line); }
.lane-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.lane-rank { color: var(--muted); font-weight: 800; font-size: 13px; width: 18px; }
.lane-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-name small { color: var(--muted); font-weight: 600; }
.lane-crown { font-size: 15px; transform: scale(0); transition: transform .4s cubic-bezier(.3,1.6,.5,1); }
.lane.lead .lane-crown { transform: scale(1); }
.lane-count { margin-left: auto; font-weight: 900; font-size: 22px; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.lane-count small { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.track { position: relative; height: 10px; background: var(--surface-2); border-radius: 999px; margin-right: 13px; }
.fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px; background: var(--c); transition: width 1s cubic-bezier(.2,.9,.25,1.05); }
.goal-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--muted); opacity: .5; border-radius: 2px; transition: left .6s; }
.runner {
  position: absolute; top: 50%; left: 0; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
  background: var(--c); color: var(--accent-ink); display: grid; place-items: center; font-size: 12px; font-weight: 900;
  transition: left 1s cubic-bezier(.2,.9,.25,1.05); box-shadow: 0 0 0 3px var(--surface);
}
.lane.done .runner::after { content: "✓"; position: absolute; right: -6px; top: -6px; width: 14px; height: 14px; border-radius: 50%; background: var(--text); color: var(--bg); font-size: 9px; display: grid; place-items: center; }
.invite-empty { width: 100%; margin-top: 10px; border: 1.5px dashed var(--line); background: none; border-radius: 14px; padding: 16px; color: var(--muted); }
.invite-empty b { color: var(--accent); }

/* Diagramm */
.chart-wrap { background: var(--surface); border-radius: 14px; padding: 12px 8px 6px; touch-action: pan-y; }
#chart { width: 100%; height: 190px; display: block; overflow: visible; }
#chart .grid { stroke: var(--line); stroke-width: 1; }
#chart text { fill: var(--muted); font-size: 10px; }
#chart .ln { fill: none; stroke-linejoin: round; stroke-linecap: round; }
#chart .cursor { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart-info { color: var(--muted); font-size: 13px; margin-top: 8px; min-height: 20px; }
.chart-info b { color: var(--text); }
.chart-info i { font-style: normal; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 4px 0 8px; }

/* Rangliste */
.share-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface); margin-bottom: 12px; }
.share-bar div { flex: 0 0 0; height: 100%; transition: flex-grow 1s cubic-bezier(.2,.9,.25,1); min-width: 0; }
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.board li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 12px 14px; animation: rise .5s both; }
.board li.me { box-shadow: inset 0 0 0 1.5px var(--line); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.medal { font-size: 22px; text-align: center; font-weight: 900; color: var(--muted); }
.b-name { font-weight: 800; display: flex; align-items: center; gap: 7px; min-width: 0; }
.b-name i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.b-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.b-score { font-weight: 900; font-size: 22px; letter-spacing: -.04em; font-variant-numeric: tabular-nums; text-align: right; }
.b-score small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0; }

/* Abzeichen */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.badge { background: var(--surface); border-radius: 14px; padding: 14px 8px 12px; text-align: center; }
.badge .ico { font-size: 30px; line-height: 1; display: block; margin-bottom: 8px; transition: transform .3s; }
.badge b { display: block; font-size: 13px; }
.badge small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; line-height: 1.3; }
.badge.locked .ico { filter: grayscale(1); opacity: .25; }
.badge.locked b { color: var(--muted); }
.badge.new { animation: pop .7s cubic-bezier(.3,1.6,.5,1); box-shadow: 0 0 0 1.5px var(--accent); }
@keyframes pop { 0% { transform: scale(.6); } }

/* Feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--surface); font-size: 15px; }
.feed i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.feed .d { font-weight: 900; margin-left: auto; font-variant-numeric: tabular-nums; }
.feed .d.neg { color: var(--muted); }
.feed time { color: var(--muted); font-size: 13px; width: 82px; text-align: right; }
.feed .empty { color: var(--muted); border: 0; }

.foot { margin-top: 48px; text-align: center; color: var(--muted); font-size: 13px; }
.foot a { color: var(--muted); }

/* Toast + Effekte */
#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, calc(100% + 60px)); visibility: hidden;
  transition: transform .45s cubic-bezier(.3,1.4,.5,1), visibility 0s .45s;
  background: var(--text); color: var(--bg); padding: 13px 18px; border-radius: 14px; font-weight: 800;
  max-width: calc(100vw - 32px); width: max-content; display: flex; gap: 14px; align-items: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
#toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform .45s cubic-bezier(.3,1.4,.5,1); }
#toast button { border: 0; background: var(--bg); color: var(--text); border-radius: 9px; padding: 6px 10px; font-weight: 800; font-size: 13px; }
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }
.float-num { position: fixed; z-index: 55; pointer-events: none; font-weight: 900; font-size: 22px; color: var(--accent); animation: floatUp .9s ease-out forwards; }
@keyframes floatUp { to { transform: translateY(-70px) scale(1.3); opacity: 0; } }

dialog {
  border: 0; border-radius: 20px; background: var(--surface); color: var(--text); padding: 22px;
  width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(4px); }
dialog h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
dialog h3 { margin: 0; font-size: 16px; }
dialog hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 6px 0; }
dialog .hint { margin: 0; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
