/* ===== Game Boy DMG (1989) — scocca fedele ===== */
:root {
  /* palette display DMG: 4 verdi autentici */
  --dmg-0: #9bbc0f; /* più chiaro */
  --dmg-1: #8bac0f;
  --dmg-2: #306230;
  --dmg-3: #0f380f; /* più scuro */
  /* scocca */
  --shell: #c8c7bf;
  --shell-dark: #b4b3aa;
  --shell-line: #a4a39a;
  --bezel: #58575f;
  --bezel-dark: #3f3e45;
  --magenta: #8e2b50;
  --magenta-dark: #6f2040;
  --dark-btn: #2a2a2e;
  --text-purple: #4a3b6b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }   /* l'attributo hidden deve vincere su display:flex */
html, body {
  margin: 0; height: 100%;
  background: #1b1d22;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}
.device {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 6px;
}

/* ---- corpo console ---- */
.gameboy {
  width: 100%; max-width: 440px;
  background: linear-gradient(160deg, var(--shell) 0%, var(--shell-dark) 100%);
  border-radius: 14px 14px 14px 56px;     /* angolo basso-sx arrotondato come il DMG */
  padding: 18px 18px 26px;
  box-shadow:
    inset 0 2px 3px rgba(255,255,255,.6),
    inset 0 -3px 6px rgba(0,0,0,.18),
    0 14px 30px rgba(0,0,0,.55);
  position: relative;
}

/* ---- sezione schermo ---- */
.screen-toplabel {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: #76757d; font-size: 9px; font-weight: 700; letter-spacing: .5px;
  margin: 2px 0 8px;
}
.screen-toplabel .line { height: 2px; width: 26px; background: #9b1b3f; border-radius: 2px; }
.screen-toplabel .line:last-child { background: #1b2f9b; }

.bezel {
  background: linear-gradient(160deg, var(--bezel) 0%, var(--bezel-dark) 100%);
  border-radius: 10px 10px 34px 10px;
  padding: 16px 26px 22px;
  box-shadow: inset 0 2px 5px rgba(0,0,0,.5), inset 0 -1px 2px rgba(255,255,255,.08);
}
.bezel-leds { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
.led-power {
  width: 9px; height: 9px; border-radius: 50%;
  background: #5a1418; box-shadow: inset 0 0 2px rgba(0,0,0,.6);
  transition: background .2s, box-shadow .2s;
}
.led-power.on { background: #ff3b30; box-shadow: 0 0 7px #ff3b30, inset 0 0 2px rgba(255,255,255,.5); }
.led-label { color: #b9b8c2; font-size: 8px; font-weight: 700; letter-spacing: 1px; }

.screen-wrap {
  position: relative; width: 100%; aspect-ratio: 160 / 144;
  background: var(--dmg-0); border-radius: 4px; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.35);
}
#display {
  width: 100%; height: 100%; display: block;
  image-rendering: pixelated; image-rendering: crisp-edges;
  background: var(--dmg-0);
}

/* avvio autentico: logo che scende */
.boot {
  position: absolute; inset: 0; background: var(--dmg-0);
  display: flex; align-items: flex-start; justify-content: center;
}
.boot-logo {
  margin-top: -30%; color: var(--dmg-3);
  font-weight: 800; font-size: clamp(20px, 7vw, 30px); letter-spacing: -1px;
  animation: bootDrop 2.2s cubic-bezier(.6,.02,.3,1) forwards;
}
.boot-logo sup, .boot-logo span { font-size: .4em; vertical-align: super; }
@keyframes bootDrop {
  0%   { transform: translateY(0); }
  55%  { transform: translateY(120%); }     /* scende fino al centro */
  100% { transform: translateY(120%); }
}

/* splash iniziale */
.splash {
  position: absolute; inset: 0; background: var(--dmg-0);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--dmg-3); text-align: center; padding: 10px;
}
.splash-title { margin: 0; font-weight: 800; font-size: 22px; letter-spacing: 2px; }
.splash-load {
  border: 2px solid var(--dmg-3); background: transparent; color: var(--dmg-3);
  font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 4px; cursor: pointer;
}
.splash-load:active { background: var(--dmg-2); color: var(--dmg-0); }
.splash-hint { margin: 0; font-size: 11px; line-height: 1.5; color: var(--dmg-2); }

.brand {
  display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-top: 12px;
}
.brand-nintendo { color: var(--text-purple); font-style: italic; font-weight: 800; font-size: 17px; }
.brand-gb { color: var(--text-purple); font-weight: 800; font-style: italic; font-size: 15px; letter-spacing: .5px; }
.brand-gb sup { font-size: .5em; }

/* ---- controlli ---- */
.controls {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 26px; padding: 0 6px;
}
/* tutti i controlli: touch affidabile (niente scroll/zoom che annulla la pressione) */
.dpad-btn, .round-btn, .pill-btn {
  touch-action: none; -webkit-user-select: none; user-select: none;
}
/* D-pad */
.dpad { position: relative; width: 132px; height: 132px; }
.dpad-btn {
  position: absolute; background: var(--dark-btn); border: none; cursor: pointer;
  box-shadow: 0 3px 4px rgba(0,0,0,.4), inset 0 1px 1px rgba(255,255,255,.12);
}
.dpad-btn.up    { top: 0; left: 45px; width: 42px; height: 50px; border-radius: 6px 6px 0 0; }
.dpad-btn.down  { bottom: 0; left: 45px; width: 42px; height: 50px; border-radius: 0 0 6px 6px; }
.dpad-btn.left  { left: 0; top: 45px; width: 50px; height: 42px; border-radius: 6px 0 0 6px; }
.dpad-btn.right { right: 0; top: 45px; width: 50px; height: 42px; border-radius: 0 6px 6px 0; }
.dpad-center { position: absolute; top: 45px; left: 45px; width: 42px; height: 42px; background: var(--dark-btn); pointer-events: none; }
.dpad-btn.pressed, .round-btn.pressed, .pill-btn.pressed { filter: brightness(.7); transform: translateY(1px); }

/* A / B */
.ab { display: flex; gap: 20px; align-items: flex-end; transform: rotate(-25deg); }
.round-btn {
  width: 62px; height: 62px; border-radius: 50%; border: none; cursor: pointer;
  background: radial-gradient(circle at 38% 32%, #a83c63, var(--magenta) 60%, var(--magenta-dark));
  color: #f0d0dc; font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 5px rgba(0,0,0,.4), inset 0 1px 2px rgba(255,255,255,.25);
}
.round-btn.a { transform: translateY(-16px); }

/* Start / Select */
.startselect { display: flex; justify-content: center; gap: 26px; margin-top: 24px; }
.pill-btn {
  background: #88858d; border: none; color: #4a4953; cursor: pointer;
  font-size: 10px; font-weight: 800; letter-spacing: .5px;
  width: 70px; height: 22px; border-radius: 11px; transform: rotate(-25deg);
  box-shadow: 0 2px 3px rgba(0,0,0,.35), inset 0 1px 1px rgba(255,255,255,.2);
}

/* Speaker */
.speaker {
  display: flex; gap: 7px; justify-content: flex-end; margin-top: 24px; padding-right: 6px;
  transform: rotate(-25deg); transform-origin: right;
}
.speaker i { width: 5px; height: 42px; border-radius: 4px;
  background: var(--shell-line); box-shadow: inset 0 1px 1px rgba(0,0,0,.3); }

@media (max-height: 720px) {
  .gameboy { max-width: 320px; padding: 12px 14px 18px; }
  .controls { margin-top: 16px; }
  .speaker { margin-top: 12px; }
  .speaker i { height: 32px; }
}
