/* Global Kenney asset pass (non-face visuals only) */
:root{
  --kenney-blue:url('assets/kenney/ui/buttonBlue.png');
  --kenney-green:url('assets/kenney/ui/buttonGreen.png');
  --kenney-red:url('assets/kenney/ui/buttonRed.png');
  --kenney-yellow:url('assets/kenney/ui/buttonYellow.png');
}

html, body {
  scrollbar-color: #7ec6ff #1b2946;
  scrollbar-width: thin;
}
::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
::-webkit-scrollbar-track {
  background: linear-gradient(180deg, #1b2946, #17223a);
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #83cdff, #5197d6);
  border-radius: 999px;
  border: 2px solid #1b2946;
}

#kenney-cloud-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.2;
}
#kenney-cloud-layer .cloud {
  position: absolute;
  width: clamp(120px, 17vw, 280px);
  will-change: transform;
  animation: kenneyCloudDrift linear infinite;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.22));
}
@keyframes kenneyCloudDrift {
  from { transform: translateX(-20vw); }
  to { transform: translateX(120vw); }
}

button,
.chip,
.touch-btn,
#menu button,
#end-controls button {
  border: 1px solid rgba(255,255,255,0.34) !important;
  background-image: var(--kenney-blue) !important;
  background-size: 100% 100% !important;
  background-repeat: no-repeat !important;
  background-color: rgba(15, 30, 58, 0.15) !important;
  color: #ecf7ff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  box-shadow: 0 4px 12px rgba(0,0,0,0.26);
}
button:hover,
.chip:hover,
.touch-btn:hover {
  filter: brightness(1.08);
}
button:active,
.chip:active,
.touch-btn:active {
  transform: translateY(1px) scale(0.985);
  filter: brightness(0.96);
}

/* Shared mobile touch-control utility classes (opt-in per page). */
.dmg-touch-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 26;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 10px 14px;
  pointer-events: none;
}
.dmg-touch-btn {
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.dmg-touch-dir {
  width: clamp(58px, 14vw, 92px);
  height: clamp(58px, 14vw, 92px);
  font-size: clamp(16px, 4vw, 24px);
}

/* Grid-based touch pads define their own cell sizing; avoid global oversized arrows. */
#touch-controls .touch-side .dmg-touch-dir,
#touch-controls #touch-left-pad .dmg-touch-dir,
#touch-controls .touch-move .dmg-touch-dir {
  width: 100% !important;
  height: 100% !important;
  font-size: inherit !important;
}

#toggle-sfx,
#toggle-music,
#toggle-performance,
#toggle-layout,
#toggle-hand {
  background-image: var(--kenney-green) !important;
}
#end-controls .chip-primary,
button.chip-primary,
#restart,
#back-to-menu {
  background-image: none !important;
  background-color: #f2cd63 !important;
  color: #1c2230 !important;
  border: 3px solid #f0cf72 !important;
  border-radius: 999px !important;
  box-shadow: 0 2px 0 rgba(84, 65, 24, 0.45), inset 0 1px 0 rgba(255, 244, 200, 0.8) !important;
}

#hud,
#role-panel,
#hint,
.panel,
#result,
#rotate-overlay .card,
#mobile-hint,
#instructions {
  border: 1px solid rgba(163, 214, 255, 0.34) !important;
  background: linear-gradient(180deg, rgba(12, 25, 49, 0.68), rgba(8, 18, 36, 0.72)) !important;
  box-shadow: 0 12px 30px rgba(0,0,0,0.34);
}

canvas {
  image-rendering: auto;
}

@media (max-width: 860px) {
  #kenney-cloud-layer {
    opacity: 0.14;
  }
  button,
  .chip,
  .touch-btn {
    font-size: max(11px, 2.8vw) !important;
  }
}

#dmg-global-controls {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 10010;
  display: flex;
  gap: 6px;
  align-items: center;
  pointer-events: auto;
}

/* Hide legacy cast.js top-right control bar when the unified Kenney control dock is active. */
#dmg-top-actions {
  display: none !important;
}

#dmg-global-controls .dmg-ctl-btn {
  border: 2px solid rgba(68, 52, 19, 0.82) !important;
  background-image: none !important;
  background-color: #f1cc61 !important;
  color: #1c2230 !important;
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 18px;
  line-height: 1;
  min-height: 45px;
  min-width: 45px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 4px 0 rgba(109, 82, 25, 0.44), inset 0 1px 0 rgba(255, 243, 194, 0.9);
}

#dmg-global-controls .dmg-ctl-btn[data-kind="menu"],
#dmg-global-controls .dmg-ctl-btn[data-kind="pause"],
#dmg-global-controls .dmg-ctl-btn[data-kind="fullscreen"] {
  background-image: none !important;
  background-color: #f2cd63 !important;
  color: #1c2230 !important;
}

#touch-controls.dmg-touch-swapped {
  flex-direction: row-reverse !important;
}

/* Unified landscape side-dock for pages that define native #touch-controls layouts. */
body.dmg-touch-landscape.dmg-has-native-touch-controls {
  --dmg-native-touch-scale: 1;
  --dmg-native-act-scale: 1;
  --dmg-native-fire-scale: 1;
}
body.dmg-touch-landscape.dmg-has-native-touch-controls #hud {
  left: 8px !important;
  top: 50% !important;
  transform: translateY(-50%);
  min-width: 0 !important;
  max-width: min(34vw, 168px) !important;
  width: min(34vw, 168px) !important;
  padding: 7px 8px !important;
  border-radius: 10px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 4px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  white-space: normal !important;
}
body.dmg-touch-landscape.dmg-has-native-touch-controls #hud .title {
  margin: 0 !important;
  font-size: 11px !important;
  line-height: 1.1 !important;
}
body.dmg-touch-landscape.dmg-has-native-touch-controls #hud .hud-row,
body.dmg-touch-landscape.dmg-has-native-touch-controls #hud #status-row {
  width: 100% !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 2px !important;
  font-size: 10px !important;
  line-height: 1.15 !important;
  flex-wrap: nowrap !important;
}
body.dmg-touch-landscape.dmg-has-native-touch-controls #hud span {
  display: block !important;
  white-space: nowrap !important;
}
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  z-index: 26 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-direction: row-reverse !important;
  padding: 10px max(8px, env(safe-area-inset-right)) 10px max(8px, env(safe-area-inset-left)) !important;
  pointer-events: none !important;
}
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls #touch-left,
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls #touch-right,
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls #touch-left-pad,
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .touch-side,
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .touch-move,
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .touch-act {
  pointer-events: auto !important;
}
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .touch-btn {
  font-size: calc(13px * var(--dmg-native-touch-scale)) !important;
  border-radius: 10px !important;
  opacity: 0.86 !important;
}
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .touch-dir,
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .dmg-touch-dir {
  width: clamp(calc(40px * var(--dmg-native-touch-scale)), calc(8vw * var(--dmg-native-touch-scale)), calc(54px * var(--dmg-native-touch-scale))) !important;
  height: clamp(calc(40px * var(--dmg-native-touch-scale)), calc(8vw * var(--dmg-native-touch-scale)), calc(54px * var(--dmg-native-touch-scale))) !important;
}
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .touch-act {
  width: clamp(calc(56px * var(--dmg-native-act-scale)), calc(12vw * var(--dmg-native-act-scale)), calc(84px * var(--dmg-native-act-scale))) !important;
  height: clamp(calc(42px * var(--dmg-native-act-scale)), calc(9vw * var(--dmg-native-act-scale)), calc(64px * var(--dmg-native-act-scale))) !important;
}
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .touch-fire,
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .shoot,
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .touch-jump-right {
  width: clamp(calc(66px * var(--dmg-native-fire-scale)), calc(14vw * var(--dmg-native-fire-scale)), calc(96px * var(--dmg-native-fire-scale))) !important;
  height: clamp(calc(66px * var(--dmg-native-fire-scale)), calc(14vw * var(--dmg-native-fire-scale)), calc(96px * var(--dmg-native-fire-scale))) !important;
  font-size: calc(14px * var(--dmg-native-fire-scale)) !important;
}
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .touch-jump-left,
body.dmg-touch-landscape.dmg-has-native-touch-controls #touch-controls .touch-crouch {
  font-size: calc(11px * var(--dmg-native-touch-scale)) !important;
}
body.dmg-touch-landscape.dmg-has-mobile-pad {
  --dmg-shared-pad-scale: 1;
  --dmg-shared-action-scale: 1;
}
body.dmg-touch-landscape.dmg-page-pacman.dmg-has-mobile-pad {
  --dmg-shared-pad-scale: 0.9;
  --dmg-shared-action-scale: 0.9;
}
body.dmg-touch-landscape.dmg-page-frogger.dmg-has-mobile-pad {
  --dmg-shared-pad-scale: 0.94;
  --dmg-shared-action-scale: 0.94;
}
body.dmg-touch-landscape.dmg-page-snake.dmg-has-mobile-pad {
  --dmg-shared-pad-scale: 0.92;
  --dmg-shared-action-scale: 0.92;
}
body.dmg-touch-landscape.dmg-page-breakout.dmg-has-mobile-pad {
  --dmg-shared-pad-scale: 0.88;
  --dmg-shared-action-scale: 0.88;
}
body.dmg-touch-landscape.dmg-page-pong.dmg-has-mobile-pad,
body.dmg-touch-landscape.dmg-page-donkeykong.dmg-has-mobile-pad {
  --dmg-shared-pad-scale: 0.9;
  --dmg-shared-action-scale: 0.9;
}
body.dmg-touch-landscape.dmg-page-adventureisland.dmg-has-native-touch-controls {
  --dmg-native-touch-scale: 0.86;
  --dmg-native-act-scale: 0.84;
  --dmg-native-fire-scale: 0.88;
}
body.dmg-touch-landscape.dmg-page-galaga.dmg-has-native-touch-controls {
  --dmg-native-touch-scale: 0.94;
  --dmg-native-act-scale: 0.9;
  --dmg-native-fire-scale: 0.95;
}
body.dmg-touch-landscape.dmg-page-gradius.dmg-has-native-touch-controls {
  --dmg-native-touch-scale: 0.9;
  --dmg-native-act-scale: 0.9;
  --dmg-native-fire-scale: 0.92;
}
body.dmg-touch-landscape.dmg-page-sidescroller.dmg-has-native-touch-controls {
  --dmg-native-touch-scale: 0.88;
  --dmg-native-act-scale: 0.86;
  --dmg-native-fire-scale: 0.88;
}
body.dmg-touch-landscape.dmg-page-kungfu.dmg-has-native-touch-controls {
  --dmg-native-touch-scale: 0.9;
  --dmg-native-act-scale: 0.9;
  --dmg-native-fire-scale: 0.92;
}
body.dmg-touch-landscape.dmg-page-tetris.dmg-has-native-touch-controls {
  --dmg-native-touch-scale: 0.84;
  --dmg-native-act-scale: 0.82;
  --dmg-native-fire-scale: 0.84;
}

/* Case-by-case landscape mobile layout overrides requested by design pass:
   - HUD: top-left, single line
   - Controls: bottom-right, translucent
*/
body.dmg-touch-landscape.dmg-page-gradius #hud,
body.dmg-touch-landscape.dmg-page-galaga #hud,
body.dmg-touch-landscape.dmg-page-sidescroller #hud,
body.dmg-touch-landscape.dmg-page-kungfu #hud,
body.dmg-touch-landscape.dmg-page-adventureisland #hud,
body.dmg-touch-landscape.dmg-page-donkeykong #hud,
body.dmg-touch-landscape.dmg-page-breakout #hud,
body.dmg-touch-landscape.dmg-page-racer #hud {
  top: 8px !important;
  left: 8px !important;
  right: auto !important;
  transform: none !important;
  min-width: 0 !important;
  width: auto !important;
  max-width: calc(100vw - 180px) !important;
  padding: 6px 8px !important;
  border-radius: 10px !important;
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 8px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  white-space: nowrap !important;
}
body.dmg-touch-landscape.dmg-page-gradius #hud .title,
body.dmg-touch-landscape.dmg-page-galaga #hud .title,
body.dmg-touch-landscape.dmg-page-sidescroller #hud .title,
body.dmg-touch-landscape.dmg-page-kungfu #hud .title,
body.dmg-touch-landscape.dmg-page-adventureisland #hud .title,
body.dmg-touch-landscape.dmg-page-donkeykong #hud .title,
body.dmg-touch-landscape.dmg-page-breakout #hud .title,
body.dmg-touch-landscape.dmg-page-racer #hud .title {
  display: none !important;
}
body.dmg-touch-landscape.dmg-page-gradius #hud .hud-row,
body.dmg-touch-landscape.dmg-page-galaga #hud .hud-row,
body.dmg-touch-landscape.dmg-page-sidescroller #hud .hud-row,
body.dmg-touch-landscape.dmg-page-kungfu #hud .hud-row,
body.dmg-touch-landscape.dmg-page-adventureisland #hud .hud-row,
body.dmg-touch-landscape.dmg-page-donkeykong #hud .hud-row,
body.dmg-touch-landscape.dmg-page-breakout #hud .hud-row,
body.dmg-touch-landscape.dmg-page-racer #hud .hud-row,
body.dmg-touch-landscape.dmg-page-gradius #hud #status-row,
body.dmg-touch-landscape.dmg-page-galaga #hud #status-row,
body.dmg-touch-landscape.dmg-page-sidescroller #hud #status-row,
body.dmg-touch-landscape.dmg-page-kungfu #hud #status-row,
body.dmg-touch-landscape.dmg-page-adventureisland #hud #status-row,
body.dmg-touch-landscape.dmg-page-donkeykong #hud #status-row,
body.dmg-touch-landscape.dmg-page-breakout #hud #status-row,
body.dmg-touch-landscape.dmg-page-racer #hud #status-row {
  width: auto !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  font-size: 11px !important;
}
body.dmg-touch-landscape.dmg-page-gradius #hud span,
body.dmg-touch-landscape.dmg-page-galaga #hud span,
body.dmg-touch-landscape.dmg-page-sidescroller #hud span,
body.dmg-touch-landscape.dmg-page-kungfu #hud span,
body.dmg-touch-landscape.dmg-page-adventureisland #hud span,
body.dmg-touch-landscape.dmg-page-donkeykong #hud span,
body.dmg-touch-landscape.dmg-page-breakout #hud span,
body.dmg-touch-landscape.dmg-page-racer #hud span {
  white-space: nowrap !important;
}

/* Native touch-control pages: dock controls bottom-right instead of side-center. */
body.dmg-touch-landscape.dmg-page-gradius.dmg-has-native-touch-controls #touch-controls,
body.dmg-touch-landscape.dmg-page-galaga.dmg-has-native-touch-controls #touch-controls,
body.dmg-touch-landscape.dmg-page-sidescroller.dmg-has-native-touch-controls #touch-controls,
body.dmg-touch-landscape.dmg-page-kungfu.dmg-has-native-touch-controls #touch-controls,
body.dmg-touch-landscape.dmg-page-adventureisland.dmg-has-native-touch-controls #touch-controls,
body.dmg-touch-landscape.dmg-page-racer.dmg-has-native-touch-controls #touch-controls {
  position: fixed !important;
  top: auto !important;
  left: auto !important;
  right: max(8px, env(safe-area-inset-right)) !important;
  bottom: max(8px, env(safe-area-inset-bottom)) !important;
  width: auto !important;
  height: auto !important;
  display: flex !important;
  flex-direction: row !important;
  justify-content: flex-end !important;
  align-items: flex-end !important;
  gap: 8px !important;
  padding: 0 !important;
  pointer-events: none !important;
}
body.dmg-touch-landscape.dmg-page-gradius.dmg-has-native-touch-controls #touch-controls .touch-btn,
body.dmg-touch-landscape.dmg-page-galaga.dmg-has-native-touch-controls #touch-controls .touch-btn,
body.dmg-touch-landscape.dmg-page-sidescroller.dmg-has-native-touch-controls #touch-controls .touch-btn,
body.dmg-touch-landscape.dmg-page-kungfu.dmg-has-native-touch-controls #touch-controls .touch-btn,
body.dmg-touch-landscape.dmg-page-adventureisland.dmg-has-native-touch-controls #touch-controls .touch-btn,
body.dmg-touch-landscape.dmg-page-racer.dmg-has-native-touch-controls #touch-controls .touch-btn {
  opacity: 0.64 !important;
}

/* Shared injected mobile-pad pages (Donkey Kong / Breakout in landscape mobile): bottom-right too. */
body.dmg-touch-landscape.dmg-page-donkeykong.dmg-has-mobile-pad #dmg-mobile-pad,
body.dmg-touch-landscape.dmg-page-breakout.dmg-has-mobile-pad #dmg-mobile-pad {
  position: fixed !important;
  top: auto !important;
  left: auto !important;
  right: max(8px, env(safe-area-inset-right)) !important;
  bottom: max(8px, env(safe-area-inset-bottom)) !important;
  width: auto !important;
  height: auto !important;
  display: flex !important;
  flex-direction: row !important;
  justify-content: flex-end !important;
  align-items: flex-end !important;
  gap: 8px !important;
  padding: 0 !important;
  pointer-events: none !important;
}
body.dmg-touch-landscape.dmg-page-donkeykong.dmg-has-mobile-pad #dmg-mobile-pad .dmg-touch-btn,
body.dmg-touch-landscape.dmg-page-breakout.dmg-has-mobile-pad #dmg-mobile-pad .dmg-touch-btn {
  opacity: 0.64 !important;
}

/* Split control layout for specific games on landscape mobile:
   move-pad left, action/fire pad right. */
body.dmg-touch-landscape.dmg-page-gradius.dmg-has-native-touch-controls #touch-controls,
body.dmg-touch-landscape.dmg-page-galaga.dmg-has-native-touch-controls #touch-controls,
body.dmg-touch-landscape.dmg-page-adventureisland.dmg-has-native-touch-controls #touch-controls,
body.dmg-touch-landscape.dmg-page-kungfu.dmg-has-native-touch-controls #touch-controls,
body.dmg-touch-landscape.dmg-page-streetfighter.dmg-has-native-touch-controls #touch-controls {
  left: max(8px, env(safe-area-inset-left)) !important;
  right: max(8px, env(safe-area-inset-right)) !important;
  bottom: max(8px, env(safe-area-inset-bottom)) !important;
  width: auto !important;
  justify-content: space-between !important;
  flex-direction: row !important;
  align-items: flex-end !important;
  gap: 8px !important;
  padding: 0 !important;
}
body.dmg-touch-landscape.dmg-page-gradius.dmg-has-native-touch-controls #touch-controls .touch-btn,
body.dmg-touch-landscape.dmg-page-galaga.dmg-has-native-touch-controls #touch-controls .touch-btn,
body.dmg-touch-landscape.dmg-page-adventureisland.dmg-has-native-touch-controls #touch-controls .touch-btn,
body.dmg-touch-landscape.dmg-page-kungfu.dmg-has-native-touch-controls #touch-controls .touch-btn,
body.dmg-touch-landscape.dmg-page-streetfighter.dmg-has-native-touch-controls #touch-controls .touch-btn {
  opacity: 0.64 !important;
}

#dmg-pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 10008;
  display: none;
  place-items: center;
  pointer-events: none;
  background: rgba(9, 17, 32, 0.28);
  backdrop-filter: blur(2px);
}

#dmg-pause-overlay .dmg-pause-card {
  border: 1px solid rgba(173, 224, 255, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  background: rgba(9, 20, 41, 0.78);
  color: #f4f8ff;
  font-size: 13px;
  letter-spacing: 0.4px;
}

body.dmg-soft-paused #dmg-pause-overlay {
  display: grid;
}

@media (max-width: 860px) {
  .dmg-touch-dock {
    padding: 8px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  #dmg-global-controls {
    top: max(6px, env(safe-area-inset-top));
    right: max(6px, env(safe-area-inset-right));
    gap: 5px;
  }

  #dmg-global-controls .dmg-ctl-btn {
    font-size: 15px !important;
    min-height: 39px;
    min-width: 39px;
    padding: 8px 12px;
  }
}
