:root { color-scheme: light; font-family: var(--font-ui); color: #f4f1e9; background: #fff; }
* { box-sizing: border-box; }
body { margin: 0; }
/* Keep intrinsic controls visible and let the paper use the remaining space. */
main { width: 100%; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 0 1 75vw; min-height: 96px; container-type: size; background: #f4f1e9; }
canvas { display: block; margin: 0 auto; width: min(100cqw, calc(100cqh * 4 / 3)); height: auto; aspect-ratio: 4 / 3; image-rendering: pixelated; background: #f4f1e9; }
canvas:focus-visible { outline: 3px solid #d58b36; outline-offset: -3px; }
section { flex: 1 0 auto; display: flex; flex-direction: column; padding: clamp(8px, 2dvh, 20px) 24px 0; background: linear-gradient(145deg, #294158, #17283b); border-top: 3px solid #81929f; }
header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
h1 { font: 700 24px/1.2 var(--font-ui); margin: 0; letter-spacing: -.02em; }
header span { font-size: 10px; letter-spacing: .1em; color: #c6cfd5; }
#status { font-size: 12px; line-height: 1.5; color: #d6dee4; margin: 8px 0 12px; }
.controls { flex: 1; display: flex; align-items: center; justify-content: center; gap: clamp(18px, 5vw, 42px); padding-bottom: 8px; }
.dpad { --key-size: clamp(44px, 7dvh, 54px); display: grid; grid-template: repeat(3, var(--key-size)) / repeat(3, var(--key-size)); gap: 6px; }
.up { grid-area: 1 / 2; } .left { grid-area: 2 / 1; } .right { grid-area: 2 / 3; } .down { grid-area: 3 / 2; }
button { min-height: 44px; border: 1px solid #7e91a2; border-top: 3px solid #8ea0af; border-radius: 12px; color: #f4f1e9; background: linear-gradient(#40566c, #2a3e54); box-shadow: 0 6px 0 #0d1927; font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.dpad button { font-size: 24px; }
button:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 #0d1927; }
button:focus-visible { outline: 3px solid #edb96c; outline-offset: 4px; }
button:disabled { cursor: wait; opacity: .5; }
.marks { display: grid; gap: 16px; width: 104px; min-width: 92px; }
.marks button[aria-pressed="true"] { background: linear-gradient(#e2ad60, #bb7a30); color: #17283b; border-color: #f1c485; box-shadow: 0 2px 0 #0d1927; }
.marks button::after { content: "OFF"; display: block; font-size: 9px; letter-spacing: .1em; margin-top: 3px; }
.marks button[aria-pressed="true"]::after { content: "ON"; }
.files { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.files button { min-width: 44px; font-size: 10px; border-radius: 8px; padding: 0; }
.files button::after { content: none; }
.keys { text-align: center; font-size: 12px; line-height: 1.5; color: #d6dee4; margin: 8px 0; }
footer { font-size: 10px; text-align: center; color: #b9c5ce; }
.back { display: flex; flex-shrink: 0; align-items: center; justify-content: center; min-height: 48px; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); margin-top: 4px; color: #f4f1e9; font-size: 12px; text-underline-offset: 4px; }
.back:focus-visible { outline: 3px solid #edb96c; outline-offset: 3px; }
#error { padding: 12px; color: #17283b; background: #f4cfb5; }
@media (max-width: 760px), (pointer: coarse) {
  section { padding-inline: 16px; }
  header span { display: none; }
  .keys { display: none; }
  .marks { width: 88px; }
}
@media (min-width: 600px) and (max-height: 500px) {
  main { flex-direction: row; }
  .screen { flex: 1 1 0; min-width: 128px; min-height: 100%; display: grid; align-content: center; }
  section { flex: 0 0 320px; min-width: 0; padding: max(8px, env(safe-area-inset-top)) 16px 0; }
  header span { display: none; }
  h1 { font-size: 18px; }
  #status { margin: 6px 0 8px; }
  .keys { font-size: 11px; margin: 6px 0; }
  .controls { gap: 18px; }
  .marks { width: 88px; }
}
