:root {
  --bg: #0b1622;
  --panel: rgba(13, 22, 34, 0.88);
  --panel-2: rgba(22, 35, 52, 0.92);
  --solid: #132131;
  --line: rgba(255, 255, 255, 0.1);
  --line-2: rgba(255, 255, 255, 0.18);
  --text: #eef3f8;
  --muted: #9fb0c2;
  --gold: #f4c542;
  --gold-2: #ffde7a;
  --gold-d: #a87a0c;
  --green: #2bb673;
  --red: #e5484d;
  --blue: #3a86ff;
  --r: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font-family: "Rubik", "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 15px; line-height: 1.35; }
body { overscroll-behavior: none; touch-action: manipulation; }
button { font: inherit; color: inherit; }
input, select { font: inherit; }
#scene { position: fixed; inset: 0; }
#scene canvas { display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.pos { color: #4be08f; }
.neg { color: #ff7b7f; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.center { text-align: center; }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }

/* ---------- tlačidlá */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 13px; border: 1px solid var(--line-2); background: rgba(255,255,255,0.07); cursor: pointer;
  font-weight: 600; transition: transform .08s, background .15s, opacity .15s; white-space: nowrap; user-select: none; }
.btn:hover { background: rgba(255,255,255,0.13); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold) 55%, #e0a91d); color: #2a1d00; border-color: #ffe9a8;
  box-shadow: 0 6px 18px rgba(244,197,66,0.28), inset 0 1px 0 rgba(255,255,255,0.6); font-weight: 800; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.big { min-height: 56px; font-size: 18px; padding: 0 26px; border-radius: 16px; }
.btn.green { background: linear-gradient(180deg, #49d18e, #26a565); border-color: #7be3ad; color: #052; font-weight: 800; }
.btn.danger { background: rgba(229,72,77,0.16); border-color: rgba(229,72,77,0.55); color: #ffb3b5; }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: 13.5px; border-radius: 10px; }
.btn.icon { width: 44px; padding: 0; }
.btn .badge { background: var(--red); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 6px; font-weight: 700; }

/* ---------- panely */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 10px 40px rgba(0,0,0,0.45); }

/* ---------- prihlásenie a hry */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  overflow-y: auto; pointer-events: auto; background: radial-gradient(ellipse at center, rgba(5,10,18,0.1), rgba(5,10,18,0.65)); }
.card { width: 100%; max-width: 420px; padding: 26px 22px; }
.logo { font-weight: 900; font-size: 46px; letter-spacing: 1px; text-align: center; margin: 0;
  background: linear-gradient(180deg, #fff3b0, var(--gold) 50%, #b07d12); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.5)); }
.tag { text-align: center; color: var(--muted); margin: 2px 0 18px; }
.tabs { display: flex; background: rgba(255,255,255,0.06); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tabs button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.on { background: rgba(255,255,255,0.12); color: var(--text); }
label.f { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
.inp { width: 100%; min-height: 46px; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(0,0,0,0.3);
  color: var(--text); padding: 0 14px; font-size: 16px; outline: none; }
.inp:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(244,197,66,0.2); }
select.inp { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.err { color: #ff9ea1; min-height: 20px; margin-top: 10px; font-size: 14px; }

.lobby { width: 100%; max-width: 720px; margin: auto; padding: 18px; align-self: flex-start; margin-top: max(18px, var(--safe-t)); }
.lobby-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.lobby-head .logo { font-size: 34px; text-align: left; }
.game-item { padding: 14px; margin-bottom: 10px; display: flex; gap: 12px; align-items: center; cursor: pointer; transition: transform .1s, border-color .15s; }
.game-item:hover { border-color: var(--line-2); transform: translateY(-1px); }
.game-item.turn { border-color: rgba(244,197,66,0.65); box-shadow: 0 0 0 1px rgba(244,197,66,0.25), 0 10px 40px rgba(0,0,0,0.45); }
.gi-main { flex: 1; min-width: 0; }
.gi-title { font-weight: 700; font-size: 16.5px; display: flex; gap: 8px; align-items: center; }
.gi-players { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 4px; border-radius: 99px; background: rgba(255,255,255,0.07); font-size: 13px; }
.chip .dot { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.chip.out { opacity: .45; text-decoration: line-through; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 99px; font-weight: 700; }
.pill.turn { background: var(--gold); color: #2a1d00; }
.pill.wait { background: rgba(255,255,255,0.1); color: var(--muted); }
.pill.over { background: rgba(43,182,115,0.2); color: #8ff0bd; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }

/* ---------- herné rozhranie */
.topbar { position: fixed; top: calc(8px + var(--safe-t)); left: 8px; right: 8px; display: flex; gap: 8px; align-items: flex-start; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.players { flex: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; justify-content: center; }
.players::-webkit-scrollbar { display: none; }
.pchip { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 14px; cursor: pointer; flex-shrink: 0;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: border-color .2s, box-shadow .2s; }
.pchip.on { border-color: var(--pc); box-shadow: 0 0 0 2px var(--pc), 0 0 22px color-mix(in srgb, var(--pc) 55%, transparent); }
.pchip.out { opacity: .4; }
.pchip .av { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 19px;
  background: var(--pc); box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25); }
.pchip .nm { font-weight: 700; font-size: 13.5px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pchip .cs { font-size: 13px; color: var(--gold); font-weight: 600; }
.pchip .wr { font-size: 11px; color: var(--muted); }
.roundinfo { position: fixed; top: calc(62px + var(--safe-t)); left: 50%; transform: translateX(-50%); font-size: 12.5px; color: var(--muted);
  background: rgba(10,18,28,0.6); padding: 3px 12px; border-radius: 99px; pointer-events: none; white-space: nowrap; }

.dock { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b)); width: min(660px, calc(100% - 16px));
  padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.dock-head { display: flex; align-items: center; gap: 10px; }
.dock-head .who { font-weight: 800; font-size: 16px; }
.dock-main { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.dock-main .btn.big { flex: 1 1 220px; }
.dock-sec { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.dock .info { font-size: 14px; color: var(--muted); text-align: center; }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,0.2); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* karta v doku */
.gcard { border-radius: 14px; overflow: hidden; background: #fbf7ee; color: #1d1d1d; box-shadow: 0 8px 26px rgba(0,0,0,0.35); }
.gcard .gc-band { padding: 10px 14px; color: #fff; font-weight: 800; display: flex; align-items: center; gap: 8px; text-shadow: 0 1px 2px rgba(0,0,0,0.35); }
.gcard .gc-band .ic { font-size: 22px; }
.gcard .gc-body { padding: 10px 14px 12px; }
.gcard .gc-title { font-weight: 800; font-size: 17px; margin-bottom: 4px; }
.gcard .gc-text { font-size: 14px; color: #3d3d3d; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; font-size: 14px; margin-top: 8px; }
.kv b { text-align: right; }
.gcard .kv { color: #222; }

/* prekrytia (karta udalosti, výplata, víťaz) */
.overlay-card { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); width: min(340px, calc(100% - 40px)); z-index: 30; pointer-events: auto;
  animation: cardIn .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes cardIn { from { transform: translate(-50%, -30%) rotateX(70deg) scale(.7); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
.overlay-card.out { animation: cardOut .3s forwards; }
@keyframes cardOut { to { transform: translate(-50%, -70%) scale(.85); opacity: 0; } }

.toasts { position: fixed; top: calc(100px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px;
  align-items: center; z-index: 40; pointer-events: none; width: min(520px, calc(100% - 24px)); }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 9px 14px; font-size: 14px; font-weight: 500;
  box-shadow: 0 6px 22px rgba(0,0,0,0.4); animation: tIn .3s ease-out; pointer-events: auto; text-align: center; }
.toast.gold { border-color: rgba(244,197,66,0.7); }
.toast.bad { border-color: rgba(229,72,77,0.7); }
@keyframes tIn { from { opacity: 0; transform: translateY(-8px); } }

.payday { width: min(320px, calc(100% - 40px)); padding: 14px 16px; }
.payday h3 { margin: 0 0 6px; font-size: 17px; display: flex; gap: 8px; align-items: center; }
.payday .total { font-size: 22px; font-weight: 900; text-align: right; margin-top: 6px; }

.banner { position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%); z-index: 35; text-align: center; padding: 20px 28px; width: min(440px, calc(100% - 30px));
  animation: cardIn .5s cubic-bezier(.2,1.4,.4,1); }
.banner h2 { margin: 0 0 6px; font-size: 26px; }

/* log */
.logbox { position: fixed; right: 8px; bottom: calc(10px + var(--safe-b)); width: 300px; max-height: 38vh; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.logbox .lh { display: flex; align-items: center; padding: 8px 10px 6px 14px; font-weight: 700; font-size: 13px; color: var(--muted); }
.logbox .ll { overflow-y: auto; padding: 0 12px 10px; font-size: 12.5px; display: flex; flex-direction: column-reverse; gap: 3px; }
.logbox .ll div { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.05); color: #cfd9e3; }
.logbox .ll div .d { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.sidebtns { position: fixed; left: 8px; bottom: calc(10px + var(--safe-b)); display: flex; flex-direction: column; gap: 6px; }

/* modálne okná */
.modal-bg { position: fixed; inset: 0; background: rgba(3,8,14,0.55); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 12px;
  animation: fade .2s; pointer-events: auto; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(600px, 100%); max-height: calc(100% - 20px); overflow: hidden; display: flex; flex-direction: column; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(20px); opacity: 0; } }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.modal-h h2 { margin: 0; font-size: 19px; flex: 1; }
.modal-b { padding: 14px 16px 18px; overflow-y: auto; }
.sec-t { font-weight: 800; font-size: 13px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
.sec-t:first-child { margin-top: 0; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; background: rgba(255,255,255,0.045); margin-bottom: 6px; }
.list-row .sw { width: 10px; align-self: stretch; border-radius: 4px; flex-shrink: 0; }
.list-row .nm { font-weight: 600; }
.lv { display: inline-flex; gap: 2px; }
.lv i { width: 9px; height: 9px; border-radius: 2px; background: rgba(255,255,255,0.15); display: inline-block; }
.lv i.on { background: var(--gold); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt { padding: 12px; border-radius: 13px; border: 1.5px solid var(--line-2); background: rgba(255,255,255,0.04); cursor: pointer; text-align: left; }
.opt.on { border-color: var(--gold); background: rgba(244,197,66,0.1); }
.opt b { display: block; margin-bottom: 3px; }
.opt span { font-size: 12.5px; color: var(--muted); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; min-height: 40px; border-radius: 11px; border: 1.5px solid var(--line-2); background: rgba(255,255,255,0.04); cursor: pointer; font-weight: 600; padding: 0 10px; }
.seg button.on { border-color: var(--gold); background: rgba(244,197,66,0.12); color: var(--gold-2); }
.prow { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 12px; background: rgba(255,255,255,0.05); margin-bottom: 6px; flex-wrap: wrap; }
.prow .tok { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; cursor: pointer; flex-shrink: 0; }
.prow .inp { min-height: 38px; font-size: 15px; }
.prow select.inp { width: auto; }
.bar { height: 10px; border-radius: 99px; background: rgba(255,255,255,0.1); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #8ef0b9); border-radius: 99px; }
.bar.gold > i { background: linear-gradient(90deg, var(--gold-d), var(--gold-2)); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t td, table.t th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
table.t td.r, table.t th.r { text-align: right; }
table.t th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.stock-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px; border-radius: 12px; background: rgba(255,255,255,0.05); margin-bottom: 6px; }
.chk { display: flex; gap: 8px; align-items: center; padding: 7px 8px; border-radius: 10px; cursor: pointer; }
.chk:hover { background: rgba(255,255,255,0.05); }
.chk input { width: 18px; height: 18px; accent-color: var(--gold); }
.rules p, .rules li { color: #d7e0ea; font-size: 14.5px; }
.rules h3 { color: var(--gold); margin: 18px 0 6px; font-size: 16px; }
.rules h3:first-child { margin-top: 0; }

.logbox { display: none; }
.logbox.open { display: flex; left: 60px; right: auto; width: min(380px, calc(100% - 70px)); bottom: auto; top: calc(96px + var(--safe-t)); max-height: 42vh; z-index: 20; }
@media (max-width: 760px) {
  .pchip { padding: 4px 8px 4px 4px; gap: 6px; }
  .pchip .av { width: 28px; height: 28px; font-size: 16px; }
  .pchip .nm { max-width: 74px; font-size: 12.5px; }
  .pchip .wr { display: none; }
  .roundinfo { top: calc(52px + var(--safe-t)); }
  .dock { padding: 10px; }
  .btn.big { min-height: 52px; font-size: 17px; }
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { width: 100%; border-radius: 18px 18px 0 0; max-height: 88%; }
  .sidebtns { bottom: auto; top: calc(86px + var(--safe-t)); }
}
