:root {
  color-scheme: light;
  --shell: #d89432;
  --shell-dark: #9d6422;
  --ink: #26342c;
  --lcd: #a9c778;
  --button: #b95832;
  --button-dark: #783923;
  --bezel: #bd8331;
  --text: #493d2c;
  --button-text: #f0d6b4;
}

body[data-colorway="blue"] {
  --shell: #4f839e;
  --shell-dark: #31566b;
  --button: #d5853f;
  --button-dark: #875126;
  --bezel: #426e84;
  --text: #1e3b49;
  --button-text: #f3dfbd;
}

body[data-colorway="green"] {
  --shell: #718c58;
  --shell-dark: #455b37;
  --button: #a95c3c;
  --button-dark: #663926;
  --bezel: #5f784b;
  --text: #2f4028;
  --button-text: #efddbd;
}

body[data-colorway="graphite"] {
  --shell: #626767;
  --shell-dark: #363b3b;
  --button: #a65a47;
  --button-dark: #62362d;
  --bezel: #505656;
  --text: #272c2c;
  --button-text: #eee1cf;
}

body[data-colorway="gameboy"] {
  --shell: #c7c5ad;
  --shell-dark: #777866;
  --button: #8f234f;
  --button-dark: #56152f;
  --bezel: #727b75;
  --text: #303856;
  --button-text: #eee9d4;
}

body[data-colorway="transparent"] {
  --shell: rgba(210, 229, 224, 0.7);
  --shell-dark: #688984;
  --button: rgb(70, 70, 70);
  --button-dark: #242424;
  --bezel: rgba(111, 151, 145, 0.7);
  --text: #ffffffe7;
  --button-text: #edf5f1;
}

body[data-colorway="gold"] {
  --shell: #d4af37;
  --shell-dark: #8f6d12;
  --button: #f0cf58;
  --button-dark: #8f6d12;
  --bezel: #b88a19;
  --text: #5f470c;
  --button-text: #5f470c;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #d9e0dc;
  font-family: Arial, Helvetica, sans-serif;
}

.toy {
  position: relative;
  width: min(88vw, 370px);
  aspect-ratio: 0.76;
  padding: 36px 34px;
  border: 3px solid var(--shell-dark);
  border-radius: 34px;
  background: var(--shell);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.12),
    0 12px 24px rgba(45, 56, 51, 0.22);
}

body[data-colorway="transparent"] .toy {
  background:
    linear-gradient(rgba(220, 235, 231, 0.58), rgba(189, 215, 208, 0.62)),
    url("circuits.jpg") center / 600px 500px repeat;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.35),
    inset 0 0 24px rgba(54, 101, 95, 0.22),
    0 12px 24px rgba(45, 56, 51, 0.22);
}

body[data-colorway="transparent"] .screen-bezel {
  background: rgba(93, 136, 130, 0.68);
  backdrop-filter: blur(2px);
}

body[data-colorway="transparent"] .round-button {
  backdrop-filter: blur(2px);
}

body[data-colorway="gold"] .toy {
  box-shadow:
    inset 0 0 0 2px rgba(255, 246, 177, 0.42),
    inset 0 0 20px rgba(105, 74, 8, 0.18),
    0 12px 24px rgba(78, 58, 12, 0.28);
}

.brand {
  position: relative;
  top: -8px;
  height: 42px;
  color: var(--text);
  text-align: left;
  font-weight: 700;
  font-size: 20px;
  line-height: 18px;
  letter-spacing: 1px;
}

.brand-j {
  color: inherit;
}

.brand small {
  display: block;
  margin-top: 3px;
  margin-left: 0;
  color: color-mix(in srgb, var(--text) 70%, transparent);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.screen-bezel {
  position: relative;
  width: 100%;
  aspect-ratio: 1.06;
  padding: 23px;
  border: 3px solid #624d30;
  border-radius: 14px;
  background: var(--bezel);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.screen-bezel::after {
  content: "";
  position: absolute;
  inset: 15px;
  z-index: 1;
  pointer-events: none;
  border: 1px solid rgba(75, 92, 53, 0.45);
  border-radius: 4px;
}

#lcd {
  display: block;
  width: 100%;
  height: 100%;
  border: 5px solid #4d563e;
  border-radius: 3px;
  background: var(--lcd);
  box-shadow: inset 0 2px 5px rgba(52, 65, 43, 0.4);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.controls {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 118px;
  padding: 0 4px;
}

.round-button {
  position: relative;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 3px solid var(--button-dark);
  border-radius: 50%;
  background: var(--button);
  color: var(--button-text);
  font: 700 20px/1 Arial, sans-serif;
  box-shadow: 0 4px 0 var(--button-dark);
  cursor: pointer;
  touch-action: manipulation;
}

.round-button:hover {
  background: #c3633b;
}

.round-button:active,
.round-button.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--button-dark);
}

.round-button:focus-visible {
  outline: 3px solid #fff7c2;
  outline-offset: 3px;
}

.speaker {
  position: absolute;
  right: 36px;
  bottom: 25px;
  display: flex;
  gap: 5px;
}

.sound-wave {
  position: absolute;
  top: 50%;
  left: -10px;
  width: 5px;
  height: 12px;
  border: 2px solid rgba(89, 59, 29, 0.7);
  border-right: 0;
  border-radius: 10px 0 0 10px;
  opacity: 0;
  transform: translateY(-50%) scale(0.5);
}

.sound-wave-two {
  left: -18px;
  width: 9px;
  height: 22px;
}

.speaker.beeping .sound-wave-one {
  animation: speaker-wave 180ms ease-out;
}

.speaker.beeping .sound-wave-two {
  animation: speaker-wave 240ms 30ms ease-out;
}

@keyframes speaker-wave {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.45);
  }

  35% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-50%) scale(1);
  }
}

.volume-control {
  position: absolute;
  left: 34px;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: color-mix(in srgb, var(--text) 78%, transparent);
  font: 700 8px/1 Arial, sans-serif;
  letter-spacing: 1px;
}

.volume-slider {
  width: 62px;
  height: 14px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.volume-slider::-webkit-slider-runnable-track {
  height: 5px;
  border: 1px solid rgba(89, 59, 29, 0.75);
  border-radius: 3px;
  background: var(--bezel);
}

.volume-slider::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -5px;
  appearance: none;
  border: 2px solid var(--button-dark);
  border-radius: 50%;
  background: var(--button);
}

.volume-slider::-moz-range-track {
  height: 3px;
  border: 1px solid rgba(89, 59, 29, 0.75);
  border-radius: 3px;
  background: var(--bezel);
}

.volume-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 2px solid var(--button-dark);
  border-radius: 50%;
  background: var(--button);
}

.volume-slider:focus-visible {
  outline: 2px solid #fff7c2;
  outline-offset: 2px;
}

.speaker i {
  display: block;
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: rgba(89, 59, 29, 0.65);
}

.help-button {
  position: fixed;
  right: 20px;
  bottom: 54px;
  padding: 9px 12px;
  border: 2px solid #624d30;
  border-radius: 5px;
  background: var(--shell);
  color: var(--text);
  font: 700 10px/1 Arial, sans-serif;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--shell-dark);
}

.reset-button {
  position: fixed;
  right: 20px;
  bottom: 90px;
  padding: 9px 12px;
  border: 2px solid #624d30;
  border-radius: 5px;
  background: #b95832;
  color: #f0d6b4;
  font: 700 10px/1 Arial, sans-serif;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 3px 0 #783923;
}

.help-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--shell-dark);
}

.reset-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #783923;
}

.help-button:focus-visible,
.reset-button:focus-visible,
.colorway-swatch:focus-visible,
.instructions-dialog button:focus-visible,
.reset-dialog button:focus-visible {
  outline: 3px solid #fff7c2;
  outline-offset: 2px;
}

.colorway-control {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #493d2c;
  font: 700 9px/1 Arial, sans-serif;
  letter-spacing: 1px;
}

.colorway-swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 2px solid #624d30;
  border-radius: 50%;
  cursor: pointer;
}

.colorway-swatch.selected {
  outline: 2px solid #26342c;
  outline-offset: 2px;
}

.colorway-swatch.amber {
  background: #d89432;
}

.colorway-swatch.blue {
  background: #4f839e;
}

.colorway-swatch.green {
  background: #718c58;
}

.colorway-swatch.graphite {
  background: #626767;
}

.colorway-swatch.gameboy {
  background: #c7c5ad;
  box-shadow: inset 0 0 0 2px #8f234f;
}

.colorway-swatch.transparent {
  background:
    linear-gradient(rgba(220, 235, 231, 0.45), rgba(189, 215, 208, 0.5));
}

.colorway-swatch.gold {
  background: #d4af37;
  box-shadow: inset 0 0 0 4px #f0cf58;
}

.instructions-dialog,
.reset-dialog {
  width: min(90vw, 430px);
  padding: 24px;
  border: 3px solid #624d30;
  border-radius: 10px;
  background: #d9e0dc;
  color: #26342c;
  box-shadow: 0 16px 36px rgba(45, 56, 51, 0.35);
}

.instructions-dialog::backdrop,
.reset-dialog::backdrop {
  background: rgba(38, 52, 44, 0.55);
}

.instructions-dialog h1,
.reset-dialog h1 {
  margin: 0 0 14px;
  color: #493d2c;
  font-size: 20px;
  letter-spacing: 1px;
}

.instructions-dialog p,
.instructions-dialog dd,
.reset-dialog p {
  font-size: 13px;
  line-height: 1.45;
}

.instructions-dialog dl {
  margin: 18px 0;
}

.instructions-dialog dt {
  margin-top: 10px;
  color: #783923;
  font-size: 12px;
  font-weight: 700;
}

.instructions-dialog dd {
  margin: 2px 0 0;
}

.instructions-dialog form,
.reset-dialog form {
  margin-top: 20px;
  text-align: right;
}

.instructions-dialog button,
.reset-dialog button {
  padding: 8px 12px;
  border: 2px solid #783923;
  border-radius: 4px;
  background: #b95832;
  color: #f0d6b4;
  font-weight: 700;
  cursor: pointer;
}

.reset-dialog .confirm-reset {
  margin-left: 8px;
  background: #783923;
}

@media (max-height: 650px) {
  .toy {
    width: min(68vh, 340px);
  }
}

@media (max-width: 600px) {
  .toy {
    transform: translateY(-70px);
  }
}
