@font-face {
  font-family: "UndertaleExtended";
  src: url("./undertale-deltarune-text-font-extended.ttf") format("truetype");
  font-display: swap;
}
:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: "UndertaleExtended", "Noto Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
#ui {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 10;
  pointer-events: none;
}
.title {
  font-weight: 600;
  letter-spacing: 0.06em;
  font-size: 14px;
  opacity: 0.9;
}
.help {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.7;
}
.pos {
  position: fixed;
  top: 16px;
  right: 16px;
  font-size: 12px;
  opacity: 0.85;
}
.pos-left { margin-top: 6px; font-size: 12px; opacity: 0.85; }
#ui, .pos { display: none; }
#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
  width: auto; /* sized by JS to maintain 4:3 */
  height: auto;
  cursor: none;
}
#joystick-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 200px;
  height: 200px;
  z-index: 20;
}
.speed-wrap { pointer-events: auto; }
#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  cursor: none;
}
.debug-controls { pointer-events: auto; margin-top: 8px; }
.debug-controls button {
  font: 12px "Noto Sans", sans-serif; color: #fff; background: #111;
  border: 1px solid #444; padding: 6px 10px; border-radius: 4px; cursor: pointer;
}
.debug-controls .battle-tuning { margin-top: 6px; display: flex; align-items: center; gap: 8px; }
#dpad, #action-buttons, #rotate-prompt { display: none; }
@media (pointer: coarse) {
  #dpad {
    position: fixed; left: 16px; bottom: 16px; z-index: 30; display: grid;
    grid-template-rows: 1fr auto 1fr; gap: 6px; touch-action: none;
  }
  #dpad .middle { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; }
  .dpad-btn {
    width: var(--dpad-btn, 64px); height: var(--dpad-btn, 64px);
    background: #111; border: 2px solid #fff; border-radius: 8px;
  }
  .dpad-btn.center { opacity: 0.25; }
  .dpad-btn:active { background: #222; }
  #dpad .dpad-btn.up,
  #dpad .dpad-btn.down { justify-self: center; align-self: center; }
  #action-buttons {
    position: fixed; right: 16px; bottom: 16px; z-index: 30; display: grid; gap: 10px;
    touch-action: none;
    grid-auto-flow: column;
  }
  .action-btn {
    width: var(--act-btn, 68px); height: var(--act-btn, 68px);
    background: #111; color: #fff; border: 2px solid #fff; border-radius: 50%;
    font: 24px "UndertaleExtended", sans-serif;
  }
  #rotate-prompt, #host-popup {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 40; display: none;
    align-items: center; justify-content: center; padding: 24px;
  }
  #rotate-prompt .box, #host-popup .box {
    width: min(640px, 92vw); background: #000; border: 2px solid #fff; border-radius: 10px;
    padding: 20px;
  }
  .prompt-title { font-size: 22px; margin-bottom: 8px; }
  .prompt-msg { font: 14px "Noto Sans", sans-serif; opacity: 0.9; }
  .prompt-actions { margin-top: 14px; display: flex; gap: 10px; justify-content: flex-end; }
  .prompt-btn { font: 14px "Noto Sans", sans-serif; color: #fff; background: #111; border: 1px solid #444; padding: 8px 12px; border-radius: 6px; }
  .prompt-btn.primary { border-color: #fff; }
  #host-recommend {
    position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
    background: #000; border: 2px solid #fff; border-radius: 10px;
    padding: 8px 12px; z-index: 50; display: none; gap: 8px; align-items: center;
    font: 14px "Noto Sans", sans-serif;
  }
  #host-recommend a { color: #fff; text-decoration: underline; }
  #host-recommend button { background: transparent; color:#fff; border:0; font-size:16px; cursor:pointer; }
}
@media (pointer: fine) {
  #rotate-prompt, #host-popup, #host-recommend { display: none !important; }
}