:root { color-scheme: dark; font-family: system-ui, sans-serif; background: #171d17; color: #f1eee2; }
body { margin: 0; }
main { width: min(60rem, 100% - 2rem); margin: 3rem auto; }
main:has(#stage:not([hidden])) { width: 100%; margin: 0; }
body:has(#stage:not([hidden])) { overflow: hidden; background: #000; }
h1 { margin-top: 0; }
label { display: block; margin-bottom: 0.5rem; }
button, input { font: inherit; }
button { padding: 0.5rem 0.85rem; margin: 0.5rem 0.25rem 0.5rem 0; }
#stage:not([hidden]) {
  position: relative;
  display: block;
  width: 100%;
  height: 100dvh;
  background: #000;
}
#stage:fullscreen { width: 100%; height: 100%; }
#screen-wrap {
  position: relative;
  container-type: size;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}
#screen {
  display: block;
  width: min(100cqw, 100cqh * var(--game-aspect, 1.3333333333333333));
  height: auto;
  background: #000;
  image-rendering: auto;
  outline: none;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
}
#screen[data-integer-scale] { image-rendering: pixelated; }
#screen[data-scaled-display] { opacity: 0; }
#scaled-screen { position: absolute; pointer-events: none; }
#fullscreen {
  position: absolute;
  z-index: 1;
  padding: 0;
  margin: 0;
  border: max(1px, .095cqw) solid #bb9753;
  border-radius: 16% 48% 48% 16% / 16% 50% 50% 16%;
  background: linear-gradient(#7b7050 0%, #343a36 33%, #25312b 67%, #574d32 100%);
  box-shadow: inset 0 0 0 max(1px, .06cqw) #342a1a, inset 0 0 .22cqw #f5dea0, 0 1px 1px #162218;
  cursor: pointer;
}
#fullscreen::before, #fullscreen::after { content: ''; position: absolute; }
#fullscreen::before {
  inset: 19% 24% 19% 18%;
  border: 1px solid #718597;
  border-radius: 14%;
  background: linear-gradient(135deg, #627d98, #1c3155 60%, #34547f);
  box-shadow: 0 1px 2px #111917;
}
#fullscreen::after {
  inset: 32% 35% 32% 29%;
  color: #f6e9bc;
  background:
    linear-gradient(currentColor, currentColor) left top / 34% 15%,
    linear-gradient(currentColor, currentColor) left top / 15% 34%,
    linear-gradient(currentColor, currentColor) right top / 34% 15%,
    linear-gradient(currentColor, currentColor) right top / 15% 34%,
    linear-gradient(currentColor, currentColor) left bottom / 34% 15%,
    linear-gradient(currentColor, currentColor) left bottom / 15% 34%,
    linear-gradient(currentColor, currentColor) right bottom / 34% 15%,
    linear-gradient(currentColor, currentColor) right bottom / 15% 34%;
  background-repeat: no-repeat;
}
#fullscreen:is(:hover, :focus-visible, [aria-pressed='true']) { border-color: #f4d482; }
#fullscreen:hover { filter: brightness(1.2); }
#stage[data-touch-input]:not([hidden]) { height: var(--touch-viewport-height, 100dvh); }
#stage[data-touch-input]:fullscreen { height: var(--touch-viewport-height, 100%); }
#stage[data-touch-input] #fullscreen { display: none; }
#touch-actions:not([hidden]) {
  position: absolute;
  z-index: 1;
  display: flex;
  gap: .375rem;
  top: max(.5rem, env(safe-area-inset-top));
  right: max(.5rem, env(safe-area-inset-right));
  pointer-events: none;
}
#touch-actions button {
  min-height: 44px;
  min-width: 44px;
  margin: 0;
  padding: .375rem .5rem;
  border: 1px solid #ac9b6d;
  border-radius: .375rem;
  color: #f1eee2;
  background: #252d22;
  font-size: .875rem;
  pointer-events: auto;
  touch-action: manipulation;
}
#touch-actions button[aria-pressed='true'] { background: #4b553a; }
#mobile-keyboard-proxy {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  pointer-events: none;
}
#capture-status, main:has(#stage:not([hidden])) > #status {
  position: fixed;
  z-index: 2;
  top: 0.75rem;
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
  padding: 0.5rem 0.75rem;
  background: #171d17;
}
main:has(#stage:not([hidden])) > .launcher-tools { display: none; }
pre { max-height: 16rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
details { margin-top: 1rem; }
details label { margin-top: 0.75rem; }
