:root {
  color-scheme: light;
  --shell: #b8cf72;
  --shell-dark: #8fa452;
  --screen: #151915;
  --screen-glass: #273326;
  --ink: #263321;
  --muted: #647259;
  --button: #30383e;
  --button-hi: #44505a;
  --accent: #d94d74;
  --accent-dark: #983a57;
  --cream: #f4f3df;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, 0.24), transparent 24%),
    linear-gradient(145deg, #dfe8a1 0%, #81a365 48%, #486a62 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
}

button,
select {
  font: inherit;
}

button,
.gamepad {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.console-shell {
  position: relative;
  width: min(100vw, 440px);
  height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.28), transparent 30%),
    var(--shell);
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  border-right: 1px solid rgba(0, 0, 0, 0.22);
  box-shadow: 0 24px 70px rgba(23, 37, 25, 0.4);
}

.viewer-bezel {
  align-self: start;
  display: grid;
  grid-template-rows: auto auto;
  gap: 10px;
  padding: 14px;
  border-radius: 22px 22px 34px 34px;
  background: #d9dfba;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.55),
    inset 0 -5px 0 rgba(67, 83, 43, 0.18),
    0 10px 24px rgba(28, 43, 25, 0.24);
}

.brand-row {
  min-height: 24px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  color: #33412f;
  letter-spacing: 0;
}

.power-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #dc405d;
  box-shadow: 0 0 12px rgba(220, 64, 93, 0.8);
}

.brand {
  font-size: 18px;
  font-weight: 800;
}

.viewer {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 0;
  overflow: hidden;
  border: 10px solid #3a4350;
  border-radius: 12px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.05) 50%, rgba(0, 0, 0, 0.06) 50%) 0 0 / 100% 4px,
    radial-gradient(circle at center, var(--screen-glass), var(--screen));
  box-shadow:
    inset 0 0 35px rgba(0, 0, 0, 0.65),
    0 4px 0 rgba(255, 255, 255, 0.3);
  touch-action: none;
}

.viewer canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.loading-overlay {
  position: absolute;
  left: 50%;
  bottom: 22px;
  width: min(78%, 280px);
  display: grid;
  gap: 9px;
  transform: translateX(-50%);
  padding: 11px 12px 12px;
  border: 1px solid rgba(216, 238, 176, 0.26);
  border-radius: 8px;
  background: rgba(5, 8, 6, 0.62);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.loading-overlay.is-hidden {
  display: none;
}

.loading-label {
  color: #d9efb5;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.4;
  text-align: center;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(229, 246, 190, 0.25);
  border-radius: 999px;
  background: rgba(15, 22, 16, 0.82);
}

.progress-fill {
  width: 0%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, #d9ef8d, #75d7b8, #f16d96);
  box-shadow: 0 0 12px rgba(217, 239, 141, 0.42);
  transition: width 160ms ease;
}

.progress-track.is-indeterminate .progress-fill {
  width: 42%;
  animation: loading-slide 1.15s ease-in-out infinite;
}

@keyframes loading-slide {
  0% {
    transform: translateX(-105%);
  }

  100% {
    transform: translateX(245%);
  }
}

.control-deck {
  position: relative;
  padding: 4px 2px 0;
}

.scene-menu {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 0;
  z-index: 10;
  overflow: hidden;
  border: 2px solid rgba(53, 66, 47, 0.35);
  border-radius: 8px;
  background: var(--cream);
  box-shadow: 0 12px 24px rgba(36, 48, 33, 0.24);
}

.scene-option {
  width: 100%;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 750;
}

.scene-option + .scene-option {
  border-top: 1px solid rgba(53, 66, 47, 0.16);
}

.scene-option[aria-selected="true"],
.scene-option:active {
  background: rgba(184, 207, 114, 0.42);
}

.gamepad {
  min-height: 172px;
  display: grid;
  grid-template-columns: 142px 1fr 132px;
  align-items: center;
  gap: 10px;
}

.debug-readout {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: max(10px, env(safe-area-inset-bottom));
  margin: 0;
  color: rgba(38, 51, 33, 0.72);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  word-break: break-word;
}

.dpad {
  width: 132px;
  height: 132px;
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 0;
  filter: drop-shadow(0 6px 0 rgba(39, 49, 42, 0.28));
}

.pad-btn {
  border: 0;
  border-radius: 50%;
  background: var(--button);
  color: #dfe6d6;
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.12);
}

.pad-btn:active,
.pad-btn.is-pressed {
  background: var(--button-hi);
  transform: translateY(2px);
}

.pad-up {
  grid-column: 2;
  grid-row: 1;
}

.pad-left {
  grid-column: 1;
  grid-row: 2;
}

.pad-center {
  grid-column: 2;
  grid-row: 2;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.pad-center:active {
  transform: none;
}

.pad-right {
  grid-column: 3;
  grid-row: 2;
}

.pad-down {
  grid-column: 2;
  grid-row: 3;
}

.system-pill {
  align-self: end;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(2, 44px);
  gap: 10px;
  padding-bottom: 26px;
}

.system-button {
  width: 44px;
  min-height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: rgba(38, 51, 33, 0.62);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-align: center;
}

.system-button::before {
  width: 36px;
  height: 9px;
  display: block;
  border-radius: 999px;
  background: rgba(50, 60, 49, 0.42);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.2);
  content: "";
}

.system-button span {
  margin-top: 4px;
}

.system-button:active::before,
.system-button.is-pressed::before {
  background: rgba(50, 60, 49, 0.62);
}

.system-button:disabled {
  opacity: 0.45;
}

.system-button:disabled::before {
  background: rgba(50, 60, 49, 0.26);
}

.ab-cluster {
  width: 124px;
  height: 92px;
  display: grid;
  grid-template-columns: repeat(2, 56px);
  gap: 10px;
  align-items: center;
  transform: rotate(-18deg);
}

.round-btn {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #ffe8ef;
  font-size: 17px;
  font-weight: 900;
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.18),
    0 7px 0 var(--accent-dark),
    0 12px 18px rgba(43, 32, 42, 0.28);
}

.round-btn:active,
.round-btn.is-pressed {
  transform: translateY(5px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.14),
    0 2px 0 var(--accent-dark),
    0 8px 12px rgba(43, 32, 42, 0.22);
}

.round-btn-a {
  align-self: start;
}

@media (max-height: 680px) {
  .console-shell {
    gap: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .viewer-bezel {
    padding: 12px;
  }

  .gamepad {
    min-height: 142px;
    transform: scale(0.92);
    transform-origin: top center;
  }
}
