:root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --border: #e0dfda;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e6e5e0;
  --accent-soft: rgba(42, 120, 214, 0.12);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --border: #33322e;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e85;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2b2a27;
    --accent-soft: rgba(57, 135, 229, 0.16);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }

header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 8px 0 16px; gap: 12px;
}
header h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
header .who { font-size: 13px; color: var(--text-muted); }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin: 0 0 14px; font-weight: 600;
}

.tabs, .ranges { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button, .ranges button {
  flex: 1; min-width: 72px;
  padding: 9px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-secondary); font-size: 14px; font-family: inherit;
}
.tabs button[aria-selected="true"], .ranges button[aria-selected="true"] {
  background: var(--accent-soft); color: var(--text-primary);
  border-color: var(--series-1); font-weight: 600;
}

.duel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.duel .side { text-align: center; }
.duel .name {
  font-size: 14px; font-weight: 600; margin-bottom: 4px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.hero { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.hero small { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; }

.splitbar {
  display: flex; height: 12px; border-radius: 6px; overflow: hidden;
  margin: 16px 0 6px; background: var(--grid); gap: 2px;
}
.splitbar span { display: block; }
.splitlabels { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 8px 4px; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; color: var(--text-secondary); }
thead th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
tbody tr:last-child td { border-bottom: none; }

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; }

figure { margin: 0; }
figcaption { font-size: 12px; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }
svg { display: block; width: 100%; height: auto; overflow: visible; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-text { fill: var(--text-muted); font-size: 11px; }
.hit { fill: transparent; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 50;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px;
  color: var(--text-primary); box-shadow: 0 4px 16px rgba(0,0,0,.18);
  opacity: 0; transition: opacity .12s;
}
.tooltip.on { opacity: 1; }
.tooltip b { display: block; margin-bottom: 3px; color: var(--text-secondary); font-weight: 600; }

.empty { color: var(--text-muted); font-size: 14px; line-height: 1.55; }
.toggle {
  background: none; border: none; color: var(--series-1); cursor: pointer;
  font-size: 13px; padding: 6px 0; font-family: inherit;
}
input[type="password"], input[type="text"] {
  width: 100%; padding: 11px; border-radius: 10px; font-size: 15px;
  border: 1px solid var(--border); background: var(--surface-0);
  color: var(--text-primary); font-family: inherit;
}
.btn {
  width: 100%; padding: 12px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--series-1); color: #fff; font-size: 15px; font-weight: 600;
  margin-top: 10px; font-family: inherit;
}
.note { font-size: 13px; color: var(--text-muted); margin-top: 10px; line-height: 1.55; }
.err { color: var(--series-2); font-size: 13px; margin-top: 10px; }

/* ---- gamifikacia ---- */

.hero small { margin-top: 2px; }

.chips {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  margin-top: 10px; font-size: 12px; color: var(--text-secondary);
}
.chips span {
  background: var(--surface-0); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}

.splitlabels { gap: 8px; }
.splitlabels span:nth-child(2) { color: var(--text-secondary); font-weight: 600; }

.smack {
  font-size: 15px; line-height: 1.5; margin: 0 0 12px;
  color: var(--text-primary);
}
.nudge-banner { border-color: var(--series-2); }

.emoji-row { display: flex; gap: 8px; flex-wrap: wrap; }
.emoji {
  font-size: 20px; line-height: 1; cursor: pointer;
  background: var(--surface-0); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-family: inherit;
}
.emoji:active { background: var(--accent-soft); }

.heat-label {
  font-size: 13px; color: var(--text-secondary); margin: 14px 0 6px;
  display: flex; align-items: center; gap: 6px;
}
/* flex, nie grid s auto-fill - ten bez pevneho poctu stlpcov bunky zrolovala */
.heat { display: flex; gap: 2px; width: 100%; }
.heat .cell {
  flex: 1 1 0; min-width: 0; aspect-ratio: 1 / 1;
  border-radius: 2px; background: var(--grid);
}
.heat .cell.future { background: transparent; border: 1px dashed var(--border); }
.heat .cell.shield { box-shadow: inset 0 0 0 2px var(--text-muted); }

.tsb {
  display: grid; grid-template-columns: 1fr 2fr auto;
  align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.tsb:last-of-type { border-bottom: none; }
.tsb-name { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tsb-track {
  position: relative; display: block; height: 10px;
  background: var(--grid); border-radius: 5px;
}
.tsb-zero {
  position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px;
  background: var(--text-muted); opacity: .6;
}
.tsb-fill { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.tsb-val { text-align: right; white-space: nowrap; }
.tsb-val small { display: block; color: var(--text-muted); font-size: 11px; }

input[type="date"] {
  width: 100%; padding: 11px; border-radius: 10px; font-size: 15px;
  border: 1px solid var(--border); background: var(--surface-0);
  color: var(--text-primary); font-family: inherit;
}

@media (max-width: 420px) {
  .hero { font-size: 32px; }
  .chips { font-size: 11px; }
  .tsb { grid-template-columns: 1fr 1.4fr auto; font-size: 13px; }
}

/* ---- zdroje bodov, rytmus, deficit ---- */

:root {
  --src-1: #1baf7a;
  --src-2: #eda100;
  --src-3: #e87ba4;
  --src-4: #008300;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --src-1: #199e70;
    --src-2: #c98500;
    --src-3: #d55181;
    --src-4: #008300;
  }
}

.stack { display: flex; gap: 2px; height: 16px; width: 100%; }
.stack i { display: block; border-radius: 3px; min-width: 2px; }
.srcline { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }

.heat.hours .cell { border-radius: 2px; }
.hour-axis {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-muted); margin-top: 6px;
}

.opts { margin: 0 0 4px; padding-left: 18px; }
.opts li { font-size: 14px; line-height: 1.6; color: var(--text-secondary); }
.opts li strong { color: var(--text-primary); }

/* ---- stavka, odznaky ---- */

.stake { border-color: var(--src-2); }
.stake #stxt { cursor: pointer; }
.stake-edit { margin-top: 10px; }
.stake-edit input { margin-bottom: 8px; }

.badges { list-style: none; margin: 0; padding: 0; }
.badges li {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 10px; align-items: start;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.badges li:last-child { border-bottom: none; }
.badges li.locked { opacity: .5; }
.bmark { font-size: 18px; line-height: 1.3; }
.btext { font-size: 14px; line-height: 1.4; }
.btext small { color: var(--text-muted); font-size: 12px; }
.bwhen { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

@media (max-width: 420px) {
  .tabs button { min-width: 0; font-size: 13px; padding: 9px 6px; }
  .bwhen { display: none; }
}

/* ---- odznaky: kamenna tabulka + zlaty lem (vlastny dizajn) ---- */

:root { --gold: #c9a227; --gold-hi: #f0d98a; --stone-1: #33322c; --stone-2: #1d1c18; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --stone-1: #2a2925; --stone-2: #131210; }
}

.ico { width: 26px; height: 26px; stroke: currentColor; }

.badge-icon {
  position: relative;
  width: 46px; height: 46px; flex: 0 0 46px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: linear-gradient(158deg, var(--stone-1), var(--stone-2));
  border: 2px solid #4a4840;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), inset 0 0 8px rgba(0,0,0,.75);
  color: #7d7b72;
}
.got .badge-icon, .badge-icon.got-icon {
  border-color: var(--gold);
  color: var(--gold-hi);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), inset 0 0 8px rgba(0,0,0,.6),
              0 0 12px rgba(201,162,39,.35);
}
.locked .badge-icon { filter: grayscale(100%); }
.locked .badge-icon .lock {
  position: absolute; right: -3px; bottom: -3px;
  width: 14px; height: 14px; border-radius: 3px;
  background: #15140f; border: 1px solid #4a4840;
}
.locked .badge-icon .lock::before {
  content: ""; position: absolute; left: 4px; top: 2px;
  width: 5px; height: 4px; border: 1.5px solid #8a8880;
  border-bottom: none; border-radius: 3px 3px 0 0;
}
.locked .badge-icon .lock::after {
  content: ""; position: absolute; left: 3px; top: 6px;
  width: 8px; height: 5px; background: #8a8880; border-radius: 1px;
}

.badges li {
  grid-template-columns: auto 1fr auto;
  align-items: center; gap: 12px;
}
.btext strong { font-size: 14px; }
.btext small { display: block; margin-top: 2px; }
.btext em {
  display: block; margin-top: 3px; font-size: 11px;
  color: var(--text-muted); font-style: italic;
}
.bpts { text-align: right; }
.pts {
  display: inline-block; min-width: 30px; padding: 3px 7px;
  border-radius: 4px; font-size: 12px; font-weight: 700;
  background: linear-gradient(160deg, #6b5a17, #3a3110);
  border: 1px solid var(--gold); color: var(--gold-hi);
}
.locked .pts { background: #232219; border-color: #4a4840; color: #6e6c63; }
.feat-mark {
  display: inline-block; padding: 3px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  border: 1px solid var(--gold); color: var(--gold-hi); background: transparent;
}
.locked .feat-mark { border-color: #4a4840; color: #6e6c63; }
.bwhen { display: block; margin-top: 4px; }

/* ---- banner ---- */

.ach-banner {
  position: fixed; left: 50%; bottom: 20px; z-index: 80;
  transform: translate(-50%, 140%);
  transition: transform .45s cubic-bezier(.2,.9,.3,1.2);
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.ach-banner.on { transform: translate(-50%, 0); }
.ach-inner {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 12px; align-items: center;
  padding: 12px 14px; border-radius: 10px;
  background: linear-gradient(160deg, #2b2a21, #17160f);
  border: 2px solid var(--gold);
  box-shadow: 0 10px 30px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.1);
}
.ach-text small {
  display: block; font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--gold);
}
.ach-text strong { display: block; font-size: 15px; color: #fff; margin-top: 2px; }
.ach-text em { display: block; font-size: 11px; color: #b9b5a4; font-style: italic; margin-top: 2px; }

@media (max-width: 420px) {
  .badge-icon { width: 40px; height: 40px; flex-basis: 40px; }
  .ico { width: 22px; height: 22px; }
  .btext strong { font-size: 13px; }
}
