:root {
  --bg: #0c0d0f;
  --panel: #131518;
  --line: #23262b;
  --fg: #c8ccd0;
  --dim: #6d747c;
  --accent: #a9b6e8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  display: flex;
  justify-content: center;
  padding: 40px 20px 80px;
}

main {
  width: 100%;
  max-width: 720px;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sub {
  margin: 8px 0 28px;
  color: var(--dim);
  max-width: 52ch;
}

.screen-wrap {
  position: relative;
  width: 720px;
  max-width: 100%;
  aspect-ratio: 240 / 160;
  border: 1px solid var(--line);
  background: #000;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(12, 13, 15, 0.88);
  color: var(--dim);
}

.overlay.hidden {
  display: none;
}

.overlay p {
  margin: 0;
  font-size: 12px;
}

button,
.file span {
  font: inherit;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 8px 20px;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

button:hover,
.file span:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  flex-wrap: wrap;
}

#status {
  color: var(--dim);
  font-size: 12px;
}

.file input {
  display: none;
}

.keys {
  margin-top: 40px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

h2 {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 12px;
  font-weight: 500;
}

dl {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 0;
}

dl div {
  display: flex;
  gap: 10px;
}

dt {
  color: var(--accent);
}

dd {
  margin: 0;
  color: var(--dim);
}

.note {
  color: var(--dim);
  font-size: 12px;
  max-width: 60ch;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.note a,
.sub a {
  color: var(--accent);
}

code {
  color: var(--fg);
}

/* Touch play. The .touch-on class is set from app.js on coarse-pointer
   devices; everything below is inert on desktop. */

.touch-on header,
.touch-on .keys dl {
  display: none;
}

.touch-on {
  padding: 0;
  display: block;
}

.touch-on main {
  max-width: none;
}

.touch-on {
  overflow: hidden;
  height: 100dvh;
}

.touch-on main {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.touch-on .player {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

.touch-on .keys {
  display: none;
}

.touch-on .screen-wrap {
  width: 100%;
  border-left: none;
  border-right: none;
}

.touch-on .bar {
  margin: 0;
  padding: 10px max(16px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
}

.touch {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px max(16px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-right));
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.touch[hidden] {
  display: none;
}

.shoulders {
  display: flex;
  justify-content: space-between;
}

.clusters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  padding: 8px 4px;
}

.meta-row {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.tbtn {
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  color: var(--dim);
  background: var(--panel);
  border: 1px solid var(--line);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tbtn.pressed {
  border-color: var(--accent);
  color: var(--accent);
  background: #1a1d24;
}

.tbtn.shoulder {
  width: 84px;
  padding: 10px 0;
  font-size: 13px;
  border-radius: 6px;
}

.tbtn.round {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  font-size: 15px;
  padding: 0;
}

.face {
  display: grid;
  grid-template-columns: 58px 58px;
  grid-template-rows: 44px 44px;
}

.face .a {
  grid-column: 2;
  grid-row: 1;
}

.face .b {
  grid-column: 1;
  grid-row: 2;
}

.tbtn.pill {
  padding: 8px 22px;
  font-size: 11px;
  border-radius: 999px;
}

.dpad {
  position: relative;
  width: 148px;
  height: 148px;
  touch-action: none;
}

.dpad .arm,
.dpad .hub {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--line);
}

.dpad .up,
.dpad .down {
  left: 50px;
  width: 48px;
  height: 52px;
}

.dpad .up {
  top: 0;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}

.dpad .down {
  bottom: 0;
  border-top: none;
  border-radius: 0 0 8px 8px;
}

.dpad .left,
.dpad .right {
  top: 50px;
  width: 52px;
  height: 48px;
}

.dpad .left {
  left: 0;
  border-right: none;
  border-radius: 8px 0 0 8px;
}

.dpad .right {
  right: 0;
  border-left: none;
  border-radius: 0 8px 8px 0;
}

.dpad .hub {
  left: 50px;
  top: 50px;
  width: 48px;
  height: 48px;
  border: none;
}

.dpad .arm.pressed {
  background: #1a1d24;
  border-color: var(--accent);
}

/* Landscape: the screen takes the full height and the controls float over
   its sides, the way every handheld shell app does it. */
@media (orientation: landscape) {
  .touch-on .player {
    position: relative;
    padding-top: 0;
  }

  .touch-on .screen-wrap {
    height: 100%;
    width: auto;
    aspect-ratio: 240 / 160;
    margin: 0 auto;
    border: none;
  }

  .touch {
    position: absolute;
    inset: 0;
    padding: 12px max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .touch .tbtn,
  .touch .dpad .arm,
  .touch .dpad .hub {
    opacity: 0.62;
  }

  .clusters {
    align-items: flex-end;
    padding: 0;
  }

  .meta-row {
    position: absolute;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
  }
}
