:root {
  --bg: #0b0c10;
  --fg: #f2f3f5;
  --muted: #9aa0ab;
  --accent: #f2a541;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#app canvas { display: block; }
[hidden] { display: none !important; }

kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0.1em 0.45em;
  margin: 0 0.1em;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom-width: 3px;
  border-radius: 6px;
  font-family: inherit; font-weight: 600; font-size: 0.85em; line-height: 1.4;
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }

#crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
}

#room-name {
  position: absolute; top: 28px; left: 50%;
  transform: translate(-50%, -10px);
  padding: 8px 22px;
  border-left: 6px solid var(--accent);
  background: rgba(10, 11, 15, 0.75);
  font-size: 26px; font-weight: 700; letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.4s, transform 0.4s;
}
#room-name.show { opacity: 1; transform: translate(-50%, 0); }

#prompt {
  position: absolute; left: 50%; bottom: 14%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(10, 11, 15, 0.8);
  font-size: 18px;
  white-space: nowrap;
}

#minimap {
  position: absolute; right: 16px; top: 16px;
  border-radius: 8px;
  background: rgba(10, 11, 15, 0.7);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
#minimap.big {
  right: 50%; top: 50%;
  transform: translate(50%, -50%);
  background: rgba(10, 11, 15, 0.88);
}

/* ---------- Menú ---------- */
#menu {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(11, 12, 16, 0.55), rgba(11, 12, 16, 0.92));
}
#menu .card { max-width: 560px; text-align: center; }
#menu h1 { margin: 0 0 6px; font-size: clamp(28px, 5vw, 46px); letter-spacing: 0.03em; }
#menu .sub { margin: 0 0 28px; color: var(--muted); }
#start-btn {
  padding: 14px 44px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: #14161c;
  font-family: inherit; font-weight: 700; font-size: 20px;
  cursor: pointer;
  transition: transform 0.15s;
}
#start-btn:hover { transform: scale(1.05); }
#start-btn:disabled { opacity: 0.5; cursor: wait; }
#theme-picker {
  display: flex;
  width: fit-content;
  margin: 18px auto 0;
  padding: 4px;
  gap: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}
#theme-picker button {
  padding: 7px 18px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--muted);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
#theme-picker button[aria-pressed="true"] { background: var(--fg); color: #14161c; }
#theme-picker button:focus-visible, #start-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#menu .keys { list-style: none; padding: 0; margin: 28px 0 0; color: var(--muted); line-height: 2.2; }
#menu-status { min-height: 1.5em; color: var(--muted); font-size: 14px; }
#menu-status.error { color: #ff6b6b; }

/* ---------- Visor de video ---------- */
#viewer {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: #000;
}
#viewer-frame { flex: 1; min-height: 0; }
#viewer-frame iframe, #viewer-frame video { width: 100%; height: 100%; border: 0; background: #000; }
#viewer-info {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px;
  background: #0f1117;
}
#viewer-info h2 { margin: 0; font-size: 18px; }
#viewer-info p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
#viewer-info a { color: var(--accent); white-space: nowrap; }
#viewer-close {
  position: absolute; top: 14px; right: 14px;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: rgba(20, 22, 28, 0.85); color: #fff;
  font-size: 20px; cursor: pointer;
}

/* ---------- Celular / táctil ---------- */
.keys-touch, #pause-btn, #cash-btn, #rotate-hint { display: none; }
body.touch .keys-desktop { display: none; }
body.touch .keys-touch { display: block; }

#touch-layer {
  position: fixed; inset: 0;
  touch-action: none;
}
#joy-base {
  position: absolute;
  width: 120px; height: 120px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
#joy-knob {
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

body.touch #pause-btn {
  display: block;
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: calc(12px + env(safe-area-inset-left, 0px));
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: rgba(10, 11, 15, 0.7); color: #fff;
  font-size: 14px;
  pointer-events: auto;
}
body.touch #cash-btn {
  display: block;
  position: absolute;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 58px; height: 58px;
  border: 2px solid rgba(255, 255, 255, 0.6); border-radius: 50%;
  background: rgba(47, 107, 76, 0.85); color: #fff;
  font: 700 26px Georgia, serif;
  pointer-events: auto;
}
body.touch #cash-btn:active { transform: scale(0.92); }
body.touch #minimap {
  pointer-events: auto;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
}
body.touch #minimap.big { top: 50%; right: 50%; }
body.touch #prompt {
  pointer-events: auto;
  bottom: calc(18% + env(safe-area-inset-bottom, 0px));
  padding: 14px 20px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  font-size: 16px;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.touch #room-name { font-size: 20px; top: calc(16px + env(safe-area-inset-top, 0px)); }

@media (orientation: portrait) {
  body.touch #rotate-hint {
    display: block;
    position: absolute; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(10, 11, 15, 0.7);
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
  }
}

/* Menú y visor en pantallas chicas */
@media (max-width: 700px), (max-height: 500px) {
  #theme-picker {
  display: flex;
  width: fit-content;
  margin: 18px auto 0;
  padding: 4px;
  gap: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}
#theme-picker button {
  padding: 7px 18px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--muted);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
#theme-picker button[aria-pressed="true"] { background: var(--fg); color: #14161c; }
#theme-picker button:focus-visible, #start-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#menu .keys { margin-top: 16px; line-height: 1.7; font-size: 14px; }
  #menu .sub { margin-bottom: 16px; }
  #menu { overflow-y: auto; }
  #viewer-info { padding: 8px 14px; }
  #viewer-info p { display: none; }
}
#viewer-close { top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px)); }
