html,
body,
#root,
#game-container,
#madd-nutz-game {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
}

body {
  overscroll-behavior: none;
}

.mn-stage,
.mn-stage canvas {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

@media (orientation: landscape) and (max-width: 1024px) and (max-height: 500px) {
  html,
  body,
  #root {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    background: #000;
  }

  .mn-shell,
  .mn-game-panel,
  .mn-layout,
  .mn-main {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #000;
  }

  .mn-game-panel,
  .mn-layout,
  .mn-main {
    position: relative;
    display: block;
  }

  .mn-stage-wrap {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    background: #101218;
  }

  .mn-stage {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: block;
  }

  .mn-stage canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
  }

  .mn-topbar {
    position: absolute;
    z-index: 3;
    top: max(6px, env(safe-area-inset-top));
    left: max(6px, env(safe-area-inset-left));
    right: max(6px, env(safe-area-inset-right));
    min-height: 36px;
    max-height: 42px;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(16, 11, 8, 0.76);
    backdrop-filter: blur(6px);
  }

  .mn-topbar h2 {
    font-size: 1.08rem;
  }

  .mn-topbar-stats span {
    padding: 3px 7px;
    font-size: 0.68rem;
  }

  .mn-hero-rail {
    position: absolute;
    z-index: 4;
    top: calc(max(6px, env(safe-area-inset-top)) + 44px);
    left: max(6px, env(safe-area-inset-left));
    right: max(6px, env(safe-area-inset-right));
    bottom: auto;
    width: auto;
    min-height: 44px;
    max-height: 50px;
    gap: 5px;
    padding: 5px;
    border-radius: 8px;
    display: flex;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    background: rgba(17, 12, 9, 0.78);
    backdrop-filter: blur(6px);
  }

  .mn-hero-rail::-webkit-scrollbar {
    display: none;
  }

  .mn-hero-rail h3 {
    display: none;
  }

  .mn-hero-chip {
    flex: 0 0 auto;
    grid-template-columns: 24px auto;
    width: 82px;
    min-height: 34px;
    max-height: 38px;
    padding: 3px 5px;
    border-radius: 8px;
    transform: none;
  }

  .mn-hero-chip img {
    width: 23px;
    height: 23px;
  }

  .mn-hero-chip strong {
    font-size: 0.64rem;
  }

  .mn-hero-chip span {
    display: none;
  }

  .mn-hero-chip.is-active,
  .mn-hero-chip:hover {
    transform: none;
  }

  .mn-hud-dock {
    position: absolute;
    z-index: 4;
    left: max(6px, env(safe-area-inset-left));
    right: max(6px, env(safe-area-inset-right));
    bottom: max(6px, env(safe-area-inset-bottom));
    width: auto;
    max-height: 72px;
    display: grid;
    grid-template-columns: minmax(132px, 0.7fr) minmax(160px, 1fr) minmax(104px, 0.42fr);
    align-items: stretch;
    gap: 4px;
    padding: 6px;
    border-radius: 8px;
    background: rgba(17, 12, 9, 0.78);
    backdrop-filter: blur(6px);
  }

  .mn-hud-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    min-width: 0;
  }

  .mn-pill {
    min-height: 0;
    padding: 3px 4px;
  }

  .mn-pill strong {
    font-size: 0.72rem;
  }

  .mn-label {
    font-size: 0.48rem;
  }

  .mn-hint {
    min-height: 0;
    padding: 4px 5px;
    min-width: 0;
  }

  .mn-hint strong {
    white-space: normal;
    text-overflow: clip;
    font-size: 0.68rem;
    line-height: 1.05;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    display: -webkit-box;
    overflow: hidden;
  }

  .mn-controls {
    gap: 4px;
    min-width: 0;
  }

  .mn-action {
    min-height: 0;
    padding: 4px 5px;
    font-size: 0.68rem;
    transform: none;
  }

  .mn-action:hover {
    transform: none;
  }

  @media (max-width: 720px) {
    .mn-topbar {
      min-height: 32px;
      max-height: 36px;
    }

    .mn-topbar h2 {
      font-size: 0.94rem;
    }

    .mn-topbar-stats span {
      padding: 2px 5px;
      font-size: 0.58rem;
    }

    .mn-hero-rail {
      top: calc(max(6px, env(safe-area-inset-top)) + 38px);
      min-height: 38px;
      max-height: 42px;
      padding: 4px;
    }

    .mn-hero-chip {
      width: 70px;
      min-height: 30px;
      max-height: 34px;
      grid-template-columns: 21px auto;
      padding: 3px 4px;
    }

    .mn-hero-chip img {
      width: 21px;
      height: 21px;
    }

    .mn-hero-chip strong {
      font-size: 0.58rem;
    }

    .mn-hud-dock {
      max-height: 64px;
      grid-template-columns: minmax(120px, 0.66fr) minmax(140px, 1fr) minmax(90px, 0.42fr);
      gap: 3px;
      padding: 4px;
    }

    .mn-hud-grid {
      gap: 3px;
    }

    .mn-pill {
      padding: 2px 3px;
    }

    .mn-pill strong {
      font-size: 0.64rem;
    }

    .mn-label {
      font-size: 0.42rem;
    }

    .mn-hint strong {
      font-size: 0.6rem;
    }

    .mn-action {
      padding: 3px 4px;
      font-size: 0.58rem;
    }
  }
}
