/* ── SHADOW STEP MOBILE / COMMERCIAL POLISH STYLES ─────────────────────
 * Floating ⚙ button, settings panel, first-launch tutorial overlay,
 * and portrait-friendly HUD tweaks (390x844 baseline).
 * Loaded after the inline <style> in index.html so it can override.
 * --------------------------------------------------------------------- */

/* ── ⚙ FLOATING SETTINGS BUTTON ────────────────────────────────────── */
.ss-set-btn {
  position: fixed;
  top: max(56px, env(safe-area-inset-top, 0px) + 56px);
  right: 10px;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: rgba(15, 7, 28, 0.78);
  border: 1px solid #7c3aed66;
  color: #f5b7c4;
  font-size: 1.05rem;
  line-height: 1;
  z-index: 60;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.32);
  transition: transform .14s, background .14s;
  -webkit-tap-highlight-color: transparent;
}
.ss-set-btn:hover, .ss-set-btn:active {
  background: rgba(124, 58, 237, 0.35);
  transform: translateY(-1px);
}

/* ── SETTINGS PANEL ────────────────────────────────────────────────── */
.ss-set {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  width: min(360px, 92vw);
  max-height: 86vh;
  background: linear-gradient(180deg, #160922 0%, #0a0418 100%);
  border: 1px solid #7c3aed99;
  border-radius: 14px;
  padding: 14px 16px;
  color: #e2e8f0;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  box-shadow: 0 18px 48px rgba(0,0,0,0.6), 0 0 24px rgba(124,58,237,0.35);
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
  font-family: 'Courier New', 'Lucida Console', monospace;
}
.ss-set.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.ss-set .hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid #7c3aed44;
}
.ss-set .ttl {
  font-weight: 700; letter-spacing: 0.16em; font-size: 0.95rem;
  background: linear-gradient(90deg, #f59e0b, #a78bfa);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ss-set .x {
  background: transparent; border: 1px solid #7c3aed66;
  color: #f5b7c4; width: 28px; height: 28px; border-radius: 6px;
  font-size: 0.9rem; cursor: pointer;
}
.ss-set .row { display: flex; flex-direction: column; gap: 6px; }
.ss-set .lab-row { display: flex; justify-content: space-between; align-items: center; }
.ss-set .lab { color: #cbd5e1; font-size: 0.82rem; letter-spacing: 0.1em; }
.ss-set .val { color: #fbbf24; font-size: 0.78rem; font-weight: 700; }
.ss-set .note { color: #94a3b8; font-size: 0.7rem; line-height: 1.45; }
.ss-set .ftr { text-align: center; opacity: 0.7; margin-top: 2px; }
.ss-set input[type=range] {
  width: 100%;
  accent-color: #7c3aed;
  height: 22px;
}
.ss-set .tog {
  width: 42px; height: 22px; border-radius: 999px;
  background: #2a1845; border: 1px solid #7c3aed66;
  position: relative; cursor: pointer; transition: background .15s;
}
.ss-set .tog::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #cbd5e1; transition: left .15s, background .15s;
}
.ss-set .tog.on { background: linear-gradient(90deg, #7c3aed, #f59e0b); }
.ss-set .tog.on::after { left: 22px; background: #fef3c7; }
.ss-set .ss-replay {
  background: rgba(124,58,237,0.25);
  border: 1px solid #7c3aed99;
  color: #e2e8f0;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.ss-set .ss-replay:hover { background: rgba(124,58,237,0.42); }

/* ── TUTORIAL OVERLAY ──────────────────────────────────────────────── */
.ss-tut {
  position: fixed; inset: 0;
  background: rgba(5,3,10,0.78);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 220;
  opacity: 0; pointer-events: none;
  transition: opacity .22s;
  padding: 16px;
}
.ss-tut.open { opacity: 1; pointer-events: auto; }
.ss-tut .card {
  width: min(380px, 96vw);
  background: linear-gradient(180deg, #1a0a2a 0%, #0a0418 100%);
  border: 1px solid #7c3aed99;
  border-radius: 16px;
  padding: 22px 22px 18px;
  text-align: center;
  color: #e2e8f0;
  font-family: 'Courier New', 'Lucida Console', monospace;
  box-shadow: 0 20px 60px rgba(0,0,0,0.65), 0 0 28px rgba(124,58,237,0.4);
}
.ss-tut .icn { font-size: 2.4rem; margin-bottom: 8px; }
.ss-tut .ttl {
  font-size: 1.05rem; font-weight: 700; letter-spacing: 0.14em;
  background: linear-gradient(90deg, #f59e0b, #a78bfa);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 8px;
}
.ss-tut .bdy { font-size: 0.86rem; line-height: 1.5; color: #cbd5e1; margin-bottom: 14px; }
.ss-tut .dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 14px; }
.ss-tut .dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #7c3aed44; display: inline-block;
  transition: background .15s, transform .15s;
}
.ss-tut .dots i.on { background: linear-gradient(90deg, #f59e0b, #a78bfa); transform: scale(1.3); }
.ss-tut .row { display: flex; justify-content: space-between; gap: 10px; }
.ss-tut .skip, .ss-tut .next {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  cursor: pointer;
}
.ss-tut .skip {
  background: rgba(148,163,184,0.18);
  border: 1px solid #94a3b855;
  color: #cbd5e1;
}
.ss-tut .next {
  background: linear-gradient(135deg, #7c3aed, #f59e0b);
  border: 1px solid #fbbf24;
  color: #0a0418;
  font-weight: 700;
}
.ss-tut .next:hover { filter: brightness(1.08); }

/* ── PORTRAIT (390x844 baseline) HUD TWEAKS ────────────────────────── */
@media (max-width: 540px) {
  #hud { font-size: 0.78rem; padding: 4px 6px; }
  #hud .hud-row { gap: 6px; }
  #hud .hud-block { padding: 4px 6px; }
  #hud .hud-value { font-size: 0.95rem; }
  .ss-set-btn { width: 34px; height: 34px; font-size: 0.95rem; right: 6px; }
}
@media (orientation: portrait) and (max-width: 540px) {
  /* keep canvas full-bleed and HUD legible at 390x844 */
  #game-container { width: 100vw; height: 100vh; }
  /* let mobile controls breathe */
  #mobile-controls .mc-pad-left  { bottom: max(10px, env(safe-area-inset-bottom, 0px) + 10px); }
  #mobile-controls .mc-pad-right { bottom: max(10px, env(safe-area-inset-bottom, 0px) + 10px); }
}
/* respect notch on landscape too */
@supports (padding: max(0px)) {
  #hud { padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
}
