/* A pocket handheld drawn in Mia's style: cream body, ink outline, hard shadow, lime keys. Not a replica of any console. */
:root {
  --bg: #f3efe6; --paper: #fffdf8; --ink: #111; --muted: #6b665d; --lime: #c8f03c; --bezel: #2a2d33;
  --lcd: #e0f8d0; --lcd-ink: #081820;
  --unit: min(1vw, 0.56vh);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: "Space Grotesk", "Noto Sans SC", system-ui, -apple-system, "PingFang SC", sans-serif; }
body { background-image: radial-gradient(rgba(17,17,17,.09) 1.6px, transparent 2px); background-size: 26px 26px;
  user-select: none; -webkit-user-select: none; touch-action: none; }

.stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: max(64px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); }
.device { position: relative; background: var(--paper); border: 4px solid var(--ink); border-radius: 26px 26px 26px 26px;
  box-shadow: 8px 8px 0 var(--ink); display: grid; }

/* portrait (phones held upright, and the default): screen on top, keys below */
.device { width: min(440px, 100%, calc((100dvh - 80px) * 0.62)); padding: 16px 16px 20px; grid-template-rows: auto auto 1fr auto;
  height: min(calc(100dvh - 80px), 760px); }
.bezel { background: var(--bezel); border-radius: 16px; padding: 12px 14px 12px; border: 3px solid var(--ink); }
.bezel-top { display: flex; align-items: center; justify-content: space-between; color: #cfd3d8; font-size: 12px; letter-spacing: .14em;
  text-transform: uppercase; margin-bottom: 9px; font-weight: 700; }
.bezel-top .led { width: 9px; height: 9px; border-radius: 50%; background: #4a2a2a; box-shadow: 0 0 0 2px #1a1c20 inset; margin-right: 7px; display: inline-block; vertical-align: -1px; }
body.playing .bezel-top .led { background: #ff4b3e; box-shadow: 0 0 8px #ff4b3e; }
#title { color: var(--lime); }
#screen-wrap { position: relative; aspect-ratio: 160 / 144; width: 100%; background: var(--lcd); border-radius: 4px; overflow: hidden;
  box-shadow: 0 0 0 2px #15171a; cursor: pointer; }
#screen { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#tap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: color-mix(in srgb, var(--lcd) 72%, transparent); color: var(--lcd-ink); font-weight: 800; cursor: pointer; border: 0; font: inherit; }
#tap-t { font-size: 22px; font-weight: 800; letter-spacing: .02em; }
#tap-s { font-size: 13px; opacity: .75; }
#tap::before { content: ""; width: 0; height: 0; border-left: 22px solid var(--lcd-ink); border-top: 14px solid transparent; border-bottom: 14px solid transparent; margin-bottom: 8px; }
body.playing #tap { display: none; }

.brand { display: flex; align-items: center; justify-content: space-between; margin: 12px 4px 0; }
.brand b { font-size: 15px; letter-spacing: .02em; }
.brand b i { font-style: normal; background: var(--lime); border: 2px solid var(--ink); border-radius: 6px; padding: 0 6px; margin-left: 4px; }
.tools { display: flex; gap: 8px; }
.tools button, .tools a, .tools-l button, .tools-l a { appearance: none; border: 2.5px solid var(--ink); background: var(--paper); color: var(--ink); border-radius: 999px;
  height: 34px; min-width: 34px; padding: 0 12px; font: 700 13px/1 inherit; font-family: inherit; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; text-decoration: none; box-shadow: 2px 2px 0 var(--ink); cursor: pointer; }
.tools button { padding: 0; width: 34px; }
.tools button:active, .tools a:active { transform: translate(2px, 2px); box-shadow: none; }
.tools svg { width: 17px; height: 17px; }
body.muted #snd .on, body:not(.muted) #snd .off { display: none; }

#controls { position: relative; touch-action: none; min-height: 230px; }
#dpad { position: absolute; left: 4%; top: 44%; width: 36%; aspect-ratio: 1; transform: translateY(-58%); }
#dpad .arm { position: absolute; background: var(--ink); border-radius: 7px; }
#dpad .h { left: 0; right: 0; top: 33.3%; height: 33.4%; }
#dpad .v { top: 0; bottom: 0; left: 33.3%; width: 33.4%; }
#dpad .hub { position: absolute; left: 41%; top: 41%; width: 18%; height: 18%; border-radius: 50%; background: #2c2c2c; }
#dpad .tri { position: absolute; width: 0; height: 0; opacity: .45; }
#dpad .tu { left: 50%; top: 9%; transform: translateX(-50%); border: 7px solid transparent; border-bottom-color: #888; }
#dpad .td { left: 50%; bottom: 9%; transform: translateX(-50%); border: 7px solid transparent; border-top-color: #888; }
#dpad .tl { top: 50%; left: 9%; transform: translateY(-50%); border: 7px solid transparent; border-right-color: #888; }
#dpad .tr { top: 50%; right: 9%; transform: translateY(-50%); border: 7px solid transparent; border-left-color: #888; }
#dpad[data-up="1"] .tu, #dpad[data-down="1"] .td, #dpad[data-left="1"] .tl, #dpad[data-right="1"] .tr { opacity: 1; border-bottom-color: var(--lime); border-top-color: var(--lime); border-left-color: var(--lime); border-right-color: var(--lime); }
#dpad[data-up="1"] .tu { border-top-color: transparent; border-left-color: transparent; border-right-color: transparent; }
#dpad[data-down="1"] .td { border-bottom-color: transparent; border-left-color: transparent; border-right-color: transparent; }
#dpad[data-left="1"] .tl { border-top-color: transparent; border-bottom-color: transparent; border-left-color: transparent; }
#dpad[data-right="1"] .tr { border-top-color: transparent; border-bottom-color: transparent; border-right-color: transparent; }

.ab { position: absolute; right: 3%; top: 44%; width: 44%; aspect-ratio: 1.6; transform: translateY(-62%) rotate(-24deg); }
.key { position: absolute; width: 42%; aspect-ratio: 1; border-radius: 50%; background: var(--lime); border: 4px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink); display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 22px; }
.key span { transform: rotate(24deg); }
.key.down, .pill.down { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); filter: brightness(.92); }
.key[data-btn="b"] { left: 2%; top: 38%; }
.key[data-btn="a"] { right: 2%; top: 4%; }
.pills { position: absolute; left: 0; right: 0; bottom: 6px; display: flex; justify-content: center; gap: 22px; }
.pill { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; font-weight: 800; letter-spacing: .12em; color: var(--muted); }
.pill::before { content: ""; width: 58px; height: 16px; border-radius: 999px; background: #4a4a4a; border: 3px solid var(--ink); transform: rotate(-24deg); }
.pill.down::before { background: var(--lime); }
.pill.down { box-shadow: none; transform: none; filter: none; }
#keys { display: none; margin: 10px 4px 0; font-size: 12px; color: var(--muted); text-align: center; }
body:not(.touch) #keys { display: block; }

/* landscape phones: screen in the middle, D-pad left, buttons right */
@media (orientation: landscape) and (max-height: 560px) {
  .stage { padding: 8px 10px 8px 96px; }
  .device { width: 100%; height: 100%; max-width: 1000px; display: block; padding: 0; }
  .bezel { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; padding: 7px 10px 9px; }
  .bezel-top { margin-bottom: 5px; font-size: 10px; }
  #screen-wrap { flex: none; height: calc(100dvh - 16px - 22px - 37px); width: auto; }
  .brand { position: absolute; right: 14px; top: 10px; margin: 0; z-index: 3; }
  .brand b { display: none; }
  #controls { position: absolute; inset: 0; min-height: 0; }
  #dpad { left: 3.5%; top: 52%; width: min(21%, 36vh); transform: translateY(-50%); }
  .ab { right: 2%; top: 56%; width: min(25%, 46vh); transform: translateY(-50%) rotate(-24deg); }
  .pills { bottom: 10px; left: auto; right: 3%; gap: 14px; }
  .pill::before { width: 46px; height: 14px; }
  #keys { display: none !important; }
}

/* desktop: a bit more air */
@media (pointer: fine) and (min-height: 700px) {
  .device { height: min(calc(100vh - 48px), 780px); }
}
