/* gameboy.css — the DMG-01 shell, drawn entirely in CSS.
   Design space: 380 x 640 px, scaled by JS transform to fit. */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --plastic: #b6b6ad;
  --plastic-hi: #c6c6be;
  --plastic-lo: #9d9d95;
  --ink-blue: #2b3179;
  --ink-magenta: #a02168;
  --dark: #2e2e33;
  --dpad: #2b2b30;
  --ab: #b02a6e;
  --pill: #7c7c76;
  --bezel: #4a4658;
  --wrot: 0deg;
}

html, body { height: 100%; }

body {
  background:
    radial-gradient(120% 90% at 50% 8%, #3d3a41 0%, #2b282e 45%, #1d1b20 100%);
  font-family: "Courier New", ui-monospace, monospace;
  color: #d8d4c8;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 26px;
}

/* ---------------- device ---------------- */
#deviceCol { position: relative; }
#deviceScale {
  width: 380px; height: 680px;
  transform-origin: 0 0;
  position: relative;
}

#device {
  position: absolute; left: 0; top: 38px;
  width: 380px; height: 620px;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.30), rgba(255,255,255,0) 30%),
    linear-gradient(340deg, rgba(0,0,0,0.18), rgba(0,0,0,0) 40%),
    var(--plastic);
  border-radius: 12px 12px 58px 12px / 12px 12px 78px 12px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.5),
    inset 0 -3px 6px rgba(0,0,0,0.22),
    inset 2px 0 4px rgba(255,255,255,0.25),
    inset -3px 0 6px rgba(0,0,0,0.18),
    0 18px 50px rgba(0,0,0,0.55),
    0 3px 10px rgba(0,0,0,0.4);
}
/* fine plastic grain + seams */
#device::before {
  content: ""; position: absolute; inset: 0;
  border-radius: inherit;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.012) 0 2px, transparent 2px 4px),
    radial-gradient(140% 60% at 50% 0%, rgba(255,255,255,0.10), transparent 60%);
  pointer-events: none;
}
/* bottom case seam */
#device::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 34px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,0.10) 15%, rgba(0,0,0,0.10) 85%, transparent);
  border-radius: 2px;
  pointer-events: none;
}

/* ---- power switch ---- */
#powerSwitch {
  position: absolute; left: 34px; top: -7px;
  width: 84px; height: 30px;
  cursor: pointer; z-index: 30;
}
#powerSwitch .sw-text {
  position: absolute; top: 30px; left: 0; width: 84px; text-align: center;
  font-size: 8px; letter-spacing: 1px; color: var(--ink-blue); font-weight: bold;
}
#powerSwitch .sw-rail {
  position: absolute; left: 4px; top: 8px; width: 76px; height: 14px;
  background: #8f8f88;
  border-radius: 7px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.4);
}
#powerSwitch .sw-knob {
  position: absolute; top: 1px; left: 2px;
  width: 30px; height: 12px;
  background: linear-gradient(180deg, #5a5a60, #3a3a40);
  border-radius: 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center; gap: 3px;
  transition: left 0.12s ease;
}
#powerSwitch .sw-knob i { width: 2px; height: 8px; background: rgba(0,0,0,0.45); border-radius: 1px; }
#device.on #powerSwitch .sw-knob { left: 44px; }

/* ---- side wheels ---- */
.side-wheel {
  position: absolute; width: 20px; height: 62px; top: 128px;
  cursor: ns-resize; z-index: 25;
}
.side-wheel.left { left: -11px; }
.side-wheel.right { right: -11px; }
.side-wheel .wheel-disc {
  position: absolute; inset: 0;
  border-radius: 10px;
  background:
    repeating-conic-gradient(from 0deg, #63636a 0deg 12deg, #3c3c42 12deg 24deg);
  box-shadow: inset 0 0 6px rgba(0,0,0,0.6), 0 2px 4px rgba(0,0,0,0.4);
  transform: rotate(var(--wrot));
  transition: transform 0.05s linear;
}
.wheel-label {
  position: absolute; top: 196px; font-size: 7px; letter-spacing: 1px;
  color: var(--ink-blue); font-weight: bold; transform: rotate(90deg);
}
.wheel-label.left { left: -34px; }
.wheel-label.right { right: -40px; }

/* ---- battery led ---- */
#batteryLed {
  position: absolute; left: 22px; top: 88px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #5a2020;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.6), 0 0 0 1px rgba(0,0,0,0.25);
}
#batteryLed.on {
  background: radial-gradient(circle at 35% 35%, #ff7a6a, #e0231a 60%, #8c0f0a);
  box-shadow: 0 0 8px 2px rgba(255,60,40,0.65), inset 0 1px 2px rgba(255,255,255,0.5);
}
.led-label {
  position: absolute; left: 7px; top: 102px;
  font-size: 7px; letter-spacing: 1px; color: var(--ink-magenta); font-weight: bold;
}

/* ---- screen bezel ---- */
#bezel {
  position: absolute; left: 40px; top: 44px;
  width: 300px; height: 258px;
  background: linear-gradient(150deg, #5a5468, #403c4e 60%, #37333f);
  border-radius: 8px 8px 26px 8px;
  box-shadow:
    inset 0 3px 8px rgba(0,0,0,0.6),
    inset 0 -2px 4px rgba(255,255,255,0.10),
    0 1px 0 rgba(255,255,255,0.35);
}
.bezel-stripes {
  position: absolute; top: 12px; left: 14px; right: 14px;
  display: flex; align-items: center; gap: 6px;
}
.bezel-stripes .bs { height: 3px; flex: 1; border-radius: 2px; box-shadow: 0 1px 0 rgba(255,255,255,0.15); }
.bezel-stripes .bs.magenta { background: linear-gradient(90deg, var(--ink-magenta), #d2458e); }
.bezel-stripes .bs.blue { background: linear-gradient(90deg, #3f7bd0, var(--ink-blue)); }
.bezel-stripes .bs-text {
  font-size: 7px; letter-spacing: 1.4px; white-space: nowrap;
  color: #cfc9de; font-weight: bold;
}
#lcdFrame {
  position: absolute; left: 34px; top: 34px;
  width: 232px; height: 209px;
  background: #111;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px #17171c, inset 0 2px 8px rgba(0,0,0,0.9);
  overflow: hidden;
}
#lcdCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block;
}
#lcdGlass {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(115deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0.02) 22%, transparent 30%),
    radial-gradient(130% 100% at 50% -10%, rgba(255,255,255,0.07), transparent 50%);
}
#device.off #lcdGlass { background:
    linear-gradient(115deg, rgba(255,255,255,0.06) 0%, transparent 30%),
    radial-gradient(130% 100% at 50% -10%, rgba(255,255,255,0.05), transparent 50%); }

/* ---- wordmark ---- */
.wordmark {
  position: absolute; left: 40px; top: 310px; width: 300px;
  display: flex; align-items: baseline; gap: 6px;
}
.wordmark .brand-dmg {
  font-size: 10px; font-weight: bold; color: var(--ink-blue); letter-spacing: 1px;
}
.wordmark .brand {
  font-size: 27px; font-weight: 900; font-style: italic;
  color: var(--ink-blue);
  font-family: "Arial Black", "Arial", sans-serif;
  letter-spacing: -1px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}
.wordmark .tm { font-size: 8px; color: var(--ink-blue); font-weight: bold; }

/* ---- d-pad ---- */
#dpad {
  position: absolute; left: 28px; top: 384px;
  width: 108px; height: 108px;
}
.dp-arm {
  position: absolute; background: var(--dpad);
  box-shadow: inset 0 -3px 4px rgba(0,0,0,0.5), inset 0 2px 2px rgba(255,255,255,0.15), 0 2px 3px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: filter 0.05s;
}
.dp-arm.up    { left: 36px; top: 0;    width: 36px; height: 40px; border-radius: 5px 5px 0 0; }
.dp-arm.down  { left: 36px; bottom: 0; width: 36px; height: 40px; border-radius: 0 0 5px 5px; }
.dp-arm.left  { left: 0;    top: 36px; width: 40px; height: 36px; border-radius: 5px 0 0 5px; }
.dp-arm.right { right: 0;   top: 36px; width: 40px; height: 36px; border-radius: 0 5px 5px 0; }
.dp-arm::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  border: solid transparent;
}
.dp-arm.up::after    { border-width: 0 7px 9px 7px; border-bottom-color: rgba(0,0,0,0.4); margin-top: -6px; }
.dp-arm.down::after  { border-width: 9px 7px 0 7px; border-top-color: rgba(0,0,0,0.4); margin-top: 6px; }
.dp-arm.left::after  { border-width: 7px 9px 7px 0; border-right-color: rgba(0,0,0,0.4); margin-left: -6px; }
.dp-arm.right::after { border-width: 7px 0 7px 9px; border-left-color: rgba(0,0,0,0.4); margin-left: 6px; }
.dp-pivot {
  position: absolute; left: 36px; top: 36px; width: 36px; height: 36px;
  background: var(--dpad);
  box-shadow: inset 0 2px 3px rgba(255,255,255,0.12);
}
.dp-dish {
  position: absolute; left: 43px; top: 43px; width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #3d3d44, #222227 70%);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.7), 0 1px 0 rgba(255,255,255,0.1);
  pointer-events: none;
}
.dp-arm.pressed, #dpad .pressed { filter: brightness(0.72); }

/* ---- A/B ---- */
#abCluster {
  position: absolute; right: 22px; top: 380px;
  width: 118px; height: 66px;
  transform: rotate(-24deg);
}
.ab-btn {
  position: absolute; width: 46px; height: 46px; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #d4558f, var(--ab) 55%, #7c1a4c 100%);
  box-shadow:
    inset 0 -4px 6px rgba(0,0,0,0.35),
    inset 0 3px 4px rgba(255,255,255,0.35),
    0 4px 6px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform 0.05s, box-shadow 0.05s;
}
.ab-btn.b-btn { left: 0; top: 10px; }
.ab-btn.a-btn { right: 0; top: 0; }
.ab-btn span {
  position: absolute; left: 50%; top: 105%;
  transform: translateX(-50%) rotate(0deg);
  font-size: 11px; font-weight: bold; color: var(--ink-blue);
}
.ab-btn.pressed {
  transform: scale(0.9);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.4), inset 0 2px 3px rgba(255,255,255,0.2), 0 1px 2px rgba(0,0,0,0.4);
  filter: brightness(0.85);
}

/* ---- start/select ---- */
#pillCluster {
  position: absolute; left: 128px; top: 528px;
  width: 130px; height: 40px;
  transform: rotate(-24deg);
  display: flex; gap: 22px; align-items: center; justify-content: center;
}
.pill {
  width: 44px; height: 13px; border-radius: 7px;
  background: linear-gradient(180deg, #9a9a93, var(--pill));
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.4), inset 0 1px 2px rgba(255,255,255,0.4), 0 2px 3px rgba(0,0,0,0.35);
  cursor: pointer;
  position: relative;
  transition: transform 0.05s;
}
.pill span {
  position: absolute; left: 50%; top: 150%; transform: translateX(-50%) rotate(24deg);
  font-size: 8px; font-weight: bold; letter-spacing: 1px; color: var(--ink-magenta);
  white-space: nowrap;
}
.pill.pressed { transform: scale(0.88); filter: brightness(0.8); }

/* ---- key hints ---- */
.keyhint {
  position: absolute; font-size: 7px; letter-spacing: 0.5px;
  color: rgba(43,49,121,0.55); font-weight: bold;
}
.dp-hint { left: 30px; top: 496px; width: 104px; text-align: center; }
.ab-hint { right: 20px; top: 464px; width: 120px; transform: rotate(-24deg); display: flex; justify-content: space-between; padding: 0 8px; }
.pill-hint { left: 128px; top: 566px; width: 130px; transform: rotate(-24deg); display: flex; justify-content: space-between; padding: 0 4px; }

/* ---- speaker ---- */
#speaker {
  position: absolute; right: 26px; bottom: 36px;
  width: 74px; height: 66px;
  transform: rotate(-32deg);
  display: flex; gap: 7px; align-items: flex-start; justify-content: center;
}
#speaker i {
  width: 5px; height: 62px; border-radius: 3px;
  background: linear-gradient(90deg, #6f6f68, #4c4c46);
  box-shadow: inset 0 0 3px rgba(0,0,0,0.7), 0 1px 0 rgba(255,255,255,0.3);
}
#speaker i:nth-child(1) { height: 40px; }
#speaker i:nth-child(2) { height: 50px; }
#speaker i:nth-child(5) { height: 50px; }
#speaker i:nth-child(6) { height: 40px; }

/* ---- small print ---- */
.print { position: absolute; font-size: 6px; letter-spacing: 1px; color: rgba(43,49,121,0.4); font-weight: bold; }
.serial { left: 30px; bottom: 14px; }
.phones { left: 150px; bottom: 14px; }
.dc { right: 118px; bottom: 14px; }

/* ---- seated cartridge sliver ---- */
#cartInSlot {
  position: absolute; left: 130px; top: -30px;
  width: 92px; height: 46px;
  background: linear-gradient(180deg, #8e8e88, #7d7d78);
  border-radius: 6px 6px 0 0;
  box-shadow: inset 0 -4px 6px rgba(0,0,0,0.3), 0 -2px 4px rgba(0,0,0,0.3);
  transform: translateY(30px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
  cursor: pointer;
  z-index: 5;
}
#cartInSlot.filled { transform: translateY(0); opacity: 1; }
#cartInSlot canvas { width: 92px; height: auto; margin-top: -24px; opacity: 0.9; }
#cartInSlot::before {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.06) 0 3px, transparent 3px 6px);
}

/* ---------------- shelf ---------------- */
#shelfCol { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#shelf {
  background: linear-gradient(170deg, #4a4238, #332d26);
  border-radius: 10px;
  padding: 14px 16px 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.12);
  max-width: 340px;
}
.shelf-title {
  text-align: center; font-size: 10px; letter-spacing: 3px;
  color: #cbb98a; font-weight: bold; margin-bottom: 10px;
}
.shelf-tray {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}
.cart {
  width: 64px; height: 74px;
  background: linear-gradient(180deg, #99998f, #82827c);
  border-radius: 5px 5px 3px 3px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.45), inset 0 -3px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
  position: relative;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.3s;
  overflow: hidden;
}
.cart .cart-grip {
  position: absolute; top: 3px; left: 8px; right: 8px; height: 5px;
  background: repeating-linear-gradient(90deg, rgba(0,0,0,0.25) 0 3px, transparent 3px 6px);
  border-radius: 2px;
}
.cart .cart-label {
  position: absolute; left: 4px; top: 10px; width: 56px; height: 50px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2);
}
.cart:hover { transform: translateY(-4px); }
.cart.focused { outline: 2px solid #cbb98a; outline-offset: 2px; transform: translateY(-3px); }
.cart.seated { opacity: 0.28; transform: none; }
.cart-ghost {
  position: fixed; z-index: 100; margin: 0; pointer-events: none;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
}
.shelf-hint {
  margin-top: 10px; text-align: center;
  font-size: 8px; letter-spacing: 1px; color: rgba(216,212,200,0.55);
}
#footnote {
  font-size: 9px; letter-spacing: 1px; color: rgba(216,212,200,0.45);
  text-align: center;
}

/* powered-off device dims slightly; powered-on "awake" */
#device { transition: filter 0.4s; }
#device.off { filter: saturate(0.85) brightness(0.94); }
#device.on { filter: none; }

/* ---------------- responsive ---------------- */
@media (max-width: 860px) {
  #stage { flex-direction: column; gap: 8px; }
  #shelf { max-width: 96vw; padding: 10px 10px 8px; }
  .shelf-tray { gap: 8px; }
  .cart { width: 56px; height: 66px; }
  .cart .cart-label { width: 48px; height: 43px; }
  #footnote { display: none; }
}
@media (max-height: 560px) and (min-width: 861px) {
  #footnote { display: none; }
}
