* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  background: #0a0a12;
  color: #e8e6e3;
  font-family: "Segoe UI", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 40%, #141428 0%, #0a0a12 70%);
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  image-rendering: auto;
  background: #12121c;
  width: min(100vw, calc(100vh * 960 / 540));
  height: min(100vh, calc(100vw * 540 / 960));
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 0 0 2px #1e1e32, 0 18px 60px rgba(0, 0, 0, 0.55);
  cursor: default;
  outline: none;
  touch-action: none;
}

#fsBtn {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border: 2px solid #4a6080;
  border-radius: 6px;
  background: rgba(18, 22, 36, 0.85);
  color: #c8d8e8;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
#fsBtn:hover {
  background: rgba(40, 50, 80, 0.95);
  border-color: #7aa0c8;
}

body.fullscreen #fsBtn { opacity: 0.35; }
body.fullscreen #fsBtn:hover { opacity: 1; }

body.desktop-app #fsBtn { display: none; }

#touch {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  pointer-events: none;
}
#touch[hidden] { display: none; }
#touch .pad {
  display: grid;
  grid-template-columns: 64px 64px 64px;
  grid-template-rows: 64px 64px;
  gap: 6px;
  pointer-events: auto;
}
#touch .pad button:nth-child(1) { grid-column: 2; grid-row: 1; }
#touch .pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
#touch .pad button:nth-child(3) { grid-column: 2; grid-row: 2; }
#touch .pad button:nth-child(4) { grid-column: 3; grid-row: 2; }
#touch button {
  width: 64px;
  height: 64px;
  border: 3px solid #d7b45a;
  border-radius: 12px;
  background: rgba(16, 22, 36, 0.88);
  color: #f4f7fb;
  font: 600 18px "Segoe UI", "PingFang TC", "Hiragino Sans", system-ui, sans-serif;
  pointer-events: auto;
  touch-action: none;
}
#touchScrub {
  min-width: 96px;
  width: auto;
  padding: 0 16px;
  margin-bottom: 6px;
}
@media (orientation: portrait) {
  #touch button { width: 72px; height: 72px; }
  #touch .pad { grid-template-columns: 72px 72px 72px; grid-template-rows: 72px 72px; }
  #touchScrub { height: 72px; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
