/* ==========================================================================
   СНЕЖНЫЙ ПАРК «БЕРЛОГА» — Аркадный 3D-симулятор сноуборда (/game)
   Адаптивный полноэкранный интерфейс для Desktop, Tablet и Mobile
   ========================================================================== */

:root {
  --g-accent: #f15a24;
  --g-accent-hover: #ff6e3a;
  --g-gold: #ffb800;
  --g-good: #22c55e;
  --g-bad: #ef4444;
  --g-surface: rgba(16, 18, 24, 0.72);
  --g-surface-light: rgba(255, 255, 255, 0.86);
  --g-border: rgba(255, 255, 255, 0.14);
  --g-ink: #f6f7f9;
  --g-muted: #adb3c2;
  --g-shadow: 0 14px 36px rgba(10, 14, 24, 0.34);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #89b9e6;
  color: var(--g-ink);
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.game-stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

/* ==================== TOP HUD BAR ==================== */
.g-topbar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.g-topbar-left,
.g-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.g-pill,
.g-icon-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  box-shadow: var(--g-shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--g-ink);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.g-back-pill {
  padding-left: 7px;
  transition: transform 0.16s ease, background-color 0.2s ease;
}

.g-back-pill:hover {
  background: rgba(26, 29, 38, 0.9);
  transform: translateY(-1px);
}

.g-back-chevron {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.g-emblem {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.g-brand-col {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.g-brand-name {
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 800;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

.g-brand-sub {
  font-size: 0.58rem;
  color: var(--g-accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.g-telemetry-pill {
  gap: 14px;
  padding: 6px 15px;
}

.g-metric {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.g-metric-val {
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 700;
  font-size: 0.98rem;
}

.g-metric-unit {
  font-size: 0.72rem;
  color: var(--g-muted);
  font-weight: 600;
}

.g-dist-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.g-dist-track {
  width: 68px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.g-dist-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--g-accent), var(--g-gold));
  transition: width 0.12s linear;
}

.g-score-pill {
  gap: 10px;
}

.g-score-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--g-muted);
}

.g-score-val {
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--g-gold);
}

.g-icon-btn {
  width: 42px;
  padding: 0;
  justify-content: center;
  border: 1px solid var(--g-border);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s ease;
}

.g-icon-btn:hover {
  background: rgba(34, 38, 50, 0.92);
}

.g-icon-btn:active {
  transform: scale(0.94);
}

.g-icon-btn svg {
  width: 18px;
  height: 18px;
}

.g-icon-btn svg[hidden] {
  display: none;
}

/* ==================== TRICK & COMBO FEED ==================== */
.g-trick-hud {
  position: fixed;
  top: max(70px, calc(env(safe-area-inset-top) + 58px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: min(92vw, 520px);
  text-align: center;
}

.g-stance-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(241, 90, 36, 0.9);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 4px 14px rgba(241, 90, 36, 0.45);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.g-stance-badge.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.g-combo-card {
  padding: 9px 18px;
  border-radius: 18px;
  background: rgba(14, 16, 22, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transform: scale(0.92) translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.g-combo-card.is-active {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.g-combo-card.is-clean {
  border-color: rgba(34, 197, 94, 0.6);
  background: rgba(12, 34, 22, 0.84);
}

.g-combo-card.is-bail {
  border-color: rgba(239, 68, 68, 0.65);
  background: rgba(44, 14, 16, 0.86);
}

.g-combo-tricks {
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 800;
  font-size: clamp(0.88rem, 2.2vw, 1.15rem);
  letter-spacing: 0.02em;
  color: #ffffff;
  text-transform: uppercase;
}

.g-combo-pts {
  margin-top: 2px;
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 800;
  font-size: clamp(0.84rem, 1.9vw, 1rem);
  color: var(--g-gold);
}

.g-combo-card.is-clean .g-combo-pts {
  color: #4ade80;
}

.g-combo-card.is-bail .g-combo-pts {
  color: #f87171;
}

.g-sector-toast {
  position: fixed;
  top: max(145px, calc(env(safe-area-inset-top) + 128px));
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  z-index: 16;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #16181f;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 92vw;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.g-sector-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==================== DESKTOP KEYBOARD STRIP ==================== */
.g-key-strip {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.74rem;
  color: var(--g-muted);
  white-space: nowrap;
  pointer-events: none;
}

.g-key-strip kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.72rem;
  margin-right: 4px;
}

/* ==================== MOBILE TOUCH HUD ==================== */
.g-touch-hud {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 19;
  pointer-events: none;
}

html.has-touch .g-touch-hud {
  display: block;
}

html.has-touch .g-key-strip {
  display: none;
}

.g-touch-left {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 48vw;
  height: 46vh;
  pointer-events: auto;
  touch-action: none;
}

.g-stick-base {
  position: absolute;
  left: max(22px, env(safe-area-inset-left));
  bottom: max(26px, env(safe-area-inset-bottom));
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(16, 18, 24, 0.34);
  border: 2px solid rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.g-stick-knob {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  transform: translate(0, 0);
}

.g-stick-arrows {
  position: absolute;
  inset: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.g-touch-right {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.g-grab-row {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.g-grab-btn {
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(16, 18, 24, 0.64);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  touch-action: none;
  cursor: pointer;
}

.g-grab-btn.is-down {
  background: var(--g-gold);
  color: #14151a;
  border-color: var(--g-gold);
  transform: scale(0.95);
}

.g-jump-btn {
  position: relative;
  pointer-events: auto;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.34);
  background: radial-gradient(circle at 35% 30%, rgba(255, 118, 62, 0.92), rgba(226, 70, 18, 0.88));
  box-shadow: 0 10px 28px rgba(241, 90, 36, 0.45);
  color: #ffffff;
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: pointer;
}

.g-jump-btn.is-charging {
  transform: scale(0.92);
  box-shadow: 0 4px 16px rgba(255, 184, 0, 0.65);
  border-color: var(--g-gold);
}

/* ==================== START / FINISH / HELP OVERLAYS ==================== */
.g-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(12, 16, 24, 0.48);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.g-modal.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.g-card {
  width: min(460px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  padding: 26px 24px 24px;
  border-radius: 26px;
  background: rgba(18, 20, 27, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  color: var(--g-ink);
  text-align: center;
}

.g-card-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(241, 90, 36, 0.18);
  color: var(--g-accent-hover);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.g-card-title {
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 800;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  line-height: 1.12;
}

.g-card-sub {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--g-muted);
  line-height: 1.45;
}

.g-controls-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  text-align: left;
}

.g-ctrl-item {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  line-height: 1.35;
}

.g-ctrl-item strong {
  display: block;
  color: #ffffff;
  font-weight: 700;
  margin-bottom: 2px;
}

.g-ctrl-item span {
  color: var(--g-muted);
}

.g-progress-wrap {
  margin-top: 18px;
}

.g-progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.g-progress-fill {
  width: 8%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--g-accent), var(--g-gold));
  transition: width 0.15s ease-out;
}

.g-progress-label {
  margin-top: 7px;
  font-size: 0.78rem;
  color: var(--g-muted);
  font-variant-numeric: tabular-nums;
}

.g-primary-btn {
  margin-top: 18px;
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--g-accent), #ff7638);
  color: #ffffff;
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(241, 90, 36, 0.42);
  transition: transform 0.16s ease, opacity 0.2s ease;
}

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

.g-primary-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.g-primary-btn:disabled {
  opacity: 0.45;
  cursor: wait;
}

.g-secondary-row {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.g-text-link {
  color: var(--g-muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}

.g-text-link:hover {
  color: #ffffff;
}

.g-stats-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.g-stat-box {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.g-stat-num {
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  color: #ffffff;
}

.g-stat-num--gold {
  color: var(--g-gold);
}

.g-stat-lbl {
  margin-top: 3px;
  font-size: 0.72rem;
  color: var(--g-muted);
}

@media (max-width: 720px) {
  .g-topbar {
    gap: 6px;
    flex-wrap: nowrap;
  }

  .g-topbar-left,
  .g-topbar-right {
    gap: 5px;
    flex-wrap: nowrap;
  }

  .g-telemetry-pill {
    display: none;
  }

  .g-brand-sub {
    display: none;
  }

  .g-pill,
  .g-icon-btn {
    min-height: 36px;
    padding: 4px 9px;
    font-size: 0.74rem;
    gap: 6px;
  }

  .g-back-pill {
    padding-left: 5px;
  }

  .g-back-chevron {
    width: 22px;
    height: 22px;
  }

  .g-emblem {
    width: 24px;
    height: 24px;
  }

  .g-brand-name {
    font-size: 0.78rem;
  }

  .g-score-label {
    display: none;
  }

  .g-icon-btn {
    width: 34px;
    padding: 0;
  }

  .g-icon-btn svg {
    width: 16px;
    height: 16px;
  }

  .g-key-strip {
    display: none;
  }

  .g-controls-grid {
    grid-template-columns: 1fr;
  }

  .g-sector-toast {
    top: max(62px, calc(env(safe-area-inset-top) + 50px));
    font-size: 0.66rem;
    padding: 4px 12px;
  }
}

@media (max-height: 460px) and (orientation: landscape) {
  .g-stick-base {
    width: 90px;
    height: 90px;
    bottom: 14px;
  }

  .g-jump-btn {
    width: 74px;
    height: 74px;
    font-size: 0.7rem;
  }

  .g-touch-right {
    bottom: 14px;
  }
}
