/* Dugout Nine: a studio photograph of a handheld you can play. The object is
   built from gradients, moulded shadows and a little noise; the only bitmap
   is the LCD canvas itself. */
:root {
  --studio: #141114;
  --studio-warm: #2e231e;
  --case-hi: #f2e6cf;
  --case: #e2cfad;
  --case-lo: #b99a72;
  --grip: #8b5a34;
  --grip-lo: #56361f;
  --bezel: #221f1c;
  --bezel-hi: #3b352e;
  --key: #d64a33;
  --key-hi: #f17955;
  --key-lo: #8d2a1d;
  --print: #46331f;
  --red: #a83224;
  --cream: #f6e8cd;
  --mono: "JetBrains Mono Variable", ui-monospace, monospace;
  --text: "Fraunces Variable", "Iowan Old Style", Georgia, serif;
  --display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Space Grotesk Variable", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background:
    radial-gradient(ellipse 70% 55% at 50% 36%, rgba(255, 182, 110, 0.15), transparent 70%),
    radial-gradient(ellipse 80% 70% at 50% 40%, var(--studio-warm) 0%, var(--studio) 55%, #0b090b 100%);
  color: var(--cream);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 245, 225, 0.055) 0.55px, transparent 0.7px);
  background-size: 3px 3px;
  opacity: 0.55;
  mix-blend-mode: overlay;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 38%, rgba(4, 3, 5, 0.6) 100%);
}
button {
  font: inherit;
  color: inherit;
}
[hidden] {
  display: none !important;
}

.room {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  perspective: 1400px;
}
.device-shadow {
  position: absolute;
  left: 50%;
  top: 54%;
  width: min(1040px, 86vw);
  height: 15%;
  transform: translate(-50%, -30%);
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.72), transparent 68%);
  filter: blur(18px);
  pointer-events: none;
}

.device {
  position: relative;
  width: min(1120px, 94vw);
  aspect-ratio: 1.56;
  border-radius: 4.5% / 7.2%;
  transform: rotate(-1.15deg);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.34), transparent 28%),
    linear-gradient(180deg, var(--case-hi) 0%, var(--case) 55%, var(--case-lo) 100%);
  box-shadow:
    0 2.6% 5.2% rgba(0, 0, 0, 0.55),
    0 0.6% 1.2% rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(255, 250, 236, 0.55),
    inset 0 -3.6% 5.4% rgba(97, 63, 35, 0.3),
    inset 0 1.2% 2% rgba(255, 255, 255, 0.4);
  isolation: isolate;
  container-type: inline-size;
}
.device::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(255, 250, 236, 0.7) 0.55px, transparent 0.8px),
    radial-gradient(rgba(90, 58, 33, 0.16) 0.55px, transparent 0.8px);
  background-size: 5px 5px, 7px 7px;
  background-position: 0 0, 3px 4px;
  opacity: 0.2;
  mix-blend-mode: soft-light;
}
.device::after {
  content: "";
  position: absolute;
  inset: 1.4% 1.2%;
  border-radius: 4% / 6.4%;
  pointer-events: none;
  box-shadow:
    inset 0 0.7% 1.1% rgba(255, 255, 255, 0.4),
    inset 0 -0.7% 1.2% rgba(83, 52, 27, 0.28);
}

/* Moulded wordmark and the small print on the case */
.brand {
  position: absolute;
  left: 6.4%;
  top: 4.2%;
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  z-index: 2;
}
.brand strong {
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(18px, 2.5vw, 38px);
  letter-spacing: 0.16em;
  line-height: 0.9;
  color: #5b4326;
  text-shadow:
    0 -1px 0 rgba(255, 250, 236, 0.72),
    0 1px 0 rgba(90, 58, 33, 0.25);
}
.brand span {
  font-family: var(--mono);
  font-size: clamp(6px, 0.74vw, 10px);
  letter-spacing: 0.2em;
  color: rgba(70, 51, 31, 0.62);
}
.red-rule {
  position: absolute;
  left: 6.4%;
  top: 15.4%;
  width: 13%;
  height: 0.7%;
  background: var(--red);
  opacity: 0.8;
  border-radius: 99px;
}

/* The recessed LCD */
.bezel {
  position: absolute;
  left: 14.8%;
  top: 50%;
  width: 65.2%;
  aspect-ratio: 640 / 440;
  transform: translateY(-50%);
  padding: 1.05%;
  border-radius: 2.6% / 3.8%;
  background:
    linear-gradient(155deg, #4b4339 0%, var(--bezel-hi) 12%, var(--bezel) 44%, #171513 100%);
  box-shadow:
    inset 0 0.8% 1.4% rgba(255, 255, 255, 0.18),
    inset 0 -0.9% 1.5% rgba(0, 0, 0, 0.6),
    0 0.5% 1.1% rgba(255, 250, 236, 0.42),
    0 1.6% 2.4% rgba(60, 36, 17, 0.35);
  z-index: 2;
}
.screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 1.4% / 2.2%;
  overflow: hidden;
  background: #aab68a;
  box-shadow:
    inset 0 0 0 1px rgba(20, 26, 13, 0.7),
    inset 0 1.5% 2.6% rgba(41, 51, 28, 0.35),
    inset 0 -1% 2% rgba(41, 51, 28, 0.25);
}
#lcd {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(116deg, rgba(255, 255, 255, 0.24) 0%, rgba(255, 255, 255, 0.05) 21%, transparent 38%),
    radial-gradient(ellipse 60% 36% at 26% 8%, rgba(255, 255, 255, 0.18), transparent 70%);
  mix-blend-mode: screen;
}
.screen-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3.2%;
  text-align: center;
  font-family: var(--mono);
  font-size: clamp(6px, 0.72vw, 10px);
  letter-spacing: 0.24em;
  color: rgba(246, 232, 205, 0.62);
}
.power {
  position: absolute;
  right: 2.2%;
  top: 2.2%;
  width: 0.9%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #8b2f22;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 0 0.8vw 0.1vw rgba(255, 89, 49, 0.55);
}

/* A moulded grip panel behind the keys */
.grip-panel {
  position: absolute;
  right: 1.15%;
  top: 10.5%;
  width: 19.4%;
  height: 79%;
  border-radius: 5.5% / 4.2%;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.2), transparent 34%),
    linear-gradient(180deg, #9c6a3e 0%, #7d4f2c 58%, #5f3a20 100%);
  box-shadow:
    inset 0 0.7% 1.2% rgba(255, 236, 201, 0.26),
    inset 0 -1% 1.8% rgba(38, 20, 9, 0.5),
    0 0.4% 0.9% rgba(255, 250, 236, 0.35);
  z-index: 1;
}

/* The two play keys and the small sound switch */
.controls {
  position: absolute;
  right: 3.2%;
  top: 14.5%;
  width: 15.2%;
  height: 70%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 2.4%;
  z-index: 3;
}
.key {
  position: relative;
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 0.12em;
  border-radius: 999px;
  background:
    radial-gradient(circle at 34% 28%, var(--key-hi) 0%, var(--key) 52%, var(--key-lo) 100%);
  color: #f9e8d2;
  box-shadow:
    0 1.1% 1.8% rgba(56, 20, 12, 0.55),
    0 0.35% 0.5% rgba(255, 255, 255, 0.5),
    inset 0 0.35% 0.4% rgba(255, 255, 255, 0.42),
    inset 0 -0.7% 1.1% rgba(74, 17, 10, 0.55);
  transition: transform 90ms ease, box-shadow 90ms ease, filter 90ms ease;
  touch-action: manipulation;
}
.key.swing {
  width: 100%;
  aspect-ratio: 1;
  margin-bottom: 3%;
}
.key.swing span {
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(10px, 1.55vw, 21px);
  letter-spacing: 0.13em;
}
.key.swing small {
  font-family: var(--mono);
  font-size: clamp(5px, 0.62vw, 9px);
  letter-spacing: 0.24em;
  opacity: 0.72;
}
.key.small {
  min-height: 44px;
  border-radius: 40% / 32%;
  background:
    radial-gradient(circle at 36% 26%, #5b5144 0%, #312b25 55%, #181512 100%);
  color: var(--cream);
  box-shadow:
    0 0.8% 1.2% rgba(40, 22, 10, 0.5),
    inset 0 0.35% 0.4% rgba(255, 255, 255, 0.22),
    inset 0 -0.6% 0.9% rgba(0, 0, 0, 0.5);
}
.key.small span {
  font-family: var(--mono);
  font-size: clamp(7px, 0.78vw, 10px);
  letter-spacing: 0.12em;
}
.key.small small {
  font-family: var(--mono);
  font-size: clamp(8px, 0.86vw, 11px);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ffc79a;
}
.key:active,
.key.lit {
  transform: translateY(1.4%) scale(0.975);
  filter: saturate(1.15) brightness(1.08);
  box-shadow:
    0 0.35% 0.7% rgba(56, 20, 12, 0.6),
    inset 0 0.25% 0.3% rgba(255, 255, 255, 0.3),
    inset 0 -0.4% 0.8% rgba(74, 17, 10, 0.5);
}
.key:focus-visible,
.hud button:focus-visible {
  outline: 3px solid #ffd59a;
  outline-offset: 3px;
}
.key.small[aria-pressed="true"] small {
  color: #baf0c1;
}

/* Speaker holes and the case screws */
.speaker {
  position: absolute;
  left: 4.6%;
  bottom: 8%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.55vw;
  width: 13%;
  opacity: 0.72;
}
.speaker i {
  display: block;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #4d3520;
  box-shadow:
    inset 0 1px 1px rgba(0, 0, 0, 0.55),
    0 0.5px 0 rgba(255, 247, 225, 0.45);
}
.screw {
  position: absolute;
  width: 1.05%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #f4e8d3, #b08c62 62%, #74512f);
  box-shadow: inset 0 0.5px 1px rgba(70, 44, 22, 0.55);
  z-index: 4;
}
.screw::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: 46%;
  height: 8%;
  background: #6c4a2a;
  transform: rotate(28deg);
}
.screw.tl { left: 2.2%; top: 3%; }
.screw.tr { right: 2.2%; top: 3%; }
.screw.bl { left: 2.2%; bottom: 4%; }
.screw.br { right: 2.2%; bottom: 4%; }

.model-line {
  position: absolute;
  left: 6.4%;
  bottom: 4.4%;
  font-family: var(--mono);
  font-size: clamp(6px, 0.74vw, 10px);
  letter-spacing: 0.19em;
  color: rgba(70, 51, 31, 0.72);
}
.case-rules {
  display: none;
}

.sample-note {
  position: absolute;
  right: 4.2%;
  bottom: 4.4%;
  font-family: var(--mono);
  font-size: clamp(6px, 0.7vw, 9.5px);
  letter-spacing: 0.08em;
  color: rgba(70, 51, 31, 0.84);
}

/* Page layer: a small caption and the only page-level controls */
.ui {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  padding:
    max(18px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}
.ui > * {
  pointer-events: auto;
}
.hud {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}
.hud button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(246, 232, 205, 0.22);
  border-radius: 999px;
  background: rgba(24, 19, 18, 0.72);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 120ms ease, border-color 120ms ease;
}
.hud button:hover {
  background: rgba(52, 40, 33, 0.92);
  border-color: rgba(255, 213, 154, 0.5);
}
.hud button[aria-pressed="true"] {
  border-color: rgba(255, 213, 154, 0.7);
  color: #ffd59a;
}
.caption {
  position: absolute;
  left: max(22px, env(safe-area-inset-left));
  top: max(16px, env(safe-area-inset-top));
  max-width: min(390px, 46vw);
  display: grid;
  gap: 2px;
}
.caption-foot {
  position: absolute;
  left: max(22px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  max-width: min(390px, 42vw);
  display: grid;
  gap: 3px;
}
.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 213, 154, 0.9);
}
.caption h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(26px, 2.55vw, 38px);
  line-height: 1;
  letter-spacing: 0.01em;
  color: #f8ecd4;
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.45);
}
.caption p {
  margin: 0;
  font-family: var(--text);
  font-size: clamp(12px, 1.05vw, 15px);
  line-height: 1.35;
  color: rgba(246, 232, 205, 0.8);
}
.caption-foot p {
  margin: 0;
  font-family: var(--text);
  font-size: clamp(12px, 1vw, 14px);
  line-height: 1.35;
  color: rgba(246, 232, 205, 0.8);
}
.caption-foot .note {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: rgba(246, 232, 205, 0.64);
}
.status {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #ffd59a;
}
.hint {
  position: absolute;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(246, 232, 205, 0.66);
  white-space: nowrap;
}
.fatal {
  position: fixed;
  inset: auto 20px 20px;
  font-family: var(--mono);
  font-size: 12px;
  color: #ffd59a;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The release renderer wants only the object, edge to edge */
body.capture .ui {
  display: none;
}
body.capture .device {
  transform: rotate(calc(-1.15deg + var(--drift, 0deg))) scale(var(--zoom, 1));
}

@media (max-width: 700px) {
  .device {
    transform: none;
    width: 96vw;
  }
  .caption {
    max-width: 68vw;
  }
  .hint {
    display: none;
  }
  .speaker {
    gap: 4px;
  }
  .bezel {
    left: 12.4%;
    width: 67.5%;
  }
  .controls {
    right: 2.8%;
    width: 15.6%;
  }
}
@media (max-width: 700px) {
  .caption-foot {
    display: none;
  }
}
@media (max-width: 460px) {
  .caption {
    max-width: calc(100vw - 44px);
  }
  .caption h1 {
    font-size: 30px;
  }
  .caption p {
    font-size: 12px;
  }
  .status {
    font-size: 11px;
  }
  .hud button {
    padding: 0 10px;
    font-size: 10px;
  }
}
@media (max-width: 560px) and (orientation: portrait) {
  body.capture .device {
    transform: translate(-50%, -50%) rotate(var(--drift, 0deg)) scale(var(--zoom, 1));
  }
  .room {
    display: block;
  }
  .device-shadow {
    display: none;
  }
  .device {
    position: absolute;
    left: 50%;
    top: 52%;
    width: min(92vw, 48vh);
    aspect-ratio: 0.62;
    transform: translate(-50%, -50%);
    border-radius: 8% / 5%;
  }
  .device::after {
    border-radius: 7.4% / 4.6%;
  }
  .brand {
    left: 7%;
    top: 3.6%;
  }
  .brand strong {
    font-size: clamp(22px, 7.4vw, 34px);
  }
  .brand span {
    font-size: 6.5px;
  }
  .red-rule {
    left: 7%;
    top: 10.4%;
    width: 21%;
    height: 0.55%;
  }
  .bezel {
    left: 7%;
    top: 12.5%;
    width: 86%;
    transform: none;
    padding: 1.5%;
  }
  .screen-caption {
    bottom: -6.5%;
    font-size: 5.5px;
  }
  .grip-panel {
    display: none;
  }
  .controls {
    left: 12%;
    right: auto;
    top: 52%;
    width: 76%;
    height: 23%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 3%;
  }
  .key.swing {
    width: 30%;
    margin: 0;
  }
  .key.swing span {
    font-size: 13px;
  }
  .key.swing small {
    font-size: 7px;
  }
  .key.small {
    width: 30%;
    aspect-ratio: 1;
    min-height: 44px;
  }
  .key.small span {
    font-size: 10px;
  }
  .key.small small {
    font-size: 11px;
  }
  .speaker {
    display: none;
  }
  .case-rules {
    display: block;
    position: absolute;
    left: 8%;
    top: 77%;
    width: 84%;
    padding-top: 2.2%;
    border-top: 1px solid rgba(70, 51, 31, 0.32);
    color: rgba(70, 51, 31, 0.74);
  }
  .case-rules span {
    display: block;
    font-family: var(--mono);
    font-size: 7px;
    letter-spacing: 0.16em;
    margin-bottom: 3px;
  }
  .case-rules p {
    margin: 0;
    font-family: var(--mono);
    font-size: 7.5px;
    line-height: 1.45;
    letter-spacing: 0.01em;
  }
  .model-line {
    left: 8%;
    bottom: 3%;
    font-size: 6px;
  }
  .sample-note {
    right: 8%;
    bottom: 6.4%;
    font-size: 7.5px;
    color: rgba(70, 51, 31, 0.88);
  }
  .screw {
    width: 1.7%;
  }
  .screw.tl { left: 3%; top: 1.6%; }
  .screw.tr { right: 3%; top: 1.6%; }
  .screw.bl { left: 3%; bottom: 2%; }
  .screw.br { right: 3%; bottom: 2%; }

  .caption {
    left: max(20px, env(safe-area-inset-left));
    top: max(16px, env(safe-area-inset-top));
    max-width: 78vw;
  }
  .caption h1 {
    font-size: 30px;
  }
  .caption p {
    display: none;
  }
  .caption .status {
    display: block;
    margin-top: 4px;
    font-size: 11px;
  }
  .hud {
    top: auto;
    bottom: max(14px, env(safe-area-inset-bottom));
    right: max(16px, env(safe-area-inset-right));
  }
  .hint {
    display: none;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .device {
    width: min(94vw, 138vh);
  }
  .caption {
    display: none;
  }
  .hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .key {
    transition: none;
  }
}
