/* Rychlý jako ČIP: vzhled TV přenos, dvě barvy (fialová ČIP + korál) na bílém sněhu.
 * Grafika sedí přímo na obraze (žádné rámečky ani skleněné panely): pruhy tmavé fialové do průhlednosti, písmo samo.
 * Písmo: Neue Haas Grotesk Display Pro (Monotype), licenci má ČIP. Soubory ve fonts/ jsou podmnožina (latinka + latin-ext-A). */
@font-face { font-family: "Neue Haas Grotesk"; font-weight: 400; font-style: normal; font-display: block; src: url("fonts/NHaasGroteskDSPro-55Rg.woff2") format("woff2"); }
@font-face { font-family: "Neue Haas Grotesk"; font-weight: 500; font-style: normal; font-display: block; src: url("fonts/NHaasGroteskDSPro-65Md.woff2") format("woff2"); }
@font-face { font-family: "Neue Haas Grotesk"; font-weight: 700; font-style: normal; font-display: block; src: url("fonts/NHaasGroteskDSPro-75Bd.woff2") format("woff2"); }
:root {
  --vio: #8802C9; --deep: #2B0748; --cor: #FF5A3C; --cor-soft: #FF8C73; --ink: #14061F;
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --sat: env(safe-area-inset-top, 0px); --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px);
  --font: "Neue Haas Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --num: clamp(40px, min(14vw, 9vh), 68px);
  --edge: 22px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden; background: var(--deep);
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
  font-family: var(--font); color: #fff; font-kerning: normal;
}
#stage { position: fixed; inset: 0; height: 100vh; height: 100dvh; overflow: hidden; touch-action: none; background: var(--deep); }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.pad { position: absolute; top: 0; bottom: 0; width: 50%; touch-action: none; }
#padL { left: 0; } #padR { right: 0; }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud::before {                          /* horní pruh: tmavá fialová do průhlednosti, drží čitelnost čísel na nebi */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: calc(var(--num) + 150px + var(--sat));
  background: linear-gradient(180deg, rgba(43,7,72,.86) 0, rgba(43,7,72,.55) 58%, rgba(43,7,72,0) 100%);
}
#hud::after {                           /* dolní pruh pod ovládáním */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: calc(150px + var(--sab));
  background: linear-gradient(0deg, rgba(43,7,72,.5) 0, rgba(43,7,72,.26) 55%, rgba(43,7,72,0) 100%);
}
.hudtop { position: absolute; z-index: 1; left: calc(var(--edge) + var(--sal)); right: calc(var(--edge) + var(--sar)); top: calc(30px + var(--sat)); }
.hudtop .row { display: flex; justify-content: space-between; align-items: flex-end; }
.lb { display: block; margin-bottom: 7px; font: 400 13px/1 var(--font); color: rgba(255,255,255,.74); }
.spd { text-align: right; }
.time b, .spd b { display: block; font: 500 var(--num)/.88 var(--font); letter-spacing: -.02em; color: #fff; white-space: nowrap; }
.time b i, .spd b i, .big i { font-style: normal; display: inline-block; text-align: center; }
.time b i.d, .spd b i.d, .big i.d { width: .6em; } .time b i.p, .spd b i.p, .big i.p { width: .28em; }
.ticks { display: flex; gap: 3px; height: 15px; margin-top: 16px; }
.ticks i { flex: 1; border-radius: 1px; background: rgba(255,255,255,.3); transform-origin: 50% 100%; }
.ticks i.on { background: #fff; animation: tick .3s var(--ease-spring) both; }
.ticks i.bad { background: var(--cor); animation: tick .3s var(--ease-spring) both; }
@keyframes tick { from { transform: scaleY(.35); } to { transform: scaleY(1); } }
.meta { display: flex; justify-content: space-between; margin-top: 9px; font: 400 13px/1.2 var(--font); color: rgba(255,255,255,.84); }
.meta #hudPen { color: var(--cor-soft); font-weight: 500; }

/* split proti rekordu: pruh vyjíždí zleva pod pruh bran (dole je lyžař a ovládání) */
.l3 { position: absolute; z-index: 1; left: 0; top: calc(var(--sat) + var(--num) + 126px); display: flex; height: 50px; font: 500 20px/1 var(--font); }
.l3 span { display: flex; align-items: center; padding: 0 22px 0 calc(var(--edge) + var(--sal)); background: #fff; color: var(--deep); letter-spacing: -.005em; }
.l3 em { display: flex; align-items: center; padding: 0 24px; border-radius: 0 14px 14px 0; font-style: normal; font-weight: 700; background: var(--vio); color: #fff; }
.l3.worse em { background: var(--cor); color: var(--ink); }
.l3[hidden] { display: none; }
.l3.show { animation: l3-in .4s var(--ease-spring) both; }
@keyframes l3-in { from { opacity: 0; transform: translateX(-36%); } to { opacity: 1; transform: translateX(0); } }

/* ovládání: šipky v půlkách, brzda uprostřed */
.arrow, .brake { position: absolute; z-index: 2; bottom: calc(36px + var(--sab)); }
.arrow {
  width: 76px; height: 76px; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff;
  display: flex; align-items: center; justify-content: center; pointer-events: none; transition: transform .14s var(--ease-spring);
}
.arrow-l { left: calc(var(--edge) + var(--sal)); } .arrow-r { right: calc(var(--edge) + var(--sar)); }
.arrow.on { transform: scale(.9); background: var(--cor); color: var(--ink); }
.brake {
  left: 50%; margin-left: -62px; width: 124px; height: 52px; border: 0; border-radius: 13px; background: var(--cor); color: var(--ink);
  font: 500 18px/1 var(--font); cursor: pointer; touch-action: none; transition: transform .14s var(--ease-spring);
}
.brake:hover { transform: translateY(-2px); }
.brake:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.brake:active, .brake.on { transform: scale(.94); }

/* za úvodem a výsledkem se HUD a ovládání schová (čísla by se zdvojovala) */
.intro #hud, .intro .arrow, .intro .brake, .res #hud, .res .arrow, .res .brake { visibility: hidden; }

/* úvod a výsledek: scéna prosvítá nahoře, text vlevo dole na tmavé fialové */
.overlay {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; overflow: hidden;
  padding: calc(132px + var(--sat)) calc(26px + var(--sar)) calc(30px + var(--sab)) calc(26px + var(--sal));
  background: linear-gradient(180deg, rgba(43,7,72,.06) 0, rgba(43,7,72,.5) 34%, rgba(43,7,72,.93) 60%, #2B0748 100%);
}
.overlay[hidden] { display: none; }
.card { width: 100%; max-width: 480px; margin-top: auto; text-align: left; }
.overlay.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.overlay .logo { position: absolute; left: calc(26px + var(--sal)); top: calc(44px + var(--sat)); width: clamp(96px, 28vw, 132px); height: auto; }
.kicker { font: 500 16px/1.2 var(--font); color: var(--cor-soft); }
.card h1 { margin-top: 14px; font: 700 clamp(48px, min(16vw, 15vh), 104px)/.93 var(--font); letter-spacing: -.035em; color: #fff; }
.card .sub { margin-top: 20px; max-width: 26em; font: 400 18px/1.5 var(--font); color: rgba(255,255,255,.9); }
.card .keys { margin-top: 14px; font: 400 14px/1.6 var(--font); color: rgba(255,255,255,.6); }
.cta {
  display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 26px; padding: 20px 24px; border: 0; border-radius: 14px;
  background: var(--cor); color: var(--ink); cursor: pointer; font: 500 20px/1 var(--font); transition: transform .16s var(--ease-spring);
}
.cta:hover { transform: translateY(-2px); }
.cta:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.cta:active { transform: scale(.98); }
.card .cta + .keys { margin-top: 12px; }

/* výsledek */
.big { margin-top: 12px; font: 500 clamp(54px, min(16vw, 14vh), 96px)/.9 var(--font); letter-spacing: -.03em; color: #fff; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 10px; margin-top: 18px; font: 500 19px/1 var(--font); color: var(--cor-soft); }
.badge::before { content: ""; width: 11px; height: 11px; border-radius: 50%; background: var(--cor); }
.badge[hidden] { display: none; }
.facts { list-style: none; margin: 24px 0 0; max-width: 420px; }
.facts li { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0 12px; border-top: 1px solid rgba(255,255,255,.22); font: 400 16px/1.2 var(--font); }
.facts li:last-child { border-bottom: 1px solid rgba(255,255,255,.22); }
.facts span { color: rgba(255,255,255,.72); } .facts b { font-weight: 500; text-align: right; }

/* výsledek: pořadí, přezdívka, okolí v žebříčku */
.rank { margin-top: 14px; font: 500 22px/1.25 var(--font); color: #fff; }
.sum { margin-top: 10px; font: 400 15px/1.5 var(--font); color: rgba(255,255,255,.72); }
.nick { margin-top: 24px; }
.nick label { display: block; margin-bottom: 6px; font: 400 13px/1 var(--font); color: rgba(255,255,255,.74); }
.nick input {
  display: block; width: 100%; padding: 8px 0 10px; border: 0; border-bottom: 2px solid rgba(255,255,255,.55); border-radius: 0; background: transparent; color: #fff;
  font: 500 28px/1.2 var(--font); letter-spacing: -.01em; outline: none; caret-color: var(--cor);
  -webkit-user-select: text; user-select: text; -webkit-appearance: none; appearance: none;
}
.nick input::placeholder { color: rgba(255,255,255,.38); }
.nick input:focus { border-bottom-color: var(--cor); }
.nick .cta { margin-top: 18px; }
.err { margin-top: 10px; font: 500 15px/1.35 var(--font); color: var(--cor-soft); }
.err[hidden], .rank[hidden], .rows[hidden] { display: none; }
.fine { margin-top: 12px; font: 400 13px/1.5 var(--font); color: rgba(255,255,255,.58); }
.cta:disabled { opacity: .6; cursor: default; transform: none; }
.link {
  display: block; margin-top: 14px; padding: 10px 0; border: 0; background: none; color: #fff; cursor: pointer; text-align: left;
  font: 500 17px/1 var(--font); text-decoration: underline; text-underline-offset: 5px; text-decoration-color: rgba(255,255,255,.4); transition: transform .14s var(--ease-spring);
}
.link:hover { text-decoration-color: var(--cor); }
.link:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.link:active { transform: scale(.97); }
.rows { list-style: none; margin: 22px 0 0; max-width: 460px; }
.rows li { display: grid; grid-template-columns: 2.6em 1fr auto; gap: 10px; align-items: baseline; padding: 12px 0 11px; border-top: 1px solid rgba(255,255,255,.2); font: 400 18px/1.2 var(--font); }
.rows li:last-child { border-bottom: 1px solid rgba(255,255,255,.2); }
.rows .r { color: rgba(255,255,255,.62); }
.rows .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .t { font-weight: 500; white-space: nowrap; }
.rows .t i { font-style: normal; display: inline-block; text-align: center; } .rows .t i.d { width: .58em; } .rows .t i.p { width: .3em; }
.rows li.me { color: var(--cor-soft); } .rows li.me .r { color: var(--cor-soft); }
.rows li.gap { border-top: 0; padding: 4px 0; color: rgba(255,255,255,.5); }
#board h2 { margin-top: 12px; font: 700 clamp(30px, min(9vw, 8vh), 48px)/1 var(--font); letter-spacing: -.03em; color: #fff; }
#board .cta { margin-top: 22px; }
/* stavy výsledku: off = bez serveru (jen čas a Jet znovu), form = přezdívka, done = pořadí a okolí */
#result.st-off .nick, #result.st-off #boardBtn, #result.st-off #againBtn, #result.st-off #resRank,
#result.st-form #againCta, #result.st-form #resNear,
#result.st-done .nick, #result.st-done #againBtn { display: none; }
#result.st-off #againCta, #result.st-done #againCta { display: flex; }

/* zvuk: ikona vpravo nahoře, nad vším */
.mute { position: absolute; z-index: 9; top: var(--sat); right: calc(8px + var(--sar)); width: 38px; height: 34px; display: flex; align-items: center; justify-content: center; border: 0; background: none; color: rgba(255,255,255,.88); cursor: pointer; transition: transform .14s var(--ease-spring); }
.mute:hover { color: #fff; } .mute:active { transform: scale(.9); } .mute:focus-visible { outline: 2px solid #fff; outline-offset: -2px; border-radius: 8px; }
.mute .x { display: none; } .mute.off .x { display: inline; } .mute.off .w { display: none; } .mute.off { color: var(--cor-soft); }

/* výsledek a žebříček: panel z „tekutého skla“ (rozmazané pozadí, jemný lesk, světlý okraj) nad scénou */
.overlay.glassy { background: linear-gradient(180deg, rgba(43,7,72,.14) 0, rgba(43,7,72,.46) 55%, rgba(43,7,72,.62) 100%); }
.under { visibility: hidden; }
.glass {
  position: relative; padding: 26px 24px 22px; border-radius: 32px;
  background: linear-gradient(165deg, rgba(255,255,255,.17) 0, rgba(255,255,255,.04) 42%, rgba(255,255,255,.08) 100%), rgba(28,5,58,.42);
  -webkit-backdrop-filter: blur(28px) saturate(1.5); backdrop-filter: blur(28px) saturate(1.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(255,255,255,.1), inset 0 0 36px rgba(255,255,255,.04), 0 30px 60px -24px rgba(8,0,24,.75), 0 2px 6px rgba(8,0,24,.3);
}
.glass::before {                          /* světelný okraj: výrazný vlevo nahoře a vpravo dole */
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.2px; pointer-events: none;
  background: linear-gradient(150deg, rgba(255,255,255,.85) 0, rgba(255,255,255,.1) 32%, rgba(255,255,255,.03) 62%, rgba(255,255,255,.5) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.glass::after {                           /* lesk: měkká záře vlevo nahoře, bez ostrých hran */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(90% 55% at 22% 0%, rgba(255,255,255,.14), rgba(255,255,255,0) 70%);
}
.glass > * { position: relative; z-index: 1; }
.glass .kicker, .glass .badge { color: #FFB3A1; }
.glass .rows li { border-top-color: rgba(255,255,255,.2); } .glass .rows li:last-child { border-bottom-color: rgba(255,255,255,.2); }
.glass .nick input { border-bottom-color: rgba(255,255,255,.5); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .glass { background: rgba(43,7,72,.86); } }
@media (max-height: 720px) { .overlay { padding-top: calc(104px + var(--sat)); } .glass .keys { display: none; } .glass { padding: 20px 20px 16px; } }
@media (min-width: 720px) { .overlay.glassy { align-items: center; } .overlay.glassy .card { margin: auto; } }

/* měření (interní) */
.dbg-btn {
  position: absolute; left: calc(8px + var(--sal)); top: calc(6px + var(--sat)); z-index: 7; min-width: 40px; height: 22px; padding: 0 9px;
  border: 0; border-radius: 11px; background: rgba(20,6,31,.5); color: #fff; font: 600 11px/1 ui-monospace, Menlo, monospace; cursor: pointer;
}
.dbg-btn:hover { background: rgba(20,6,31,.8); }
.dbg-btn:focus-visible { outline: 2px solid var(--cor); }
.dbg { position: absolute; left: calc(10px + var(--sal)); top: calc(34px + var(--sat)); z-index: 8; width: min(420px, calc(100% - 20px)); max-height: calc(100% - 70px); overflow: auto;
  padding: 12px; border-radius: 14px; background: rgba(18,2,31,.92); border: 1px solid rgba(255,255,255,.18); color: #fff;
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; touch-action: pan-y;
  box-shadow: 0 20px 40px -12px rgba(0,0,0,.6); }
.dbg[hidden] { display: none; }
.dbg pre { font: 12px/1.45 ui-monospace, Menlo, monospace; color: #e9ddf6; white-space: pre-wrap; margin: 8px 0; }
.dbg .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; justify-content: space-between; }
.dbg .row.res { justify-content: flex-start; }
.mini { padding: 7px 11px; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; background: rgba(255,255,255,.08); color: #fff; font: 500 12px/1 var(--font); cursor: pointer; }
.mini:hover { background: rgba(255,255,255,.18); }
.mini:focus-visible { outline: 2px solid var(--cor); }
.mini:active, .mini.sel { background: var(--vio); border-color: #B45CF0; }

@media (prefers-reduced-motion: reduce) { .l3.show, .ticks i.on, .ticks i.bad { animation: none; } }
/* na šířku: čas vlevo, rychlost vpravo, pruh bran uprostřed (HUD nezakrývá nebe a hory) */
@media (orientation: landscape) {
  :root { --num: clamp(30px, 8vh, 56px); }
  #hud::before { height: calc(var(--num) + 70px + var(--sat)); }
  .l3 { top: calc(var(--sat) + var(--num) + 80px); height: 44px; font-size: 18px; }
  .hudtop { display: grid; grid-template-columns: auto 1fr auto; column-gap: 28px; }
  .hudtop .row { display: contents; }
  .time { grid-area: 1 / 1 / 3 / 2; } .spd { grid-area: 1 / 3 / 3 / 4; }
  .ticks { grid-area: 1 / 2; align-self: end; margin: 0; } .meta { grid-area: 2 / 2; margin-top: 8px; }
  .overlay { align-items: flex-start; }
}
@media (max-height: 460px) {
  :root { --edge: 16px; }
  .arrow { width: 62px; height: 62px; } .arrow svg { width: 28px; height: 28px; } .brake { height: 44px; }
  .card h1 br { display: none; } .card .sub { font-size: 16px; margin-top: 12px; } .cta { margin-top: 16px; padding: 16px 20px; }
}
/* počítač (myš + klávesnice): ovládací prvky na obrazovce nejsou potřeba, zóny dotyku fungují dál */
@media (hover: hover) and (pointer: fine) { body:not(.touch) .arrow, body:not(.touch) .brake { display: none; } }
