/* ==========================================================================
   Академия Грифонов — оболочка игры.
   Цвета взяты с сайта команды: тёмный фон #0d0e16, акцент #3b82f6.
   ========================================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #05060c;
  color: #e9e9ed;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(233, 233, 237, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(233, 233, 237, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px;
  padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
}

/* ------------------------------------------------------------------ ЭКРАН */

#stage {
  position: relative;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px #3b82f6, 0 0 30px rgba(59, 130, 246, 0.25);
  background: #05060c;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0d0e16;
}

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: #93c5fd;
  background: #05060c;
}

/* --------------------------------------------------------------- ОВЕРЛЕИ */

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(5, 6, 12, 0.72);
}

.overlay.is-on { display: flex; }

.overlay--bottom {
  align-items: flex-end;
  background: none;
  padding-bottom: 8px;
  pointer-events: none;
}

.overlay--bottom .row { pointer-events: auto; }

.box {
  width: 100%;
  max-width: 300px;
  background: #0b0e17;
  border: 2px solid #3b82f6;
  padding: 14px;
  text-align: center;
}

.box label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: #93c5fd;
  margin-bottom: 8px;
  text-transform: uppercase;
}

#nameInput {
  width: 100%;
  background: #05060c;
  border: 2px solid rgba(233, 233, 237, 0.25);
  color: #e9e9ed;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  padding: 10px 8px;
  outline: none;
}

#nameInput:focus { border-color: #3b82f6; }
#nameInput::placeholder { color: #4b5162; letter-spacing: 0.08em; }

.box .hint {
  margin: 8px 0 0;
  font-size: 10px;
  line-height: 1.4;
  color: #75798c;
}

.btn,
#nameGo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 11px 14px;
  width: 100%;
  border: 2px solid #3b82f6;
  background: #3b82f6;
  color: #05060c;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}

.row {
  display: flex;
  gap: 6px;
  width: 100%;
  padding: 0 8px;
}

.row .btn { margin-top: 0; }

.btn:not(.btn--primary) {
  background: rgba(5, 6, 12, 0.9);
  color: #e9e9ed;
  border-color: rgba(233, 233, 237, 0.4);
}

.btn:active, #nameGo:active { transform: translateY(1px); }

/* -------------------------------------------------------- ЭКРАННЫЙ ПАД */

#pad {
  display: none;
  width: 100%;
  max-width: 520px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 0 8px;
  flex: 0 0 auto;
}

body.touch #pad[data-mode="walk"],
body.touch #pad[data-mode="dpad"],
body.touch #pad[data-mode="dialog"],
body.touch #pad[data-mode="tap"] { display: flex; }

/* Только кнопка действия: заставка, финальные карточки */
#pad[data-mode="tap"] { justify-content: flex-end; }
#pad[data-mode="tap"] .pad-dirs { display: none; }

.pad-dirs {
  position: relative;
  width: 132px;
  height: 92px;
  flex: 0 0 auto;
}

.pad-btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 2px solid #3b82f6;
  background: rgba(13, 14, 22, 0.92);
  color: #93c5fd;
  font-size: 15px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  touch-action: none;
}

.pad-btn.is-down {
  background: #3b82f6;
  color: #05060c;
}

.pad-left  { left: 0;    bottom: 0; width: 60px; height: 60px; }
.pad-right { left: 68px; bottom: 0; width: 60px; height: 60px; }
.pad-up    { left: 34px; bottom: 62px; }
.pad-down  { left: 34px; bottom: 0; display: none; }

.pad-a {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 0;
  font-size: 22px;
  font-weight: 800;
  color: #e9e9ed;
  flex: 0 0 auto;
}

/* Режимы пада */
#pad[data-mode="walk"] .pad-up,
#pad[data-mode="walk"] .pad-down { display: none; }

#pad[data-mode="dpad"] .pad-dirs { width: 132px; height: 132px; }
#pad[data-mode="dpad"] .pad-left  { left: 0;    bottom: 44px; width: 44px; height: 44px; }
#pad[data-mode="dpad"] .pad-right { left: 88px; bottom: 44px; width: 44px; height: 44px; }
#pad[data-mode="dpad"] .pad-up    { left: 44px; bottom: 88px; display: flex; }
#pad[data-mode="dpad"] .pad-down  { left: 44px; bottom: 0;    display: flex; }

#pad[data-mode="dialog"] .pad-dirs { width: 44px; height: 92px; }
#pad[data-mode="dialog"] .pad-left,
#pad[data-mode="dialog"] .pad-right { display: none; }
#pad[data-mode="dialog"] .pad-up   { left: 0; bottom: 48px; display: flex; }
#pad[data-mode="dialog"] .pad-down { left: 0; bottom: 0; display: flex; }

/* ------------------------------------------------------------- ЗВУК */

#mute {
  position: fixed;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 2px solid rgba(59, 130, 246, 0.7);
  background: rgba(5, 6, 12, 0.8);
  color: #93c5fd;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
}

/* ------------------------------------------------------- АДАПТИВНОСТЬ */

@media (max-width: 420px) {
  .pad-btn { font-size: 13px; }
}

/* В портрете места под экраном много — делаем кнопки крупнее */
@media (orientation: portrait) {
  .pad-dirs { width: 148px; height: 100px; }
  .pad-left  { width: 68px; height: 68px; }
  .pad-right { left: 76px; width: 68px; height: 68px; }
  .pad-up    { left: 38px; bottom: 70px; }
  .pad-a { width: 88px; height: 88px; font-size: 26px; }
}

/* Ландшафт на телефоне: пад уезжает по краям поверх экрана */
@media (orientation: landscape) and (max-height: 480px) {
  #app { padding-bottom: 4px; }
  #pad {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 6px;
    max-width: none;
    background: none;
    pointer-events: none;
    z-index: 4;
  }
  #pad > * { pointer-events: auto; }
  .pad-btn { opacity: 0.9; }
}

/* ------------------------------------------------------- ШАПКА И ПОДПИСЬ */

#brand,
#foot {
  flex: 0 0 auto;
  text-align: center;
  line-height: 1.4;
}

#brand strong {
  display: block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #e9e9ed;
}

#brand span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #75798c;
}

#foot {
  font-size: 10px;
  color: #75798c;
}

#foot a {
  color: #93c5fd;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.1em;
}

#foot span {
  display: block;
  margin-top: 2px;
}

@media (orientation: landscape) and (max-height: 480px) {
  #brand, #foot { display: none; }
}

/* --------------------------------------------- ПОДСКАЗКА ПРО ОРИЕНТАЦИЮ */

#rotate {
  display: none;
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: #3b82f6;
  text-align: center;
}

body.touch #rotate { display: block; }

@media (orientation: landscape) {
  body.touch #rotate { display: none; }
}
