/* GamesBoard Play - Wyścig Klawiszy.
   Skóra wspólna siedzi w gb-play.css (pasek, karty, przyciski, pola, czat,
   stopka). Tu leżą wyłącznie elementy tej gry: pole tekstu, licznik postępu,
   ranking na żywo i tabela wyników. Prefiks .wr-. */


/* ============================================================ układ pokoju */

.wr-room {
  max-width: var(--gp-max); margin: 20px auto 40px; padding: 0 24px;
  display: grid; gap: 16px;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  align-items: start;
}
.wr-side { display: flex; flex-direction: column; gap: 16px; }
.wr-center { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* ================================================================= status */

.wr-status {
  background: var(--gp-card2);
  border: 1px solid var(--gp-line);
  border-left: 3px solid var(--gp-line2);
  border-radius: 8px; padding: 11px 15px;
  font-size: 14.5px; font-weight: 700; color: var(--gp-text);
}
.wr-status .hint { font-weight: 400; color: var(--gp-muted); font-size: 13px; }
.wr-status.is-you { border-left-color: var(--gp-accent); }
.wr-status.is-count { border-left-color: var(--gp-blue); }
.wr-status.is-done { border-left-color: var(--gp-green); }

/* ==================================================================== HUD */

.wr-hud {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px;
}
.wr-hud-item {
  background: var(--gp-card); border: 1px solid var(--gp-line);
  border-radius: 8px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.wr-hud-lab {
  font-size: 10.5px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--gp-muted);
}
.wr-hud-item b {
  font-family: var(--gp-mono); font-size: 19px; font-weight: 700;
  color: var(--gp-text); line-height: 1.1;
}
.wr-hud-item.is-low b { color: var(--gp-red); }

.wr-progress {
  height: 6px; border-radius: 3px; overflow: hidden;
  background: var(--gp-card2); border: 1px solid var(--gp-line);
}
.wr-progress i {
  display: block; height: 100%; width: 0;
  background: var(--gp-accent);
  transform-origin: left center;
  transition: width .18s linear;
}

/* ================================================================== tor
   Pas na gracza, po nim jedzie lotka. Pozycja to WYŁĄCZNIE transform:translateX
   w procentach szerokości toru: przy stu graczach nic tu nie przelicza układu.
   --wr-pad to pole startowe, w którym mieści się licznik zn/min i smuga; dzięki
   niemu obiekt na 0% ma co ciągnąć za sobą, a na 100% dobija do samej mety. */

.wr-track { padding: 12px 14px 12px; --wr-pad: 68px; }
.wr-track-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 9px;
}
.wr-track-note { font-size: 11.5px; color: var(--gp-muted); font-weight: 600; text-align: right; }
/* Wysokość dobrana tak, żeby 12 pasów czołówki PLUS własny pas mieściły się
   bez przewijania: przy przewijaniu własny pas, dokładany na końcu, chowałby
   się dokładnie wtedy, gdy jest najbardziej potrzebny. */
.wr-track-lanes {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 268px; overflow-y: auto;
}
.wr-track-lanes::-webkit-scrollbar { width: 7px; }
.wr-track-lanes::-webkit-scrollbar-thumb { background: var(--gp-line2); border-radius: 4px; }
.wr-track-empty { font-size: 12.5px; color: var(--gp-muted); padding: 6px 2px; }

.wr-lane {
  display: grid; grid-template-columns: 22px 148px minmax(0, 1fr) 54px;
  align-items: center; gap: 8px;
  padding: 1px 6px 1px 4px; border-radius: 5px;
  border-left: 2px solid transparent;
  background: var(--gp-card2);
  color: var(--gp-blue); /* barwa obiektu i smugi, dziedziczona przez currentColor */
}
/* Podświetlenie, bez podnoszenia i bez poświaty. */
.wr-lane:hover { background: #23262f; }
.wr-lane.is-me { border-left-color: var(--gp-accent); background: rgba(255, 194, 51, .10); color: var(--gp-accent); }
.wr-lane.is-me:hover { background: rgba(255, 194, 51, .16); }
.wr-lane.is-lead { border-left-color: var(--gp-violet); color: var(--gp-violet); }
.wr-lane.is-lead.is-me { border-left-color: var(--gp-accent); color: var(--gp-accent); }
.wr-lane.is-done { color: var(--gp-green); }

.wr-lane-no {
  font-family: var(--gp-mono); font-size: 12px; font-weight: 700; line-height: 16px;
  color: var(--gp-muted); text-align: right;
}
.wr-lane.is-lead .wr-lane-no { color: var(--gp-violet); }
.wr-lane.is-me .wr-lane-no { color: var(--gp-accent); }

.wr-lane-nick { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.wr-lane-name {
  font-size: 12.5px; font-weight: 700; color: var(--gp-text); line-height: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wr-lane-bot, .wr-lane-lead {
  flex: 0 0 auto; font-size: 10px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase; padding: 0 4px; border-radius: 3px; line-height: 14px;
}
.wr-lane-bot { color: var(--gp-text2); background: rgba(255, 255, 255, .09); }
.wr-lane-lead { color: #cbb6ff; background: rgba(167, 139, 250, .20); }

/* --------------------------------------------------------------- pas i obiekt */

/* overflow:hidden przycina pudełko jadącego obiektu. Bez tego pas przy 100%
   rozpycha listę w poziomie i wyskakuje pasek przewijania. */
.wr-lane-strip { position: relative; height: 16px; min-width: 0; overflow: hidden; }
.wr-lane-rail {
  position: absolute; left: var(--wr-pad); right: 0; top: 50%; height: 2px;
  margin-top: -1px; border-radius: 1px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .13) 0 1px, transparent 1px 10%),
    rgba(255, 255, 255, .05);
}
.wr-lane-start {
  position: absolute; left: var(--wr-pad); top: 2px; bottom: 2px; width: 1px;
  background: var(--gp-line2);
}
.wr-lane-fin {
  position: absolute; right: 0; top: 0; bottom: 0; width: 3px; border-radius: 2px;
  background: repeating-linear-gradient(180deg, var(--gp-accent) 0 3px, transparent 3px 6px);
  opacity: .6;
}
.wr-lane.is-done .wr-lane-fin { opacity: 1; }

/* Szerokość pudełka = cały dystans do przejechania, więc translateX(62%)
   to dokładnie 62% toru. Obiekt siedzi przy jego lewej krawędzi. */
.wr-lane-mover {
  position: absolute; left: var(--wr-pad); right: 30px; top: 0; bottom: 0;
  transform: translateX(0);
  transition: transform .95s linear;
}
.wr-lane.is-moving .wr-lane-mover { will-change: transform; }

.wr-lane-craft {
  position: absolute; left: 0; top: 50%; margin-top: -8px;
  width: 30px; height: 16px; display: block; fill: currentColor;
}
/* Smuga prędkości: gaśnie ku tyłowi, znika po dobiciu do mety. */
.wr-lane-mover::after {
  content: ''; position: absolute; right: 100%; margin-right: 3px;
  top: 50%; margin-top: -1px; width: 15px; height: 2px; border-radius: 1px;
  background: linear-gradient(to left, currentColor, transparent);
  opacity: .55;
}
.wr-lane.is-done .wr-lane-mover::after { opacity: 0; }

.wr-lane-cpm {
  position: absolute; right: 100%; margin-right: 21px; top: 50%; margin-top: -8px; height: 16px;
  min-width: 42px; text-align: right;
  font-family: var(--gp-mono); font-size: 10.5px; font-weight: 700; line-height: 14px;
  color: var(--gp-text2);
  background: rgba(14, 16, 21, .82); border: 1px solid var(--gp-line);
  border-radius: 4px; padding: 0 4px; white-space: nowrap;
}
.wr-lane-cpm[hidden] { display: none; }

.wr-lane-pct {
  font-family: var(--gp-mono); font-size: 12px; font-weight: 700; line-height: 16px;
  color: var(--gp-text2); text-align: right; white-space: nowrap;
}
.wr-lane.is-done .wr-lane-pct { color: #6ee7a8; }

/* ============================================================ pole tekstu */

.wr-textcard { padding: 14px 16px 12px; }
.wr-texthead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.wr-textmeta {
  font-size: 11.5px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--gp-muted);
}
.wr-textwrap { position: relative; }

.wr-text {
  font-family: var(--gp-mono);
  font-size: 19px; line-height: 1.85;
  color: var(--gp-muted);
  background: var(--gp-panel);
  border: 1px solid var(--gp-line2); border-radius: 8px;
  padding: 16px 18px;
  /* Stała wysokość obszaru pisania. Puste pole miało 34 px, więc komunikat
     "Czekamy na start" wylewał się pod ramkę. Wartość dobrana do realnego tekstu
     rundy (316 znaków dało 315 px), żeby w chwili startu układ nie przeskakiwał. */
  min-height: 304px;
  max-height: 340px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
  outline: none;
  caret-color: transparent;
}
.wr-text:focus-visible { border-color: var(--gp-accent); }
.wr-text::-webkit-scrollbar { width: 7px; }
.wr-text::-webkit-scrollbar-thumb { background: var(--gp-line2); border-radius: 4px; }

/* Znak wpisany poprawnie jaśnieje, chybiony dostaje czerwone tło z podkreśleniem
   (sam kolor nie wystarczy: informacja nie może zależeć wyłącznie od barwy). */
.wr-ch.is-ok { color: var(--gp-text); }
.wr-ch.is-bad {
  color: #ffffff; background: rgba(255, 77, 90, .30);
  border-bottom: 2px solid var(--gp-red); border-radius: 2px;
}
.wr-ch.is-bad-space { background: rgba(255, 77, 90, .45); }
.wr-ch.is-cur {
  background: rgba(255, 194, 51, .22);
  box-shadow: inset 2px 0 0 var(--gp-accent);
  border-radius: 2px;
}
.wr-text.is-idle .wr-ch.is-cur { box-shadow: none; background: none; }

/* Zasłona pola tekstu: odliczanie, przerwa, koniec. */
.wr-cover {
  position: absolute; inset: 0; border-radius: 8px;
  background: rgba(14, 16, 21, .90);
  display: grid; place-items: center; text-align: center; padding: 20px;
}
.wr-cover-inner .big {
  font-family: var(--gp-mono); font-size: 58px; font-weight: 700;
  color: var(--gp-accent); line-height: 1;
}
.wr-cover-inner .sub {
  color: var(--gp-text); font-size: 17px; font-weight: 700; line-height: 1.3;
  margin-top: 10px;
}
.wr-cover-inner .hint { color: var(--gp-muted); font-size: 13px; margin-top: 7px; }

/* Czekanie na start: pod spodem nie ma jeszcze tekstu, więc zasłona jest zbędna
   i tylko przyciemniałaby puste pole. Sam komunikat siedzi na środku ramki. */
.wr-cover.is-empty { background: none; }
.wr-cover.is-empty .wr-cover-inner .sub::before {
  content: '';
  display: block;
  width: 26px; height: 2px;
  margin: 0 auto 12px;
  border-radius: 1px;
  background: var(--gp-accent);
  opacity: .8;
}

/* Skrót zasad w polu tekstu przed startem. Pole ma stałą wysokość, więc zamiast
   pustego prostokąta stoi tu to, co gracz i tak chce wiedzieć przed rundą. */
.wr-brief { margin-top: 16px; width: min(470px, 100%); text-align: left; }
.wr-brief-grid {
  margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 13px;
}
.wr-brief-grid dt { color: var(--gp-muted); }
.wr-brief-grid dd { margin: 0; color: var(--gp-text2); font-weight: 600; text-align: right; }
.wr-brief-people {
  margin: 11px 0 0; padding-top: 10px; border-top: 1px solid var(--gp-line);
  font-size: 12.5px; color: var(--gp-text2); line-height: 1.5;
}
.wr-brief-people span {
  color: var(--gp-muted); font-size: 11px; font-weight: 700;
  letter-spacing: .8px; text-transform: uppercase; margin-right: 7px;
}
.wr-brief-people i { color: var(--gp-muted); font-style: normal; font-size: 11px; }
.wr-brief-foot { margin: 9px 0 0; font-size: 12px; color: var(--gp-muted); line-height: 1.45; }

.wr-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wr-hostbox { display: flex; flex-direction: column; gap: 10px; }
.wr-botrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ========================================================== ranking żywy */

.wr-rank-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 10px;
}
.wr-rank-note { font-size: 11.5px; color: var(--gp-muted); font-weight: 600; }
.wr-rank-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 5px;
}
.wr-row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center; gap: 8px;
  padding: 5px 7px; border-radius: 6px;
  background: var(--gp-card2); border: 1px solid transparent;
  font-size: 13px;
}
.wr-row.is-you { border-color: var(--gp-accent); background: rgba(255, 194, 51, .08); }
.wr-row.is-done .wr-row-nick { color: var(--gp-green); }
.wr-row-no {
  font-family: var(--gp-mono); font-weight: 700; color: var(--gp-muted);
  text-align: right; font-size: 12.5px;
}
.wr-row.is-top1 .wr-row-no { color: var(--gp-accent); }
.wr-row-main { min-width: 0; }
.wr-row-nick {
  display: block; color: var(--gp-text); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wr-row-bar {
  height: 4px; margin-top: 4px; border-radius: 2px;
  background: rgba(255, 255, 255, .08); overflow: hidden;
}
.wr-row-bar i {
  display: block; height: 100%; background: var(--gp-blue);
  transition: width .3s linear;
}
.wr-row.is-you .wr-row-bar i { background: var(--gp-accent); }
.wr-row.is-done .wr-row-bar i { background: var(--gp-green); }
.wr-row-stat {
  font-family: var(--gp-mono); font-size: 12.5px; color: var(--gp-text2);
  text-align: right; white-space: nowrap;
}
.wr-row-stat small { color: var(--gp-muted); font-size: 11px; }
.wr-rank-you { margin-top: 8px; border-top: 1px solid var(--gp-line); padding-top: 8px; }

.wr-flag {
  display: inline-grid; place-items: center;
  width: 15px; height: 15px; border-radius: 4px;
  background: rgba(255, 77, 90, .18); border: 1px solid var(--gp-red);
  color: var(--gp-red); font-size: 10px; font-weight: 700; line-height: 1;
  vertical-align: -2px;
}

.wr-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.wr-legend li { font-size: 12.5px; color: var(--gp-muted); line-height: 1.45; }
.wr-legend b { color: var(--gp-text2); }

/* ============================================================= prawa kolumna */

.wr-chat { height: 340px; }
.wr-people li { display: flex; align-items: center; gap: 7px; }
.wr-people .bot { color: var(--gp-muted); font-size: 12px; }
.wr-people .host { color: var(--gp-accent); font-size: 12px; font-weight: 700; }

.wr-setup-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 13px; }
.wr-setup-list dt { color: var(--gp-muted); }
.wr-setup-list dd { margin: 0; color: var(--gp-text2); font-weight: 600; text-align: right; }

/* ============================================================ podsumowanie */

.wr-modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 11, 15, .82);
  display: grid; place-items: center; padding: 24px;
}
.wr-modal-card {
  background: var(--gp-card); border: 1px solid var(--gp-line2);
  border-radius: 12px; padding: 20px;
  width: min(860px, 100%); max-height: 86vh;
  display: flex; flex-direction: column; gap: 14px;
}
.wr-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.wr-modal-head h2 { margin: 0; font-size: 22px; }
.wr-table-wrap { overflow: auto; border: 1px solid var(--gp-line); border-radius: 8px; }
.wr-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.wr-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--gp-panel); color: var(--gp-muted);
  font-size: 11px; letter-spacing: .8px; text-transform: uppercase;
  text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--gp-line);
  white-space: nowrap;
}
.wr-table th:nth-child(1), .wr-table th:nth-child(2) { text-align: left; }
.wr-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--gp-line);
  text-align: right; font-family: var(--gp-mono); color: var(--gp-text2);
  white-space: nowrap;
}
.wr-table td:nth-child(1) { text-align: left; color: var(--gp-muted); }
.wr-table td:nth-child(2) {
  text-align: left; font-family: inherit; color: var(--gp-text); font-weight: 700;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.wr-table tr:last-child td { border-bottom: none; }
.wr-table tr.is-you td { background: rgba(255, 194, 51, .08); }
.wr-table tr.is-you td:nth-child(1) { color: var(--gp-accent); }
.wr-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ============================================================ responsywność */

@media (max-width: 1180px) {
  .wr-room { grid-template-columns: 260px minmax(0, 1fr); }
  .wr-room > .wr-side:last-child { grid-column: 1 / -1; flex-direction: row; }
  .wr-room > .wr-side:last-child > * { flex: 1; min-width: 0; }
}

@media (max-width: 860px) {
  .wr-room { grid-template-columns: minmax(0, 1fr); padding: 0 14px; margin: 14px auto 28px; }
  .wr-room > .wr-side:last-child { flex-direction: column; }
  .wr-hud { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wr-text { font-size: 17px; line-height: 1.8; max-height: 260px; }
  .wr-chat { height: 280px; }
  /* Na wąskim ekranie pole startowe zjadałoby połowę toru, więc licznik
     zn/min schodzi z obiektu (zostaje w rankingu obok), a obiekt startuje
     tuż przy krawędzi i ma cały pas do przejechania. */
  .wr-track { --wr-pad: 8px; }
  .wr-lane { grid-template-columns: 18px 74px minmax(0, 1fr) 44px; gap: 6px; }
  .wr-lane-cpm { display: none; }
  .wr-track-lanes { max-height: 240px; }
}

/* Bez animacji obiekt PRZESKAKUJE na swoją pozycję przy każdym pakiecie stanu. */
@media (prefers-reduced-motion: reduce) {
  .wr-progress i, .wr-row-bar i, .wr-lane-mover { transition: none; }
}
