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

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: #04040a;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  touch-action: none; overscroll-behavior: none;
}

#wrap {
  position: relative; width: 100vw; height: 100vh; height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: #04040a; user-select: none;
}

canvas#game {
  background: #06060f; display: block;
  width: 100%; height: 100%;
  max-width: 100vw; max-height: 100vh; max-height: 100dvh;
  touch-action: none;
}
@media (min-aspect-ratio: 16/9) { canvas#game { width: auto; height: 100%; } }
@media (max-aspect-ratio: 16/9) { canvas#game { width: 100%; height: auto; } }

/* ---------- hud ---------- */
#hud {
  position: absolute; top: env(safe-area-inset-top, 0px); left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 15px; pointer-events: none;
  font-size: clamp(12px, 2.4vw, 16px); font-weight: 600;
  color: #cfd3ff; letter-spacing: 1px;
  text-shadow: 0 1px 3px #000;
}
#hud-left { color: #7ef0d0; font-family: ui-monospace, Consolas, monospace; }
#hud-mid { color: #ffd166; font-size: clamp(11px, 2.2vw, 14px); font-weight: 500; }
#btn-phys {
  pointer-events: auto; font-family: inherit;
  font-size: clamp(10px, 2vw, 12px); font-weight: 600; letter-spacing: 1px;
  color: #9aa0d8; background: rgba(120, 130, 255, 0.12);
  border: 1px solid rgba(150, 160, 255, 0.35); border-radius: 14px;
  padding: 3px 11px; cursor: pointer;
}
#btn-phys.on { background: #ffd166; border-color: #ffd166; color: #2b2100; }

#rotate {
  position: absolute; bottom: 6px; left: 0; right: 0; text-align: center;
  color: #8a8fc8; font-size: 12px; pointer-events: none; display: none;
}
@media (orientation: portrait) and (max-width: 640px) { #rotate { display: block; } }

/* ---------- touch ---------- */
#pads {
  position: absolute; left: 0; right: 0; bottom: env(safe-area-inset-bottom, 0px);
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 14px 16px; pointer-events: none; z-index: 12;
}
.cluster { display: flex; gap: 11px; }
.pad {
  pointer-events: auto;
  width: clamp(50px, 13vw, 70px); height: clamp(50px, 13vw, 70px);
  border-radius: 50%; border: 2px solid rgba(190, 200, 255, 0.45);
  background: rgba(120, 140, 255, 0.14); color: #e8ebff;
  font-size: clamp(18px, 4.4vw, 25px);
  display: flex; align-items: center; justify-content: center; touch-action: none;
}
.pad:active, .pad.on { background: rgba(190, 200, 255, 0.4); }
.pad.big {
  width: clamp(64px, 17vw, 92px); height: clamp(64px, 17vw, 92px);
  background: rgba(255, 209, 102, 0.22); border-color: rgba(255, 209, 102, 0.65);
}
.pad.big:active, .pad.big.on { background: rgba(255, 209, 102, 0.5); }

/* ---------- overlay ---------- */
#ov {
  position: absolute; inset: 0; background: rgba(4, 4, 10, 0.93);
  display: flex; align-items: center; justify-content: center;
  padding: 18px; z-index: 20;
}
#ov.hidden { display: none; }
#ov .card { max-width: 560px; width: 100%; text-align: center; color: #e8ebff; }
#ov h1 {
  margin: 0; font-size: clamp(34px, 9vw, 62px); letter-spacing: 10px;
  color: #fff; font-weight: 800;
  text-shadow: 0 0 24px rgba(126, 240, 208, 0.5);
}
#ov .tag {
  margin: 6px 0 20px; color: #7ef0d0;
  font-size: clamp(13px, 3vw, 17px); letter-spacing: 1px;
}
#ov-body { font-size: clamp(12.5px, 2.7vw, 15px); line-height: 1.7; color: #c3c8ee; }
#ov-body p { margin: 0 0 12px; }
#ov-body b { color: #ffd166; }
#ov-body .big {
  font-size: clamp(15px, 3.4vw, 19px); color: #fff; margin: 16px 0;
}
#ov-body .sub { color: #8a8fc8; font-size: clamp(11px, 2.3vw, 13px); }
#ov .go {
  font-family: inherit; font-weight: 800; letter-spacing: 2px;
  font-size: clamp(15px, 3.6vw, 19px);
  background: #7ef0d0; color: #032019; border: none; border-radius: 9px;
  padding: 13px 42px; cursor: pointer; margin-top: 8px;
  box-shadow: 0 5px 0 #3fae94;
}
#ov .go:active { transform: translateY(2px); box-shadow: 0 3px 0 #3fae94; }
#ov .keys { margin-top: 18px; color: #6f75ab; font-size: clamp(10.5px, 2.2vw, 12.5px); }
#ov .keys b { color: #9aa0d8; }
