@font-face {
  font-family: "Snake Regular";
  src: url("assets/font/SnakeRegular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg-1: #1a120c;
  --bg-2: #241813;
  --bg-3: #2d1c16;
  --panel: rgba(32, 20, 14, 0.84);
  --line: rgba(255, 179, 120, 0.34);
  --text: #f1f4ff;
  --muted: #d9bf9f;
  --accent: #ffaf62;
  --accent-2: #ffd27a;
  --danger: #ff7f6d;
  --warn: #ffd067;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Exo 2", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(70vw 70vw at 15% 20%, #4a2f1d 0%, transparent 60%),
    radial-gradient(60vw 60vw at 82% 85%, #5a3324 0%, transparent 58%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  overflow-x: hidden;
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image:
    linear-gradient(transparent 0, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, transparent 0, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 3px 3px, 3px 3px;
}

.app {
  max-width: 1720px;
  margin: 0 auto;
  padding: 14px 16px 22px;
}

.app-header {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 6px;
  position: relative;
  z-index: 18;
}

.app-header h1 {
  margin: 0;
  font-family: "Snake Regular", "Russo One", sans-serif;
  letter-spacing: 0.035em;
  font-size: clamp(2.7rem, 7.4vw, 6rem);
  line-height: 1;
  text-transform: uppercase;
}

.app-header h1.title-snake-wave {
  position: relative;
  display: block;
  width: var(--wave-stage-width, min(100%, 800px));
  max-width: min(100%, 800px);
  height: 1.05em;
  line-height: 1;
  letter-spacing: 0;
  overflow: visible;
  transform: none !important;
}

.title-wave-char {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  margin: 0;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg, #f7ffd8 0%, #bbf778 44%, #72bd3d 100%);
  color: #cbff8a;
  -webkit-text-fill-color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow:
    0 1px 0 #6f9430,
    0 2px 0 #5d7e28,
    0 3px 0 #4b6620,
    0 4px 0 #3b5219,
    0 5px 0 #2d3d12,
    0 8px 14px rgba(0, 0, 0, 0.44),
    0 0 14px rgba(177, 255, 114, 0.24);
  will-change: left, top;
}

.title-wave-char::before {
  content: attr(data-char);
  position: absolute;
  inset: 0;
  transform: translate(2px, 3px);
  color: rgba(45, 66, 23, 0.94);
  -webkit-text-fill-color: rgba(45, 66, 23, 0.94);
  text-shadow: none;
  z-index: -1;
}

.title-wave-space {
  text-shadow: none;
}

.title-wave-space::before {
  content: none;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.btn-language {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 62px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  letter-spacing: 0.09em;
  line-height: 1;
  z-index: 2;
}

body.race-screen-active .app-header {
  margin-bottom: clamp(-24px, -2.2vw, -10px);
  z-index: 40;
  pointer-events: auto;
}

body.race-screen-active .app-header h1,
body.race-screen-active .app-header p {
  pointer-events: none;
}

body.race-screen-active .app-header .btn-language {
  pointer-events: auto;
}

body.race-screen-active .app {
  max-width: none;
  width: 100%;
  padding-left: 0;
  padding-right: 0;
}

body.race-screen-active .app-header p {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
}

body.race-screen-active #screen-race {
  display: flex;
  justify-content: center;
  margin-top: 0;
}

body.race-screen-active .app-header h1.title-snake-wave {
  max-width: none;
  transform: translateY(-4px) !important;
}

.screen {
  display: none;
  margin-top: 14px;
  animation: fade-in 220ms ease-out;
}

.screen.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(10px);
}

.menu-panel {
  display: grid;
  gap: 10px;
  max-width: 560px;
  width: min(560px, 94vw);
  margin: 0 auto;
  padding: 22px 22px;
}

#screen-leaderboard .panel {
  max-width: 1280px;
  width: min(1280px, 96vw);
  margin: 0 auto;
}

#screen-main .menu-panel .btn {
  font-size: 1.05rem;
  padding: 13px 16px;
}

#screen-main .menu-field {
  text-align: left;
}

.menu-field {
  display: grid;
  gap: 6px;
}

.menu-field span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.menu-field input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  outline: none;
}

.menu-field select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  outline: none;
  color-scheme: dark;
}

.menu-field select option {
  background: #2a1a12;
  color: #f6e7d4;
}

#leaderboard-track-select {
  background: linear-gradient(135deg, rgba(53, 33, 22, 0.95), rgba(30, 20, 14, 0.95));
  color: #ffe8ca;
  border-color: rgba(255, 194, 132, 0.52);
}

#leaderboard-track-select option {
  background: #2a1a12;
  color: #ffe8ca;
}

.menu-field input:focus {
  border-color: rgba(255, 210, 122, 0.9);
  box-shadow: 0 0 0 2px rgba(255, 210, 122, 0.2);
}

.menu-field select:focus {
  border-color: rgba(255, 210, 122, 0.9);
  box-shadow: 0 0 0 2px rgba(255, 210, 122, 0.2);
}

.menu-field input::placeholder {
  color: rgba(241, 244, 255, 0.46);
}

.online-room-picker {
  margin-top: 6px;
  margin-bottom: 10px;
  display: grid;
  gap: 8px;
}

.online-room-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.online-room-actions input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  outline: none;
}

.online-room-actions input:focus {
  border-color: rgba(255, 210, 122, 0.9);
  box-shadow: 0 0 0 2px rgba(255, 210, 122, 0.2);
}

.online-room-actions input::placeholder {
  color: rgba(241, 244, 255, 0.46);
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.btn,
.card,
.rules-modal__close,
.about-modal__close {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.08);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.btn.primary {
  color: #051927;
  background: linear-gradient(120deg, var(--accent), #7ef5ff);
  box-shadow: 0 8px 20px rgba(50, 211, 255, 0.28);
}

.btn.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.card {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  color: #ffe9c8;
  cursor: pointer;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: #fff3ce;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.card p {
  margin: 0;
  color: #ffe0bc;
  font-size: 0.88rem;
  line-height: 1.32;
}

.card ul {
  margin: 8px 0 0;
  padding-left: 16px;
  color: #ffd5a8;
  font-size: 0.84rem;
  line-height: 1.34;
}

.card li::marker {
  color: #ffbf79;
}

.card--track {
  border-color: rgba(255, 203, 143, 0.44);
  background:
    radial-gradient(110% 90% at 18% 12%, rgba(255, 174, 90, 0.16), transparent 62%),
    linear-gradient(145deg, rgba(78, 47, 24, 0.9), rgba(34, 21, 14, 0.92));
  box-shadow:
    inset 0 0 0 1px rgba(255, 244, 228, 0.05),
    0 10px 18px rgba(17, 10, 7, 0.33);
}

.card--track h3 {
  font-size: 1.32rem;
  letter-spacing: 0.015em;
}

.card--track.selected {
  border-color: #b8ff8c;
  box-shadow:
    0 0 0 1px rgba(120, 255, 170, 0.62),
    0 14px 24px rgba(95, 230, 145, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.card--snake {
  text-align: left;
}

.snake-card__header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.snake-card__preview {
  position: relative;
  width: 94px;
  height: 56px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.15), rgba(18, 20, 24, 0.72));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 6px 12px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  pointer-events: none;
}

.snake-card__segment,
.snake-card__head {
  position: absolute;
  image-rendering: auto;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.4));
}

.snake-card__segment {
  opacity: 0.94;
}

.snake-card__segment--tip {
  width: 12px;
  height: 12px;
  left: 4px;
  top: 23px;
  opacity: 0.72;
}

.snake-card__segment--tail {
  width: 16px;
  height: 16px;
  left: 12px;
  top: 20px;
  opacity: 0.8;
}

.snake-card__segment--mid {
  width: 20px;
  height: 20px;
  left: 25px;
  top: 15px;
  opacity: 0.88;
}

.snake-card__segment--front {
  width: 24px;
  height: 24px;
  left: 42px;
  top: 11px;
  opacity: 0.96;
}

.snake-card__head {
  width: 32px;
  height: 32px;
  left: 60px;
  top: 8px;
  transform: scaleX(-1) rotate(-4deg);
}

.card.selected {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(115, 255, 150, 0.6), 0 14px 20px rgba(115, 255, 150, 0.1);
}

.card--snake.selected .snake-card__preview {
  border-color: rgba(255, 238, 150, 0.76);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    0 8px 16px rgba(126, 245, 255, 0.18);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.btn.mode-active {
  color: #072022;
  background: linear-gradient(120deg, #73ff96, #b5ffd1);
  border-color: rgba(115, 255, 150, 0.84);
  box-shadow: 0 8px 20px rgba(115, 255, 150, 0.2);
}

.mode-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.race-layout {
  position: relative;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
}

#race-stage {
  --stage-ar: 1.5806;
  width: min(97vw, calc(90dvh * var(--stage-ar))) !important;
  aspect-ratio: 980 / 620;
  height: auto !important;
  max-height: 90dvh;
  min-width: 320px;
  min-height: 220px;
  border-radius: 16px;
  border: 1px solid rgba(255, 214, 170, 0.35);
  box-shadow:
    0 20px 34px rgba(20, 12, 8, 0.52),
    inset 0 0 0 1px rgba(255, 235, 210, 0.08);
  background: #1f2f1c;
  overflow: hidden;
  display: block;
  margin: 0 auto;
}

#race-stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.hud-overlay-layer {
  position: absolute;
  inset: 8px;
  pointer-events: none;
  z-index: 8;
}

.hud-cluster {
  position: absolute;
  display: grid;
  gap: 6px;
  width: min(255px, 26vw);
}

.hud-cluster--tl {
  top: 0;
  left: 0;
  width: min(210px, 22vw);
}

.hud-cluster--tr {
  top: 0;
  right: 0;
}

.hud-cluster--bl {
  bottom: 0;
  left: 0;
  width: min(210px, 21vw);
}

.hud-cluster--br {
  right: 0;
  bottom: 0;
  width: min(275px, 28vw);
}

.hud-box {
  background: linear-gradient(135deg, rgba(46, 30, 20, 0.72), rgba(26, 18, 13, 0.76));
  border: 1px solid rgba(255, 188, 132, 0.4);
  border-radius: 10px;
  padding: 8px 9px;
  display: grid;
  gap: 4px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 246, 231, 0.05),
    0 7px 12px rgba(14, 8, 6, 0.33);
}

.hud-box span {
  color: #f7ce9d;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.hud-box strong {
  font-family: "Russo One", sans-serif;
  font-size: 0.9rem;
  color: #fff4e6;
  text-shadow: 0 2px 0 rgba(25, 15, 10, 0.42);
}

.hud-box--time {
  border-color: rgba(255, 204, 112, 0.62);
  background: linear-gradient(135deg, rgba(74, 41, 18, 0.9), rgba(36, 22, 12, 0.93));
}

.hud-box--speed {
  border-color: rgba(220, 181, 110, 0.58);
  background: linear-gradient(135deg, rgba(72, 49, 24, 0.9), rgba(35, 26, 16, 0.92));
}

.hud-box--position {
  border-color: rgba(255, 162, 115, 0.58);
  background: linear-gradient(135deg, rgba(73, 33, 22, 0.9), rgba(36, 20, 15, 0.92));
}

.hud-box--effect {
  border-color: rgba(255, 190, 130, 0.56);
  background: linear-gradient(135deg, rgba(65, 42, 24, 0.89), rgba(34, 24, 15, 0.92));
}

.hud-box--standings {
  border-color: rgba(255, 198, 138, 0.56);
  background: linear-gradient(145deg, rgba(58, 33, 20, 0.9), rgba(30, 20, 15, 0.93));
}

.hud-cluster--tl .hud-box {
  padding: 6px 7px;
  gap: 3px;
  border-radius: 9px;
}

.hud-cluster--tl .hud-box span {
  font-size: 0.56rem;
  letter-spacing: 0.05em;
}

.hud-cluster--tl .hud-box strong {
  font-size: 0.8rem;
  line-height: 1.05;
}

.standings ol {
  margin: 0;
  padding-left: 14px;
  display: grid;
  gap: 3px;
  font-size: 0.78rem;
  line-height: 1.22;
  max-height: min(26vh, 160px);
  overflow-y: auto;
  color: #ffe6c8;
  text-shadow: 0 1px 0 rgba(20, 12, 8, 0.42);
}

.controls {
  border-radius: 12px;
  border: 1px solid rgba(255, 185, 122, 0.42);
  background: linear-gradient(140deg, rgba(42, 27, 19, 0.84), rgba(24, 16, 12, 0.9));
  padding: 10px 12px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 246, 231, 0.04),
    0 8px 14px rgba(16, 10, 7, 0.4);
}

.controls p {
  margin: 0;
  color: #f5cfaa;
  font-size: 0.82rem;
  line-height: 1.3;
}

.touch-controls {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 170px;
  display: grid;
  justify-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 14;
}

.touch-controls__hint {
  margin: 0;
  color: #ffd9b2;
  font-size: 0.7rem;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
}

.touch-joystick {
  --joy-x: 0px;
  --joy-y: 0px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 1px solid rgba(255, 209, 154, 0.48);
  background: radial-gradient(circle at 35% 30%, rgba(255, 211, 160, 0.2), rgba(38, 23, 14, 0.84));
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 236, 0.06),
    0 10px 16px rgba(16, 10, 8, 0.35);
  position: relative;
  pointer-events: auto;
  touch-action: none;
}

.touch-joystick::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  border-radius: 50%;
  background: rgba(255, 226, 188, 0.55);
}

.touch-joystick__knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(255, 223, 190, 0.64);
  background: linear-gradient(145deg, rgba(255, 205, 145, 0.9), rgba(122, 79, 42, 0.9));
  transform: translate(calc(-50% + var(--joy-x)), calc(-50% + var(--joy-y)));
  box-shadow:
    0 6px 11px rgba(22, 14, 10, 0.45),
    inset 0 0 0 1px rgba(255, 251, 245, 0.15);
}

.race-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(7, 12, 24, 0.28);
  font-family: "Russo One", sans-serif;
  font-size: clamp(2.1rem, 5vw, 4rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--overlay-color, #edf3ff);
  text-shadow:
    0 0 10px rgba(214, 234, 255, 0.75),
    0 6px 14px rgba(3, 8, 18, 0.55);
  opacity: 0;
  transform: scale(1);
  pointer-events: none;
  border-radius: 16px;
  z-index: 24;
}

.race-overlay.visible {
  display: flex;
  opacity: 1;
}

.race-overlay.countdown {
  font-size: clamp(5rem, 18vw, 18rem);
  font-family: "Snake Regular", "Russo One", sans-serif;
  letter-spacing: 0.02em;
}

.race-overlay.countdown.countdown-burst {
  animation: countdown-burst 820ms cubic-bezier(0.13, 0.16, 0.19, 1) both;
}

.race-overlay.overlay-go {
  font-size: clamp(3.2rem, 10vw, 9rem);
  animation: overlay-pop 640ms ease-out both;
}

.race-overlay.overlay-finish {
  font-size: clamp(2.6rem, 7.2vw, 5.6rem);
  animation: overlay-pop 700ms ease-out both;
}

.race-overlay.overlay-rules {
  font-size: clamp(1.55rem, 3.4vw, 3rem);
  letter-spacing: 0.045em;
  text-align: center;
  line-height: 1.22;
  width: min(94%, 920px);
  max-width: 94%;
  margin: 0 auto;
  padding: 0 22px;
  background: rgba(7, 12, 24, 0.38);
  animation: overlay-rules-in 260ms ease-out both;
}

@keyframes countdown-burst {
  0% {
    opacity: 0;
    transform: scale(0.08);
  }
  10% {
    opacity: 1;
    transform: scale(0.17);
  }
  28% {
    opacity: 1;
    transform: scale(0.5);
  }
  48% {
    opacity: 0.98;
    transform: scale(1.4);
  }
  68% {
    opacity: 0.82;
    transform: scale(3.6);
  }
  84% {
    opacity: 0.45;
    transform: scale(8.8);
  }
  100% {
    opacity: 0;
    transform: scale(15);
  }
}

@keyframes overlay-pop {
  0% {
    opacity: 0;
    transform: scale(0.72);
  }
  22% {
    opacity: 1;
    transform: scale(1.06);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes overlay-rules-in {
  0% {
    opacity: 0;
    transform: scale(0.92);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.rules-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 18px;
}

.rules-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 20, 0.72);
}

.rules-modal__panel {
  position: relative;
  width: min(1100px, 96vw);
  max-height: min(88vh, 820px);
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 187, 128, 0.46);
  background: linear-gradient(140deg, rgba(37, 22, 14, 0.96), rgba(24, 15, 10, 0.98));
  box-shadow:
    0 24px 56px rgba(5, 7, 12, 0.55),
    inset 0 0 0 1px rgba(255, 250, 240, 0.06);
  padding: 18px 18px 16px;
}

.rules-modal__close {
  position: sticky;
  top: 0;
  float: right;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.06);
  color: #ffe1bf;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.rules-modal h2 {
  margin: 2px 0 8px;
}

.rules-modal h3 {
  margin: 12px 0 8px;
  color: #ffd6a5;
  letter-spacing: 0.02em;
}

.rules-modal__goal {
  margin: 6px 0;
  color: #f0d8ba;
}

.rules-snakes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.rules-snake {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
}

.rules-snake__head-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.rules-snake__preview {
  width: 94px;
  height: 56px;
}

.rules-snake h4 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.rules-snake p {
  margin: 0;
  color: #f1deca;
  font-size: 0.87rem;
  line-height: 1.32;
}

.rules-snake ul {
  margin: 8px 0 0;
  padding-left: 16px;
  color: #f7e5d0;
  font-size: 0.82rem;
  line-height: 1.3;
}

.rules-snake--speedster {
  border-color: rgba(112, 235, 255, 0.44);
  background: linear-gradient(135deg, rgba(44, 122, 136, 0.22), rgba(26, 18, 14, 0.32));
}

.rules-snake--handler {
  border-color: rgba(160, 255, 130, 0.42);
  background: linear-gradient(135deg, rgba(70, 138, 64, 0.22), rgba(26, 18, 14, 0.32));
}

.rules-snake--bully {
  border-color: rgba(255, 163, 143, 0.42);
  background: linear-gradient(135deg, rgba(142, 72, 62, 0.22), rgba(26, 18, 14, 0.32));
}

.rules-snake--trickster {
  border-color: rgba(224, 175, 255, 0.42);
  background: linear-gradient(135deg, rgba(116, 73, 151, 0.22), rgba(26, 18, 14, 0.32));
}

.rules-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.rules-item {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.rules-item img {
  width: 34px;
  height: 34px;
  image-rendering: auto;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.34));
}

.rules-item h4 {
  margin: 0;
  font-size: 0.96rem;
}

.rules-item p {
  margin: 4px 0 0;
  color: #f2dfcc;
  font-size: 0.86rem;
  line-height: 1.3;
}

.rules-item--buff {
  border-color: rgba(111, 255, 171, 0.36);
  background: linear-gradient(135deg, rgba(78, 162, 98, 0.13), rgba(20, 29, 22, 0.2));
}

.rules-item--debuff {
  border-color: rgba(255, 147, 129, 0.32);
  background: linear-gradient(135deg, rgba(150, 66, 56, 0.18), rgba(34, 20, 18, 0.22));
}

body.modal-open {
  overflow: hidden;
}

.about-modal {
  position: fixed;
  inset: 0;
  z-index: 46;
  display: grid;
  place-items: center;
  padding: 18px;
}

.about-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 20, 0.72);
}

.about-modal__panel {
  position: relative;
  width: min(900px, 96vw);
  max-height: min(88vh, 820px);
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 187, 128, 0.46);
  background: linear-gradient(140deg, rgba(37, 22, 14, 0.96), rgba(24, 15, 10, 0.98));
  box-shadow:
    0 24px 56px rgba(5, 7, 12, 0.55),
    inset 0 0 0 1px rgba(255, 250, 240, 0.06);
  padding: 18px 18px 16px;
}

.about-modal__close {
  position: sticky;
  top: 0;
  float: right;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.06);
  color: #ffe1bf;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.about-modal h2 {
  margin: 2px 0 10px;
}

.about-modal p {
  margin: 0;
  color: #f0d8ba;
  font-size: 1rem;
  line-height: 1.45;
}

.about-modal__image {
  display: block;
  width: min(100%, 780px);
  height: auto;
  margin: 16px auto 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 195, 138, 0.45);
  box-shadow: 0 14px 26px rgba(10, 6, 4, 0.45);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table th,
.results-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.results-table td:last-child,
.results-table th:last-child {
  text-align: right;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(140%);
  background: rgba(10, 18, 33, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 14px;
  transition: transform 180ms ease;
  z-index: 30;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 990px) {
  #race-stage {
    width: min(98vw, calc(82dvh * 1.5806)) !important;
    max-height: 82dvh;
    min-width: 0;
    min-height: 0;
  }

  .hud-overlay-layer {
    inset: 6px;
  }

  .hud-cluster {
    gap: 6px;
    width: min(176px, 27vw);
  }

  .hud-cluster--tl {
    width: min(140px, 22vw);
  }

  .hud-cluster--bl {
    width: min(140px, 22vw);
  }

  .hud-cluster--br {
    width: min(172px, 27vw);
  }

  .hud-box {
    padding: 7px 8px;
  }

  .hud-box span {
    font-size: 0.62rem;
  }

  .hud-box strong {
    font-size: 0.84rem;
  }

  .hud-cluster--tl .hud-box {
    padding: 5px 6px;
  }

  .hud-cluster--tl .hud-box span {
    font-size: 0.53rem;
  }

  .hud-cluster--tl .hud-box strong {
    font-size: 0.72rem;
  }

  .standings ol {
    font-size: 0.73rem;
    max-height: min(24vh, 120px);
  }

  .controls p {
    font-size: 0.76rem;
  }

  .touch-controls {
    width: 156px;
    right: -30px;
    bottom: 4px;
  }

  .touch-joystick {
    width: 118px;
    height: 118px;
  }

  .touch-joystick__knob {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 680px) {
  .app {
    padding: 16px 10px 20px;
  }

  .btn-language {
    top: -4px;
    right: 2px;
    min-width: 56px;
    padding: 7px 10px;
    font-size: 0.76rem;
  }

  .actions {
    flex-wrap: wrap;
  }

  .online-room-actions {
    grid-template-columns: 1fr;
  }

  .hud-overlay-layer {
    inset: 5px;
  }

  .hud-cluster {
    width: min(150px, 34vw);
    gap: 4px;
  }

  .hud-cluster--tl {
    width: min(124px, 30vw);
  }

  .hud-cluster--br {
    left: auto;
    right: 0;
    width: min(154px, 36vw);
  }

  .standings ol {
    max-height: 88px;
  }

  .controls {
    padding: 8px 9px;
  }

  .controls p {
    font-size: 0.72rem;
  }

  .rules-modal {
    padding: 8px;
  }

  .rules-modal__panel {
    width: min(100%, 96vw);
    max-height: 92vh;
    padding: 12px 11px 12px;
  }

  .rules-items-grid {
    grid-template-columns: 1fr;
  }

  .rules-snakes-grid {
    grid-template-columns: 1fr;
  }

  .about-modal {
    padding: 8px;
  }

  .about-modal__panel {
    width: min(100%, 96vw);
    max-height: 92vh;
    padding: 12px 11px 12px;
  }

  .about-modal p {
    font-size: 0.92rem;
  }
}

@media (max-width: 990px) and (orientation: landscape) {
  body.race-screen-active #race-stage {
    width: min(74vw, calc(86dvh * 1.5806)) !important;
    max-height: 86dvh;
  }

  body.race-screen-active .hud-overlay-layer {
    inset: 6px;
  }

  body.race-screen-active .hud-cluster--tl,
  body.race-screen-active .hud-cluster--bl {
    left: clamp(-210px, -22vw, -130px);
  }

  body.race-screen-active .hud-cluster--tr,
  body.race-screen-active .hud-cluster--br {
    right: clamp(-210px, -22vw, -130px);
  }

  body.race-screen-active .touch-controls {
    right: clamp(-140px, -15vw, -70px);
    bottom: 8px;
  }
}
