:root {
  --navy: #0b2a63;
  --navy-deep: #071c45;
  --blue: #1257b8;
  --gold: #f6b70e;
  --gold-text: #8a6100;
  --bg: #eef2f9;
  --card: #fff;
  --card-alt: #f5f7fc;
  --text: #14213d;
  --muted: #5b6780;
  --line: #dde3ef;
  --green-bg: #dff5e5;
  --green: #17693a;
  --blue-bg: #dfeafb;
  --gray-bg: #e8ecf4;
  --white-piece: #fff;
  --black-piece: #1b2233;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1120;
    --card: #131c30;
    --card-alt: #18233b;
    --text: #e8edf7;
    --muted: #9dabc4;
    --line: #2a3650;
    --blue: #7db0ff;
    --gold-text: #f6b70e;
    --green-bg: #143a25;
    --green: #8fe0ad;
    --blue-bg: #1b3257;
    --gray-bg: #243049;
    --black-piece: #000;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1120; --card: #131c30; --card-alt: #18233b; --text: #e8edf7; --muted: #9dabc4; --line: #2a3650;
  --blue: #7db0ff; --gold-text: #f6b70e; --green-bg: #143a25; --green: #8fe0ad; --blue-bg: #1b3257; --gray-bg: #243049; --black-piece: #000;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
a.plain, a.plain:hover { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; }
small { font-size: .78em; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.state { padding-top: 48px; padding-bottom: 48px; text-align: center; color: var(--muted); }
.page { padding-top: 20px; padding-bottom: 40px; }
.page > h1 { font-size: 1.6rem; margin-bottom: 14px; }

/* zaglavlje */
.site-header { background: var(--navy-deep); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: block; min-width: 0; }
.brand img { display: block; width: 210px; max-width: 100%; height: auto; }
.header-right { display: flex; align-items: center; gap: 8px; flex: none; }
.lang-switch { font: inherit; font-size: .85rem; font-weight: 700; color: #fff; background: transparent; border: 1px solid #3a5288; border-radius: 8px; padding: 5px 4px; cursor: pointer; }
.lang-switch option { color: #14213d; background: #fff; }
.main-nav { display: flex; gap: 4px; flex: none; }
.main-nav a { color: #dbe5f7; font-weight: 600; padding: 10px; border-bottom: 3px solid transparent; }
.main-nav a:hover { color: #fff; text-decoration: none; }
.main-nav a[aria-current] { color: #fff; border-bottom-color: var(--gold); }
.site-footer { background: var(--navy-deep); color: #b9c6df; font-size: .875rem; padding: 18px 0; margin-top: 16px; }
.footer-source { display: inline-flex; align-items: center; gap: 8px; }
.footer-source img { border-radius: 6px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 20px; }

/* naslovna */
/* gornja trećina: baner i SwissTour; ispod redovi turnira */
.home-top { background: var(--navy-deep); }
.home-top-inner { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; max-width: 1180px; margin: 0 auto; padding: 0 16px 16px; min-height: clamp(230px, 33vh, 330px); }
.home-banner { position: relative; display: block; min-height: 0; }
.home-banner img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; object-position: 30% 50%; border-radius: 0 0 12px 12px; }
.home-rows { padding-top: 14px; padding-bottom: 32px; }
.ticker { display: flex; align-items: center; gap: 18px; background: var(--navy-deep); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.ticker a { color: #fff; font-weight: 500; }
.ticker-label { color: var(--gold); font-weight: 700; }
.promo { align-self: end; background: linear-gradient(160deg, var(--navy), #12397f); border: 1px solid #1d4590; border-radius: 12px; color: #fff; padding: 12px 16px 16px; }
.promo h2 img { display: block; width: auto; max-width: 100%; height: auto; max-height: 112px; margin: -8px auto -2px; }
.promo p { margin: 6px 0 10px; color: #dbe5f7; }
.promo ul { margin: 0; padding-left: 18px; font-size: .9rem; }
.promo li::marker { color: var(--gold); }
.card-row { margin-bottom: 18px; }
.card-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-row-head h2 { font-size: 1.1rem; }
.card-row-head a { font-weight: 600; white-space: nowrap; }
.card-row > .panel-empty { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
/* jedan turnir = jedan red: datum, status, naziv i podaci u nastavku */
.cards { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.t-card { display: flex; align-items: center; gap: 10px; padding: 7px 12px; color: inherit; border-top: 1px solid var(--line); }
.t-card:first-child { border-top: 0; }
.t-card:hover { background: var(--card-alt); text-decoration: none; }
.t-card .date-tile { width: 42px; padding: 2px 0; }
.t-card .date-tile b { font-size: 1rem; }
.t-card .badge { flex: none; }
.t-card-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.t-card-text small { color: var(--muted); font-size: .85rem; margin-left: 6px; }
@media (max-width: 1000px) {
  .home-top-inner { grid-template-columns: minmax(0, 1fr) 250px; }
}
@media (max-width: 700px) {
  .home { display: flex; flex-direction: column; }
  .home-top, .home-top-inner { display: contents; }
  .home-banner { order: 1; background: var(--navy-deep); }
  .home-banner img { position: static; height: auto; border-radius: 0; }
  .home-rows { order: 2; padding-bottom: 0; }
  .promo { order: 3; margin: 0 16px 24px; }
}
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--navy); color: #fff; padding: 12px 14px; }
.panel-head h2 { font-size: 1.05rem; }
.panel-head a { color: #dbe5f7; font-size: .85rem; white-space: nowrap; }
.panel-empty { color: var(--muted); padding: 18px 14px; margin: 0; }
.date-tile { flex: none; width: 46px; padding: 4px 0; border-radius: 8px; background: var(--blue-bg); color: var(--blue); text-align: center; font-size: .68rem; font-weight: 700; line-height: 1.15; }
.date-tile b { display: block; font-size: 1.1rem; }
.badge { flex: none; display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--gray-bg); color: var(--muted); white-space: nowrap; }
.badge-in_progress { background: var(--green-bg); color: var(--green); }
.badge-upcoming { background: var(--blue-bg); color: var(--blue); }

/* lista turnira */
.filters { display: grid; gap: 10px; margin-bottom: 14px; }
#list-search { width: 100%; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 38px; padding: 6px 13px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); color: var(--text); font: inherit; font-size: .875rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.t-head, .t-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px 180px 80px 100px; gap: 12px; align-items: center; padding: 10px 14px; }
.t-head { background: var(--card-alt); color: var(--muted); font-size: .8rem; font-weight: 600; }
.t-row { color: inherit; border-top: 1px solid var(--line); }
.t-row:hover { background: var(--card-alt); text-decoration: none; }
.t-name strong { display: block; overflow-wrap: anywhere; }
.t-name small { color: var(--muted); }

/* zaglavlje turnira */
.t-hero { background: linear-gradient(135deg, var(--navy-deep), var(--navy) 70%); color: #fff; padding: 12px 0 16px; }
.t-hero .back { color: #cfdcf3; font-size: .875rem; }
.t-hero h1 { font-size: clamp(1.35rem, 5vw, 2rem); margin-top: 6px; overflow-wrap: anywhere; }
.subtitle { margin: 4px 0 0; color: #dbe5f7; }
.t-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 6px 0 0; color: #cfdcf3; font-size: .875rem; }
.tabs { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); }
.tabs-row { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs-row a { flex: none; padding: 12px 12px 10px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs-row a:hover { text-decoration: none; color: var(--text); }
.tabs-row a[aria-current] { color: var(--text); border-bottom-color: var(--gold); }

/* tabele */
.table-scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data th { background: var(--card-alt); color: var(--muted); font-size: .78rem; font-weight: 600; padding: 8px 6px; white-space: nowrap; }
.data td { padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
.data tbody tr:hover td { background: var(--card-alt); }
.num { text-align: center; }
.name { text-align: left; min-width: 130px; }
.strong { font-weight: 700; }
.sub { display: block; color: var(--muted); }
.title { color: var(--gold-text); font-weight: 700; font-size: .85em; }
.team-name strong { display: block; font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
.team-name small { color: var(--muted); }
.team-name.withdrawn strong, .team-name.withdrawn small { color: var(--muted); text-decoration: line-through; }
.cross td, .cross th { background: var(--card); }
.cross thead th { background: var(--card-alt); }
.cross .sticky-a, .cross .sticky-b { position: sticky; z-index: 1; }
.cross .sticky-a { left: 0; min-width: 32px; }
.cross .sticky-b { left: 32px; border-right: 1px solid var(--line); min-width: 130px; max-width: 150px; }
.cross .diag { background: var(--gray-bg); }
.xc { white-space: nowrap; }
.xc small { color: var(--muted); margin: 0 1px; }
.note { color: var(--muted); font-size: .875rem; margin: 10px 2px; }
.legend { color: var(--muted); font-size: .875rem; margin-top: 14px; }
.legend h3 { font-size: .875rem; color: var(--text); margin-bottom: 4px; }
.legend ol { margin: 0 0 6px; padding-left: 22px; }
.legend p { margin: 0; }

/* kola */
.round-picker { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; margin-bottom: 12px; }
.round-picker a { flex: none; min-width: 48px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); text-align: center; line-height: 1.15; }
.round-picker a:hover { text-decoration: none; }
.round-picker b { display: block; }
.round-picker small { color: var(--muted); }
.round-picker a[aria-current] { background: var(--navy); border-color: var(--navy); color: #fff; }
.round-picker a[aria-current] small { color: #cfdcf3; }
.round-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.round-head h2 { font-size: 1.15rem; }
.round-head small { color: var(--muted); font-weight: 400; }
.matches { display: grid; gap: 8px; }
.match { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.match-head { display: grid; grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr); align-items: center; gap: 6px; padding: 10px 12px; list-style: none; }
summary.match-head { cursor: pointer; }
summary.match-head::-webkit-details-marker { display: none; }
summary.match-head:hover { background: var(--card-alt); }
.match-head .right, .match-head .static > :last-child { text-align: right; }
.match-head.static > :last-child { text-align: right; }
.match-head .winner strong { color: var(--blue); }
.score { text-align: center; font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.score.muted { color: var(--muted); font-weight: 500; font-size: .8rem; white-space: normal; }
.boards { border-top: 1px solid var(--line); }
.panel-plain { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.board { display: grid; grid-template-columns: 22px minmax(0, 1fr) 62px minmax(0, 1fr); align-items: center; gap: 4px; padding: 7px 10px; border-top: 1px solid var(--line); font-size: .875rem; }
.board:first-child { border-top: 0; }
.board-no { color: var(--muted); font-size: .75rem; }
.board-res { text-align: center; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.board-res small { display: block; color: var(--muted); font-weight: 400; }
.side { display: flex; align-items: center; gap: 6px; min-width: 0; }
.side.right { flex-direction: row-reverse; text-align: right; }
.side-text { min-width: 0; }
.side-name { display: block; overflow-wrap: anywhere; line-height: 1.2; }
.side small { color: var(--muted); }
.side em { color: var(--muted); }
.piece { flex: none; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--muted); }
.piece.white { background: var(--white-piece); }
.piece.black { background: var(--black-piece); }

/* ekipe */
.team-block { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; scroll-margin-top: 56px; overflow: hidden; }
.team-block summary { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; list-style: none; }
.team-block summary::-webkit-details-marker { display: none; }
.team-rank { font-weight: 700; text-align: center; }
.team-sum { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.team-sum small { display: block; color: var(--muted); font-weight: 400; }
.team-body { border-top: 1px solid var(--line); padding: 10px; }
.team-body h3, .tab-body > h3 { font-size: 1rem; margin: 14px 0 8px; }
.outcome-win { color: var(--green); font-weight: 700; }
.outcome-loss { color: #c0392b; font-weight: 700; }

/* kup */
.cup-bracket { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 6px; }
.cup-round { flex: 0 0 min(82vw, 270px); scroll-snap-align: start; display: flex; flex-direction: column; justify-content: space-around; gap: 8px; }
.cup-round h3 { font-size: .95rem; }
.cup-match { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cup-match summary { list-style: none; cursor: pointer; }
.cup-match summary::-webkit-details-marker { display: none; }
.cup-slot { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; font-size: .9rem; }
.cup-slot + .cup-slot { border-top: 1px solid var(--line); }
.cup-slot.winner { font-weight: 700; }
.cup-slot em { color: var(--muted); }
.cup-games { border-top: 1px solid var(--line); padding: 6px 10px; font-size: .8rem; }
.cup-games h4 { margin: 6px 0 2px; color: var(--muted); }
.cup-games ul { list-style: none; margin: 0; padding: 0; }

/* info */
.info { display: grid; grid-template-columns: minmax(110px, 170px) minmax(0, 1fr); gap: 0; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.info dt, .info dd { margin: 0; padding: 9px 12px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.info dt { color: var(--muted); font-size: .875rem; }
.info dt:first-of-type, .info dt:first-of-type + dd { border-top: 0; }

@media (max-width: 900px) {
  .t-head { display: none; }
  .t-row { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; }
  .t-name { grid-column: 1 / -1; }
  .t-city, .t-date, .t-rounds { color: var(--muted); font-size: .85rem; }
  .t-status { grid-column: 2; grid-row: 2 / span 3; align-self: end; }
  .t-city, .t-date, .t-rounds { grid-column: 1; }
}
@media (max-width: 480px) {
  .brand img { width: 140px; }
  .header-right { gap: 4px; }
  .main-nav { gap: 0; }
  .main-nav a { padding: 8px 5px; font-size: .88rem; }
  .board { grid-template-columns: 16px minmax(0, 1fr) 54px minmax(0, 1fr); padding: 7px 8px; font-size: .8rem; }
  .data th, .data td { padding: 8px 4px; }
  .match-head { grid-template-columns: minmax(0, 1fr) 62px minmax(0, 1fr); padding: 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: auto; }
}

/* FIDE kalendar */
.f-intro { color: var(--muted); margin: -6px 0 14px; }
.f-note { color: var(--muted); font-size: .85rem; margin-top: 10px; }
.f-month { background: var(--card-alt); color: var(--muted); font-size: .85rem; font-weight: 700; padding: 8px 14px; border-top: 1px solid var(--line); }
.f-month:first-child { border-top: 0; }
.f-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 190px 100px; gap: 12px; align-items: center; padding: 10px 14px; color: inherit; border-top: 1px solid var(--line); }
.f-row:hover { background: var(--card-alt); text-decoration: none; }
.f-date, .f-place { font-size: .9rem; }
.badge-fide { background: var(--navy); color: #fff; }
@media (max-width: 700px) {
  .f-row { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; }
  .f-row .t-name { grid-column: 1; grid-row: 2; }
  .f-date, .f-place { grid-column: 1; color: var(--muted); font-size: .85rem; }
  .f-row .t-status { grid-column: 2; grid-row: 1; }
}
