* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #080604;
  font-family: "Courier New", Courier, monospace;
  color: #e8e0c8;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#app {
  height: 100%; height: 100dvh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 0%, #3a2810 0%, transparent 48%),
    radial-gradient(ellipse at top, #1a1810 0%, #080604 55%);
}
#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 8px 0;
}
#c {
  width: 100%;
  max-width: 720px;
  height: auto;
  max-height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0a0806;
  border: 3px solid #3a3020;
  box-shadow:
    0 0 0 2px #e8c84a,
    0 0 0 4px rgba(42, 90, 70, 0.35),
    0 0 28px rgba(200, 140, 40, 0.25),
    0 0 56px rgba(20, 40, 50, 0.15),
    0 12px 40px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px #1a1410;
}
#hudDom {
  display: none; /* canvas HUD primary */
}

/* Game Boy bar — dirty yellow / concrete grit */
.gb {
  flex: 0 0 auto;
  position: relative;
  z-index: 20;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #1c1810 0%, #100c08 100%);
  border-top: 2px solid rgba(232, 200, 74, 0.35);
  box-shadow: 0 -10px 30px rgba(0,0,0,.45);
  pointer-events: auto;
}
.gb button {
  pointer-events: auto;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
.gb-shell {
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
}
.gb-left { display: flex; justify-content: flex-start; }
.gb-right { display: flex; justify-content: flex-end; }
.gb-mid {
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
}

.dpad {
  position: relative;
  width: 148px; height: 148px;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,.4));
}
.d-btn {
  position: absolute;
  width: 48px; height: 48px;
  border: 0; border-radius: 8px;
  background: linear-gradient(180deg, #3a3528, #1a1610);
  color: #d4c8a0;
  font-size: 16px; font-weight: 900;
  display: grid; place-items: center;
  touch-action: manipulation;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.1), 0 3px 0 #080604;
}
.d-btn:active, .d-btn.is-down {
  transform: translateY(2px);
  color: #e8c84a;
  background: linear-gradient(180deg, #2a2620, #12100c);
}
.d-up { left: 50px; top: 2px; }
.d-down { left: 50px; bottom: 2px; }
.d-left { left: 2px; top: 50px; }
.d-right { right: 2px; top: 50px; }
.d-center {
  left: 50px; top: 50px; width: 48px; height: 48px;
  pointer-events: none !important;
  background: radial-gradient(circle at 40% 35%, #2e2a20, #12100c);
}

.sel {
  min-width: 74px; min-height: 34px;
  padding: 6px 10px;
  border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #3a3020, #1a1410);
  color: #e0d0a0;
  font-size: 10px; font-weight: 800; letter-spacing: .06em;
  touch-action: manipulation;
  box-shadow: 0 3px 0 #0a0604;
}
.sel:active, .sel.is-down { transform: translateY(2px); color: #e8c84a; }

.ab { position: relative; width: 150px; height: 120px; }
.face {
  position: absolute;
  width: 72px; height: 72px;
  border: 0; border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  touch-action: manipulation;
  font-weight: 900;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.18), 0 6px 0 rgba(0,0,0,.35);
}
.face span { font-size: 22px; line-height: 1; }
.face small { font-size: 9px; letter-spacing: .06em; opacity: .9; }
.a-btn {
  right: 0; top: 8px;
  background: linear-gradient(160deg, #e8c84a, #a07820);
  color: #1a1008;
}
.b-btn {
  left: 0; bottom: 0;
  background: linear-gradient(160deg, #4a9aaa, #2a6070);
  color: #041018;
}
.face:active, .face.is-down { transform: translateY(3px); }

@media (max-width: 380px) {
  .dpad { width: 128px; height: 128px; }
  .d-btn { width: 42px; height: 42px; }
  .d-up, .d-down { left: 43px; }
  .d-left, .d-right { top: 43px; }
  .d-center { left: 43px; top: 43px; width: 42px; height: 42px; }
  .face { width: 64px; height: 64px; }
  .ab { width: 132px; height: 110px; }
}
