/* Neon Kabaddi Arena — edge-device, accessibility and safe-area polish (2026-09-10). */

html,
body,
#stage {
  min-width: 0;
  min-height: 0;
}

#stage {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
}

#frame {
  max-width: 100%;
  max-height: 100%;
}

.screen,
.tutorial-overlay {
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  overflow: auto;
  overscroll-behavior: contain;
}

.screen > .panel,
.tutorial-overlay > .tut-panel {
  max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.hud-btn,
.power-btn,
.auth-link,
.fb-btn,
.nn-nudge-later,
.nn-nudge-signup,
.btn {
  min-height: 44px;
}

.hud-btn,
.power-btn {
  min-width: 44px;
}

button,
a,
[role="button"] {
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid #fff5dc;
  outline-offset: 3px;
}

@media (max-width: 560px) {
  #screen-start .auth-row {
    display: flex;
    margin-top: 8px;
    gap: 4px;
    min-height: 44px;
    justify-content: center;
  }

  #screen-start .controls-hint {
    display: block;
    margin-top: 5px;
    line-height: 1.35;
  }

  #screen-start .controls-hint > span:first-child {
    display: none;
  }

  #screen-start .touch-only {
    display: block;
  }

  #screen-start .panel {
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .hud {
    padding-left: max(7px, env(safe-area-inset-left, 0px));
    padding-right: max(7px, env(safe-area-inset-right, 0px));
  }

  .hud-row,
  .hud-group {
    min-width: 0;
  }

  .hud-value {
    font-size: 17px !important;
  }

  .combo-chip {
    min-width: 0;
    max-width: 34%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 380px) {
  #screen-start .logo {
    font-size: clamp(2.25rem, 12vw, 3.5rem);
  }

  #screen-start .subtitle {
    font-size: 12px;
  }

  .hud {
    padding-inline: 5px;
  }

  .hud-group,
  .hud-row {
    gap: 3px;
  }

  .hud-btn {
    width: 44px;
    height: 44px;
  }

  .hud-label {
    letter-spacing: .08em !important;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  body {
    align-items: stretch;
  }

  #stage {
    align-items: center;
  }

  #frame {
    height: 100%;
    width: auto;
  }

  #screen-start .panel {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, .75fr);
    grid-template-rows: auto auto auto auto;
    gap: 6px 18px;
    align-content: center;
    padding: 12px 18px;
    max-height: 100%;
    overflow-y: auto;
  }

  #screen-start::before,
  #screen-start::after {
    display: none;
  }

  #screen-start .tag,
  #screen-start .logo,
  #screen-start .subtitle {
    grid-column: 1;
  }

  #screen-start .logo {
    font-size: clamp(2.1rem, 8vh, 3.25rem);
    margin: 2px 0;
  }

  #screen-start .subtitle {
    margin: 0;
    font-size: 11px;
  }

  #screen-start .btn,
  #screen-start .best-line {
    grid-column: 2;
    width: 100%;
    justify-self: stretch;
    margin: 0;
  }

  #screen-start .auth-row,
  #screen-start .controls-hint {
    grid-column: 1 / -1;
    margin: 0;
  }

  .screen > .panel,
  .tutorial-overlay > .tut-panel {
    max-height: calc(100dvh - 12px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .hud {
    padding-top: 4px;
  }

  .hud-bottom {
    margin-top: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
