:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1c2230;
  --muted: #6b7382;
  --accent: #1f7a5c;
  --accent-text: #ffffff;
  --pos: #18794e;
  --neg: #c2362b;
  --warn-bg: #fff4d6;
  --home: #2d6cdf;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --grid: #e6e8ec;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 5%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b1f27;
    --surface-2: #232834;
    --border: #2f3542;
    --text: #e7eaf0;
    --muted: #9099a8;
    --accent: #3fb68b;
    --accent-text: #0d1512;
    --pos: #4cc38a;
    --neg: #f07167;
    --warn-bg: #3a3320;
    --home: #6b9cf0;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --grid: #2a303b;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; color: var(--muted); font-weight: 600; }

button, .button {
  font: inherit;
  padding: .45em .9em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
button:hover:not(:disabled), .button:hover { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--neg); }
button.link { border: none; background: none; color: var(--accent); padding-inline: .3em; }
button.big { font-size: 1.1rem; padding: .8em 1.4em; width: 100%; }

input {
  font: inherit;
  padding: .45em .7em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: .85em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.error { color: var(--neg); }

/* ---------- Úvodní stránka ---------- */

body.landing { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.landing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  max-width: 460px;
  width: 100%;
}
.landing-card h1 { font-size: 2rem; margin-bottom: .2em; }
.tagline { margin: 0 0 1.2rem; color: var(--accent); font-weight: 600; font-size: .95em; }
.lead { color: var(--muted); margin: 0 0 1.8rem; }
.divider { display: flex; align-items: center; gap: .8em; color: var(--muted); margin: 1.6rem 0 1rem; font-size: .9em; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.join-form { display: flex; gap: .5rem; }
.join-form input { flex: 1; }

/* ---------- Horní lišta ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: .7rem 1.2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.stat { display: flex; flex-direction: column; }
.stat .label, .budget-item .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat .value { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-main .value { font-size: 1.6rem; font-weight: 700; }
.breakdown { display: flex; gap: 1.4rem; flex-wrap: wrap; padding-left: 1.4rem; border-left: 1px solid var(--border); }
.breakdown .value { font-size: 1rem; }
.me-age { margin: 0; font-size: 1.05rem; }
.topbar-actions { margin-left: auto; }

/* ---------- Rozvržení ---------- */

.layout { display: grid; grid-template-columns: 260px 1fr; gap: 1.2rem; padding: 1.2rem; padding-bottom: 6rem; }
.sidebar {
  position: sticky;
  top: 5.5rem;
  align-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.content { display: flex; flex-direction: column; gap: 1.2rem; min-width: 0; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
}
.hint { color: var(--muted); font-size: .85em; margin: 1rem 0 0; }

/* ---------- Záložky ---------- */

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs button { padding: .3em .8em; border-radius: 99px; font-size: .9em; }
.tabs button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- Žebříčky ---------- */

.board-hint { margin: 0 0 .8rem; }
.players { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.players li {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .5rem .5rem 1.8rem;
  border-radius: 8px;
  position: relative;
}
.players li::before { content: counter(rank) "."; position: absolute; left: .5rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.players li.me { background: var(--surface-2); }
.players li.offline { opacity: .5; }
.player-info { flex: 1; min-width: 0; }
.player-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.player-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-worth { font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { font-size: .75rem; padding: .05em .5em; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ready { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.ready-summary { margin: .8rem 0 0; font-size: .9em; color: var(--muted); }

/* ---------- Piktogramy ---------- */

.icon {
  width: 52px; height: 52px; flex: none;
  padding: 6px; border-radius: 12px;
  background: #eef1f5; color: #1c2230;
}
.icon .ic-fill { fill: #ffffff; }
.icon.tier-1 .ic-fill { fill: #d7dbe1; }
.icon.tier-2 .ic-fill { fill: #9fc4ef; }
.icon.tier-3 .ic-fill { fill: #f3c64f; }
.icon .ic-wheel { fill: #3a4150; }
.icon .ic-gold { fill: #f3c64f; }
.icon .ic-gold-stroke { stroke: #b8860b; }
.icon .ic-face { fill: #ffffff; }
.icon .ic-up { stroke: #18794e; }
.icon .ic-brown { fill: #9a5b2e; }
.icon .ic-bus { fill: #e2483d; }
.icon .ic-star { fill: #e2483d; }
.icon .ic-water { stroke: #2d6cdf; }
.icon .ic-shark { fill: #7a8796; }
.panel-title { display: flex; align-items: center; gap: .6rem; }
.panel-title .icon { width: 44px; height: 44px; padding: 4px; border-radius: 10px; }
.icon .ic-mane { stroke: #4a2a14; }

.avatar { width: 100%; max-width: 220px; height: auto; color: #1c2230; display: block; }
.avatar.mini { width: 40px; flex: none; }
.avatar .sc-office { fill: #e9eef5; stroke: none; }
.avatar .sc-window { fill: #cfe6ff; }
.avatar .sc-clock { fill: #ffffff; }
.avatar .sc-skin { fill: #f2c9a0; }
.avatar .sc-shirt { fill: #5b8def; }
.avatar .sc-tie { fill: #d64545; }
.avatar .sc-laptop { fill: #9aa4b2; }
.avatar .sc-sky { fill: #bfe3ff; stroke: none; }
.avatar .sc-sand { fill: #f3d9a4; stroke: none; }
.avatar .sc-sun { fill: #ffcf3f; }
.avatar .sc-umbrella { fill: #ff7a59; }
.avatar .sc-swim { stroke: #2d6cdf; }

/* ---------- Můj život ---------- */

.life { display: grid; grid-template-columns: 220px 1fr; gap: 1.5rem; }
.me-card { display: flex; flex-direction: column; gap: .6rem; align-items: flex-start; }
.me-status { margin: 0; font-size: .92em; }
.life-main { min-width: 0; }
.life-main h2 { margin-top: 1.2rem; }

.freedom-head { display: flex; justify-content: space-between; align-items: baseline; }
.freedom-head .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.freedom-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.meter { height: 12px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin: .3rem 0; }
.meter-bar { width: 0; height: 100%; background: var(--home); border-radius: 99px; transition: width .4s; }
.meter-bar.full { background: var(--accent); }
.freedom p { margin: 0; }

.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: .7rem .5rem; text-align: center; white-space: normal;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
  font-size: .9em;
}
button.tile:hover { border-color: var(--accent); }
.tile.static { cursor: default; }
.tile.debt .icon { background: #fde4e1; }
.tile-effects {
  display: grid; grid-template-columns: auto auto; gap: 0 .4rem; justify-items: end;
  font-size: .75em; font-variant-numeric: tabular-nums; margin-top: -.15rem;
}
.tile-effects .muted { justify-self: start; }
.tile-name { font-weight: 600; line-height: 1.2; }
.tile-value { font-variant-numeric: tabular-nums; }
.tag { font-size: .8em; padding: 0 .45em; border-radius: 4px; background: var(--border); color: var(--text); }
.tag.rented { background: var(--accent); color: var(--accent-text); }
.tag.broken, .tag.empty { background: var(--neg); color: #fff; font-weight: 600; }
.tile.warn { border-color: var(--neg); box-shadow: inset 0 0 0 1px var(--neg); }
.tag.home { background: var(--home); color: var(--accent-text); }

/* ---------- Rozpočet a report ---------- */

.budget { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.budget-item { display: flex; flex-direction: column; gap: .15rem; }
.budget-item .value { font-size: 1.2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.budget-item .sub { color: var(--muted); font-size: .85em; }
.budget-item summary, .report summary { cursor: pointer; }
.report[open] summary { margin-bottom: 1rem; }
.notes .note { margin: 0 0 .8rem; padding: .5rem .8rem; border-radius: 8px; background: var(--warn-bg); }

.lines { width: 100%; border-collapse: collapse; font-size: .92em; }
.lines td { padding: .25em 0; border-bottom: 1px dashed var(--border); }
.lines td.num { padding-left: 1em; }
.lines tr.total td { font-weight: 700; border-bottom: none; padding-top: .5em; }
.report-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }

/* ---------- Obchod ---------- */

.shop { display: flex; flex-direction: column; gap: 1.4rem; }
.shop-group h3 { color: var(--text); font-size: 1rem; }
.shop-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.shop-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  background: var(--surface-2);
}
.shop-head { display: flex; gap: .7rem; align-items: center; }
.shop-name { font-weight: 600; }
.shop-price { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.shop-facts { margin: .2rem 0 .4rem; padding-left: 1.1rem; color: var(--muted); font-size: .85em; flex: 1; }
.cost-lines { margin: .1rem 0 0; padding-left: 1rem; list-style: '– '; }
.buy-buttons { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .4rem; }
.mortgage-offer { margin: 0; color: var(--muted); }

.finance { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.finance p { margin: 0 0 .6rem; }
.amount-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.amount-row input { flex: 1 1 140px; }

/* ---------- Tlačítko Další rok ---------- */

.next-year {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 10;
  font-size: 1.1rem;
  padding: .9em 1.8em;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 20%);
}
.next-year.waiting { background: var(--warn-bg); color: var(--text); border-color: var(--border); font-weight: 500; }

/* ---------- Dialogy a toast ---------- */

.overlay { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 45%); display: grid; place-items: center; padding: 16px; }
.overlay[hidden], .toast[hidden] { display: none; }
.dialog {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.6rem;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.dialog.wide { width: min(900px, 100%); }
.dialog { max-height: calc(100vh - 32px); overflow-y: auto; }
.dialog h2 { margin: 0; }
.dialog-head { display: flex; gap: .9rem; align-items: center; }
.dialog-head .icon { width: 64px; height: 64px; }
.dialog-actions.column { flex-direction: column; align-items: stretch; }
.dialog-actions.column button { text-align: left; white-space: normal; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.story { margin: 0; }
.lifelong { margin: 0; padding: .6rem .8rem; border-radius: 8px; background: var(--warn-bg); }

.final-holdings { display: flex; flex-direction: column; gap: 1rem; margin-top: .6rem; }
.final-player { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; }
.final-player.me { background: var(--surface-2); }
.final-player .player-row { margin-bottom: .6rem; }
.final-player .player-name { display: inline-flex; align-items: center; gap: .4rem; }
.tile.mini { padding: .5rem .4rem; font-size: .82em; }
.tile.mini .icon { width: 40px; height: 40px; }
.chart-card { border-top: 1px solid var(--border); padding-top: 1rem; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.chart-head h3 { color: var(--text); font-size: 1rem; margin: 0; }
.dialog label.toggle, .toggle { flex-direction: row; display: flex; align-items: center; gap: .4rem; font-size: .9em; color: var(--muted); cursor: pointer; }
.legend { display: flex; gap: .4rem 1rem; flex-wrap: wrap; margin: .6rem 0; font-size: .9em; }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; display: inline-block; }
.chart { position: relative; }
.chart svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--muted); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end-dot { stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--text); font-size: 13px; font-weight: 600; }
.chart .leader { stroke: var(--muted); stroke-width: 1; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-tip {
  position: absolute; z-index: 2; pointer-events: none; min-width: 180px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 15%); padding: .5rem .7rem; font-size: .88em;
}
.tip-row { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: center; }
.final-boards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.2rem; }
.final-board h3 { color: var(--text); font-size: 1rem; margin-bottom: .2rem; }
.final-board p { margin: 0 0 .5rem; }
.dialog label { display: flex; flex-direction: column; gap: .3rem; color: var(--muted); font-size: .9em; }
.dialog-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }

.connection {
  position: fixed; top: .6rem; left: 50%; transform: translateX(-50%); z-index: 40;
  background: var(--warn-bg); color: var(--text); border: 1px solid var(--border);
  padding: .4rem .9rem; border-radius: 99px; font-size: .9em; box-shadow: var(--shadow);
}
.connection[hidden] { display: none; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 30;
  background: var(--text);
  color: var(--bg);
  padding: .7rem 1.1rem;
  border-radius: 10px;
  max-width: calc(100% - 32px);
}

/* ---------- Mobil ---------- */

@media (max-width: 1200px) {
  .budget { grid-template-columns: repeat(2, 1fr); }
  .shop-items { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px 16px 6rem; }
  .sidebar { position: static; }
  .shop-items, .budget, .report-cols, .finance, .final-boards { grid-template-columns: 1fr; }
  .life { grid-template-columns: 1fr; }
  .me-card { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .me-card .avatar { max-width: 140px; }
  .me-status { flex: 1 1 160px; }
  .topbar { gap: .6rem 1rem; flex-wrap: wrap; padding: .6rem 16px; }
  .topbar-actions { margin-left: 0; }
  .breakdown { order: 3; flex-basis: 100%; gap: .4rem 1rem; padding: .5rem 0 0; border-left: 0; border-top: 1px solid var(--border); }
  .me-age { flex-basis: 100%; }
  .brand { display: none; }
  .next-year { right: 16px; left: 16px; bottom: 16px; }
}
