/* ============================================================
   Handball Tippspiel — Opel HBL 2026/27
   ============================================================ */

:root {
  --bg: #0d1015;
  --bg-2: #131822;
  --surface: #181f2b;
  --surface-2: #1f2836;
  --surface-3: #27313f;
  --line: #2a3341;
  --line-soft: #202836;

  --text: #e9eef7;
  --text-dim: #93a0b4;
  --text-faint: #61708a;

  --accent: #ff2d55;
  --accent-2: #ff6b35;
  --teal: #00d4a6;
  --blue: #3d8bff;
  --amber: #ffc53d;
  --violet: #a86bff;

  --good: #2fd07a;
  --warn: #ffb020;
  --bad: #ff4d6a;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.55);

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  background-image:
    radial-gradient(1100px 520px at 12% -8%, rgba(255, 45, 85, 0.13), transparent 62%),
    radial-gradient(900px 480px at 92% 2%, rgba(0, 212, 166, 0.09), transparent 60%);
  background-attachment: fixed;
  min-height: 100dvh;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; }

/* ---- boot ------------------------------------------------- */

.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--text-dim);
}
.boot__ball { font-size: 46px; animation: bounce 1.1s var(--ease) infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-18px) scale(1.06); }
}

/* ---- shell ------------------------------------------------ */

.app { max-width: 1180px; margin: 0 auto; padding: 0 16px 96px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 4px 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; margin-right: auto; min-width: 0; }
.brand__ball {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  font-size: 21px; border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(255, 45, 85, 0.35);
}
.brand__text { min-width: 0; }
.brand h1 {
  margin: 0; font-size: 17px; font-weight: 750; letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand p { margin: 1px 0 0; font-size: 12px; color: var(--text-faint); }

.whoami {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 8px 6px 6px; border-radius: 999px; font-size: 13px;
}
.whoami__dot { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 750; color: #0d1015; }

/* ---- tabs ------------------------------------------------- */

.tabs {
  display: flex; gap: 4px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; margin-bottom: 22px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; white-space: nowrap; padding: 10px 15px;
  border-radius: 9px; font-size: 13.5px; font-weight: 600;
  color: var(--text-dim); transition: 0.18s var(--ease);
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-selected="true"] {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: 0 4px 14px rgba(255, 45, 85, 0.32);
}

/* ---- cards ------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card__head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }

/* Emoji glyphs carry no usable side bearing, so the gap is set here rather
   than with a space character in the string. See ico() in js/ui.js. */
.ico {
  display: inline-block;
  margin-right: 0.5em;
  font-style: normal;
  letter-spacing: normal;
}
.card__head .spacer { margin-left: auto; }
.card__sub { margin: -8px 0 14px; font-size: 12.5px; color: var(--text-faint); line-height: 1.5; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }

/* ---- countdown -------------------------------------------- */

.countdown {
  background: linear-gradient(140deg, rgba(255, 45, 85, 0.15), rgba(255, 107, 53, 0.07));
  border-color: rgba(255, 45, 85, 0.3);
}
.countdown--locked {
  background: linear-gradient(140deg, rgba(0, 212, 166, 0.13), rgba(61, 139, 255, 0.06));
  border-color: rgba(0, 212, 166, 0.28);
}
.countdown__label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-dim); font-weight: 650; }
.countdown__clock { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.cd-unit {
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line);
  border-radius: 11px; padding: 9px 13px; min-width: 66px; text-align: center;
}
.cd-unit b { display: block; font-size: 25px; font-weight: 780; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.cd-unit span { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.07em; }
.countdown__meta { margin-top: 12px; font-size: 13px; color: var(--text-dim); }

/* ---- leaderboard ------------------------------------------ */

.lb { display: grid; gap: 10px; }
.lb-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center; gap: 13px;
  padding: 13px 15px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: 0.2s var(--ease);
}
.lb-row:hover { border-color: var(--surface-3); transform: translateY(-1px); }
.lb-row--lead {
  background: linear-gradient(120deg, rgba(255, 197, 61, 0.14), var(--surface-2) 55%);
  border-color: rgba(255, 197, 61, 0.34);
}
.lb-rank { font-size: 21px; font-weight: 800; text-align: center; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.lb-row--lead .lb-rank { color: var(--amber); }
.lb-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.lb-sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.lb-total { text-align: right; }
.lb-total b { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.lb-total span { display: block; font-size: 11px; color: var(--text-faint); }

.pdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.bar { height: 5px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 9px; }
.bar__fill { height: 100%; border-radius: 99px; transition: width 0.7s var(--ease); }

/* ---- stat tiles ------------------------------------------- */

.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat__k { font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 650; }
.stat__v { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; margin-top: 5px; font-variant-numeric: tabular-nums; }
.stat__n { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---- league table ----------------------------------------- */

.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.lg { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 620px; }
table.lg th {
  text-align: right; padding: 9px 7px; font-size: 11px; font-weight: 650;
  color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.lg th:nth-child(1), table.lg th:nth-child(2) { text-align: left; }
table.lg td { padding: 9px 7px; text-align: right; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
table.lg td:nth-child(1), table.lg td:nth-child(2) { text-align: left; }
table.lg tbody tr:hover { background: var(--surface-2); }
.lg__pos { font-weight: 750; color: var(--text-dim); width: 32px; }
.lg__team { display: flex; align-items: center; gap: 9px; font-weight: 620; min-width: 190px; }
.lg__logo { width: 24px; height: 24px; object-fit: contain; flex: none; }
.lg__pts { font-weight: 750; }

.zone { display: inline-block; width: 3px; height: 22px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.zone--cl { background: var(--blue); }
.zone--el { background: var(--teal); }
.zone--rel { background: var(--bad); }
.zone--none { background: transparent; }

.form { display: inline-flex; gap: 2.5px; }
.form i {
  width: 15px; height: 15px; border-radius: 4px; font-size: 9px; font-style: normal;
  display: grid; place-items: center; font-weight: 750; color: #0d1015;
}
.form i.W { background: var(--good); }
.form i.D { background: var(--text-faint); }
.form i.L { background: var(--bad); }

/* delta chips: how far a player's guess sits from reality */
.delta {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2.5px 7px; border-radius: 7px;
  font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--surface-3); color: var(--text-dim);
}
.delta--exact { background: rgba(47, 208, 122, 0.18); color: var(--good); }
.delta--close { background: rgba(255, 176, 32, 0.16); color: var(--warn); }
.delta--far { background: rgba(255, 77, 106, 0.15); color: var(--bad); }
.delta--new { background: rgba(168, 107, 255, 0.18); color: var(--violet); }

/* ---- sortable tip list ------------------------------------ */

.sortable { display: grid; gap: 7px; position: relative; touch-action: pan-y; }

.sort-item {
  display: grid;
  grid-template-columns: 36px 30px 1fr auto auto;
  align-items: center; gap: 11px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  transition: transform 0.26s var(--ease), box-shadow 0.2s, border-color 0.2s, background 0.2s;
  will-change: transform;
  /* A press-and-hold on the row starts a drag, so suppress the text selection
     and the iOS callout menu that the same gesture would otherwise trigger. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.sort-item:hover { border-color: var(--surface-3); }

/* The entire row is the drag target, so it carries the grab affordance. */
.sort-item:not(.is-locked) { cursor: grab; }
.sort-item.is-dragging {
  z-index: 30; box-shadow: var(--shadow-lg);
  border-color: var(--accent); background: var(--surface-3);
  transition: none; cursor: grabbing;
  touch-action: none;
}

/* Touch press-and-hold in progress: confirms the row is arming for a drag. */
.sort-item.is-pending {
  border-color: var(--surface-3);
  background: var(--surface-3);
  transform: scale(0.985);
}

.sort-item.is-locked { opacity: 0.92; cursor: default; }

.sort-pos {
  font-size: 17px; font-weight: 800; text-align: center;
  color: var(--text-faint); font-variant-numeric: tabular-nums;
}
.sort-item:nth-child(-n + 2) .sort-pos { color: var(--amber); }

.sort-handle {
  display: grid; place-items: center; height: 30px;
  color: var(--text-faint); cursor: grab; border-radius: 7px;
  transition: 0.15s;
}
.sort-handle:hover { color: var(--text); background: var(--surface-3); }
.sort-handle:active { cursor: grabbing; }
.sort-handle svg { pointer-events: none; }

.sort-team { display: flex; align-items: center; gap: 10px; font-weight: 640; font-size: 14px; min-width: 0; }
.sort-team img { width: 26px; height: 26px; object-fit: contain; flex: none; }
.sort-team span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sort-live { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }

.nudge { display: flex; flex-direction: column; gap: 3px; }
.nudge button {
  width: 30px; height: 21px; display: grid; place-items: center;
  border-radius: 6px; color: var(--text-dim); font-size: 11px; line-height: 1;
  background: var(--surface-3); border: 1px solid var(--line);
  transition: 0.15s;
}
.nudge button:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #fff; }
.nudge button:disabled { opacity: 0.28; cursor: default; }

/* ---- comparison ------------------------------------------- */

.cmp { display: grid; gap: 7px; }
.cmp-row {
  display: grid; grid-template-columns: 34px 1fr; gap: 11px; align-items: center;
  padding: 9px 12px; background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: 10px;
}
.cmp-team { display: flex; align-items: center; gap: 9px; font-weight: 620; font-size: 13.5px; min-width: 0; }
.cmp-team img { width: 22px; height: 22px; object-fit: contain; flex: none; }
.cmp-guesses { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.cmp-guess {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 8px; font-size: 12px; font-weight: 650;
  background: var(--surface-3); font-variant-numeric: tabular-nums;
}

/* ---- bonus ------------------------------------------------ */

.bonus-q {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 15px; display: grid; gap: 11px;
}
.bonus-q + .bonus-q { margin-top: 11px; }
.bonus-q__head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.bonus-q__head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.bonus-q__hint { font-size: 12px; color: var(--text-faint); }
.pill {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px;
  background: rgba(255, 197, 61, 0.16); color: var(--amber);
}
.pill--ok { background: rgba(47, 208, 122, 0.16); color: var(--good); }
.pill--muted { background: var(--surface-3); color: var(--text-dim); }

.answer-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 13px; }

/* ---- fixtures --------------------------------------------- */

.fixture {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 11px;
  padding: 10px 13px; background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: 10px; font-size: 13px;
}
.fixture + .fixture { margin-top: 7px; }
.fixture__side { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fixture__side--away { flex-direction: row-reverse; text-align: right; }
.fixture__side img { width: 22px; height: 22px; object-fit: contain; flex: none; }
.fixture__side span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fixture__mid {
  font-variant-numeric: tabular-nums; font-weight: 750; text-align: center;
  min-width: 68px; font-size: 12px; color: var(--text-dim);
}
.fixture__score { font-size: 15px; color: var(--text); }

/* ---- forms ------------------------------------------------ */

.field { display: grid; gap: 6px; }
.field label { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.input, select.input {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 12px; font-size: 14px; width: 100%;
  transition: 0.16s; color: var(--text);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 45, 85, 0.14); }
.input::placeholder { color: var(--text-faint); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 17px; border-radius: 10px; font-size: 13.5px; font-weight: 650;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line); transition: 0.16s var(--ease);
}
.btn:hover:not(:disabled) { background: var(--line); transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn--primary {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 5px 16px rgba(255, 45, 85, 0.3);
}
.btn--primary:hover:not(:disabled) { box-shadow: 0 8px 22px rgba(255, 45, 85, 0.4); }
.btn--ghost { background: transparent; }
.btn--sm { padding: 6px 12px; font-size: 12.5px; }
.btn--good { background: rgba(47, 208, 122, 0.18); border-color: rgba(47, 208, 122, 0.35); color: var(--good); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.note {
  background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 13px; color: var(--text-dim); line-height: 1.55;
}
.note--ok { border-left-color: var(--good); }
.note--warn { border-left-color: var(--warn); }

.empty { text-align: center; padding: 34px 18px; color: var(--text-faint); font-size: 13.5px; }

/* ---- sticky save bar -------------------------------------- */

.savebar {
  position: sticky; bottom: 12px; z-index: 20; margin-top: 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 15px; border-radius: 13px;
  background: rgba(24, 31, 43, 0.93);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
.savebar__msg { font-size: 13px; color: var(--text-dim); margin-right: auto; }

/* ---- toast ------------------------------------------------ */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 24px);
  background: var(--surface-3); border: 1px solid var(--line);
  padding: 11px 19px; border-radius: 11px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: 0.28s var(--ease); z-index: 100; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(47, 208, 122, 0.4); }
.toast.err { border-color: rgba(255, 77, 106, 0.45); }

/* ---- trend chart ------------------------------------------ */

.chart { width: 100%; height: 200px; display: block; }
.chart-legend { display: flex; gap: 15px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--text-dim); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---- login ------------------------------------------------ */

.login-wrap { max-width: 400px; margin: 40px auto; }
.seg { display: flex; gap: 4px; background: var(--bg-2); padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.seg button { flex: 1; padding: 8px; border-radius: 7px; font-size: 13px; font-weight: 620; color: var(--text-dim); }
.seg button.active { background: var(--surface-3); color: var(--text); }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid transparent; transition: 0.15s; }
.swatch.active { border-color: var(--text); transform: scale(1.1); }

@media (max-width: 620px) {
  .app { padding: 0 12px 90px; }
  .card { padding: 15px; }
  .sort-item { grid-template-columns: 30px 26px 1fr auto; gap: 8px; padding: 9px 10px; }
  .sort-live { display: none; }
  .lb-row { grid-template-columns: 34px 1fr auto; padding: 11px 12px; }
  .cd-unit { min-width: 58px; padding: 8px 10px; }
  .cd-unit b { font-size: 21px; }
  .tab { padding: 9px 12px; font-size: 12.5px; }
}

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