/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Main layout: vertical stack, fills full viewport */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ZONE 1: HUD */
#zone-hud {
  flex-shrink: 0;
  width: 100%;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1a1a1a;
  min-height: 44px;
  z-index: 10;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 80px;
}
.hud-right { justify-content: flex-end; }
.hud-center { font-size: 18px; font-weight: 700; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud-timer { font-size: 12px; font-weight: 400; color: #aaa; font-variant-numeric: tabular-nums; }

.hud-lives, .hud-collectible {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.hud-lives img, .hud-collectible img {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

/* ZONE 2: VIEWPORT */
#zone-viewport {
  flex-shrink: 0;
  width: 100vw;
  height: 100vw;
  position: relative;
  overflow: hidden;
  background: #000;
}

#zone-viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Screen overlay (effects layer above canvas) */
#screen-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.15s, background-color 0.15s;
  opacity: 0;
  background-color: transparent;
}

#screen-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 19;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.6) 100%);
  opacity: 0;
  transition: opacity 0.3s;
}

/* ZONE 3: POWER-UP PANEL */
#zone-powerup {
  flex-shrink: 0;
  width: 100%;
  height: 15vw;
  max-height: 60px;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  transition: height 0.2s ease, opacity 0.2s ease;
  overflow: hidden;
  z-index: 10;
}
#zone-powerup.hidden {
  height: 0;
  opacity: 0;
  padding: 0;
}

.powerup-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 14px;
}
.powerup-slot img { width: 32px; height: 32px; image-rendering: pixelated; }

/* ZONE 4: CONTROLS */
#zone-controls {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 6px;
  padding: 6px;
  background: #1a1a1a;
  min-height: 100px;
  z-index: 10;
}

.ctrl-btn {
  background: #2a2a2a;
  border: 2px solid #444;
  color: rgba(255,255,255,0.4);
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  padding: 0;
  outline: none;
}
.ctrl-btn:active, .ctrl-btn.pressed {
  background: #3a3a3a;
}

.ctrl-row-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  min-height: 80px;
}

.ctrl-left-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.ctrl-dir {
  border-radius: 12px;
  font-size: clamp(18px, 5vw, 28px);
  letter-spacing: 1px;
}

.ctrl-right-col {
  position: relative;
  border-radius: 12px;
  border: 2px solid #444;
  overflow: hidden;
}

.ctrl-jump, .ctrl-skill {
  position: absolute;
  inset: 0;
  border: none;
  border-radius: 0;
  font-size: clamp(12px, 3.5vw, 18px);
  letter-spacing: 1.5px;
}

.ctrl-skill {
  clip-path: polygon(0 0, calc(100% - 5px) 0, 0 calc(100% - 5px));
  padding-right: 30%;
  padding-bottom: 30%;
}

.ctrl-jump {
  clip-path: polygon(100% 5px, 100% 100%, 5px 100%);
  padding-left: 30%;
  padding-top: 30%;
}

.ctrl-jump:active, .ctrl-jump.pressed {
  background: #3a3a3a;
}
.ctrl-skill:active, .ctrl-skill.pressed {
  background: #3a3a3a;
}

.ctrl-row-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  height: clamp(44px, 10vw, 60px);
}

.ctrl-down {
  border-radius: 12px;
  font-size: clamp(14px, 4vw, 22px);
  letter-spacing: 1px;
}

.ctrl-pause {
  border-radius: 12px;
  font-size: clamp(12px, 3vw, 16px);
  letter-spacing: 3px;
}

/* HUD ICON BAR */
#hud-icon-bar {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 4px 12px;
  background: #1a1a1a;
  min-height: 0;
  z-index: 10;
}

.hud-icon-slot {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.hud-icon-slot[data-empty="true"] {
  display: none;
}
.hud-icon-slot .hud-icon-img {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
}
.hud-icon-slot .hud-icon-count {
  min-width: 16px;
  text-align: center;
}
.hud-icon-slot .hud-icon-label {
  font-size: 11px;
  color: #999;
  margin-left: 2px;
}
