:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --tx: #1e293b;
  --mu: #64748b;
  --bd: #d8e0ea;
  --p: #6366f1;
  --ok: #059669;
  --no: #e11d48;
  --wa: #d97706;
  --sf: #f8fafc;
  --ai: #8b5cf6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f172a;
    --card: #1e293b;
    --tx: #f8fafc;
    --mu: #94a3b8;
    --bd: #334155;
    --ok: #10b981;
    --no: #f43f5e;
    --wa: #fbbf24;
    --sf: #0f172a;
    --ai: #a78bfa;
  }
}

:root[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --tx: #f8fafc;
  --mu: #94a3b8;
  --bd: #334155;
  --ok: #10b981;
  --no: #f43f5e;
  --wa: #fbbf24;
  --sf: #0f172a;
  --ai: #a78bfa;
}

:root {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  font-size: 16px;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  transition: background .2s ease, color .2s ease;
}

.w {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px;
  padding-bottom: 80px;
}

h2, h3 { margin: 0 0 .5em; }
p { margin: 0 0 .6em; }
.mu { color: var(--mu); }
.sm { font-size: .85rem; }
.ok { color: var(--ok); }
.no { color: var(--no); }

.card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.03);
  transition: box-shadow .2s ease, transform .15s ease;
}
.card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.07);
}

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

.b {
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--bd);
  border-radius: 12px;
  background: var(--sf);
  color: var(--tx);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s ease;
}
.b:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,.08);
}
.b:active:not(:disabled) { transform: translateY(0); }

.b.p { background: var(--p); border-color: var(--p); color: #fff; }
.b.p:hover:not(:disabled) { box-shadow: 0 4px 14px rgba(99,102,241,.35); }

.b.g { background: var(--ok); border-color: var(--ok); color: #fff; }
.b.g:hover:not(:disabled) { box-shadow: 0 4px 14px rgba(5,150,105,.35); }

.b.ai { background: var(--ai); border-color: var(--ai); color: #fff; }
.b.ai:hover:not(:disabled) { box-shadow: 0 4px 14px rgba(139,92,246,.35); }

.b.d { color: var(--no); border-color: var(--no); background: transparent; }
.b.s { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.b.xs { min-height: 28px; padding: 3px 8px; font-size: .78rem; border-radius: 8px; }
.b:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  margin: 4px 0 12px;
  font: inherit;
  color: var(--tx);
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
  outline: none;
}
label { font-size: .88rem; font-weight: 600; color: var(--mu); }

.hero {
  background: linear-gradient(135deg, #4338ca 0%, #6366f1 50%, #7c3aed 100%);
  color: #fff;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(79,70,229,.28);
}
.hero .a {
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -.02em;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 12px;
  padding-bottom: 2px;
}
.tab {
  flex: none;
  padding: 9px 18px;
  border-radius: 99px;
  border: 1px solid var(--bd);
  background: var(--card);
  color: var(--mu);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s ease;
}
.tab:hover:not(.on) {
  background: rgba(99,102,241,.08);
  color: var(--tx);
}
.tab.on {
  background: var(--p);
  border-color: var(--p);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,.3);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 700;
  background: var(--sf);
  border: 1px solid var(--bd);
  line-height: 1.3;
}
.tag.ok { color: var(--ok); border-color: var(--ok); background: rgba(5,150,105,.08); }
.tag.no { color: var(--no); border-color: var(--no); background: rgba(225,29,72,.08); }
.tag.p { color: var(--p); border-color: var(--p); background: rgba(99,102,241,.08); }

/* Totalizatora koeficientu bloks (.opts & .opt) */
.opts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.opt {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding: 12px 14px;
  text-align: left;
  font: inherit;
  color: var(--tx);
  background: var(--sf);
  border: 2px solid var(--bd);
  border-radius: 14px;
  cursor: pointer;
  transition: all .16s ease;
}
.opt:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--p);
  box-shadow: 0 6px 16px rgba(99,102,241,.18);
}
.opt.on {
  border-color: var(--p);
  background: rgba(99,102,241,.08);
  box-shadow: 0 0 0 1px var(--p);
}
.opt.win {
  border-color: var(--ok);
  background: rgba(5,150,105,.12);
  box-shadow: 0 0 0 1px var(--ok);
}
.opt.lost {
  opacity: .55;
}
.opt:disabled { cursor: default; }

.opt-hd {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}
.opt-name { font-weight: 700; font-size: .95rem; line-height: 1.25; }
.opt-tag { font-size: .72rem; font-weight: 700; padding: 2px 6px; border-radius: 6px; line-height: 1.2; }
.opt-tag.win { background: var(--ok); color: #fff; }
.opt-tag.my { background: var(--p); color: #fff; }

.opt-ft {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-top: 4px;
}
.opt-odd { font-size: 1.35rem; font-weight: 900; color: var(--tx); }
.opt-pc { font-size: .78rem; color: var(--mu); }
.opt-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--p); opacity: .85; }

.li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bd);
  transition: background .15s;
}
.li:last-child { border: 0; }
.li>div:first-child { min-width: 0; overflow-wrap: anywhere; }
.li small { display: block; color: var(--mu); }

.empty {
  padding: 24px;
  text-align: center;
  color: var(--mu);
  border: 2px dashed var(--bd);
  border-radius: 14px;
  font-size: .95rem;
}

dialog {
  width: min(92vw, 440px);
  padding: 22px;
  color: var(--tx);
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
dialog::backdrop {
  background: rgba(15,23,42,.7);
  backdrop-filter: blur(4px);
}
.r { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.ch { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

#T {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(92vw, 380px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
  pointer-events: none;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.t {
  padding: 12px 16px;
  border-radius: 14px;
  background: #334155;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: slideUp .25s ease-out;
}
.t.e { background: var(--no); }
.t.k { background: var(--ok); }
.t.w { background: var(--wa); color: #000; }

.dd {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  min-width: 250px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.25);
}
.dd .b { text-align: left; }
.mw { position: relative; }
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--no);
  box-shadow: 0 0 0 2px var(--card);
}
.row2 {
  display: grid;
  grid-template-columns: 1fr 100px 40px;
  gap: 8px;
  align-items: end;
}
.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
  color: var(--no);
  border-color: var(--no);
  text-decoration: none;
  font-weight: 700;
}
.pbar {
  height: 8px;
  border-radius: 5px;
  background: var(--bd);
  overflow: hidden;
  margin-top: 4px;
}
.pbar i { display: block; height: 100%; background: var(--ok); }

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 16px;
  margin-bottom: 14px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--mu);
  font: inherit;
  font-weight: 700;
  font-size: .9rem;
  padding: 9px 4px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  line-height: 1.2;
  transition: all .15s;
}
.seg button span { font-size: 1.4rem; }
.seg button.on {
  background: var(--p);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,.3);
}

.chip {
  padding: 7px 16px;
  border-radius: 10px;
  border: 1px solid var(--bd);
  background: var(--card);
  color: var(--tx);
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover {
  background: rgba(99,102,241,.08);
  border-color: var(--p);
}
.chip.on {
  background: var(--tx);
  color: var(--bg);
  border-color: var(--tx);
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.lbl {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--mu);
  margin: 0 0 6px;
  font-weight: 700;
}
.sg {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.st {
  padding: 12px;
  border-radius: 12px;
  background: var(--sf);
  border: 1px solid var(--bd);
}
.st b { display: block; font-size: 1.25rem; }
.st small { color: var(--mu); }

/* Sub-navigācija */
.subseg {
  display: flex;
  gap: 6px;
  background: var(--sf);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--bd);
  margin-bottom: 14px;
}
.subseg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--mu);
  padding: 8px 10px;
  font: inherit;
  font-size: .88rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all .15s;
}
.subseg button.on {
  background: var(--card);
  color: var(--tx);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}

.q-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--bd);
  background: var(--sf);
  color: var(--tx);
  font: inherit;
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
  transition: all .15s;
}
.q-btn:hover {
  background: var(--p);
  border-color: var(--p);
  color: #fff;
}

/* Netflix Stila Avatari */
.nf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.nf-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 6px;
  background: var(--sf);
  border: 2px solid var(--bd);
  border-radius: 14px;
  cursor: pointer;
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.nf-card:hover {
  transform: translateY(-3px);
  border-color: var(--p);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.nf-card.on {
  border-color: #e50914;
  background: rgba(229,9,20,.08);
  box-shadow: 0 0 0 2px #e50914, 0 4px 16px rgba(229,9,20,.25);
}
.nf-pic {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
  margin-bottom: 6px;
  flex-shrink: 0;
}
.nf-name { font-size: .82rem; font-weight: 700; color: var(--tx); line-height: 1.2; }
.nf-show { font-size: .7rem; color: var(--mu); margin-top: 2px; line-height: 1.2; }

/* Universālais avatara žetons (badge) */
.av-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,.2);
  vertical-align: middle;
  flex-shrink: 0;
  line-height: 1;
}
.av-badge.xs { width: 22px; height: 22px; font-size: 13px; border-radius: 6px; }
.av-badge.sm { width: 28px; height: 28px; font-size: 16px; border-radius: 8px; }
.av-badge.md { width: 38px; height: 38px; font-size: 22px; border-radius: 10px; }
.av-badge.lg { width: 64px; height: 64px; font-size: 36px; border-radius: 16px; }

/* AI analītika */
.ai-box {
  background: rgba(139,92,246,.08);
  border: 1px solid rgba(139,92,246,.35);
  border-radius: 14px;
  padding: 12px;
  margin: 10px 0;
}
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--ai);
  color: #fff;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
}

/* Peldošais čats - labajā apakšējā stūrī */
#chat-fab {
  position: fixed;
  right: 16px;
  left: auto;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 99px;
  background: var(--p);
  color: #fff;
  border: 0;
  font-weight: 800;
  font-size: .95rem;
  box-shadow: 0 10px 30px rgba(99,102,241,.4);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
#chat-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(99,102,241,.5);
}
#chat-box {
  position: fixed;
  right: 16px;
  left: auto;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  width: min(390px, calc(100vw - 32px));
  height: 500px;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 20px;
  box-shadow: 0 16px 45px rgba(0,0,0,.35);
  z-index: 91;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@keyframes chatPop {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
#chat-box:not([hidden]) {
  animation: chatPop .2s cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-hd {
  padding: 12px 14px;
  background: var(--sf);
  border-bottom: 1px solid var(--bd);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-tabs { display: flex; gap: 4px; }
.chat-tab {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  font-size: .84rem;
  font-weight: 700;
  color: var(--mu);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
}
.chat-tab.on {
  background: var(--card);
  color: var(--tx);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-ft {
  padding: 10px 12px;
  background: var(--sf);
  border-top: 1px solid var(--bd);
  display: flex;
  gap: 8px;
}
.chat-msg {
  font-size: .88rem;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--sf);
  border: 1px solid var(--bd);
  overflow-wrap: anywhere;
}
.chat-msg.mine {
  background: rgba(99,102,241,.12);
  border-color: rgba(99,102,241,.3);
  margin-left: 18px;
}
.chat-msg-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
  font-size: .75rem;
  color: var(--mu);
}
.chat-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  justify-content: flex-end;
}
