@font-face {
  font-family: Monocraft;
  src: url('./assets/font/Monocraft.ttf') format('truetype');
  font-display: swap;
}
:root {
  color-scheme: dark;
  background: #0d0e14;
  color: #e9edf2;
  font-family: Monocraft, ui-monospace, monospace;
  --reserve: 108px;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { min-height: 100vh; min-height: 100dvh; }
.shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 12px max(10px, env(safe-area-inset-right)) 12px max(10px, env(safe-area-inset-left));
  overflow: hidden;
}
.frame {
  position: relative;
  flex: 0 0 auto;
  width: min(100%, 1280px, calc((100dvh - var(--reserve)) * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  /* No visible frame/border around the game during play. */
  box-shadow: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  image-rendering: pixelated;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#loading, .pause-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
}
#loading { background: #11131d; font-size: clamp(12px, 1.4vw, 19px); padding: 18px; }
#loading[hidden], .pause-overlay[hidden] { display: none; }
.pause-overlay { background: rgb(7 8 16 / .74); backdrop-filter: blur(3px); }
.pause-card { display: flex; flex-direction: column; gap: 12px; align-items: center; padding: 20px; }
.pause-card strong { font-size: clamp(18px, 3vw, 34px); letter-spacing: 2px; }
.pause-card p { margin: 0; font-size: clamp(12px, 1.3vw, 16px); }
.pause-card small { color: #b3b9c8; font-size: clamp(9px, 1vw, 12px); }
.controlbar {
  width: min(100%, 1280px);
  max-width: 1280px;
  min-height: 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.instructions { margin: 0; color: #b8becb; font-size: 11px; line-height: 1.6; flex: 1 1 370px; }
.actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; min-width: 0; }
.ui-icon {
  width: 17px;
  height: 17px;
  display: inline-block;
  flex: 0 0 17px;
  vertical-align: middle;
}
.actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.actions button, .pause-card button {
  border: 1px solid #434a5e;
  border-radius: 6px;
  background: #232938;
  color: #eff3ff;
  font: 12px Monocraft, monospace;
  cursor: pointer;
  padding: 10px 12px;
  white-space: nowrap;
  line-height: 1.2;
}
.actions button:hover:not(:disabled), .pause-card button:hover { background: #344259; border-color: #87a3c2; }
.actions button:focus-visible, .pause-card button:focus-visible, input:focus-visible {
  outline: 2px solid #65fbec;
  outline-offset: 2px;
}
.actions button:disabled { opacity: .42; cursor: not-allowed; }
.pause-card .primary { background: #176e71; border-color: #4bd6ce; }
.audio-mix, .track-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}
.audio-mix label, .audio-mix output, .track-picker output {
  font: 10px Monocraft, monospace;
  white-space: nowrap;
  color: #c9d0db;
}
.audio-mix input { width: 66px; min-width: 46px; accent-color: #5ce5db; cursor: pointer; }
.audio-mix output { min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.track-picker output { min-width: 85px; text-align: center; }
.track-picker button { padding: 8px 7px; min-width: 32px; font-size: 10px; }

.touch-hint { display: none; font-size: 10px; color: #a6adbc; text-align: center; }
.frame:fullscreen {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  display: grid;
  place-items: center;
  background: #000;
  box-shadow: none;
}
.frame:fullscreen canvas {
  width: min(100vw, calc(100dvh * 16 / 9));
  height: auto;
  max-height: 100dvh;
  aspect-ratio: 16 / 9;
}
.frame:fullscreen .pause-overlay, .frame:fullscreen #loading { inset: 0; }
@media (max-width: 1180px) {
  .instructions { display: none; }
  .controlbar { justify-content: center; }
  :root { --reserve: 105px; }
}
@media (max-width: 900px) {
  :root { --reserve: 126px; }
  .controlbar { justify-content: center; }
  .instructions { text-align: center; flex: 1 1 100%; }
}
@media (max-height: 650px) {
  :root { --reserve: 86px; }
  .shell { gap: 6px; padding-block: 6px; }
  .instructions { display: none; }
  .controlbar { min-height: 44px; }
}
@media (max-height: 420px) {
  :root { --reserve: 62px; }
  .shell { padding-block: 3px; gap: 3px; }
  .controlbar { min-height: 36px; }
  .actions button { padding: 7px 10px; }
}
@media (max-width: 480px) {
  .actions button .button-text { display: none; }
  .audio-mix { gap: 4px; }
  .audio-mix input { width: 54px; }
  .track-picker output { min-width: 70px; font-size: 9px; }
  .actions { justify-content: center; }
  .actions button { min-width: 44px; min-height: 38px; }
  .touch-hint { display: block; margin: 0; }
  :root { --reserve: 176px; }
}
@media (max-width: 480px) and (max-height: 650px) {
  .touch-hint { display: none; }
  :root { --reserve: 110px; }
}
@media (prefers-reduced-motion: reduce) {
  .pause-overlay { backdrop-filter: none; }
}

/* The usual fullscreen toggle sits outside .frame and is hidden in native
   fullscreen mode. Keep an accessible exit action inside the fullscreen frame. */
.exit-fullscreen {
  display: none;
  position: absolute;
  z-index: 10;
  top: 12px;
  right: 12px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgb(16 20 31 / .94);
  color: #fff;
  border: 1px solid #5b748e;
  border-radius: 6px;
  padding: 12px 14px;
  font: 12px Monocraft, monospace;
  cursor: pointer;
}
.frame:fullscreen .exit-fullscreen { display: inline-flex; }
.exit-fullscreen:hover { background: #263549; }
.exit-fullscreen:focus-visible { outline: 2px solid #65fbec; outline-offset: 2px; }
