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

html, body {
  height: 100%;
  background: #000;
  color: #eee;
  font-family: system-ui, -apple-system, sans-serif;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#app {
  height: 100dvh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

#game {
  width: min(100vw, calc(100dvh * 384 / 224));
  height: auto;
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  touch-action: none;
}

#rotate {
  display: none;
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: #f0d020;
  color: #110818;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 4px;
}

.pad {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 5;
  padding: 8px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.pad button {
  pointer-events: auto;
  border: 0;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  -webkit-user-select: none;
}

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dpad .mid { display: flex; gap: 28px; }

.dpad button {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: rgba(255,255,255,0.18);
}

.actions { display: flex; gap: 10px; }

.atk {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(240, 40, 40, 0.8);
}
.atk.k { background: rgba(40, 120, 240, 0.8); }
.atk.s { background: rgba(240, 180, 20, 0.88); color: #111; }

@media (pointer: fine) and (min-width: 900px) {
  .pad { display: none !important; }
}

@media (orientation: portrait) and (max-width: 900px) {
  #rotate { display: block; }
  #app { justify-content: flex-start; padding-top: 36px; }
  #game { width: 100vw; max-height: 52dvh; }
  .pad { display: flex; }
}

#reset {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  z-index: 15;
  border: 0;
  background: #e01820;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  border-radius: 4px;
  pointer-events: auto;
}
