/* SHADOW SISTERS — UI base (Fase 1). Paleta: noche violeta + plata + verde fantastico. */
:root {
  --ss-bg: #140c1e;
  --ss-bg-2: #1f1430;
  --ss-violet: #7b4bd1;
  --ss-violet-2: #a77bff;
  --ss-silver: #e6e1f0;
  --ss-muted: #a59bb8;
  --ss-green: #5dffa8;      /* fluido fantastico, nunca rojo */
  --ss-warn: #ffcf6b;
  --ss-panel: rgba(20, 12, 30, 0.88);
  --ss-border: rgba(167, 123, 255, 0.35);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea { -webkit-user-select: text; user-select: text; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: var(--ss-bg); color: var(--ss-silver);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5;
  overflow: hidden; overscroll-behavior: none;
}
body { position: fixed; inset: 0; }

#game-root { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }

[hidden] { display: none !important; }

/* ---------- Pantallas ---------- */
.screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: calc(1rem + var(--safe-t)) calc(1rem + var(--safe-r)) calc(1rem + var(--safe-b)) calc(1rem + var(--safe-l));
}
.screen-boot {
  flex-direction: column; gap: 1.25rem;
  background: radial-gradient(ellipse at 50% 35%, #2b1a45 0%, var(--ss-bg) 70%);
}
.boot-logo { width: min(62vw, 46vh, 360px); height: auto; border-radius: 14px; box-shadow: 0 0 60px rgba(123, 75, 209, .45); }
.boot-bar { width: min(70vw, 320px); height: 4px; background: rgba(255,255,255,.12); border-radius: 2px; overflow: hidden; }
.boot-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ss-violet), var(--ss-green)); transition: width .2s ease; }
.boot-msg { margin: 0; font-size: 13px; color: var(--ss-muted); letter-spacing: .06em; }

.screen-title {
  background:
    linear-gradient(180deg, rgba(20,12,30,.25) 0%, rgba(20,12,30,.85) 70%),
    radial-gradient(ellipse at 50% 20%, rgba(123,75,209,.35), transparent 60%);
}
.title-card { display: flex; flex-direction: column; align-items: center; gap: .75rem; max-width: 420px; width: 100%; }
.title-logo { width: min(58vw, 40vh, 300px); height: auto; border-radius: 14px; box-shadow: 0 0 50px rgba(123,75,209,.5); }
.title-sub { margin: 0; font-size: 13px; letter-spacing: .3em; text-transform: uppercase; color: var(--ss-violet-2); text-align: center; }
.title-menu { display: flex; flex-direction: column; gap: .6rem; width: min(80vw, 300px); margin-top: .5rem; }
.title-save { margin: 0; font-size: 12px; color: var(--ss-muted); min-height: 1.2em; text-align: center; }

/* Horizontal bajo: logo al costado del menu */
@media (orientation: landscape) and (max-height: 520px) {
  .title-card { flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 760px; gap: 1.5rem; }
  .title-logo { width: min(36vw, 62vh); }
  .title-sub { width: 100%; order: 3; }
}

/* ---------- Botones ---------- */
.btn {
  min-height: 48px; padding: .75rem 1.25rem;
  border-radius: 10px; border: 1px solid var(--ss-border);
  background: rgba(31, 20, 48, .85); color: var(--ss-silver);
  font: 600 15px/1 Inter, system-ui, sans-serif; letter-spacing: .04em;
  cursor: pointer; transition: transform .1s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--ss-violet-2); background: rgba(55, 34, 88, .9); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--ss-green); outline-offset: 2px; }
.btn-primary { background: linear-gradient(135deg, #6a3dc4, #8f5cf0); border-color: transparent; color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, #7a4ad6, #a072ff); }

/* ---------- Panel pausa ---------- */
.screen-pause { background: rgba(10, 6, 16, .6); z-index: 30; }
.panel {
  width: min(92vw, 340px); max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: .6rem;
  background: var(--ss-panel); border: 1px solid var(--ss-border); border-radius: 14px;
  padding: 1.25rem; box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.panel h2 { margin: 0 0 .25rem; font-size: 22px; font-weight: 600; text-align: center; }
.panel-note { margin: .25rem 0 0; font-size: 13px; color: var(--ss-muted); text-align: center; min-height: 1.2em; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.hud-top {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(.6rem + var(--safe-t)) calc(.75rem + var(--safe-r)) 0 calc(.75rem + var(--safe-l));
}
.hud-sister {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--ss-panel); border: 1px solid var(--ss-border); border-radius: 10px; padding: .4rem .7rem;
}
.hud-sister-name { font-weight: 600; font-size: 15px; }
.hud-tag { font-size: 12px; color: var(--ss-muted); letter-spacing: .04em; }
.hud-right { display: flex; align-items: center; gap: .5rem; }
.hud-save { font-size: 12px; color: var(--ss-green); text-shadow: 0 1px 2px #000; }
.hud-btn {
  pointer-events: auto; width: 48px; height: 48px; border-radius: 12px;
  border: 1px solid var(--ss-border); background: var(--ss-panel); color: var(--ss-silver);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.hud-btn svg { fill: currentColor; }
.hud-btn:active { transform: scale(.95); }
.hud-objective {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(4.1rem + var(--safe-t));
  font-size: 13px; color: var(--ss-silver); background: rgba(20,12,30,.6);
  padding: .3rem .8rem; border-radius: 999px; white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
.hud-objective:empty { display: none; }
.hud-fps {
  position: absolute; left: calc(.75rem + var(--safe-l)); bottom: calc(.6rem + var(--safe-b));
  font: 12px/1.3 ui-monospace, Menlo, monospace; color: var(--ss-green);
  background: rgba(0,0,0,.55); padding: .25rem .5rem; border-radius: 6px; white-space: pre;
}
.hud-hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(1rem + var(--safe-b)); font-size: 13px; color: var(--ss-muted);
  text-shadow: 0 1px 2px #000; text-align: center; transition: opacity .6s ease; white-space: nowrap;
}

/* Joystick tactil dinamico */
.joy {
  position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px;
  border-radius: 50%; border: 2px solid rgba(230,225,240,.35); background: rgba(20,12,30,.25);
}
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgba(167,123,255,.6); border: 2px solid rgba(255,255,255,.6);
}

/* ---------- Toasts ---------- */
#toasts {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(4.5rem + var(--safe-b)); z-index: 50;
  display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none;
}
.toast {
  padding: .6rem 1rem; border-radius: 10px; font-size: 14px; max-width: 90vw;
  background: var(--ss-panel); border: 1px solid var(--ss-border); color: var(--ss-silver);
  animation: toast-in .25s ease;
}
.toast-ok { border-color: rgba(93,255,168,.6); }
.toast-warn { border-color: rgba(255,207,107,.7); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
