@import url('/engine/play.css');

/*
|--------------------------------------------------------------------------
| MavoraTech game mode
|--------------------------------------------------------------------------
| Requires FRAMEWORK_HEADER to output the optional $mavora_body_class value.
| This removes the visual site chrome only for game pages.
*/
body.mavora-game-mode {
  overflow: hidden;
}

body.mavora-game-mode .top-stack,
body.mavora-game-mode .scene {
  display: none;
}

body.mavora-game-mode main {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  padding: 0;
  margin: 0;
}

body.mavora-game-mode .dz-game-shell {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border-radius: 0;
}

/* Dead Zone Survival page styles.
   Scoped to .dz-game-shell so MavoraTech themes do not change game UI/canvas colors. */
.dz-game-shell {
  width: 100%;
  min-height: calc(100vh - var(--header-h, 112px) - var(--menu-h, 58px) - 96px);
  border-radius: 24px;
  overflow: hidden;
  position: relative;
}
.dz-game-shell *{ box-sizing: border-box; }.dz-game-shell{
  --bg: #090d12;
  --panel: rgba(18, 25, 34, 0.94);
  --panel-strong: #131c27;
  --text: #f4f7fb;
  --muted: #aeb9c8;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #47f3a4;
  --accent-dark: #1fbf76;
  --danger: #ff5b5b;
  --warning: #ffd166;
}.dz-game-shell{
  width: 100%;
  min-height: calc(100vh - var(--header-h, 112px) - var(--menu-h, 58px) - 96px);
  margin: 0;
  overflow: hidden;
  background: radial-gradient(circle at center, #182334 0%, var(--bg) 65%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}.dz-game-shell button, .dz-game-shell input{ font: inherit; }.dz-game-shell #app, .dz-game-shell .screen{
  width: 100%;
  height: 100%;
}.dz-game-shell .screen{
  display: none;
  place-items: center;
  padding: 18px;
}.dz-game-shell .screen.active{ display: grid; }.dz-game-shell .game-screen.active{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
}.dz-game-shell .panel{
  width: min(520px, 94vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
  backdrop-filter: blur(10px);
}.dz-game-shell .wide-panel{ width: min(800px, 94vw); }.dz-game-shell .leaderboard-panel{ width: min(1050px, 96vw); max-height: 86vh; overflow: hidden; }.dz-game-shell .menu-panel{ text-align: center; }.dz-game-shell .eyebrow{
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 800;
}.dz-game-shell .eyebrow.danger{ color: var(--danger); }.dz-game-shell h1, .dz-game-shell h2{
  margin: 0 0 14px;
  line-height: 1;
}.dz-game-shell h1{ font-size: clamp(2.6rem, 8vw, 5rem); }.dz-game-shell h2{ font-size: clamp(2rem, 5vw, 3.2rem); }.dz-game-shell .intro{
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 24px;
}.dz-game-shell .button-stack{
  display: grid;
  gap: 12px;
}.dz-game-shell .row-buttons{
  grid-template-columns: repeat(3, 1fr);
  margin-top: 16px;
}.dz-game-shell button{
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  cursor: pointer;
  color: var(--text);
  font-weight: 800;
  transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
}.dz-game-shell button:hover{ transform: translateY(-1px); filter: brightness(1.08); }.dz-game-shell button:active{ transform: translateY(1px); }.dz-game-shell .primary-btn{
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #04110b;
}.dz-game-shell .secondary-btn{
  background: rgba(255,255,255,0.09);
  border: 1px solid var(--line);
}.dz-game-shell .small-btn{ padding: 9px 13px; }.dz-game-shell .help-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}.dz-game-shell .help-grid div{
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 15px;
}.dz-game-shell .help-grid strong, .dz-game-shell .help-grid span{
  display: block;
}.dz-game-shell .help-grid span{
  color: var(--muted);
  margin-top: 5px;
}.dz-game-shell .panel-header{
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 14px;
}.dz-game-shell .table-wrap{
  overflow: auto;
  max-height: 62vh;
  border: 1px solid var(--line);
  border-radius: 16px;
}.dz-game-shell table{
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}.dz-game-shell th, .dz-game-shell td{
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}.dz-game-shell th{
  position: sticky;
  top: 0;
  background: var(--panel-strong);
  z-index: 1;
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}.dz-game-shell tr.high-score td{
  background: rgba(255, 209, 102, 0.16);
  color: #fff7d7;
}.dz-game-shell .empty-board{
  padding: 28px;
  color: var(--muted);
}.dz-game-shell #gameCanvas{
  display: block;
  width: min(1280px, calc(100vw - 28px));
  height: min(720px, calc(100vh - 138px));
  min-height: 360px;
  background: #10161e;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.42);
  cursor: crosshair;
}.dz-game-shell #hud{
  position: relative;
  z-index: 5;
  width: min(1280px, calc(100vw - 28px));
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}.dz-game-shell .hud-card{
  min-width: 112px;
  background: rgba(7, 10, 14, 0.72);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 15px;
  padding: 9px 11px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.22);
}.dz-game-shell .hud-card span{
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 3px;
}.dz-game-shell .hud-card strong{ font-size: 1.12rem; }.dz-game-shell .bar-shell{
  width: 160px;
  height: 10px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0;
}.dz-game-shell .health-bar{
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--danger), #ff9f43, var(--accent));
  border-radius: inherit;
}.dz-game-shell .death-panel label{
  display: block;
  color: var(--muted);
  margin: 16px 0 7px;
}.dz-game-shell .death-panel input{
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: rgba(0,0,0,0.22);
  color: var(--text);
  outline: none;
}.dz-game-shell .death-stats{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}.dz-game-shell .stat-box{
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px;
}.dz-game-shell .stat-box span{
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 4px;
}.dz-game-shell .save-message{
  color: var(--warning);
  min-height: 20px;
}@media (max-width: 720px){.dz-game-shell #hud{ flex-wrap: wrap; }.dz-game-shell .hud-card{ min-width: calc(50% - 5px); }.dz-game-shell .bar-shell{ width: 100%; }.dz-game-shell .hide-small{ display: none; }.dz-game-shell .row-buttons{ grid-template-columns: 1fr; }.dz-game-shell .help-grid, .dz-game-shell .death-stats{ grid-template-columns: 1fr; }
}.dz-game-shell .config-panel{
  width: min(1120px, 96vw);
  max-height: 90vh;
  overflow: auto;
}.dz-game-shell .config-note{
  color: var(--muted);
  margin-top: -4px;
  line-height: 1.45;
}.dz-game-shell .config-form{
  display: grid;
  gap: 16px;
  margin-top: 18px;
}.dz-game-shell .config-form fieldset{
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255,255,255,0.04);
}.dz-game-shell .config-form legend{
  color: var(--accent);
  font-weight: 800;
  padding: 0 8px;
}.dz-game-shell .config-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}.dz-game-shell .config-grid label span{
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
}.dz-game-shell .config-grid input{
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  background: rgba(0,0,0,0.22);
  color: var(--text);
  outline: none;
}.dz-game-shell .config-buttons{
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(18,25,34,0), var(--panel) 22%);
  padding-top: 14px;
}@media (max-width: 900px){.dz-game-shell .config-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}@media (max-width: 620px){.dz-game-shell .config-grid{ grid-template-columns: 1fr; }
}.dz-game-shell .config-grid small{
  display: block;
  color: #8fa0b5;
  font-size: 0.74rem;
  line-height: 1.3;
  margin-top: 5px;
}.dz-game-shell .level-popup{
  position: fixed;
  inset: 0;
  z-index: 8;
  display: none;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(71,243,164,0.12), rgba(0,0,0,0.26));
}.dz-game-shell .level-popup.show{
  display: grid;
  animation: levelPulse 0.5s ease;
}.dz-game-shell .level-popup strong{
  display: block;
  font-size: clamp(3rem, 10vw, 8rem);
  line-height: 0.9;
  color: #d8fff0;
  text-shadow: 0 0 28px rgba(71,243,164,0.75);
  text-align: center;
}.dz-game-shell .level-popup span{
  display: block;
  margin-top: 18px;
  color: #ffffff;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}@keyframes levelPulse{
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}.dz-game-shell .wide-hud{
  min-width: 240px;
  flex: 1 1 240px;
  max-width: 520px;
}.dz-game-shell .wide-hud strong{
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}.dz-game-shell .pause-overlay{
  position: fixed;
  inset: 0;
  z-index: 12;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(5px);
}.dz-game-shell .pause-overlay.show{
  display: grid;
}.dz-game-shell .pause-panel{
  width: min(440px, 92vw);
  text-align: center;
}.dz-game-shell .audio-notice{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(18px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  background: rgba(10, 15, 22, 0.92);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.9rem;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  transition: opacity 0.18s ease, transform 0.18s ease;
}.dz-game-shell .audio-notice.show{
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* Game mode viewport overrides */
body.mavora-game-mode .dz-game-shell #app,
body.mavora-game-mode .dz-game-shell .screen {
  height: 100vh;
}

body.mavora-game-mode .dz-game-shell .game-screen.active {
  gap: 8px;
  padding: 8px;
}

body.mavora-game-mode .dz-game-shell #hud {
  width: min(1280px, calc(100vw - 16px));
  gap: 8px;
}

body.mavora-game-mode .dz-game-shell .hud-card {
  padding: 7px 9px;
}

body.mavora-game-mode .dz-game-shell #gameCanvas {
  width: min(1280px, calc(100vw - 16px));
  height: min(720px, calc(100vh - 112px));
  min-height: 260px;
  border-radius: 14px;
}

.dz-game-shell .game-menu-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 14px;
  padding: 13px 18px;
  color: var(--text);
  font-weight: 800;
  transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
}

.dz-game-shell .game-menu-link:hover,
.dz-game-shell .game-menu-link:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.08);
  outline: none;
}

.dz-game-shell .game-menu-link:active {
  transform: translateY(1px);
}

@media (max-height: 760px) {
  body.mavora-game-mode .dz-game-shell #gameCanvas {
    height: min(720px, calc(100vh - 96px));
  }

  body.mavora-game-mode .dz-game-shell .hud-card span {
    font-size: 0.68rem;
    margin-bottom: 1px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card strong {
    font-size: 0.98rem;
  }
}


.dz-game-shell .your-high-score-wrap {
  margin-bottom: 14px;
}

.dz-game-shell .your-score-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.dz-game-shell .your-score-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.dz-game-shell .your-score-card-header span {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
}

.dz-game-shell .your-score-card-header strong {
  font-size: 1.1rem;
  color: var(--accent);
}

.dz-game-shell .your-score-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.dz-game-shell .your-score-grid div {
  padding: 9px;
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
}

.dz-game-shell .your-score-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 3px;
}

.dz-game-shell .muted-score-card {
  color: var(--muted);
}

.dz-game-shell .auto-save-message:empty {
  display: none;
}

.dz-game-shell .death-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 720px) {
  .dz-game-shell .your-score-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dz-game-shell .death-buttons {
    grid-template-columns: 1fr;
  }
}


.movement-panel {
  width: min(720px, 94vw);
}

.movement-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0 14px;
}

.movement-choice {
  min-height: 148px;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  line-height: 1.35;
}

.movement-choice strong {
  font-size: 1.15rem;
}

.movement-choice span {
  font-weight: 600;
  opacity: 0.88;
}

.movement-back-btn {
  width: 100%;
}

@media (max-width: 720px) {
  .movement-choice-grid {
    grid-template-columns: 1fr;
  }
}

/*
|--------------------------------------------------------------------------
| Responsive / mobile play layer
|--------------------------------------------------------------------------
| Desktop 1080p+ keeps the normal layout. These rules only take over on
| smaller windows and touch-first devices so the HUD, canvas and controls
| all fit inside the visible viewport.
*/
.dz-game-shell .touch-controls {
  display: none;
}

@media (max-width: 1079px), (max-height: 780px) {
  body.mavora-game-mode .dz-game-shell,
  body.mavora-game-mode .dz-game-shell #app,
  body.mavora-game-mode .dz-game-shell .screen {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
  }

  body.mavora-game-mode .dz-game-shell .screen {
    padding: 10px;
  }

  body.mavora-game-mode .dz-game-shell .game-screen.active {
    height: 100dvh;
    padding: 6px;
    gap: 6px;
    overflow: hidden;
  }

  body.mavora-game-mode .dz-game-shell #hud {
    flex: 0 0 auto;
    width: calc(100vw - 12px);
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card {
    min-width: 0;
    border-radius: 10px;
    padding: 5px 6px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card span {
    font-size: 0.58rem;
    letter-spacing: 0.045em;
    margin-bottom: 1px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card strong {
    font-size: 0.82rem;
    line-height: 1.05;
  }

  body.mavora-game-mode .dz-game-shell .bar-shell {
    width: 100%;
    height: 6px;
    margin: 2px 0;
  }

  body.mavora-game-mode .dz-game-shell .wide-hud {
    grid-column: 1 / -1;
    min-width: 0;
    max-width: none;
  }

  body.mavora-game-mode .dz-game-shell #gameCanvas {
    flex: 1 1 auto;
    width: calc(100vw - 12px);
    height: auto;
    min-height: 0;
    max-height: none;
    border-radius: 12px;
  }
}

@media (max-width: 720px), (pointer: coarse) and (max-width: 1079px) {
  body.mavora-game-mode .dz-game-shell {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }

  body.mavora-game-mode .dz-game-shell #hud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card {
    padding: 4px 5px;
  }

  body.mavora-game-mode .dz-game-shell .hide-small {
    display: none;
  }

  body.mavora-game-mode .dz-game-shell .wide-hud {
    grid-column: span 2;
  }

  body.mavora-game-mode .dz-game-shell .wide-hud strong {
    max-width: 100%;
  }

  body.mavora-game-mode .dz-game-shell .touch-controls {
    flex: 0 0 116px;
    width: calc(100vw - 12px);
    display: grid;
    grid-template-columns: 116px minmax(64px, 1fr) 116px;
    align-items: center;
    gap: 10px;
    padding: 0 4px 4px;
    touch-action: none;
  }

  body.mavora-game-mode .dz-game-shell .touch-pad {
    position: relative;
    width: 116px;
    height: 116px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.16);
    background:
      radial-gradient(circle at center, rgba(255,255,255,0.10), rgba(255,255,255,0.035) 58%, rgba(0,0,0,0.24));
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.12),
      0 12px 30px rgba(0,0,0,0.28);
    overflow: hidden;
    touch-action: none;
  }

  body.mavora-game-mode .dz-game-shell .touch-move-pad {
    justify-self: start;
  }

  body.mavora-game-mode .dz-game-shell .touch-aim-pad {
    justify-self: end;
    border-color: rgba(255, 209, 102, 0.28);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.12),
      0 0 24px rgba(255, 209, 102, 0.08),
      0 12px 30px rgba(0,0,0,0.28);
  }

  body.mavora-game-mode .dz-game-shell .touch-label {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    color: rgba(244,247,251,0.56);
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
    pointer-events: none;
  }

  body.mavora-game-mode .dz-game-shell .touch-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle at 34% 28%, #d8fff0, #47f3a4 44%, #128653 100%);
    border: 1px solid rgba(255,255,255,0.42);
    box-shadow:
      0 0 18px rgba(71,243,164,0.34),
      0 8px 18px rgba(0,0,0,0.32);
    pointer-events: none;
    transition: transform 0.045s linear;
  }

  body.mavora-game-mode .dz-game-shell .touch-aim-knob {
    background: radial-gradient(circle at 34% 28%, #fff3bc, #ffd166 48%, #b46e00 100%);
    box-shadow:
      0 0 20px rgba(255,209,102,0.36),
      0 8px 18px rgba(0,0,0,0.32);
  }

  body.mavora-game-mode .dz-game-shell .touch-pause-btn {
    justify-self: center;
    align-self: center;
    min-width: 74px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.08);
    color: var(--text);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  }
}

@media (max-width: 520px) {
  body.mavora-game-mode .dz-game-shell .screen {
    padding: 8px;
  }

  body.mavora-game-mode .dz-game-shell .panel {
    width: min(440px, calc(100vw - 16px));
    padding: 18px;
    border-radius: 20px;
  }

  body.mavora-game-mode .dz-game-shell h1 {
    font-size: clamp(2.2rem, 12vw, 3.6rem);
  }

  body.mavora-game-mode .dz-game-shell h2 {
    font-size: clamp(1.7rem, 8vw, 2.5rem);
  }

  body.mavora-game-mode .dz-game-shell .intro {
    margin-bottom: 18px;
  }

  body.mavora-game-mode .dz-game-shell #hud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.mavora-game-mode .dz-game-shell .hud-card span {
    font-size: 0.52rem;
  }

  body.mavora-game-mode .dz-game-shell .hud-card strong {
    font-size: 0.76rem;
  }

  body.mavora-game-mode .dz-game-shell .touch-controls {
    flex-basis: 104px;
    grid-template-columns: 104px minmax(54px, 1fr) 104px;
    gap: 6px;
  }

  body.mavora-game-mode .dz-game-shell .touch-pad {
    width: 104px;
    height: 104px;
  }

  body.mavora-game-mode .dz-game-shell .touch-knob {
    width: 40px;
    height: 40px;
  }

  body.mavora-game-mode .dz-game-shell .touch-pause-btn {
    min-width: 62px;
    min-height: 38px;
    font-size: 0.68rem;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  body.mavora-game-mode .dz-game-shell .game-screen.active {
    gap: 4px;
    padding: 4px;
  }

  body.mavora-game-mode .dz-game-shell #hud {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 3px;
  }

  body.mavora-game-mode .dz-game-shell .wide-hud {
    grid-column: span 2;
  }

  body.mavora-game-mode .dz-game-shell .hud-card {
    padding: 3px 4px;
    border-radius: 8px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card span {
    display: none;
  }

  body.mavora-game-mode .dz-game-shell .hud-card strong {
    font-size: 0.72rem;
  }

  body.mavora-game-mode .dz-game-shell .touch-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 4px;
    z-index: 9;
    pointer-events: none;
    grid-template-columns: 92px minmax(0, 1fr) 92px;
    width: 100vw;
    padding: 0 8px;
  }

  body.mavora-game-mode .dz-game-shell .touch-pad,
  body.mavora-game-mode .dz-game-shell .touch-pause-btn {
    pointer-events: auto;
  }

  body.mavora-game-mode .dz-game-shell .touch-pad {
    width: 92px;
    height: 92px;
    opacity: 0.82;
  }

  body.mavora-game-mode .dz-game-shell .touch-knob {
    width: 36px;
    height: 36px;
  }

  body.mavora-game-mode .dz-game-shell .touch-label {
    display: none;
  }
}

/*
|--------------------------------------------------------------------------
| Viewport fit patch
|--------------------------------------------------------------------------
| Uses the real visible browser viewport supplied by page.js (--dz-vh), so
| browser tabs/bookmarks/address bars do not push game content below screen.
*/
body.mavora-game-mode,
body.mavora-game-mode main,
body.mavora-game-mode .dz-game-shell,
body.mavora-game-mode .dz-game-shell #app,
body.mavora-game-mode .dz-game-shell .screen {
  height: var(--dz-vh, 100dvh);
  min-height: var(--dz-vh, 100dvh);
  max-height: var(--dz-vh, 100dvh);
}

body.mavora-game-mode .dz-game-shell .screen {
  overflow: hidden;
}

body.mavora-game-mode .dz-game-shell .game-screen.active {
  height: var(--dz-vh, 100dvh);
  min-height: 0;
}

body.mavora-game-mode .dz-game-shell #gameCanvas {
  flex: 1 1 auto;
  min-height: 220px;
  max-height: 720px;
}

@media (min-width: 1080px) {
  body.mavora-game-mode .dz-game-shell #hud {
    gap: 7px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card {
    min-width: 98px;
    padding: 7px 8px;
  }

  body.mavora-game-mode .dz-game-shell .wide-hud {
    min-width: 190px;
    flex-basis: 190px;
  }
}

body.mavora-game-mode .dz-game-shell .death-panel {
  max-height: calc(var(--dz-vh, 100dvh) - 20px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 720px), (pointer: coarse) and (max-width: 1079px) {
  body.mavora-game-mode .dz-game-shell .death-panel {
    width: min(440px, calc(100vw - 16px));
    max-height: calc(var(--dz-vh, 100dvh) - 12px);
    padding: 14px;
    border-radius: 18px;
  }

  body.mavora-game-mode .dz-game-shell .death-panel h2 {
    margin-bottom: 8px;
    font-size: clamp(1.45rem, 7vw, 2rem);
  }

  body.mavora-game-mode .dz-game-shell .death-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 10px;
  }

  body.mavora-game-mode .dz-game-shell .death-stats .stat-box {
    padding: 8px;
    border-radius: 12px;
  }

  body.mavora-game-mode .dz-game-shell .death-stats .stat-box span {
    font-size: 0.64rem;
    margin-bottom: 2px;
  }

  body.mavora-game-mode .dz-game-shell .death-stats .stat-box strong {
    font-size: 0.88rem;
    line-height: 1.15;
  }

  body.mavora-game-mode .dz-game-shell .save-message {
    min-height: 0;
    margin: 8px 0 0;
    font-size: 0.9rem;
  }

  body.mavora-game-mode .dz-game-shell .death-buttons {
    gap: 8px;
    margin-top: 10px;
  }

  body.mavora-game-mode .dz-game-shell .death-buttons button {
    min-height: 42px;
    padding: 10px 14px;
  }
}

@media (max-height: 620px) {
  body.mavora-game-mode .dz-game-shell .death-panel {
    max-height: calc(var(--dz-vh, 100dvh) - 8px);
    padding: 12px;
  }

  body.mavora-game-mode .dz-game-shell .death-stats {
    gap: 6px;
  }

  body.mavora-game-mode .dz-game-shell .death-stats .stat-box {
    padding: 7px;
  }
}

/* Desktop HUD fit fix
   Keep desktop/fine-pointer HUD on one row even when the browser viewport is
   slightly smaller than the physical display because of tabs/bookmarks/toolbars. */
@media (hover: hover) and (pointer: fine) {
  body.mavora-game-mode .dz-game-shell #hud {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch;
    justify-content: center;
    width: min(1280px, calc(100vw - 16px));
    gap: 6px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card {
    flex: 0 1 92px;
    min-width: 0 !important;
    padding: 6px 7px;
    border-radius: 10px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card:first-child {
    flex-basis: 158px;
  }

  body.mavora-game-mode .dz-game-shell .bar-shell {
    width: 100%;
    height: 7px;
    margin: 2px 0;
  }

  body.mavora-game-mode .dz-game-shell .hud-card span {
    font-size: 0.64rem;
    letter-spacing: 0.045em;
    margin-bottom: 1px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card strong {
    font-size: 0.92rem;
    line-height: 1.05;
  }

  body.mavora-game-mode .dz-game-shell .wide-hud {
    grid-column: auto !important;
    flex: 1 1 150px !important;
    min-width: 120px !important;
    max-width: 260px;
  }

  body.mavora-game-mode .dz-game-shell .wide-hud strong {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (hover: hover) and (pointer: fine) and (max-width: 980px) {
  body.mavora-game-mode .dz-game-shell #hud {
    gap: 4px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card {
    flex-basis: 76px;
    padding: 5px 6px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card:first-child {
    flex-basis: 138px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card span {
    font-size: 0.58rem;
  }

  body.mavora-game-mode .dz-game-shell .hud-card strong {
    font-size: 0.82rem;
  }

  body.mavora-game-mode .dz-game-shell .wide-hud {
    flex-basis: 110px !important;
    min-width: 92px !important;
  }
}


/*
|--------------------------------------------------------------------------
| Desktop browser chrome / taskbar fit patch
|--------------------------------------------------------------------------
| A 1080p monitor does not provide a 1080px browser viewport once the
| Windows taskbar, browser tabs, bookmarks bar and scrollbars are visible.
| These rules only affect desktop/fine-pointer layouts and keep the game
| inside the actual visible viewport without changing the mobile layout.
*/
@media (hover: hover) and (pointer: fine) {
  body.mavora-game-mode main {
    height: var(--dz-vh, 100dvh) !important;
    min-height: 0 !important;
    max-height: var(--dz-vh, 100dvh) !important;
    overflow: hidden !important;
  }

  body.mavora-game-mode .dz-game-shell .game-screen.active {
    padding: 6px;
    gap: 6px;
  }

  body.mavora-game-mode .dz-game-shell #gameCanvas {
    min-height: 180px;
    height: min(720px, calc(var(--dz-vh, 100dvh) - 96px));
  }
}

@media (hover: hover) and (pointer: fine) and (max-height: 880px) {
  body.mavora-game-mode .dz-game-shell .game-screen.active {
    padding: 5px;
    gap: 5px;
  }

  body.mavora-game-mode .dz-game-shell #hud {
    gap: 4px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card {
    padding: 4px 6px;
    border-radius: 9px;
  }

  body.mavora-game-mode .dz-game-shell .hud-card span {
    font-size: 0.56rem;
    margin-bottom: 0;
  }

  body.mavora-game-mode .dz-game-shell .hud-card strong {
    font-size: 0.82rem;
  }

  body.mavora-game-mode .dz-game-shell .bar-shell {
    height: 5px;
    margin: 1px 0;
  }

  body.mavora-game-mode .dz-game-shell #gameCanvas {
    height: min(700px, calc(var(--dz-vh, 100dvh) - 78px));
  }
}

@media (hover: hover) and (pointer: fine) and (max-height: 760px) {
  body.mavora-game-mode .dz-game-shell .hud-card span {
    display: none;
  }

  body.mavora-game-mode .dz-game-shell .hud-card {
    padding: 4px 6px;
  }

  body.mavora-game-mode .dz-game-shell #gameCanvas {
    height: min(660px, calc(var(--dz-vh, 100dvh) - 48px));
  }
}


/*
|--------------------------------------------------------------------------
| Final desktop/mobile viewport containment
|--------------------------------------------------------------------------
| This replaces height guessing with a real grid layout. The active game
| screen is exactly the visible browser viewport: HUD on top, controls on
| bottom when present, and the canvas gets only the remaining middle row.
| This prevents the bottom edge from being clipped by Windows taskbar,
| browser tabs/bookmarks, or any other browser chrome because those are
| already removed from the actual viewport height.
*/
body.mavora-game-mode,
body.mavora-game-mode main,
body.mavora-game-mode .dz-game-shell,
body.mavora-game-mode .dz-game-shell #app {
  width: 100vw !important;
  height: var(--dz-vh, 100dvh) !important;
  min-height: 0 !important;
  max-height: var(--dz-vh, 100dvh) !important;
  overflow: hidden !important;
}

body.mavora-game-mode .dz-game-shell .screen {
  width: 100% !important;
  height: var(--dz-vh, 100dvh) !important;
  min-height: 0 !important;
  max-height: var(--dz-vh, 100dvh) !important;
  overflow: hidden !important;
}

body.mavora-game-mode .dz-game-shell .game-screen.active {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: stretch;
  justify-items: center;
  width: 100% !important;
  height: var(--dz-vh, 100dvh) !important;
  min-height: 0 !important;
  max-height: var(--dz-vh, 100dvh) !important;
  padding: 6px 8px 10px !important;
  gap: 6px !important;
  overflow: hidden !important;
}

body.mavora-game-mode .dz-game-shell #hud {
  grid-row: 1;
  width: min(1280px, calc(100vw - 16px)) !important;
  max-width: calc(100vw - 16px) !important;
}

body.mavora-game-mode .dz-game-shell #gameCanvas {
  grid-row: 2;
  align-self: stretch;
  justify-self: center;
  width: min(1280px, calc(100vw - 16px)) !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: 720px !important;
  max-width: calc(100vw - 16px) !important;
}

body.mavora-game-mode .dz-game-shell .touch-controls {
  grid-row: 3;
}

@media (hover: hover) and (pointer: fine) {
  body.mavora-game-mode .dz-game-shell .game-screen.active {
    padding-bottom: 12px !important;
  }
}

@media (hover: hover) and (pointer: fine) and (max-height: 820px) {
  body.mavora-game-mode .dz-game-shell .game-screen.active {
    padding: 4px 8px 12px !important;
    gap: 4px !important;
  }
}

@media (max-width: 720px), (pointer: coarse) and (max-width: 1079px) {
  body.mavora-game-mode .dz-game-shell .game-screen.active {
    padding: 5px 8px max(8px, env(safe-area-inset-bottom)) !important;
    gap: 5px !important;
  }

  body.mavora-game-mode .dz-game-shell #gameCanvas {
    width: calc(100vw - 16px) !important;
    max-height: none !important;
  }
}

/* Final horizontal centering fix
   Keep the viewport-fit grid, but make the playable column explicitly centered.
   This prevents the HUD/canvas from sitting to the left on wide browser windows. */
body.mavora-game-mode .dz-game-shell .game-screen.active {
  grid-template-columns: minmax(0, min(1280px, calc(100vw - 16px))) !important;
  justify-content: center !important;
  justify-items: stretch !important;
}

body.mavora-game-mode .dz-game-shell #hud,
body.mavora-game-mode .dz-game-shell #gameCanvas,
body.mavora-game-mode .dz-game-shell .touch-controls {
  grid-column: 1 !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

body.mavora-game-mode .dz-game-shell #hud,
body.mavora-game-mode .dz-game-shell #gameCanvas {
  width: 100% !important;
  max-width: 1280px !important;
}

@media (max-width: 720px), (pointer: coarse) and (max-width: 1079px) {
  body.mavora-game-mode .dz-game-shell .game-screen.active {
    grid-template-columns: minmax(0, calc(100vw - 16px)) !important;
  }

  body.mavora-game-mode .dz-game-shell #hud,
  body.mavora-game-mode .dz-game-shell #gameCanvas {
    width: 100% !important;
    max-width: none !important;
  }
}


/* Final polish: responsive help screen */
.dz-game-shell .help-panel {
  width: min(860px, 94vw);
  max-height: calc(var(--dz-vh, 100dvh) - 28px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.dz-game-shell .help-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.dz-game-shell .help-header h2 {
  margin-bottom: 0;
}

.dz-game-shell .help-controls-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  margin: 14px 0 0;
}

.dz-game-shell .help-actions {
  display: none;
  margin-top: 14px;
}

@media (max-width: 720px), (pointer: coarse) and (max-width: 1079px) {
  .dz-game-shell .help-panel {
    width: min(520px, calc(100vw - 16px));
    max-height: calc(var(--dz-vh, 100dvh) - 12px);
    padding: 16px;
    border-radius: 18px;
  }

  .dz-game-shell .help-header {
    gap: 10px;
    margin-bottom: 10px;
  }

  .dz-game-shell .help-header h2 {
    font-size: clamp(1.55rem, 7vw, 2rem);
  }

  .dz-game-shell .help-controls-grid {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .dz-game-shell .help-controls-grid div {
    padding: 11px;
    border-radius: 14px;
  }

  .dz-game-shell .help-controls-grid strong {
    font-size: 0.96rem;
  }

  .dz-game-shell .help-controls-grid span {
    font-size: 0.88rem;
    line-height: 1.4;
  }

  .dz-game-shell .help-back-top {
    display: none;
  }

  .dz-game-shell .help-actions {
    display: grid;
  }

  .dz-game-shell .help-actions button {
    width: 100%;
  }
}

@media (max-height: 620px) {
  .dz-game-shell .help-panel {
    padding: 12px;
  }

  .dz-game-shell .help-controls-grid {
    gap: 7px;
  }

  .dz-game-shell .help-controls-grid div {
    padding: 9px;
  }
}
