:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #02040c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #02040c; }
body { overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; }

.game-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: #02040c;
  overflow: hidden;
}

#phaser-game,
#phaser-game canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  background: #02040c;
  touch-action: none;
}

.gate,
.overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 18%, rgba(45,116,255,.22), transparent 42%),
    linear-gradient(180deg, rgba(2,5,16,.94), rgba(0,0,0,.985));
  line-height: 1.25;
}
.gate.show,
.overlay.show { display: flex; }

.gate-card,
.panel {
  width: min(760px, 92vw);
  max-height: 92dvh;
  overflow: auto;
  text-align: center;
  padding: clamp(20px, 4vw, 42px);
  border: 1px solid rgba(131,220,255,.5);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(14,23,47,.97), rgba(4,7,16,.98));
  box-shadow: 0 0 60px rgba(39,121,255,.22), inset 0 0 50px rgba(104,219,255,.06);
  backdrop-filter: blur(10px);
}

.rotate-icon {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border: 2px solid #72e9ff;
  border-radius: 22px;
  color: #dffcff;
  font-size: 46px;
  box-shadow: 0 0 28px rgba(76,223,255,.28);
}

h1,h2 { margin: 0 0 14px; letter-spacing: .08em; line-height: 1.02; }
h1 { font-size: clamp(34px, 6vw, 68px); color: #eafaff; text-shadow: 0 0 24px rgba(69,216,255,.45); }
h2 { font-size: clamp(30px, 5vw, 54px); color: #eafaff; }
p { color: #c8d5e9; line-height: 1.5; }
.fine { margin-bottom: 0; font-size: 12px; color: #8496b5; }

.button-stack { display: grid; gap: 11px; margin-top: 18px; }
button {
  min-height: 56px;
  border: 1px solid rgba(128,228,255,.78);
  border-radius: 14px;
  background: linear-gradient(180deg, #53e7ff, #1978ff);
  color: #04101e;
  font-weight: 900;
  letter-spacing: .04em;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(19,123,255,.22), inset 0 1px rgba(255,255,255,.7);
}
button:active { transform: translateY(1px) scale(.995); }
button:disabled { opacity: .45; cursor: default; filter: grayscale(.5); }
button.secondary { color: #d8e5f8; background: linear-gradient(180deg, #17213a, #0a1020); border-color: #3f557c; box-shadow: none; }
button:focus-visible { outline: 3px solid #f7f7ff; outline-offset: 3px; }

.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.tutorial-grid > div {
  padding: 12px;
  border: 1px solid rgba(101,149,204,.28);
  border-radius: 12px;
  background: rgba(7,13,29,.7);
}
.tutorial-grid strong { display: block; color: #72e9ff; font-size: 12px; letter-spacing: .07em; }
.tutorial-grid span { display: block; margin-top: 4px; color: #b7c7de; font-size: 12px; line-height: 1.35; }

.save-status { min-height: 2.4em; color: #78ffa8; }

.touch-controls {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: none;
}
.game-active .touch-controls { display: block; }

.stick {
  --size: clamp(116px, 17vmin, 146px);
  position: absolute;
  bottom: max(5px, env(safe-area-inset-bottom));
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
}
.stick-left { left: max(5px, calc(env(safe-area-inset-left) + 2px)); }
.stick-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(155,226,255,.33);
  background: radial-gradient(circle, rgba(20,55,88,.22) 0 50%, rgba(8,18,34,.38) 51% 100%);
  box-shadow: inset 0 0 34px rgba(54,197,255,.1), 0 0 24px rgba(0,0,0,.28);
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 45%;
  height: 45%;
  transform: translate(-50%,-50%);
  border-radius: 50%;
  border: 2px solid rgba(211,248,255,.6);
  background: radial-gradient(circle at 38% 30%, rgba(145,236,255,.72), rgba(27,90,142,.78));
  box-shadow: 0 0 22px rgba(83,222,255,.22);
  will-change: transform;
}
.stick > span {
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  color: rgba(207,235,255,.75);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .18em;
}


.saber-direct-hint {
  position: absolute;
  right: max(76px, calc(env(safe-area-inset-right) + 72px));
  bottom: max(14px, calc(env(safe-area-inset-bottom) + 10px));
  padding: 7px 11px;
  border: 1px solid rgba(103,232,255,.16);
  border-radius: 999px;
  background: rgba(3,12,25,.28);
  color: rgba(189,239,255,.38);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .12em;
  pointer-events: none;
  opacity: .65;
}

.pause-btn {
  position: absolute;
  top: max(12px, calc(env(safe-area-inset-top) + 6px));
  right: max(12px, calc(env(safe-area-inset-right) + 6px));
  width: 48px;
  height: 42px;
  min-height: 0;
  padding: 0;
  border-radius: 12px;
  pointer-events: auto;
  color: #dff8ff;
  background: rgba(4,13,28,.72);
  border-color: rgba(123,219,255,.45);
  box-shadow: none;
  font-size: 20px;
}

.toast {
  position: absolute;
  z-index: 70;
  left: 50%;
  bottom: 22%;
  transform: translate(-50%, 14px);
  max-width: min(76vw, 720px);
  padding: 10px 16px;
  border: 1px solid rgba(115,231,255,.68);
  border-radius: 12px;
  background: rgba(2,9,20,.9);
  color: #eafdff;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
  box-shadow: 0 0 26px rgba(55,198,255,.18);
}
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (orientation: portrait) {
  .game-active .touch-controls { display: none; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .stick { --size: clamp(112px, 29vh, 132px); bottom: max(3px, env(safe-area-inset-bottom)); }
  .stick-left { left: max(3px, env(safe-area-inset-left)); }
  .stick > span { display:none; }
  .saber-direct-hint { display:none; }
  .panel, .gate-card { padding: 16px 22px; }
  .tutorial-grid { margin-top: 10px; }
  .tutorial-grid > div { padding: 8px; }
}

@media (max-width: 620px) {
  .tutorial-grid { grid-template-columns: 1fr; }
}

/* v2.6: orientation/fullscreen gate is a hard input lock above every other UI layer. */
#orientationOverlay { z-index: 1000; pointer-events: auto; }
#orientationOverlay.show ~ #touchControls { pointer-events: none; }
@media (orientation: portrait) { #phaser-game { pointer-events: none; } }
