:root { font-family: system-ui, sans-serif; color: #17234e; background: #fbf7ef; }
* { box-sizing: border-box; }
body { margin: 0; font-weight: 750; }
main { width: min(100% - 30px, 960px, calc((100svh - 140px) * 4 / 3)); min-width: min(100% - 30px, 404px); margin: auto; }
header { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 2px solid; }
header img { width: clamp(132px, 28vw, 195px); display: block; }
header a { color: inherit; text-decoration: none; font-size: clamp(12px, 2vw, 15px); }
header a:hover { text-decoration: underline; }
h1 { font-size: clamp(27px, 5.5vmin, 46px); letter-spacing: -.065em; font-style: italic; font-weight: 1000; text-transform: uppercase; line-height: 1; margin: 10px 0 9px; }
.stage { position: relative; overflow: hidden; border-radius: 16px; aspect-ratio: 4/3; box-shadow: 0 0 0 3px #17234e, 0 6px #17234e; background: #b8dcf8; touch-action: none; user-select: none; }
canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.hud { position: absolute; inset: 0 0 auto; padding: 2.7%; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
#stats { display: flex; flex-wrap: wrap; gap: 6px; }
#stats span, button { border: 2px solid #17234e; box-shadow: 0 3px #17234e; border-radius: 9px; background: #fff9eb; }
#stats span { padding: .4em .65em; font-size: clamp(10px, 2.4vw, 15px); font-weight: 950; }
button { color: inherit; font: inherit; font-weight: 950; cursor: pointer; touch-action: manipulation; }
#pause { pointer-events: auto; width: clamp(36px, 6vw, 47px); height: clamp(36px, 6vw, 45px); font-size: 21px; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; background: #10183e36; }
.overlay[hidden], #pause[hidden] { display: none; }
.card { background: #fff9ee; border: 3px solid; border-radius: 16px; box-shadow: 0 6px; text-align: center; padding: clamp(13px, 3vw, 29px) clamp(15px, 4vw, 39px); }
.card h2 { margin: 0 0 8px; font-size: clamp(22px, 5vmin, 43px); line-height: 1; font-style: italic; letter-spacing: -.055em; text-transform: uppercase; }
.card p { font-size: clamp(12px, 2.5vw, 16px); }
.card p { margin: 0 0 13px; }
#action { padding: 8px 24px; background: #5ceccc; }
#action:hover { background: #a6f5de; }
button:focus-visible, a:focus-visible { outline: 3px solid #2056e4; outline-offset: 3px; }
#command { position: absolute; right: 3%; bottom: 4%; z-index: 1; min-height: 44px; padding: .42em .85em; background: #ffae4a; touch-action: none; }
#command[hidden] { display: none; }
[data-game="pancake-panic"] #command { background: #ff7e92; }
[data-game="magnet-mayhem"] #command { background: #78e2ff; }
#command:active { transform: translateY(2px); box-shadow: 0 1px #17234e; }
.flight-controls, .factory-controls {
  display: flex;
  align-items: stretch;
  gap: 9px;
  margin-top: 14px;
}
.flight-controls #command, .factory-controls #command { position: static; }
.steering-control {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 4px 12px;
  border: 2px solid #17234e;
  border-radius: 9px;
  box-shadow: 0 3px #17234e;
  background: #d4f8f5;
  font-size: clamp(12px, 2.5vw, 16px);
  font-weight: 950;
}
.factory-controls > button { flex: 1; min-height: 44px; padding: .42em .85em; }
[data-game="canyon-glider"] main { width: min(100% - 30px, 960px, calc((100svh - 205px) * 4 / 3)); }
@media (max-height: 560px) and (orientation: landscape) {
  [data-game="canyon-glider"] main { min-width: 0; width: min(100% - 28px, calc((100svh - 169px) * 4 / 3)); }
  [data-game="canyon-glider"] header { padding: 4px 0; }
  [data-game="canyon-glider"] header img { width: 133px; }
  [data-game="canyon-glider"] h1 { margin: 6px 0; }
  .steering-control, :is(#steering-slider, #plate-slider) { min-height: 44px; }
  .flight-controls { margin-top: 10px; }
}
.mobile-control-row { display: flex; align-items: stretch; gap: 8px; margin: 14px 0 4px; }
.mobile-control-row[hidden] { display: none; }
.mobile-control-row #command { position: static; }
.mobile-control-row > button { min-height: 44px; padding: .42em .8em; white-space: nowrap; }
[data-game="grapple"] .mobile-control-row #command { flex: 1; background: #c9b8ff; }
[data-game="bank-shot"] .mobile-control-row #command { background: #ffd05f; }
.factory-controls > button { flex: 0 0 auto; }
.steering-control input[type="range"] { flex: 1; width: 100%; min-width: 0; height: 44px; margin: 0; accent-color: #1e70c7; touch-action: none; }
.steering-control input[type="range"]:focus-visible { outline: 3px solid #2056e4; outline-offset: 2px; }
:is(#steering-slider, #plate-slider) {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: grab;
  --slot: #8abdbb;
  --grip: #ffce72 linear-gradient(90deg, #725329 0 2px, transparent 2px 6px, #725329 6px 8px) center / 8px 12px no-repeat;
}
:is(#steering-slider, #plate-slider):active { cursor: grabbing; }
:is(#steering-slider, #plate-slider)::-webkit-slider-runnable-track {
  height: 10px;
  box-sizing: border-box;
  background: var(--slot);
  border: 2px solid #17234e;
  border-radius: 6px;
}
:is(#steering-slider, #plate-slider)::-moz-range-track {
  height: 10px;
  box-sizing: border-box;
  background: var(--slot);
  border: 2px solid #17234e;
  border-radius: 6px;
}
:is(#steering-slider, #plate-slider)::-moz-range-progress { background: transparent; border: 0; }
:is(#steering-slider, #plate-slider)::-webkit-slider-thumb {
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 42px;
  height: 32px;
  margin-top: -13px;
  background: var(--grip);
  border: 2px solid #17234e;
  border-radius: 10px;
  box-shadow: 0 2px #17234e;
}
:is(#steering-slider, #plate-slider)::-moz-range-thumb {
  box-sizing: border-box;
  width: 42px;
  height: 32px;
  background: var(--grip);
  border: 2px solid #17234e;
  border-radius: 10px;
  box-shadow: 0 2px #17234e;
}
@media (max-height: 600px) and (orientation: landscape) {
  main, [data-game="canyon-glider"] main { min-width: 0; width: min(100% - 26px,960px,calc((100svh - 76px) * 4 / 3)); padding-bottom: 10px; }
  .mobile-control-row { margin-top: 11px; gap: 5px; }
  .steering-control { min-height: 44px; padding: 1px 8px; }
  .mobile-control-row > button { font-size: 12px; padding-inline: .55em; }
  .factory-controls .steering-control span { display: none; }
}
