:root {
  --black: #000000;
  --surface: #151518;
  --line: #2b2b31;
  --text: #ffffff;
  --muted: #a3a3ad;
  --red: #e10600;
  --red-dim: #3a0503;
  --green: #1fb14b;
  --orange: #f28a00;
  --grey: #3a3a41;

  --font-display: 'Days One', 'Arial Black', sans-serif;
  --font-body: 'Onest', system-ui, sans-serif;
  --font-pixel: 'Press Start 2P', ui-monospace, monospace;
  --font-shop: 'Oswald', 'Arial Narrow', sans-serif;

  --slant: -10deg;
  --tile: min(62px, calc((100vw - 32px - 5 * 6px) / 5.6));
  --gutter: 16px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--black);
  color: var(--text);
  font: 400 16px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }

a { color: inherit; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

h1, h2, h3 { margin: 0; font-weight: 400; }

[tabindex="-1"]:focus { outline: none; }

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px var(--gutter) 6px;
}

.brand {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
}

.brand-mark {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1;
  text-transform: uppercase;
  transform: skewX(var(--slant));
  letter-spacing: .01em;
}

/* Червона лінія з банера каналу: тонка зліва, товщає й обрізана навскіс справа */
.speedline {
  display: block;
  height: 5px;
  width: 100%;
  background: linear-gradient(90deg, rgba(225, 6, 0, .15), var(--red) 55%);
  clip-path: polygon(0 75%, 100% 0, 97% 100%, 0 100%);
}

.topbar-actions { display: flex; gap: 6px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--muted); }

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* ---------- Game ---------- */

.game {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px var(--gutter) 48px;
}

.game-intro { text-align: center; }

.game-intro h1 {
  font-family: var(--font-display);
  font-size: clamp(20px, 4.4vw, 28px);
  line-height: 1.15;
  text-transform: uppercase;
  transform: skewX(var(--slant));
}

.game-lede {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

/* Стартові вогні: п’ять ламп — п’ять літер */
.gantry {
  display: flex;
  gap: 10px;
  margin: 22px 0 6px;
  padding: 8px 14px;
  background: #0d0d0f;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.light {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--red-dim);
  transition: background-color .08s, box-shadow .08s;
}

.light.on {
  background: var(--red);
  box-shadow: 0 0 10px 2px rgba(225, 6, 0, .75), 0 0 26px rgba(225, 6, 0, .45);
}

.gantry.done .light { background: #1c1c20; }

.toast-zone {
  position: relative;
  height: 0;
  width: 100%;
  z-index: 5;
}

.toast {
  position: absolute;
  left: 50%;
  top: 6px;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: var(--text);
  color: var(--black);
  font-weight: 700;
  font-size: 15px;
  border-radius: 8px;
  white-space: nowrap;
  animation: toast-in .18s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -6px); }
}

.board {
  display: grid;
  gap: 6px;
  margin: 14px 0 22px;
}

.row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, var(--tile));
  gap: 6px;
}

.row-lap {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-pixel);
  font-size: 9px;
  color: #55555e;
  white-space: nowrap;
}

.row.current .row-lap { color: var(--red); }

.tile {
  display: grid;
  place-items: center;
  width: var(--tile);
  height: var(--tile);
  border: 2px solid var(--line);
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: calc(var(--tile) * .5);
  line-height: 1;
  text-transform: uppercase;
  transform: skewX(var(--slant));
  user-select: none;
}

.tile[data-state="filled"] {
  border-color: #6b6b75;
  animation: pop .1s ease-out;
}

.tile[data-state="correct"],
.tile[data-state="present"],
.tile[data-state="absent"] { border-color: transparent; }

.tile[data-state="correct"], .mini-tile[data-state="correct"] { background: var(--green); }
.tile[data-state="present"], .mini-tile[data-state="present"] { background: var(--orange); }
.tile[data-state="absent"], .mini-tile[data-state="absent"] { background: var(--grey); }

.tile.flip { animation: flip .5s ease-in-out; }

.row.shake { animation: shake .4s; }

.row.win .tile { animation: bounce .5s ease-out both; }
.row.win .tile:nth-child(3) { animation-delay: .08s; }
.row.win .tile:nth-child(4) { animation-delay: .16s; }
.row.win .tile:nth-child(5) { animation-delay: .24s; }
.row.win .tile:nth-child(6) { animation-delay: .32s; }

@keyframes pop {
  50% { transform: skewX(var(--slant)) scale(1.08); }
}

@keyframes flip {
  0% { transform: skewX(var(--slant)) rotateX(0); }
  50% { transform: skewX(var(--slant)) rotateX(90deg); }
  100% { transform: skewX(var(--slant)) rotateX(0); }
}

@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@keyframes bounce {
  40% { transform: skewX(var(--slant)) translateY(-14px); }
  70% { transform: skewX(var(--slant)) translateY(3px); }
}

/* ---------- Keyboard ---------- */

.keyboard {
  display: grid;
  gap: 7px;
  width: 100%;
  max-width: 520px;
  user-select: none;
}

.kb-row { display: flex; gap: 5px; }

.key {
  flex: 1 1 0;
  min-width: 0;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #2c2c32;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 17px;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

.key:hover { background: #3a3a42; }
.key:active { transform: translateY(1px); }

.key.wide {
  flex: 1.6 1 0;
  font-size: 13px;
  text-transform: none;
}

.key svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }

.key[data-state="correct"] { background: var(--green); }
.key[data-state="present"] { background: var(--orange); }
.key[data-state="absent"] { background: #19191c; color: #6d6d76; }

.keyboard.locked { opacity: .45; pointer-events: none; }

.keyboard[hidden], .gantry[hidden] { display: none; }

/* ---------- Finish panel ---------- */

.finish {
  width: 100%;
  max-width: 520px;
  display: grid;
  gap: 18px;
}

.finish[hidden] { display: none; }

.finish-result {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.2;
  text-transform: uppercase;
  transform: skewX(var(--slant));
  text-align: center;
}

.finish-fact {
  margin: 8px 0 0;
  color: var(--muted);
  text-align: center;
}

.finish-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}

.countdown {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 14px;
  background: #0d0d0f;
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
}

.countdown-label { color: var(--muted); font-size: 14px; }

.countdown-clock {
  font-family: var(--font-pixel);
  font-size: clamp(15px, 4.4vw, 20px);
  color: #ffd200;
  letter-spacing: .04em;
}

.finish-actions { display: grid; gap: 8px; }

.wait-promo {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
}

.wait-promo:hover { border-color: #55555e; }

.wait-promo img {
  width: 96px;
  height: 128px;
  object-fit: cover;
  border-radius: 8px;
}

.wait-promo-text { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.wait-promo-text strong { color: var(--text); font-size: 16px; }
.wait-promo-link { color: var(--text); text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 3px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}

.btn svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; }

.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: #ff1a12; }

.btn-white { background: #fff; color: #000; }
.btn-white:hover { background: #e6e6e6; }

.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--muted); }

/* ---------- Channel ---------- */

.slanted {
  font-family: var(--font-display);
  text-transform: uppercase;
  transform: skewX(var(--slant));
  transform-origin: left;
}

.channel {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 36px;
  align-items: center;
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px var(--gutter);
  border-top: 1px solid var(--line);
}

.channel-logo {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: #fff;
}

.channel-body { max-width: 62ch; }

.channel-body h2 {
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.1;
  padding-bottom: 14px;
  background: linear-gradient(90deg, rgba(225, 6, 0, .1), var(--red)) bottom left / 100% 4px no-repeat;
}

.channel-body p { color: var(--muted); margin: 16px 0 22px; }

/* ---------- Shop ---------- */

.shop {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 40px;
  align-items: center;
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px var(--gutter);
  border-top: 1px solid var(--line);
}

.shop-kicker {
  margin: 0 0 10px;
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--red);
}

.shop-title {
  font-family: var(--font-shop);
  font-weight: 700;
  font-size: clamp(40px, 6vw, 64px);
  line-height: .98;
  text-transform: uppercase;
  color: var(--red);
  transform: rotate(-4deg);
  transform-origin: left;
  margin: 6px 0 22px;
}

.shop-copy > p { color: var(--muted); max-width: 46ch; }

.price-list {
  margin: 20px 0 24px;
  padding: 0;
  border-top: 1px solid var(--line);
}

.price-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.price-list dt { font-weight: 500; }
.price-list dd { margin: 0; font-family: var(--font-shop); font-weight: 600; font-size: 19px; }

.shop-note { font-size: 14px; margin: 12px 0 0; }

.shop-gallery {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  height: 560px;
}

.shot {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: var(--surface);
}

.shot-tall { grid-row: span 2; }

.shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}

.shot:hover img { transform: scale(1.03); }

.shot-cap {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 5px 10px;
  background: rgba(0, 0, 0, .78);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Community ---------- */

.community {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 24px;
  align-items: center;
  max-width: 1088px;
  margin: 0 auto 56px;
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

/* Картатий прапор */
.community-flag {
  width: 64px;
  height: 48px;
  background: repeating-conic-gradient(#fff 0 25%, #000 0 50%) 0 0 / 16px 16px;
  border-radius: 4px;
  transform: skewX(var(--slant));
}

.community h2 { font-family: var(--font-display); font-size: 22px; text-transform: uppercase; }
.community p { margin: 6px 0 0; color: var(--muted); }

/* ---------- Footer ---------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px var(--gutter) 40px;
  border-top: 1px solid var(--line);
  color: #74747d;
  font-size: 14px;
}

.footer p { margin: 0; }
.footer nav { display: flex; gap: 18px; }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--text); }

/* ---------- Modals ---------- */

.modal {
  width: min(440px, calc(100vw - 2 * var(--gutter)));
  padding: 26px 24px 24px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}

.modal::backdrop { background: rgba(0, 0, 0, .72); }

.modal h2 { font-size: 22px; margin: 0 0 16px; }

.modal p { color: var(--muted); }

/* z-index: інакше нахилений заголовок (transform) перекриває кнопку й забирає кліки */
.modal-close-form { position: absolute; top: 12px; right: 12px; z-index: 1; margin: 0; }
.modal-close { width: 36px; height: 36px; font-size: 16px; border: 0; }

.legend { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 10px; }
.legend li { display: flex; align-items: center; gap: 12px; }

.mini-tile {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 5px;
  font-family: var(--font-display);
  transform: skewX(var(--slant));
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
  margin-bottom: 22px;
}

.stat-num { display: block; font-family: var(--font-display); font-size: 30px; line-height: 1.1; }
.stat-label { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; margin-top: 4px; }

.chart-title { font-weight: 700; font-size: 15px; margin-bottom: 12px; }

.chart {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  align-items: end;
  height: 170px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.bar-col {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  text-align: center;
}

.bar-value { font-size: 13px; font-weight: 700; margin-bottom: 4px; }

.bar-track { display: flex; align-items: flex-end; }

.bar {
  width: 100%;
  min-height: 3px;
  border-radius: 4px 4px 0 0;
  background: var(--grey);
}

.bar-col.today .bar { background: var(--red); }

.bar-label { font-family: var(--font-pixel); font-size: 10px; color: var(--muted); padding-top: 8px; }

.chart-axis { margin: 6px 0 0; font-size: 12px; text-align: center; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .shop { grid-template-columns: 1fr; }
  .shop-gallery { height: 440px; }
  .community { grid-template-columns: 48px 1fr; }
  .community .btn { grid-column: 1 / -1; }
  .community-flag { width: 48px; height: 36px; background-size: 12px 12px; }
}

@media (max-width: 600px) {
  .row-lap { display: none; }
  .channel { grid-template-columns: 1fr; justify-items: start; gap: 22px; padding: 44px var(--gutter); }
  .channel-logo { width: 120px; height: 120px; }
  .shop { padding: 44px var(--gutter); }
  .shop-gallery { height: 360px; }
  .finish-grid { grid-template-columns: 1fr; }
  .community { margin: 0 var(--gutter) 44px; padding: 20px; }
  .key { height: 50px; font-size: 15px; }
  .kb-row { gap: 4px; }
  .footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
