/* ── Reset для игровой страницы ── */
body { overflow: hidden !important; touch-action: none; }
/* Скрываем навбар — освобождаем 56px для игры */
main { padding-top: 0 !important; min-height: 100dvh; display: flex; flex-direction: column; }

/* ── HUD (верхняя полоска) ── */
#hud {
  height: 52px; flex-shrink: 0;
  display: flex; align-items: center; gap: 8px; padding: 0 14px;
  background: linear-gradient(90deg, rgba(240,253,244,.98), rgba(220,252,231,.98));
  border-bottom: 2px solid rgba(22,163,74,.2); z-index: 20;
  box-shadow: 0 2px 14px rgba(22,163,74,.1);
}
#hud .logo {
  font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 800; letter-spacing: 3px;
  background: linear-gradient(90deg,#15803d,#22c55e);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-right: 4px; white-space: nowrap; text-decoration: none;
}
.hbal {
  display: flex; flex-direction: column; align-items: center;
  background: #fff; border: 1.5px solid rgba(22,163,74,.3); border-radius: 9px;
  padding: 3px 12px; min-width: 90px; box-shadow: 0 1px 6px rgba(22,163,74,.1);
}
.hbal-v {
  font-family: 'Syne', monospace; font-size: 15px; font-weight: 800;
  color: #15803d; line-height: 1.2;
}
.hbal-l { font-size: 8px; color: rgba(22,163,74,.6); letter-spacing: 1.5px; margin-top: 1px; }
.mbadge { padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
.mbadge-demo { background: #e0f2fe; color: #0284c7; border: 1px solid #bae6fd; }
.mbadge-real { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.hspacer { flex: 1; }
.hcab {
  font-size: 11px; padding: 5px 12px; border-radius: 8px;
  border: 1.5px solid rgba(22,163,74,.28); color: #16a34a; background: #fff;
  text-decoration: none; transition: .2s; white-space: nowrap;
}
.hcab:hover { border-color: #15803d; background: #f0fdf4; }

/* ── Игровой канвас ── */
#game { flex: 1; position: relative; overflow: hidden; }
#cv   { display: block; width: 100%; height: 100%; }

/* ── Оверлей старта/ошибок ── */
#ov {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; pointer-events: none; z-index: 10;
  padding-bottom: 32%;
}
#ovBig {
  font-family: 'Syne', sans-serif; font-weight: 800;
  font-size: clamp(16px, 3.5vw, 38px); letter-spacing: 3px; text-align: center;
  text-shadow: 0 2px 20px rgba(255,255,255,.9); color: #14532d;
}
#ovSub {
  margin-top: 10px; font-size: 12px; color: rgba(0,0,0,.5); letter-spacing: 2px;
  text-align: center; background: rgba(255,255,255,.7); padding: 5px 14px;
  border-radius: 20px; backdrop-filter: blur(4px);
}

/* ── Множитель (правый верхний угол внутри #game) ── */
#multH {
  position: absolute; top: 10px; right: 14px; text-align: right;
  pointer-events: none; z-index: 5;
}
#multV {
  font-family: 'Syne', monospace; font-weight: 800;
  font-size: clamp(22px, 4.5vw, 52px); line-height: 1;
  color: #14532d; text-shadow: 0 2px 12px rgba(255,255,255,.8);
  transition: color .2s;
}
#multH.green  #multV { color: #16a34a; }
#multH.amber  #multV { color: #d97706; }
#multH.red    #multV { color: #dc2626; }
#multL {
  font-size: 8px; color: rgba(0,0,0,.32); letter-spacing: 3px; margin-top: 2px;
  font-family: 'Syne', monospace;
}

/* ── Скорость (левый верхний угол внутри #game) ── */
#spdH {
  position: absolute; top: 10px; left: 14px;
  pointer-events: none; z-index: 5;
}
#spdL {
  font-family: 'Syne', monospace; font-size: 10px; color: #16a34a;
  letter-spacing: 2px; text-shadow: 0 1px 6px rgba(255,255,255,.8); font-weight: 700;
}

/* ── Стрелка к гнезду ── */
#nestArr {
  position: absolute; pointer-events: none;
  display: none; align-items: center; z-index: 5;
}
#nestArr .ak { font-size: 18px; animation: nestBob .65s ease-in-out infinite alternate; }
#nestArr .gl { width: 2px; height: 28px; background: linear-gradient(to bottom, transparent, rgba(22,163,74,.7)); }
.nest-edge-lbl {
  font-family: 'Syne', monospace; font-size: 12px; font-weight: 700;
  color: #fff; letter-spacing: 1px;
  background: rgba(21,128,61,0.82); border: 1.5px solid rgba(74,222,128,0.6);
  border-radius: 10px; padding: 4px 10px;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 12px rgba(22,163,74,.35);
  animation: nestPulse 1s ease-in-out infinite alternate;
}
.nest-edge-arr {
  font-size: 16px; color: #4ade80;
  animation: nestPulse 1s ease-in-out infinite alternate;
  margin: 0 4px;
}
@keyframes nestPulse { from { opacity: 0.7; } to { opacity: 1; } }
@keyframes nestBob { from { transform: translateY(0); } to { transform: translateY(-7px); } }

/* ── Авто-режим ── */
#autoInfo {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,.92); border: 1.5px solid rgba(22,163,74,.32);
  border-radius: 9px; padding: 5px 16px; font-size: 11px; color: #15803d;
  letter-spacing: 2px; font-family: 'Syne', monospace; display: none;
  pointer-events: none; font-weight: 700; box-shadow: 0 2px 10px rgba(22,163,74,.12);
  z-index: 5;
}

/* ── Модальное окно (поверх #game) ── */
#modal {
  position: fixed; inset: 0; background: rgba(0,50,15,.52);
  backdrop-filter: blur(6px); display: none;
  align-items: center; justify-content: center; z-index: 100;
}
#modal.open { display: flex; }
#mbox {
  background: linear-gradient(150deg, #f0fdf4, #fff);
  border: 2px solid rgba(22,163,74,.28); border-radius: 24px;
  padding: 32px 40px; text-align: center; min-width: 270px;
  box-shadow: 0 8px 60px rgba(22,163,74,.22), 0 2px 20px rgba(0,0,0,.09);
  animation: popIn .28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn { from { transform: scale(.82); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#mTitle { font-family: 'Syne', sans-serif; font-size: clamp(14px,2.8vw,22px); font-weight: 800; letter-spacing: 2px; margin-bottom: 12px; }
.mrow { display: flex; justify-content: space-between; gap: 24px; margin: 5px 0; font-size: 12px; color: rgba(0,0,0,.42); }
.mrow span:last-child { font-family: 'Syne', monospace; font-weight: 700; color: rgba(0,0,0,.72); }
#mBig { font-family: 'Syne', monospace; font-size: clamp(24px,5vw,48px); font-weight: 800; margin: 14px 0; }
.mbtns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

/* ── Нижняя панель ── */
#bot {
  height: 72px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: linear-gradient(90deg, rgba(240,253,244,.98), rgba(220,252,231,.98));
  border-top: 2px solid rgba(22,163,74,.18); z-index: 20; position: fixed; bottom: 0; left: 0; right: 0; width: 100%;
}
.bsec { display: flex; flex-direction: column; gap: 3px; }
.blbl { font-size: 8px; color: rgba(0,0,0,.38); letter-spacing: 2px; text-transform: uppercase; font-weight: 600; }
.bval { display: flex; gap: 4px; align-items: center; }
#betIn {
  background: #fff; border: 1.5px solid rgba(22,163,74,.32); border-radius: 9px;
  color: #15803d; font-family: 'Syne', monospace; font-size: 14px; font-weight: 800;
  width: 78px; padding: 5px 8px; text-align: center; outline: none; transition: .2s;
}
#betIn:focus { border-color: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.1); }
.adj {
  background: #fff; border: 1.5px solid rgba(22,163,74,.25); border-radius: 7px;
  color: #16a34a; font-size: 13px; font-weight: 700; padding: 4px 9px; cursor: pointer; transition: .2s;
}
.adj:hover { background: #dcfce7; }
.distv { font-family: 'Syne', monospace; font-size: 11px; color: #15803d; font-weight: 700; letter-spacing: 1px; }

/* Кнопки скорости */
#spdS { display: flex; gap: 4px; }
.spd {
  background: #fff; border: 1.5px solid rgba(22,163,74,.18); border-radius: 9px;
  color: rgba(0,0,0,.42); font-size: 10px; padding: 4px 8px; cursor: pointer;
  text-align: center; transition: .2s; white-space: nowrap; line-height: 1.3;
}
.spd.active { background: #dcfce7; border-color: #22c55e; color: #15803d; font-weight: 700; }
.spd:hover { background: #f0fdf4; border-color: rgba(22,163,74,.4); color: #16a34a; }

/* Кнопка ЗАПУСК */
#launchBtn {
  margin-left: auto; font-family: 'Syne', sans-serif; font-weight: 800;
  font-size: 13px; letter-spacing: 2px; border: none; border-radius: 12px;
  height: 50px; padding: 0 22px; cursor: pointer; transition: all .2s; white-space: nowrap;
  background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff;
  box-shadow: 0 4px 18px rgba(22,163,74,.38);
}
#launchBtn:hover:not(:disabled) { transform: scale(1.05); box-shadow: 0 6px 24px rgba(22,163,74,.5); }
#launchBtn:disabled { background: #d1d5db; color: #9ca3af; cursor: not-allowed; box-shadow: none; transform: none; }
#launchBtn.stop-mode { background: linear-gradient(135deg, #dc2626, #f87171); box-shadow: 0 4px 18px rgba(220,38,38,.32); }
#launchBtn.stop-mode:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(220,38,38,.45); }

/* ══════════════════════════════════════════════════════
   МОБИЛЬНАЯ АДАПТАЦИЯ ИГРЫ
   ════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* HUD */
  #hud { padding: 0 8px; gap: 5px; height: 40px; }
  #hud .logo { font-size: 12px; letter-spacing: 2px; margin-right: 2px; }
  .hbal { padding: 2px 8px; min-width: 70px; }
  .hbal-v { font-size: 13px; }
  .hbal-l { font-size: 7px; }
  .mbadge { font-size: 9px; padding: 2px 7px; }
  .hcab { font-size: 10px; padding: 4px 8px; }

  /* Нижняя панель — одна строка, всё влезает */
  #bot {
    height: auto;
    min-height: 60px;
    padding: 6px 8px;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
  }
  #betIn { width: 52px; font-size: 12px; }
  .blbl { font-size: 6px; letter-spacing: 1px; }
  .adj { font-size: 12px; padding: 2px 6px; }
  .bsec { gap: 2px; }



  /* Скорости — компактно */
  .spd { font-size: 8px; padding: 2px 4px; }

  /* Кнопка запуска — вся доступная ширина */
  #launchBtn {
    font-size: 10px;
    letter-spacing: 0.5px;
    padding: 0 10px;
    height: 38px !important;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Авто-режим */
  #autoInfo { font-size: 9px; padding: 4px 10px; bottom: 8px; }

  /* Модал */
  #mbox { padding: 22px 20px; min-width: 0; width: calc(100vw - 32px); }
  #mTitle { font-size: 16px; }
  #mBig { font-size: 32px; margin: 10px 0; }
  .mrow { font-size: 11px; gap: 12px; }
  .mbtns { gap: 8px; }
  .mbtns .btn { font-size: 12px; padding: 8px 14px; }

  /* Баннер гостя */
  #guestBanner { font-size: 11px; padding: 6px 12px; flex-direction: column; gap: 4px; text-align: center; }
}

@media (max-width: 380px) {
  /* Очень маленькие экраны — прячем скорость совсем */
  #spdS { display: none; }
  .hcab { display: none; }
  #bot { gap: 4px; }
}


/* ══════════════════════════════════════════════════════
   ПОВОРОТ ТЕЛЕФОНА — показываем оверлей в портрете
   ════════════════════════════════════════════════════ */
#rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #0a1a0f;
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
#rotate-overlay .rot-icon {
  font-size: 72px;
  animation: rotatePhone 2s ease-in-out infinite;
}
#rotate-overlay .rot-text {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: #4ade80;
  letter-spacing: 1px;
  text-align: center;
  padding: 0 20px;
}
#rotate-overlay .rot-sub {
  font-size: 14px;
  color: rgba(255,255,255,.4);
  text-align: center;
  padding: 0 20px;
}
@keyframes rotatePhone {
  0%   { transform: rotate(0deg) scale(1);    }
  30%  { transform: rotate(90deg) scale(1.1); }
  60%  { transform: rotate(90deg) scale(1.1); }
  100% { transform: rotate(0deg) scale(1);    }
}

/* Показываем оверлей только на мобильных в портретном режиме */
@media screen and (max-width: 768px) and (orientation: portrait) {
  #rotate-overlay {
    display: flex !important;
  }
}

/* ══════════════════════════════════════════════════════
   ЛАНДШАФТ НА ТЕЛЕФОНЕ — максимально компактно
   ════════════════════════════════════════════════════ */
@media screen and (max-height: 500px) and (orientation: landscape) {
  /* Скрываем баннер демо — экономим место */
  #demoBanner { display: none !important; }

  /* HUD — минимальная высота */
  #hud { height: 32px !important; min-height: 32px; padding: 0 8px; gap: 4px; }
  #hud .logo { font-size: 10px; }
  .hbal { padding: 1px 6px; min-width: 60px; }
  .hbal-v { font-size: 11px; }
  .hbal-l { font-size: 6px; }
  .hcab { font-size: 9px; padding: 2px 6px; }
  .mbadge { display: none; }

  /* Bot — одна строка, минимум высоты */
  #bot {
    height: auto;
    min-height: 52px;
    padding: 4px 8px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .blbl { font-size: 6px; }
  #betIn { width: 48px; font-size: 11px; padding: 2px 4px; }
  .adj { font-size: 11px; padding: 1px 5px; }
  .spd { font-size: 8px; padding: 2px 3px; }
  #launchBtn { height: 32px !important; font-size: 10px; padding: 0 10px; }


}
/* Уменьшаем canvas в 2 раза на мобильных */
@media (max-width: 640px) {
  #game canvas {
    transform: scale(0.5);
    transform-origin: top left;
    width: 200% !important;
    height: 200% !important;
  }
}
