:root {
  --tlo: #070b1f; --karta: #141a3d; --karta2: #1c2455; --zloto: #ffd24a; --zloto2: #f5a300;
  --tekst: #f2f4ff; --przyg: #9aa3d6; --blad: #ff7b8a; --ok: #7be495;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--tlo); color: var(--tekst);
  font-family: 'Trebuchet MS', 'Segoe UI', Roboto, sans-serif; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input { -webkit-user-select: text; user-select: text; }

#gra { position: relative; display: flex; flex-direction: column; height: 100vh; height: 100dvh; width: 100%; }
#scena { position: absolute; inset: 0; }
#plotno { display: block; width: 100%; height: 100%; touch-action: none; }


#hud { position: absolute; inset: 0 0 auto 0; padding: max(10px, env(safe-area-inset-top)) 12px 0; pointer-events: none; display: flex; flex-direction: column; gap: 8px; }
.mini { pointer-events: auto; align-self: flex-start; background: rgba(10, 14, 40, .75); color: var(--tekst); border: 1px solid #3a4590;
  border-radius: 10px; padding: 8px 12px; font: 700 14px inherit; min-height: 40px; cursor: pointer; }
#pasekCzasu { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .18); overflow: hidden; }
#pasekWypelnienie { height: 100%; background: linear-gradient(90deg, var(--zloto), var(--zloto2)); transform-origin: left center; transform: scaleX(0); }
#podpowiedz { margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(10, 14, 40, .75); font-size: 15px; text-align: center; }
#debug { position: absolute; left: 6px; bottom: 6px; font: 12px monospace; background: rgba(0, 0, 0, .6); padding: 3px 6px; border-radius: 4px; pointer-events: none; }


#sterowanie { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 56.25dvh);
  display: flex; height: clamp(104px, 26dvh, 200px); padding: 6px 6px max(8px, env(safe-area-inset-bottom)); gap: 8px; background: transparent; }
#sterowanie.ukryte { visibility: hidden; }
#sterowanie.zablokowane { opacity: .4; }
.ster { flex: 1; min-width: 0; border: 0; border-radius: 22px; color: #fff; font: 900 clamp(20px, min(6.5vw, 4dvh), 38px) 'Trebuchet MS', sans-serif; letter-spacing: 1px;
  touch-action: none; cursor: pointer; box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .28); transition: transform .06s, filter .06s; }
.ster-l { background: #2f6bff; } .ster-p { background: #ff7a1a; }
.ster.wcisniety { transform: scale(.96); filter: brightness(1.3); }
@media (orientation: landscape) { #sterowanie { height: clamp(78px, 30dvh, 130px); } }


.ekran { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow-y: auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 30%, rgba(30, 40, 100, .55), rgba(4, 6, 20, .88)); }
.karta { width: 100%; max-width: 460px; margin: auto; padding: 22px 18px; background: var(--karta); border: 2px solid #2d3a8c; border-radius: 22px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5); text-align: center; }
.nadtytul { margin: 0; color: var(--zloto); font-weight: 800; letter-spacing: 3px; text-transform: uppercase; }
h1 { margin: 4px 0 8px; font-size: clamp(34px, 11vw, 52px); line-height: 1; color: var(--zloto); text-shadow: 0 3px 0 #8a5a00; }
h2 { margin: 18px 0 6px; font-size: clamp(20px, 5.6vw, 26px); color: var(--zloto); }
.opis { color: var(--przyg); margin: 6px 0 16px; line-height: 1.4; }
.duzy { font-size: clamp(18px, 5vw, 22px); font-weight: 800; margin: 0 0 12px; line-height: 1.3; }

.przycisk { display: block; width: 100%; min-height: 52px; margin: 10px 0 0; padding: 12px 20px; border: 0; border-radius: 14px; cursor: pointer;
  font: 900 clamp(16px, 4.6vw, 19px) 'Trebuchet MS', sans-serif; letter-spacing: .5px; color: #2a1a00;
  background: linear-gradient(#ffd54a, var(--zloto2)); box-shadow: 0 4px 0 #a86a00; }
.przycisk.drugi { color: var(--tekst); background: var(--karta2); box-shadow: 0 4px 0 #0f1538; border: 1px solid #3a4590; }
.przycisk:active { transform: translateY(3px); box-shadow: none; }
.przycisk:disabled { opacity: .5; cursor: default; }
.rzad { display: flex; gap: 10px; } .rzad .przycisk { flex: 1; }

.lista-wyniku { list-style: none; margin: 0 0 6px; padding: 12px; background: var(--karta2); border-radius: 14px; text-align: left; }
.lista-wyniku li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); font-size: 15px; }
.lista-wyniku li:last-child { border-bottom: 0; } .lista-wyniku span { color: var(--przyg); } .lista-wyniku b { color: var(--zloto); white-space: nowrap; }

#formularz { text-align: left; }
#formularz label { display: block; margin: 6px 0; font-weight: 700; }
#imie { width: 100%; padding: 13px 14px; font: 700 18px inherit; border-radius: 12px; border: 2px solid #3a4590; background: #0d1230; color: var(--tekst); }
#imie:focus { outline: 3px solid var(--zloto); border-color: var(--zloto); }
#komunikatZapisu { min-height: 1.4em; margin: 8px 0 0; font-weight: 700; text-align: center; }
.ok { color: var(--ok); } .blad { color: var(--blad); }


.karta.ranking { display: flex; flex-direction: column; max-width: 520px; height: min(100%, 720px); padding: 16px 12px; }
.ranking h2 { margin: 4px 0 10px; font-size: clamp(22px, 6.4vw, 30px); }
#rankingLista { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-radius: 12px; background: var(--karta2); scrollbar-width: thin; }
#rankingLista table { width: 100%; border-collapse: collapse; table-layout: fixed; }
#rankingLista th, #rankingLista td { padding: 10px 6px; font-size: clamp(13px, 3.8vw, 16px); }
#rankingLista th { position: sticky; top: 0; z-index: 1; background: #0f1538; color: var(--przyg); font-size: clamp(11px, 3.1vw, 13px); padding-left: 3px; padding-right: 3px; white-space: nowrap; overflow: hidden; text-overflow: clip; }
#rankingLista th:nth-child(1), #rankingLista td:nth-child(1) { width: 19%; text-align: center; }
#rankingLista th:nth-child(2), #rankingLista td:nth-child(2) { width: 30%; text-align: left; }
#rankingLista th:nth-child(3), #rankingLista td:nth-child(3) { width: 27%; text-align: right; }
#rankingLista th:nth-child(4), #rankingLista td:nth-child(4) { width: 24%; text-align: right; }
#rankingLista td { border-bottom: 1px solid rgba(255, 255, 255, .07); white-space: nowrap; }
#rankingLista td.imie { overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
#rankingLista tr.top1 td { color: #ffd24a; } #rankingLista tr.top2 td { color: #dfe4f5; } #rankingLista tr.top3 td { color: #e6a76a; }
#rankingStatus { margin: 0; padding: 22px 14px; text-align: center; color: var(--przyg); font-weight: 700; }
#rankingStatus.blad { color: var(--blad); }

@media (max-width: 380px) { .karta { padding: 16px 12px; } }
@media (prefers-reduced-motion: reduce) { .ster, .przycisk { transition: none; } }
