/* ==========================================================================
   ПОНГ-АРЕНА — стили экранов: лендинг, лобби, игра (HUD), итоги.
   Базовая дизайн-система (токены/кнопки/карточки) — в base.css.
   ========================================================================== */

/* ---------- каркас: одна страница, четыре экрана ---------- */
.pong-app {
  position: relative;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 1;
}

.screen.is-active {
  display: flex;
}

/* Цветные blob-подсветки — не мешают кликам */
.blobs {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ==========================================================================
   1. ЛЕНДИНГ
   ========================================================================== */
.screen--landing {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.landing {
  margin: auto;
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(14px, 2.4vmin, 26px);
  animation: pop-in 0.4s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.2vmin, 14px);
}

.brand__emoji {
  font-size: clamp(34px, 7vmin, 64px);
  line-height: 1;
  animation: brand-bounce 2.8s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(255, 62, 138, 0.45));
}

.brand__title {
  font-family: var(--font-display);
  font-weight: 900;
  text-transform: uppercase;
  line-height: 0.88;
  letter-spacing: 0.01em;
  font-size: clamp(44px, 10.5vmin, 104px);
  text-wrap: balance;
}

.brand__title-main {
  color: #fff;
  text-shadow: 0 0 34px rgba(53, 224, 255, 0.5), 0 6px 40px rgba(0, 0, 0, 0.6);
}

.brand__title-accent {
  margin-left: 0.12em;
}

.brand__tag {
  color: var(--muted);
  font-size: clamp(13px, 1.8vmin, 18px);
  letter-spacing: 0.04em;
}

.landing__card {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vmin, 18px);
  padding: clamp(16px, 2.6vmin, 30px);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__label {
  font-size: clamp(11px, 1.4vmin, 14px);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.text-input,
.code-input {
  width: 100%;
  min-height: 56px;
  padding: 0.6em 1em;
  border-radius: var(--r-md);
  border: 2px solid var(--stroke);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: clamp(17px, 2.3vmin, 22px);
  font-weight: 700;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.text-input::placeholder,
.code-input::placeholder {
  color: var(--dim);
  font-weight: 600;
}

.text-input:focus,
.code-input:focus {
  border-color: var(--cyan);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 4px rgba(53, 224, 255, 0.14), 0 0 34px rgba(53, 224, 255, 0.16);
}

.code-input {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  text-transform: uppercase;
  font-family: var(--font-mono);
  font-size: clamp(22px, 3.2vmin, 30px);
  letter-spacing: 0.42em;
  padding-left: calc(1em + 0.42em);
  font-weight: 900;
}

.join-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.join-row__btn {
  flex: 0 0 auto;
  min-width: 118px;
}

.landing__divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--dim);
  font-size: clamp(11px, 1.4vmin, 14px);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.landing__divider::before,
.landing__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--stroke), transparent);
}

.landing__hint {
  color: var(--muted);
  font-size: clamp(12px, 1.6vmin, 15px);
  text-align: center;
  min-height: 1.2em;
}

.landing__hint.is-error {
  color: #ff9cb5;
}

.landing__rules {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 0 4px;
  color: var(--muted);
  font-size: clamp(12px, 1.6vmin, 15px);
}

.landing__rules li {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.landing__rules li::before {
  content: "▸";
  color: var(--cyan);
  font-weight: 900;
}

.landing__rules b {
  color: var(--text);
}

.landing__foot {
  text-align: center;
  font-size: clamp(11px, 1.4vmin, 13px);
}

@keyframes brand-bounce {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-7px) rotate(8deg); }
}

/* ==========================================================================
   2. ЛОББИ
   ========================================================================== */
.screen--lobby {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.lobby {
  margin: auto;
  width: min(1180px, 100%);
  min-height: min-content;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vmin, 22px);
  animation: pop-in 0.35s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.lobby__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 2.4vmin, 30px);
}

.lobby__code-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.lobby__code-label {
  font-size: clamp(10px, 1.3vmin, 13px);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.code-box {
  display: inline-flex;
  gap: clamp(6px, 1.4vmin, 18px);
  padding: clamp(8px, 1.4vmin, 18px) clamp(12px, 2.2vmin, 30px);
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--stroke-strong);
  box-shadow: var(--glow-pink), inset 0 0 30px rgba(255, 62, 138, 0.1);
  transition: transform 0.14s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.code-box:hover { border-color: var(--stroke-strong); transform: translateY(-1px); }
.code-box:active { transform: translateY(1px) scale(0.99); }
.code-box.is-copied { border-color: var(--green); box-shadow: 0 0 40px rgba(62, 242, 155, 0.35); }

.code-box__char {
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: clamp(38px, 8vmin, 104px);
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 26px rgba(255, 62, 138, 0.75);
}

.lobby__code-url {
  font-family: var(--font-mono);
  font-size: clamp(10px, 1.3vmin, 12px);
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(52vw, 460px);
}

.lobby__head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.lobby__main {
  display: grid;
  grid-template-columns: minmax(250px, 0.95fr) minmax(300px, 1.15fr) minmax(220px, 0.8fr);
  gap: clamp(12px, 2vmin, 22px);
  align-items: start;
}

.lobby__col {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vmin, 22px);
  min-width: 0;
}

.lobby__players {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lobby__players-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: clamp(11px, 1.4vmin, 14px);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.lobby__count {
  font-size: clamp(11px, 1.3vmin, 13px);
}

.players {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0.35em 0.7em;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  animation: pop-in 0.28s ease both;
}

.player.is-me {
  border-color: color-mix(in srgb, var(--player-color, var(--cyan)) 55%, transparent);
  background: color-mix(in srgb, var(--player-color, var(--cyan)) 12%, rgba(255, 255, 255, 0.04));
}

.player__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--player-color, #fff);
  box-shadow: 0 0 12px var(--player-color, #fff);
  flex: 0 0 auto;
}

.player__name {
  font-weight: 800;
  font-size: clamp(14px, 1.8vmin, 18px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.player__badges {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.player__crown { font-size: 1.05em; filter: drop-shadow(0 0 8px rgba(255, 197, 62, 0.8)); }
.player__you {
  font-size: clamp(9px, 1.1vmin, 11px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--cyan);
  border: 1px solid rgba(53, 224, 255, 0.4);
  border-radius: var(--r-pill);
  padding: 0.1em 0.5em;
}

.lobby__players-tip,
.lobby__colors-tip {
  font-size: clamp(11px, 1.4vmin, 14px);
  line-height: 1.35;
}

.lobby__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lobby__wait {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: clamp(12px, 1.6vmin, 15px);
  text-align: center;
  padding: 4px 0;
}

.wait-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.wait-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  display: block;
  animation: wait-bounce 1.1s infinite ease-in-out;
}

.wait-dots i:nth-child(2) { animation-delay: 0.16s; }
.wait-dots i:nth-child(3) { animation-delay: 0.32s; }

@keyframes wait-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.lobby__preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: clamp(10px, 1.6vmin, 18px);
}

#previewCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 46vh;
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.22);
}

.lobby__preview-caption {
  text-align: center;
  font-size: clamp(11px, 1.4vmin, 14px);
  color: var(--muted);
}

.lobby__colors {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.color-btn {
  position: relative;
  aspect-ratio: 1;
  min-height: 48px;
  border-radius: 14px;
  border: 2px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.14s ease, border-color 0.16s ease, box-shadow 0.16s ease,
    opacity 0.16s ease;
}

.color-btn__swatch {
  width: 62%;
  height: 62%;
  border-radius: 50%;
  background: var(--swatch, #fff);
  box-shadow: 0 0 18px var(--swatch, #fff), inset 0 -6px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.16s ease;
}

.color-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--stroke-strong); }
.color-btn:hover:not(:disabled) .color-btn__swatch { transform: scale(1.08); }
.color-btn:active:not(:disabled) { transform: translateY(0) scale(0.97); }

.color-btn.is-selected {
  border-color: var(--swatch);
  background: color-mix(in srgb, var(--swatch) 18%, transparent);
  box-shadow: 0 0 22px color-mix(in srgb, var(--swatch) 55%, transparent);
}

.color-btn.is-selected::after {
  content: "✓";
  position: absolute;
  right: 5px;
  bottom: 3px;
  font-size: 12px;
  font-weight: 900;
  color: var(--swatch);
  text-shadow: 0 0 8px #000;
}

.color-btn.is-occupied {
  opacity: 0.32;
  cursor: not-allowed;
}

.color-btn.is-occupied::after {
  content: "";
  position: absolute;
  width: 60%;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.7);
  transform: rotate(-45deg);
}

/* ==========================================================================
   3. ИГРА: canvas + HUD
   ========================================================================== */
.screen--game {
  padding: 0;
  overflow: hidden;
  touch-action: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  -webkit-user-select: none;
  user-select: none;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  padding:
    max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.hud__top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.hud__timer {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 16px 8px;
  border-radius: var(--r-md);
  background: rgba(13, 8, 32, 0.62);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-1);
}

.hud__timer-text {
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: clamp(24px, 4vmin, 40px);
  line-height: 1;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0 18px rgba(53, 224, 255, 0.5);
  font-variant-numeric: tabular-nums;
}

.hud__timer.is-low .hud__timer-text {
  color: #ffd4de;
  text-shadow: 0 0 20px rgba(255, 84, 112, 0.85);
  animation: timer-throb 1s ease-in-out infinite;
}

@keyframes timer-throb {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.hud__timer-bar {
  width: clamp(96px, 16vmin, 180px);
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.hud__timer-bar i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  transform-origin: left center;
  transition: width 0.25s linear;
}

.hud__mute {
  pointer-events: auto;
  margin-left: auto;
  min-width: 46px;
  min-height: 46px;
  font-size: 20px;
  background: rgba(13, 8, 32, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.hud__board {
  position: absolute;
  top: max(78px, calc(env(safe-area-inset-top) + 74px));
  right: max(12px, env(safe-area-inset-right));
  width: clamp(190px, 19vw, 260px);
  padding: 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-radius: var(--r-md);
  background: rgba(13, 8, 32, 0.55);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-1);
  pointer-events: none;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 7px;
  border-radius: 9px;
  font-size: clamp(12px, 1.5vmin, 15px);
  line-height: 1.15;
  min-width: 0;
}

.lb-row__rank {
  width: 1.4em;
  flex: 0 0 auto;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 900;
  color: var(--dim);
  font-size: 0.92em;
}

.lb-row__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c, #fff);
  box-shadow: 0 0 8px var(--c, #fff);
  flex: 0 0 auto;
}

.lb-row__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: var(--muted);
}

.lb-row__score {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 1.02em;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.lb-row.is-me {
  background: rgba(255, 255, 255, 0.09);
}

.lb-row.is-me .lb-row__name { color: #fff; }

.lb-row.is-me .lb-row__score {
  color: var(--c, var(--cyan));
  text-shadow: 0 0 12px var(--c, var(--cyan));
}

.lb-row.is-first .lb-row__rank { color: var(--amber); }

.hud__me {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px 7px 9px;
  border-radius: var(--r-pill);
  background: rgba(13, 8, 32, 0.66);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-1);
  max-width: min(62vw, 320px);
}

.hud__me-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--c, var(--cyan));
  box-shadow: 0 0 14px var(--c, var(--cyan));
  flex: 0 0 auto;
}

.hud__me-name {
  font-weight: 800;
  font-size: clamp(13px, 1.7vmin, 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud__me-score {
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: clamp(17px, 2.3vmin, 23px);
  color: var(--c, var(--cyan));
  text-shadow: 0 0 14px var(--c, var(--cyan));
  font-variant-numeric: tabular-nums;
}

.hud__me-shield {
  font-size: clamp(14px, 1.8vmin, 18px);
  filter: drop-shadow(0 0 8px rgba(53, 224, 255, 0.9));
}

.hud__hint {
  position: absolute;
  left: 50%;
  bottom: max(64px, calc(env(safe-area-inset-bottom) + 58px));
  transform: translateX(-50%);
  width: max-content;
  max-width: min(92vw, 640px);
  text-align: center;
  color: rgba(245, 242, 255, 0.82);
  font-size: clamp(12px, 1.6vmin, 16px);
  line-height: 1.4;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  background: rgba(13, 8, 32, 0.55);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.hud__hint b {
  color: var(--cyan);
  font-family: var(--font-mono);
}

.hud__hint.is-fading {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}

/* отсчёт 4-3-2-1 */
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: radial-gradient(circle at 50% 50%, rgba(13, 8, 32, 0.22), rgba(13, 8, 32, 0.52));
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: none;
}

.countdown__num {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(96px, 26vmin, 260px);
  line-height: 0.9;
  color: #fff;
  text-shadow:
    0 0 34px rgba(255, 62, 138, 0.85),
    0 0 90px rgba(53, 224, 255, 0.45),
    0 10px 60px rgba(0, 0, 0, 0.7);
  animation: count-pop 0.95s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  font-variant-numeric: tabular-nums;
}

.countdown__label {
  font-size: clamp(14px, 2.2vmin, 24px);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

@keyframes count-pop {
  0% { opacity: 0.7; transform: scale(1.65); }
  35% { opacity: 1; transform: scale(0.94); }
  55% { opacity: 1; transform: scale(1); }
  100% { opacity: 0.92; transform: scale(1.08); }
}

/* всплывающие +1/−2/+3 рядом со своим счётом */
.pops {
  position: absolute;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(64px, calc(env(safe-area-inset-bottom) + 50px));
  width: 0;
  height: 0;
  pointer-events: none;
}

.pop {
  position: absolute;
  left: 0;
  bottom: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(20px, 2.8vmin, 30px);
  color: var(--c, #fff);
  text-shadow: 0 0 16px var(--c, #fff), 0 2px 8px #000;
  white-space: nowrap;
  animation: pop-float 1.15s ease-out forwards;
}

@keyframes pop-float {
  0% { opacity: 0; transform: translateY(6px) scale(0.7); }
  18% { opacity: 1; transform: translateY(-6px) scale(1.08); }
  100% { opacity: 0; transform: translateY(-74px) scale(1); }
}

/* ==========================================================================
   4. ИТОГИ
   ========================================================================== */
.screen--results {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.results {
  position: relative;
  margin: auto;
  width: min(640px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(12px, 2.2vmin, 22px);
  animation: pop-in 0.4s cubic-bezier(0.2, 1.3, 0.4, 1) both;
  z-index: 1;
}

.results__head {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.results__title {
  font-family: var(--font-display);
  font-size: clamp(30px, 6.5vmin, 66px);
  text-transform: uppercase;
  font-weight: 900;
  line-height: 0.95;
  background: linear-gradient(100deg, var(--pink), var(--amber) 45%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-wrap: balance;
}

.results__sub {
  font-size: clamp(12px, 1.7vmin, 16px);
}

.results__winner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: clamp(14px, 2.4vmin, 26px);
  box-shadow: var(--glow-pink);
  border-color: rgba(255, 197, 62, 0.35);
}

.results__emoji {
  font-size: clamp(40px, 8vmin, 72px);
  line-height: 1;
  animation: brand-bounce 2.4s ease-in-out infinite;
}

.results__winner-label {
  font-size: clamp(10px, 1.3vmin, 13px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--muted);
}

.results__winner-name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(24px, 4.6vmin, 44px);
  text-align: center;
  line-height: 1.05;
  color: #fff;
  word-break: break-word;
}

.results__winner-score {
  font-family: var(--font-mono);
  font-weight: 900;
  color: var(--amber);
  font-size: clamp(16px, 2.4vmin, 24px);
  text-shadow: 0 0 18px rgba(255, 197, 62, 0.6);
}

.results__table-wrap {
  padding: clamp(10px, 1.8vmin, 18px);
}

.final-table {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.final-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.5em 0.7em;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid transparent;
}

.final-row.is-me {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--stroke-strong);
}

.final-row.is-winner {
  background: linear-gradient(90deg, rgba(255, 197, 62, 0.16), rgba(255, 255, 255, 0.04));
  border-color: rgba(255, 197, 62, 0.4);
}

.final-row__rank {
  width: 2em;
  flex: 0 0 auto;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: clamp(14px, 1.9vmin, 19px);
  color: var(--muted);
}

.final-row.is-winner .final-row__rank { color: var(--amber); }

.final-row__dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--c, #fff);
  box-shadow: 0 0 12px var(--c, #fff);
  flex: 0 0 auto;
}

.final-row__name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 800;
  font-size: clamp(14px, 1.9vmin, 18px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.final-row__crown { font-size: 0.95em; margin-left: 4px; }

.final-row__score {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: clamp(15px, 2vmin, 20px);
  color: var(--c, #fff);
  font-variant-numeric: tabular-nums;
}

.results__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.results__actions .btn {
  flex: 1 1 180px;
  max-width: 280px;
}

.results__wait {
  text-align: center;
  font-size: clamp(11px, 1.5vmin, 14px);
  line-height: 1.4;
}

/* конфетти на экране итогов */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -8vh;
  display: block;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.9;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0% { transform: translate3d(0, -10vh, 0) rotate(0deg); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate3d(var(--drift, 0px), 112vh, 0) rotate(var(--spin, 720deg)); opacity: 0; }
}

/* ==========================================================================
   ОВЕРЛЕИ / ТОСТ / АДАПТИВ
   ========================================================================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 3, 16, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.overlay__card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: clamp(20px, 3vmin, 34px);
  border-radius: var(--r-lg);
  background: rgba(26, 17, 56, 0.92);
  border: 1px solid var(--stroke-strong);
  box-shadow: var(--shadow-2);
}

.overlay__spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--pink);
  border-right-color: var(--cyan);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.overlay__title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(16px, 2.4vmin, 22px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.overlay__text {
  font-size: clamp(12px, 1.6vmin, 15px);
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 18px));
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(92vw, 480px);
  padding: 0.7em 1.2em;
  border-radius: var(--r-pill);
  background: rgba(26, 17, 56, 0.96);
  border: 1px solid var(--stroke-strong);
  box-shadow: var(--shadow-2);
  color: var(--text);
  font-weight: 700;
  font-size: clamp(13px, 1.7vmin, 16px);
  text-align: center;
  animation: pop-in 0.22s ease both;
}

/* ---------- планшеты и телефоны ---------- */
@media (max-width: 1020px) {
  .lobby__main {
    grid-template-columns: minmax(240px, 1fr) minmax(260px, 1fr);
  }
  .lobby__col--colors { grid-column: 1 / -1; }
  .palette { grid-template-columns: repeat(8, 1fr); }
  #previewCanvas { max-height: 34vh; }
}

@media (max-width: 760px) {
  .landing { gap: 16px; }
  .landing__card { padding: 16px; }
  .join-row__btn { min-width: 96px; }
  .brand__emoji { font-size: clamp(30px, 8vmin, 46px); }

  .lobby__main { grid-template-columns: 1fr; }
  .lobby__col--field { order: 3; }
  .lobby__col--colors { order: 2; grid-column: auto; }
  .palette { grid-template-columns: repeat(8, 1fr); gap: 6px; }
  .color-btn { min-height: 42px; border-radius: 11px; }
  #previewCanvas { max-height: 40vh; aspect-ratio: 1.15 / 1; }

  .lobby__head { flex-direction: column; align-items: stretch; }
  .lobby__head-actions { justify-content: space-between; }
  .code-box { justify-content: center; }

  /* HUD: таймер сверху, таблица — компактными чипами под ним */
  .hud__board {
    top: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    margin-top: calc(env(safe-area-inset-top) + 68px);
    width: auto;
    max-width: min(96vw, 560px);
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    padding: 5px 6px;
  }

  .hud__board .lb-row {
    gap: 4px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--r-pill);
    font-size: clamp(10px, 2.9vmin, 13px);
  }

  .hud__board .lb-row__rank { width: auto; font-size: 0.85em; }
  .hud__board .lb-row__name { max-width: 76px; flex: 0 1 auto; }
  .hud__board .lb-row__score { font-size: 0.95em; }

  .hud__me {
    bottom: max(10px, env(safe-area-inset-bottom));
    padding: 6px 11px 6px 8px;
  }

  .hud__hint {
    bottom: max(56px, calc(env(safe-area-inset-bottom) + 50px));
    font-size: clamp(11px, 3vmin, 14px);
  }

  .results__actions .btn { flex: 1 1 140px; }
}

@media (max-width: 430px) {
  .brand__title { font-size: clamp(38px, 13vw, 58px); }
  .code-box__char { font-size: clamp(30px, 9vw, 46px); }
  .code-box { gap: 8px; padding: 10px 14px; }
  .lobby__code-url { max-width: 84vw; }
  .palette { grid-template-columns: repeat(4, 1fr); }
  .lobby__players-tip { display: none; }
  .results__winner-label { font-size: 10px; }
}

/* низкий ландшафт (телефон боком) */
@media (max-height: 520px) and (orientation: landscape) {
  .screen--landing,
  .screen--lobby,
  .screen--results {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .landing { width: min(720px, 100%); }
  .landing__rules { display: none; }
  .landing__foot { display: none; }
  .brand__emoji { display: none; }
  .brand__title { font-size: clamp(30px, 8vh, 52px); }
  .lobby__main { grid-template-columns: 1.1fr 1fr 0.9fr; }
  .lobby__col--colors { grid-column: auto; }
  #previewCanvas { max-height: 44vh; }
  .lobby__players-tip,
  .lobby__colors-tip { display: none; }
  .code-box__char { font-size: clamp(28px, 7vh, 48px); }
  .results__wrapper,
  .results { flex-direction: column; }
  .results__emoji { font-size: 36px; }
  .hud__hint { display: none; }
}

/* доступность: уважаем reduced motion */
@media (prefers-reduced-motion: reduce) {
  .brand__emoji,
  .results__emoji,
  .wait-dots i,
  .countdown__num {
    animation: none !important;
  }
  .pop { animation-duration: 0.6s; }
  .confetti i { animation-duration: 4s; }
}
