:root {
  --bg: #0d0d18;
  --window-bg: #1a2140;
  --window-border-outer: #f0f4ff;
  --window-border-inner: #4a5aa8;
  --text: #f4f4f8;
  --accent: #ffce54;
  --hp: #ff5566;
  --mp: #4fa8ff;
  --exp: #6ee06e;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  font-family: "Yu Gothic", "Hiragino Sans", sans-serif;
  color: var(--text);
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

#gameFrame {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 520px;
  max-height: 920px;
  aspect-ratio: 9 / 16;
  background: #000;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
}

@media (min-aspect-ratio: 9/16) {
  #gameFrame { height: 100%; width: auto; }
}
@media (max-aspect-ratio: 9/16) {
  #gameFrame { width: 100%; height: auto; }
}

#gameCanvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

#overlayRoot {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
#overlayRoot > * { pointer-events: auto; }

.touchlayer {
  position: absolute;
  bottom: 3%;
  z-index: 20;
  user-select: none;
}
#dpad { left: 3%; width: 34%; aspect-ratio: 1; }
#actionButtons { right: 3%; width: 30%; display: flex; justify-content: space-between; align-items: flex-end; height: 22%; }

.dbtn {
  position: absolute;
  width: 34%;
  height: 34%;
  background: rgba(240,244,255,0.16);
  border: 2px solid rgba(240,244,255,0.5);
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.dbtn:active { background: rgba(240,244,255,0.4); }
.dup { top: 0; left: 33%; }
.ddown { bottom: 0; left: 33%; }
.dleft { top: 33%; left: 0; }
.dright { top: 33%; right: 0; }

.abtn {
  width: 46%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(240,244,255,0.2);
  border: 2px solid rgba(240,244,255,0.6);
  color: #fff;
  font-size: 16px;
  font-weight: bold;
}
.abtn:active { background: rgba(240,244,255,0.45); }
#btnOk { background: rgba(255,206,84,0.3); border-color: #ffce54; }

.hidden { display: none !important; }
