/* Arcade showcase: variance 5 / motion 3 / density 3.
   Layers: canvases 0, comparison 1, loading 2, full-screen controls 3.
   The native dialog uses the browser's top layer. */
:root {
  color-scheme: light dark;
  --bg: #eeefed;
  --surface: #fafbf8;
  --text: #202421;
  --muted: #5c645f;
  --line: #d2d7cf;
  --accent: #a33e20;
  --accent-text: #fff8ed;
  --hover: #e4e8df;
  --track: #c8cec4;
  --screen-bg: #101613;
  --screen-text: #f9f8ee;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151916;
    --surface: #202621;
    --text: #f0f1e9;
    --muted: #aab5ac;
    --line: #39443b;
    --accent: #f4a67f;
    --accent-text: #28170e;
    --hover: #303b31;
    --track: #4e5c4f;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
main {
  max-width: 1160px;
  margin: auto;
  padding: 24px 32px 16px;
}
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
h1 {
  font-size: 32px;
  letter-spacing: -0.055em;
  line-height: 1;
  margin: 0;
  font-weight: 850;
}
h1 span {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--muted);
  margin-left: 14px;
  vertical-align: middle;
}
.identity p {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}
a {
  color: inherit;
  text-underline-offset: 4px;
}
.source-link {
  font-size: 12px;
  white-space: nowrap;
}
button,
select,
input {
  font: inherit;
}
button,
select {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
button {
  cursor: pointer;
  padding: 10px 13px;
  font-size: 12px;
  font-weight: 600;
  min-height: 40px;
  white-space: nowrap;
}
button:hover:not(:disabled) {
  background: var(--hover);
}
button:active:not(:disabled) {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
button.primary:hover:not(:disabled) {
  filter: brightness(0.94);
  background: var(--accent);
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
.playground {
  scroll-margin-block: 12px;
  width: min(100%, calc((100svh - 278px) * 4 / 3));
  min-width: min(100%, 600px);
  max-width: 1000px;
  margin: auto;
}
.comparison {
  padding: 0 0 12px;
}
.comparison-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.comparison h2 {
  font-size: 19px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.025em;
  margin: 0;
}
.comparison-track {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}
.view-end {
  padding: 0;
  min-width: 40px;
  border: 0;
  background: transparent;
  font-size: 12px;
  letter-spacing: 0.06em;
}
#wipe {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 40px;
  margin: 0;
  background: transparent;
  cursor: ew-resize;
  touch-action: pan-y;
}
#wipe::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 4px;
  background: var(--track);
}
#wipe::-moz-range-track {
  height: 6px;
  border-radius: 4px;
  background: var(--track);
}
#wipe::-webkit-slider-thumb {
  appearance: none;
  width: 30px;
  height: 30px;
  margin-top: -12px;
  border-radius: 50%;
  border: 5px solid var(--surface);
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
#wipe::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 5px solid var(--surface);
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
#comparison-help {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  margin: -2px 0 0;
}
#stage {
  position: relative;
  aspect-ratio: 4/3;
  width: 100%;
  background: var(--screen-bg);
  overflow: hidden;
  border-radius: 8px 8px 0 0;
  isolation: isolate;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}
#original,
#preview-cga {
  position: absolute;
  inset: 0;
  pointer-events: none;
  image-rendering: pixelated;
  clip-path: inset(0 50% 0 0);
}
#divider {
  position: absolute;
  width: 40px;
  background: linear-gradient(
    to right,
    transparent calc(50% - 1px),
    #fff6dc calc(50% - 1px),
    #fff6dc calc(50% + 1px),
    transparent calc(50% + 1px)
  );
  pointer-events: auto;
  touch-action: none;
  cursor: ew-resize;
  z-index: 1;
  transform: translateX(-50%);
}
#divider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  border: 2px solid #fff6dc;
  border-radius: 50%;
  background: #26352bf0;
  color: #fff6dc;
  padding: 0;
  font-size: 26px;
  pointer-events: auto;
  touch-action: none;
  cursor: ew-resize;
  box-shadow: 0 2px 8px #0a151740;
}
#divider-handle:hover,
#divider-handle:active {
  background: #26352b;
  transform: translate(-50%, -50%);
}
.view-labels {
  position: absolute;
  inset: 10px 12px auto;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 1;
}
.view-labels span {
  font:
    10px ui-monospace,
    monospace;
  letter-spacing: 0.04em;
  color: #fff6dc;
  background: #142018de;
  padding: 5px 7px;
  border-radius: 3px;
}
#cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #142018ed;
  color: var(--screen-text);
  z-index: 2;
  text-align: center;
  padding: 24px;
}
#boot {
  max-width: 320px;
  font-size: 15px;
  line-height: 1.6;
}
#cover.night-over {
  inset: auto 12px 18px;
  padding: 8px 16px;
  border-radius: 6px;
}
#cover.night-over #boot {
  margin: 0;
}
#skip-intro {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff6dc;
  color: #202a23;
  border: 0;
  z-index: 1;
}
#exit-fullscreen {
  display: none;
}
.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 0 0 8px 8px;
}
.play-actions,
.utility-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
#status {
  font-size: 11px;
  color: var(--muted);
  padding-left: 4px;
}
.keyboard-hint {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin: 12px 0 0;
}
.keyboard-hint span {
  margin-left: 16px;
}
kbd {
  font: inherit;
  display: inline-block;
  min-width: 19px;
  padding: 2px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  margin-right: 3px;
}
.touch {
  display: none;
  gap: 5px;
  padding-top: 10px;
  user-select: none;
  -webkit-user-select: none;
}
.touch button {
  min-width: 0;
  min-height: 48px;
  padding: 8px;
  touch-action: none;
  -webkit-touch-callout: none;
  font-size: 18px;
}
.touch .touch-action {
  font-size: 12px;
}
.touch .held {
  background: var(--accent);
  color: var(--accent-text);
}
footer {
  text-align: center;
  font-size: 10px;
  line-height: 1.65;
  color: var(--muted);
  margin-top: 18px;
}
footer p {
  margin: 0;
}
dialog {
  background: var(--surface);
  color: var(--text);
  width: min(440px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
dialog::backdrop {
  background: #0b161ac4;
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.dialog-heading h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.035em;
}
dialog p {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.game-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0 12px;
}
.game-settings label {
  display: grid;
  gap: 8px;
  font-size: 12px;
}
select {
  width: 100%;
  padding: 11px 8px;
  min-width: 0;
  font-size: 12px;
}
#restart {
  width: 100%;
}
.save-options {
  margin: 22px 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.save-options div {
  display: flex;
  gap: 8px;
}
#snapshot-status {
  margin-bottom: 0;
}
details {
  font-size: 12px;
}
summary {
  cursor: pointer;
  padding: 6px 0;
}
dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  font-size: 12px;
  line-height: 1.8;
}
dt {
  color: var(--muted);
}
dd {
  margin: 0;
}
@media (max-width: 640px) {
  main {
    padding: 18px 12px 14px;
  }
  .masthead {
    margin-bottom: 24px;
    gap: 12px;
  }
  h1 {
    font-size: 29px;
  }
  h1 span {
    display: block;
    font-size: 9px;
    margin: 7px 0 0;
  }
  .identity p {
    display: none;
  }
  .source-link {
    font-size: 11px;
  }
  .playground {
    width: 100%;
    min-width: 0;
  }
  .comparison h2 {
    font-size: 18px;
  }
  .player-bar {
    flex-wrap: wrap;
    padding: 8px;
  }
  #status {
    display: none;
  }
  .play-actions,
  .utility-actions {
    gap: 4px;
  }
  .player-bar button {
    font-size: 11px;
    padding: 9px 10px;
    min-height: 44px;
  }
  .keyboard-hint {
    line-height: 2;
  }
}
@media (pointer: coarse) {
  .touch {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .keyboard-hint {
    display: none;
  }
  .view-end {
    min-height: 44px;
  }
}
@media (max-width: 370px) {
  .comparison h2 {
    font-size: 16px;
  }
  .player-bar {
    justify-content: center;
  }
}
.playground:fullscreen,
.playground.expanded {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  min-width: 0;
  max-width: none;
  padding: 10px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  margin: 0;
}
.playground.expanded {
  z-index: 10;
}
.playground:fullscreen .comparison,
.playground.expanded .comparison {
  width: min(100%, 800px);
  margin: auto;
  flex-shrink: 0;
  padding-bottom: 8px;
}
.playground:fullscreen #stage,
.playground.expanded #stage {
  flex: 1;
  min-height: 0;
  aspect-ratio: auto;
  border-radius: 6px 6px 0 0;
}
.playground:fullscreen .keyboard-hint,
.playground.expanded .keyboard-hint {
  display: none;
}
.playground:fullscreen #exit-fullscreen,
.playground.expanded #exit-fullscreen {
  display: block;
  position: absolute;
  right: 10px;
  top: 42px;
  z-index: 3;
  background: #24332be8;
  color: #fff6dc;
}
.playground:fullscreen .player-bar,
.playground.expanded .player-bar {
  flex-shrink: 0;
}
@media (max-height: 500px) and (orientation: landscape) {
  .playground:fullscreen .comparison-heading,
  .playground.expanded .comparison-heading,
  .playground:fullscreen #comparison-help,
  .playground.expanded #comparison-help {
    display: none;
  }
  .playground:fullscreen .comparison,
  .playground.expanded .comparison {
    padding: 0;
  }
  .playground:fullscreen .player-bar,
  .playground.expanded .player-bar {
    padding: 4px;
  }
  .playground:fullscreen .touch,
  .playground.expanded .touch {
    padding-top: 4px;
  }
  .playground:fullscreen .touch button,
  .playground.expanded .touch button {
    min-height: 40px;
  }
}

#hd-label {
  margin-left: auto;
}

#preview-hd,
#preview-cga {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.direction-pad {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  gap: 5px;
}
.touch .touch-action {
  width: 72px;
  min-height: 64px;
}
.playing #divider-handle {
  opacity: 0.55;
}
.playing #divider:hover #divider-handle,
.playing #divider:focus-within #divider-handle {
  opacity: 1;
}
/* Thumb controls use the landscape margins, leaving the game its full height. */
@media (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  .playground:is(:fullscreen, .expanded) {
    display: grid;
    grid-template-columns: 154px minmax(0, 1fr) 104px;
    grid-template-rows: 44px minmax(0, 1fr);
    gap: 8px;
    padding: 8px max(8px, env(safe-area-inset-right)) 8px
      max(8px, env(safe-area-inset-left));
  }
  .playground:is(:fullscreen, .expanded) .comparison {
    grid-column: 1 / -1;
    width: min(100%, 600px);
  }
  .playground:is(:fullscreen, .expanded) .comparison-track {
    margin: 0;
  }
  .playground:is(:fullscreen, .expanded) #stage {
    grid-column: 2;
    grid-row: 2;
    height: 100%;
    border-radius: 6px;
    align-self: stretch;
  }
  .playground:is(:fullscreen, .expanded) .player-bar {
    grid-column: 3;
    grid-row: 2;
    align-self: start;
    flex-direction: column;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .playground:is(:fullscreen, .expanded) .play-actions,
  .playground:is(:fullscreen, .expanded) .utility-actions {
    flex-direction: column;
    width: 100%;
  }
  .playground:is(:fullscreen, .expanded) .player-bar button {
    width: 100%;
    min-height: 40px;
    padding: 8px 4px;
    font-size: 11px;
  }
  .playground:is(:fullscreen, .expanded) #status,
  .playground:is(:fullscreen, .expanded) #exit-fullscreen {
    display: none;
  }
  .playground:is(:fullscreen, .expanded) .touch {
    display: contents;
  }
  /* Before play, leave room for both New game and Continue on short screens. */
  .playground:is(:fullscreen, .expanded):has(#start:not([hidden])) .touch {
    visibility: hidden;
  }
  .playground:is(:fullscreen, .expanded) .direction-pad {
    grid-column: 1;
    grid-row: 2;
    align-self: end;
    margin-bottom: 16px;
  }
  .playground:is(:fullscreen, .expanded) .touch .touch-action {
    grid-column: 3;
    grid-row: 2;
    align-self: end;
    justify-self: center;
    min-height: 64px;
    margin-bottom: 0;
  }
  .playground:is(:fullscreen, .expanded) .direction-pad button {
    min-height: 48px;
  }
}
