* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background-color: #EEEBE3;
  background-image: radial-gradient(rgba(0,0,0,.035) .6px, transparent .9px);
  background-size: 3px 3px;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  color: #23221F;
}
[hidden] { display: none !important; }

#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#device {
  position: relative; flex: none; width: 390px; height: 844px; overflow: hidden;
  transform: scale(var(--s, 1)); transform-origin: center center;
}

.screw { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: #DCD8CD; box-shadow: inset 0 1px 2px rgba(0,0,0,.25); }
.screw i { display: block; margin: 5px 2px 0; height: 1px; background: #A9A497; }
.screw.low { top: 806px; width: 10px; height: 10px; background: rgba(0,0,0,.18); box-shadow: inset 0 1px 2px rgba(0,0,0,.3); }
.brand { position: absolute; left: 30px; top: 24px; font-size: 11px; font-weight: 700; letter-spacing: 3px; color: #6B665C; text-shadow: 0 1px 0 #fff; }

/* Pet lights */
.lights { position: absolute; left: 20px; top: 56px; width: 350px; height: 190px; display: flex; align-items: center; justify-content: center; transition: opacity .2s; }
.track { display: flex; gap: 4px; padding: 4px 8px; border-radius: 30px; background: rgba(0,0,0,.035); box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
.slot { width: 44px; height: 44px; border: 0; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cap { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: #EEEBE3; box-shadow: 0 3px 0 #B9B3A4, inset 0 1px 0 #fff; }
.slot.active .cap { box-shadow: inset 0 2px 4px rgba(0,0,0,.28); transform: translateY(2px); }
.lamp { display: block; width: 14px; height: 14px; border-radius: 50%; background: #C4BEB0; box-shadow: inset 0 1px 2px rgba(0,0,0,.18); }
.lamp.green, .lamp.yellow, .lamp.red { box-shadow: inset 1px 1px 0 rgba(255,255,255,.5), inset -1px -1px 0 rgba(0,0,0,.15); }
.lamp.green { background: #4CC36A; }
.lamp.yellow { background: #F2C230; }
.lamp.red { background: #E5493F; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .35; } }
#device.game .lights { opacity: 0; pointer-events: none; }

/* Screen */
.lens {
  position: absolute; left: 20px; width: 350px; padding: 7px; background: #DCD8CD;
  box-shadow: inset 0 2px 3px rgba(0,0,0,.18), 0 1px 0 #fff;
  top: 262px; height: 266px; border-radius: 40px 40px 32px 32px;
  transition: top .2s steps(4), height .2s steps(4);
}
#device.game .lens { top: 52px; height: 476px; border-radius: 44px 44px 32px 32px; }
.bezel { height: 100%; padding: 14px 16px; border-radius: 34px 34px 26px 26px; background: #121318; box-shadow: inset 0 3px 8px rgba(0,0,0,.7); }
#device.game .bezel { padding: 15px 16px; border-radius: 38px 38px 26px 26px; }
.screen { position: relative; width: 304px; height: 224px; border-radius: 6px; overflow: hidden; background: #F4ECDC; }
#device.game .screen { height: 432px; }
#cv { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.grid { position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(90deg, rgba(0,0,0,.07) 1px, transparent 1px), linear-gradient(rgba(0,0,0,.07) 1px, transparent 1px);
  background-size: 4px 4px; }
.glare { position: absolute; left: -40px; top: -60px; width: 130px; height: 520px; pointer-events: none;
  background: linear-gradient(90deg, rgba(255,255,255,.10), rgba(255,255,255,0)); transform: rotate(24deg); }

/* Case bottom */
.panel { position: absolute; left: -12px; top: 540px; width: 414px; height: 330px; border-radius: 50% 50% 0 0 / 56px 56px 0 0; background: #5B7394; box-shadow: inset 0 3px 0 rgba(255,255,255,.2), 0 -2px 0 rgba(0,0,0,.10); }
.grip { position: absolute; top: 600px; width: 14px; height: 200px; background-image: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 2px, transparent 2px 12px); }
.grip.left { left: 0; border-radius: 0 8px 8px 0; }
.grip.right { right: 0; border-radius: 8px 0 0 8px; }
.holes { position: absolute; left: 163px; top: 762px; display: grid; grid-template-columns: repeat(6, 6px); grid-auto-rows: 6px; gap: 5px; }
.holes span { border-radius: 50%; background: rgba(0,0,0,.28); box-shadow: 0 1px 0 rgba(255,255,255,.15); }

/* Buttons */
.controls { position: absolute; left: 0; top: 606px; width: 390px; display: flex; justify-content: center; align-items: flex-start; gap: 26px; }
.controls.game { top: 584px; }
.key {
  width: 76px; height: 76px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: #EEEBE3; box-shadow: 0 6px 0 #B9B3A4, inset 0 3px 0 #fff, inset 0 0 0 7px #E4E0D6;
  display: flex; align-items: center; justify-content: center; touch-action: manipulation;
}
.key.mid { margin-top: 16px; }
.key.big { width: 150px; height: 150px; box-shadow: 0 8px 0 #B9B3A4, inset 0 3px 0 #fff, inset 0 0 0 12px #E4E0D6; }
.key.down { transform: translateY(4px); box-shadow: 0 2px 0 #B9B3A4, inset 0 3px 0 #fff, inset 0 0 0 7px #E4E0D6; }
.key.big.down { box-shadow: 0 3px 0 #B9B3A4, inset 0 3px 0 #fff, inset 0 0 0 12px #E4E0D6; }
.key:focus-visible, .slot:focus-visible { outline: 3px solid #26354F; outline-offset: 3px; }

/* Naming */
.namebox {
  position: absolute; left: 32px; right: 32px; top: 74px; padding: 18px; border-radius: 22px;
  background: #F4ECDC; box-shadow: 0 0 0 3px #2a2622, 0 8px 0 rgba(0,0,0,.15);
  display: flex; flex-direction: column; gap: 12px;
}
.namebox label { font-size: 15px; font-weight: 700; }
.namebox .row { display: flex; gap: 10px; }
.namebox input {
  flex: 1; min-width: 0; height: 48px; border: 3px solid #2a2622; border-radius: 12px; padding: 0 12px;
  font: 700 22px 'Chakra Petch', system-ui, sans-serif; letter-spacing: 3px; text-transform: uppercase; background: #fff; color: #2a2622;
}
.namebox button {
  width: 76px; height: 48px; border: 0; border-radius: 12px; background: #5B7394; color: #fff;
  font: 700 16px 'Chakra Petch', system-ui, sans-serif; letter-spacing: 2px; cursor: pointer;
}
