/* K-Cup — mobile only. There is deliberately no desktop layout: wider
   screens just show the phone column centered. Tokens come from tokens.css
   (Ocean & Sun, copied from k-platform; re-sync manually). Component looks
   follow apps.k-jahn.de/design: cards on --s1, inputs on --s2, pill buttons
   in Barlow Condensed, uppercase micro labels, gold left-line callouts. */

:root {
  --col: 480px;            /* max column width on anything wider than a phone */
  --gutter: 16px;
  --tap: 48px;             /* minimum touch target */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --bar-h: 96px;           /* bottom bar height, measured by JS where it varies */
  --gold-soft: rgba(232, 200, 74, 0.12);
  --gold-line: rgba(232, 200, 74, 0.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--dark);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;     /* no double-tap zoom delay */
  overscroll-behavior-y: none;
}
body.no-scroll { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ── Shared header (k-platform §7), padded for the notch ──────────────── */
.k-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}
.k-header-inner {
  max-width: var(--col);
  margin: 0 auto;
  padding: 10px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.k-header-logo { width: 30px; height: 30px; flex-shrink: 0; display: block; }
.k-header-logo img { width: 100%; height: 100%; border-radius: 50%; display: block; }
.k-header-nav { display: flex; align-items: center; gap: 4px; }
.k-header-nav a, .k-header-nav button {
  font-size: var(--fs-sm); color: var(--t2); font-weight: 500;
  min-height: 40px; padding: 0 10px; display: inline-flex; align-items: center;
  background: none; border: 0; border-radius: var(--r-interactive);
}
.k-header-nav a.active { color: var(--text); font-weight: 700; }
.k-header-nav button:active, .k-header-nav a:active { background: var(--s1); }
.lang-toggle { letter-spacing: .08em; font-weight: 700 !important; }

/* ── Layout ────────────────────────────────────────────────────────────── */
main {
  max-width: var(--col);
  margin: 0 auto;
  padding: 20px var(--gutter) calc(var(--bar-h) + 24px + var(--safe-b));
}

h1 {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.1;
  margin: 4px 0 18px;
  overflow-wrap: anywhere;
}
.label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-xs);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--t3);
}
.muted { color: var(--t3); }
.lead { color: var(--t2); font-size: var(--fs-sm); margin: -8px 0 20px; }

/* Primary actions live in a bar at the bottom: that's where thumbs are. */
.bottom-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 14px var(--gutter) calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--dark) 70%, rgba(7, 18, 30, 0));
  z-index: 10;
}
.bottom-bar > * { max-width: calc(var(--col) - 2 * var(--gutter)); margin-left: auto; margin-right: auto; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--r-interactive);
  background: var(--acc);
  color: var(--dark);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: .04em;
  transition: transform .08s ease, opacity .15s;
  -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .35; }
.btn-ghost {
  background: transparent;
  color: var(--t2);
  border: 1.5px solid var(--border);
}
.btn-danger { background: var(--red); color: var(--dark); }
.btn-small { width: auto; min-height: 44px; font-size: var(--fs-md); padding: 0 18px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn-ghost { flex: 0 0 auto; width: auto; }

.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: var(--r-circle);
  background: var(--s1);
  color: var(--t2);
}
.icon-btn:active { background: var(--s2); }
.icon-btn svg { width: 20px; height: 20px; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 22px; }
.field-label { display: block; margin-bottom: 8px; }
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-content);
  background: var(--s2);
  font-size: 16px;            /* <16px makes iOS zoom in on focus */
  outline: none;
}
.input::placeholder { color: var(--t3); }
.input:focus { border-color: var(--acc); }

.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }

/* Segmented control (also used for tabs) */
.segmented { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 4px; padding: 4px; background: var(--s1); border-radius: var(--r-interactive); }
.segmented button {
  min-height: 52px;
  border: 0;
  border-radius: var(--r-interactive);
  background: none;
  color: var(--t2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: .03em;
  line-height: 1.15;
}
.segmented button small { font-family: var(--font-body); font-weight: 400; font-size: var(--fs-xs); color: var(--t3); letter-spacing: 0; }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--s3); color: var(--text); }
.segmented button[aria-pressed="true"] small { color: var(--t2); }

/* Switch */
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  min-height: var(--tap);
  margin-top: 10px;
  font-size: var(--fs-md);
  font-weight: 600;
}
.switch { position: relative; width: 52px; height: 32px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--s2); transition: background .15s; pointer-events: none; }
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px;
  border-radius: 50%; background: var(--text); transition: transform .15s;
}
.switch input:checked + span { background: var(--acc); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--dark); }

/* Player chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center;
  min-height: 40px;
  padding: 0 4px 0 14px;
  border-radius: var(--r-interactive);
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  color: var(--acc);
  font-weight: 600;
  animation: pop .18s ease-out;
}
.chip button {
  width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: none;
  color: var(--acc); font-size: 20px; line-height: 1; opacity: .7;
}
.chip button:active { background: var(--gold-soft); }
.count { font-size: var(--fs-xs); color: var(--t3); margin-top: 8px; }
.count.ok { color: var(--green); }

@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.error { color: var(--red); font-size: var(--fs-sm); min-height: 1.4em; margin: 8px 0 0; }

/* Callout: squared, gold left line (design reference "qitem") */
.callout {
  padding: 14px 16px;
  background: var(--s1);
  border-left: 3px solid var(--acc);
  border-radius: 0 var(--r-content) var(--r-content) 0;
  font-size: var(--fs-sm);
  color: var(--t2);
}
.callout strong { color: var(--text); }
.callout.warn { border-left-color: var(--red); }

/* ── Cards / lists ─────────────────────────────────────────────────────── */
.card {
  display: block;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-content);
  padding: 14px 16px;
}
.card + .card { margin-top: 10px; }
a.card:active { background: var(--s2); }
.card-title { font-weight: 700; font-size: var(--fs-md); overflow-wrap: anywhere; display: flex; align-items: center; gap: 8px; }
.card-meta { font-size: var(--fs-xs); color: var(--t3); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.progress { height: 3px; border-radius: 3px; background: var(--s2); margin-top: 12px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--acc); border-radius: 3px; }
.pill {
  display: inline-block; flex-shrink: 0;
  font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 10px; border-radius: var(--r-interactive);
  background: rgba(232, 200, 74, .85); color: var(--dark);
}
.pill-green { background: rgba(109, 191, 138, .85); }

.empty { text-align: center; color: var(--t2); padding: 40px 10px; font-size: var(--fs-sm); }
.empty-icon { font-size: 52px; display: block; margin-bottom: 10px; }

/* ── Tournament ────────────────────────────────────────────────────────── */
.title-row { display: flex; align-items: flex-start; gap: 8px; }
.title-row h1 { flex: 1; min-width: 0; margin-bottom: 6px; }
.meta { font-size: var(--fs-xs); color: var(--t3); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 18px; }

.tabs { position: sticky; top: 0; z-index: 5; padding: 8px 0; margin: 0 0 6px; background: var(--dark); }
.tabs .segmented button { min-height: 44px; }

.matchday { margin-top: 18px; }
.matchday-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.matchday-head .label { color: var(--t2); }
.matchday-head .count-small { font-size: var(--fs-xs); color: var(--t3); }

.match {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 14px;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-content);
  margin-bottom: 8px;
  text-align: left;
  position: relative;
}
.match:active { background: var(--s2); }
.match .p { font-weight: 600; font-size: var(--fs-md); overflow-wrap: anywhere; color: var(--text); }
.match .p:first-child { text-align: right; }
.match .p.lost { color: var(--t3); font-weight: 500; }
.match .p.won::after { content: ' ✓'; color: var(--acc); }
.match .p:first-child.won::after { content: none; }
.match .p:first-child.won::before { content: '✓ '; color: var(--acc); }
.match .mid {
  min-width: 56px; text-align: center;
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg);
}
.match .mid.open { font-family: var(--font-body); font-size: var(--fs-xs); font-weight: 500; color: var(--t3); text-transform: uppercase; }
.match.next { border-color: var(--gold-line); background: linear-gradient(90deg, var(--gold-soft), var(--s1) 70%); }
.match.next::before {
  content: attr(data-next); position: absolute; top: -8px; left: 12px;
  font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  background: var(--acc); color: var(--dark); padding: 1px 8px; border-radius: 999px;
}
.bye { font-size: var(--fs-sm); color: var(--t3); padding: 0 4px 4px; }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--t3); text-align: center; padding: 6px 2px; }
.table td { text-align: center; padding: 0 2px; height: 48px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; color: var(--t2); }
.table .pl { text-align: left; color: var(--text); font-weight: 600; font-size: var(--fs-md); overflow-wrap: anywhere; padding-left: 6px; }
.table th.pl { padding-left: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--t3); }
.table .pos { width: 30px; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); color: var(--t2); }
.table .pts { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); color: var(--text); width: 40px; }
.table tr.first .pos, .table tr.first .pts { color: var(--acc); }
.table th.pts { font-family: var(--font-display); font-size: var(--fs-xs); color: var(--t3); }
.table-card { background: var(--s1); border: 1px solid var(--border); border-radius: var(--r-content); padding: 4px 8px 0; }
.table-note { font-size: var(--fs-xs); color: var(--t3); margin: 10px 4px 0; }

/* Log */
.log-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.log-item:first-child { border-top: 0; }
.log-what { flex: 1; min-width: 0; }
.log-what .vs { color: var(--t3); }
.log-change { display: block; margin-top: 2px; color: var(--t2); }
.log-change .old { color: var(--t3); text-decoration: line-through; }
.log-change .new { color: var(--acc); font-weight: 700; }
.log-time { font-size: var(--fs-xs); color: var(--t3); white-space: nowrap; }
.tag-edit { font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--blue); margin-left: 6px; }

/* Up-next bar */
.next-bar { background: var(--s1); border: 1px solid var(--gold-line); border-radius: 16px; padding: 12px 12px 12px 16px; box-shadow: 0 -8px 30px rgba(0, 0, 0, .35); }
.next-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.next-top .label { color: var(--acc); }
.next-after { font-size: var(--fs-xs); color: var(--t3); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next-names { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-xl); line-height: 1.15; margin: 4px 0 10px; overflow-wrap: anywhere; }
.next-names .vs { font-size: var(--fs-sm); color: var(--t3); font-weight: 600; margin: 0 6px; text-transform: uppercase; }
.next-bar .btn { min-height: 48px; font-size: var(--fs-md); }
.next-bar .btn-row .btn:last-child { flex: 1; }

/* ── Bottom sheets ─────────────────────────────────────────────────────── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(3, 9, 15, .6);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease-out;
}
.sheet {
  width: 100%; max-width: var(--col);
  max-height: 92dvh; overflow-y: auto;
  background: var(--bg);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  border-top: 1px solid var(--border);
  padding: 10px var(--gutter) calc(18px + var(--safe-b));
  animation: slide-up .22s cubic-bezier(.2, .9, .3, 1.05);
}
.sheet::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--s3); margin: 0 auto 14px; }
.sheet h2 { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); margin: 0 0 2px; }
.sheet .sub { font-size: var(--fs-sm); color: var(--t3); margin: 0 0 18px; }
.sheet .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(100%); } }

/* Score entry */
.score-grid { display: grid; grid-template-columns: 1fr auto 1fr; justify-items: center; align-items: center; gap: 10px 8px; }
.score-name { font-weight: 700; font-size: var(--fs-md); text-align: center; overflow-wrap: anywhere; align-self: end; }
.score-input {
  width: 100%; max-width: 120px; height: 84px;
  text-align: center;
  font-family: var(--font-display); font-size: 56px; font-weight: 700;
  background: var(--s2); border: 1px solid var(--border); border-radius: 14px; outline: none;
  font-variant-numeric: tabular-nums;
}
.score-input:focus { border-color: var(--acc); }
.score-colon { font-family: var(--font-display); font-size: 40px; font-weight: 700; color: var(--t3); }
.stepper { display: flex; gap: 8px; }
.stepper button {
  width: 52px; height: 52px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--s1);
  font-size: 26px; font-weight: 600; line-height: 1; color: var(--text);
}
.stepper button:active { background: var(--s3); }

.winner-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.winner-btn {
  min-height: 110px; padding: 12px;
  border-radius: 16px; border: 2px solid var(--border); background: var(--s1);
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-xl); line-height: 1.1;
  overflow-wrap: anywhere;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.winner-btn small { font-family: var(--font-body); font-size: var(--fs-xs); font-weight: 500; color: var(--t3); }
.winner-btn[aria-pressed="true"] { border-color: var(--acc); background: var(--gold-soft); color: var(--acc); }
.winner-btn[aria-pressed="true"] small { color: var(--acc); }

/* Menu list in a sheet */
.menu { display: flex; flex-direction: column; }
.menu button {
  display: flex; align-items: center; gap: 14px;
  min-height: 56px; padding: 0 6px;
  background: none; border: 0; border-top: 1px solid var(--border);
  text-align: left; font-size: var(--fs-md); font-weight: 600;
}
.menu button:first-child { border-top: 0; }
.menu button:active { background: var(--s1); }
.menu button:disabled { opacity: .4; }
.menu .ico { width: 28px; text-align: center; font-size: 20px; }
.menu .hint { display: block; font-size: var(--fs-xs); font-weight: 400; color: var(--t3); }
.menu .danger { color: var(--red); }

/* ── Full-screen overlays: draw + champion ─────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: radial-gradient(120% 70% at 50% 0%, var(--s2), var(--dark) 70%);
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) var(--gutter) calc(16px + var(--safe-b));
  animation: fade .25s ease-out;
}
.overlay-inner { width: 100%; max-width: calc(var(--col) - 2 * var(--gutter)); margin: 0 auto; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.overlay-top { display: flex; justify-content: space-between; align-items: center; }
.overlay h2 { font-family: var(--font-display); font-size: var(--fs-3xl); font-weight: 700; margin: 10px 0 2px; line-height: 1.05; }

.draw-list { flex: 1; overflow-y: auto; margin: 14px -4px 14px; padding: 0 4px; scroll-behavior: smooth; }
.draw-day { margin-bottom: 16px; animation: rise .3s ease-out both; }
.draw-day .label { color: var(--acc); display: block; margin-bottom: 8px; }
.draw-match {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center;
  min-height: 50px; padding: 6px 14px; margin-bottom: 6px;
  background: var(--s1); border: 1px solid var(--border); border-radius: var(--r-content);
  animation: rise .25s ease-out both;
}
.draw-match .p { font-weight: 700; overflow-wrap: anywhere; }
.draw-match .p:first-child { text-align: right; }
.draw-match .p.spinning { color: var(--t3); filter: blur(.4px); }
.draw-match .p.landed { animation: land .3s ease-out; color: var(--text); }
.draw-match .vs { font-size: var(--fs-xs); color: var(--t3); text-transform: uppercase; }
.draw-bye { font-size: var(--fs-sm); color: var(--t3); padding: 0 4px; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes land { 0% { transform: scale(1.25); color: var(--acc); } 100% { transform: scale(1); } }

.champ { text-align: center; }
.champ-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; }
.champ .trophy { font-size: 96px; line-height: 1; animation: bounce-in .7s cubic-bezier(.2, 1.6, .4, 1) both; filter: drop-shadow(0 8px 24px rgba(232, 200, 74, .35)); }
.champ .label { color: var(--acc); margin-top: 18px; }
.champ-names { font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 1.05; color: var(--acc); margin: 8px 0 6px; overflow-wrap: anywhere; animation: rise .5s .25s ease-out both; }
.champ-sub { color: var(--t2); font-size: var(--fs-sm); animation: rise .5s .4s ease-out both; }
.podium { margin: 26px auto 0; width: 100%; max-width: 320px; text-align: left; animation: rise .5s .55s ease-out both; }
.podium-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--s1); border-radius: var(--r-content); margin-bottom: 6px; }
.podium-row .pos { font-family: var(--font-display); font-weight: 700; color: var(--t2); width: 24px; }
.podium-row .nm { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.podium-row .pt { font-family: var(--font-display); font-weight: 700; }
.champ .actions { padding-top: 24px; display: flex; flex-direction: column; gap: 10px; }
@keyframes bounce-in { from { transform: scale(.2) rotate(-20deg); opacity: 0; } }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 24px + var(--safe-b));
  transform: translate(-50%, 20px);
  background: var(--text); color: var(--dark);
  padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: var(--fs-sm);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 70;
  max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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