﻿.board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.highway-arena {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  width: 100%;
}

.highway-arena__field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.highway-arena__field--opponent {
  display: none;
}

.highway-arena--multiplayer .highway-arena__field--opponent {
  display: flex;
}

.highway-arena:not(.highway-arena--multiplayer) > .highway-arena__field:not(.highway-arena__field--opponent) .highway-arena__label {
  display: none;
}

.highway-arena__label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.highway-arena__field--opponent .highway-arena__label {
  color: var(--orange);
}

.highway-arena--multiplayer .game-canvas {
  width: min(100%, 220px);
  max-height: min(70vh, 640px);
}

.mode-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-picker__btn {
  padding: 12px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.mode-picker__btn--active {
  border-color: rgba(184, 255, 46, 0.45);
  background: rgba(184, 255, 46, 0.08);
  color: var(--text);
}

.friend-picker {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.friend-picker__empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 8px;
}

.friend-picker__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.friend-picker__btn:hover {
  border-color: rgba(184, 255, 46, 0.35);
  background: rgba(184, 255, 46, 0.06);
}

.friend-picker__avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  font-weight: 800;
  overflow: hidden;
  flex-shrink: 0;
}

.friend-picker__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.setup__note {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.setup__message {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.setup__message--success {
  color: var(--green);
}

.game-canvas--opponent {
  border-color: rgba(255, 159, 26, 0.35);
  opacity: 0.95;
}

.game-canvas--crashed {
  filter: saturate(0.65);
}

@media (max-width: 720px) {
  .highway-arena--multiplayer {
    flex-direction: column;
    align-items: center;
  }

  .highway-arena--multiplayer .game-canvas {
    width: min(100%, 270px);
    max-height: min(42vh, 420px);
  }
}

.game-canvas {
  display: block;
  width: min(100%, 270px);
  max-height: min(82vh, 780px);
  height: auto;
  border-radius: var(--radius);
  background: #1a1f28;
  border: 2px solid rgba(184, 255, 46, 0.28);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  touch-action: none;
}

.board-status {
  min-height: 1.4em;
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}

.touch-controls {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.touch-controls__row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.touch-btn {
  min-height: 64px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn:active {
  background: rgba(184, 255, 46, 0.12);
  border-color: rgba(184, 255, 46, 0.35);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.modal__dialog {
  position: relative;
  width: min(420px, 100%);
  padding: 28px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  text-align: center;
}

.modal__title {
  margin: 0 0 8px;
  font-family: var(--font-display);
}

.modal__text {
  margin: 0 0 20px;
  color: var(--text-muted);
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
    max-width: 420px;
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  }

  .panel--left {
    order: 2;
  }

  .board-wrap {
    order: 1;
  }

  .panel--right {
    order: 3;
  }

  .touch-controls {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(7, 9, 13, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    gap: 10px;
  }

  .touch-controls__row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
  }

  .touch-btn {
    min-height: 56px;
  }

  .controls-list {
    display: none;
  }

  .game-canvas {
    width: auto;
    max-width: min(100vw - 40px, 270px);
    max-height: min(calc(100dvh - 220px), 520px);
  }
}

@media (max-width: 560px) {
  .header__stats {
    width: 100%;
    margin-left: 0;
  }

  .game-canvas {
    max-height: min(calc(100dvh - 200px), 460px);
  }
}

.highway-preview-surface {
  display: block;
  width: 100%;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.highway-preview-surface--asphalt { background: linear-gradient(180deg, #3d4550 0 20%, #2a3038 20% 80%, #3d4550 80%); }
.highway-preview-surface--night { background: linear-gradient(180deg, #2a3548 0 20%, #1a2230 20% 80%, #2a3548 80%); }
.highway-preview-surface--desert { background: linear-gradient(180deg, #6a5840 0 20%, #4a4030 20% 80%, #6a5840 80%); }
.highway-preview-surface--forest { background: linear-gradient(180deg, #3d5038 0 20%, #2a3828 20% 80%, #3d5038 80%); }
.highway-preview-surface--neon { background: linear-gradient(180deg, #2a2050 0 20%, #1a1830 20% 80%, #2a2050 80%); }

.highway-preview-marking {
  display: block;
  width: 100%;
  height: 36px;
  border-radius: 8px;
  background: #2a3038;
  position: relative;
  overflow: hidden;
}

.highway-preview-marking::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  bottom: 4px;
  width: 3px;
  transform: translateX(-50%);
  border-radius: 2px;
}

.highway-preview-marking--white::after { background: rgba(255, 255, 255, 0.7); }
.highway-preview-marking--yellow::after { background: rgba(255, 210, 60, 0.85); }
.highway-preview-marking--neon::after { background: rgba(184, 255, 46, 0.9); box-shadow: 0 0 8px rgba(184, 255, 46, 0.5); }

.highway-car-packs {
  display: grid;
  gap: 14px;
}

.highway-pack {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.highway-pack--locked {
  opacity: 0.72;
}

.highway-pack__head {
  margin-bottom: 8px;
}

.highway-pack__title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.highway-pack__desc {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.highway-pack__lock {
  margin: 0 0 8px;
  font-size: 0.76rem;
  color: var(--orange);
}

.highway-pack__cars {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.highway-car-btn {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.highway-car-btn:hover:not(:disabled) {
  border-color: rgba(184, 255, 46, 0.35);
}

.highway-car-btn--active {
  border-color: rgba(184, 255, 46, 0.55);
  background: rgba(184, 255, 46, 0.1);
  color: var(--green);
}

.highway-car-btn--locked,
.highway-car-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.highway-car-btn__name {
  display: block;
  line-height: 1.3;
}
