:root {
  --bg: #0b0b0d;
  --panel: #16161a;
  --line: #2c2c33;
  --text: #ececf1;
  --muted: #9a9aa6;
  --accent: #f2c14e;
  --accent-ink: #1a1405;
  --danger: #e5484d;
  --ok: #46a758;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }

#game-surface { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #000; }
#canvas { width: 100%; height: 100%; display: block; outline: none; touch-action: none; }

/* Pantalla de carga */
.intro-container { position: fixed; inset: 0; z-index: 30; background: #000; }
.intro-container[hidden] { display: none; }
.loader-box { position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%); width: min(480px, 90%);
  display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 16px 22px;
  background: rgba(0,0,0,.9); border: 2px solid rgba(255,255,255,.35); }
#spinner { width: 100%; height: 10px; border: 2px solid rgba(255,255,255,.35); background: rgba(255,255,255,.08); overflow: hidden; }
#spinner[hidden] { display: none; }
.progress-bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#status { font-weight: 600; font-size: 14px; text-align: center; }
#status[data-state="error"] { color: var(--danger); white-space: pre-wrap; }
#loader-subtext { font-size: 12px; color: rgba(255,255,255,.75); text-align: center; }

/* Lanzador */
.start-container { position: fixed; inset: 0; z-index: 20; overflow-y: auto; display: flex; align-items: flex-start; justify-content: center;
  padding: max(24px, 6vh) 16px 24px; background: radial-gradient(ellipse at top, #1d1d24, var(--bg) 70%);
  transition: opacity .3s, visibility .3s; }
.start-container.is-leaving { opacity: 0; }
.start-container.is-gone { visibility: hidden; opacity: 0; pointer-events: none; }
body.show-saves .start-container.is-gone { visibility: visible; opacity: 1; pointer-events: auto; background: rgba(0,0,0,.75); }
body.show-saves .start-container .actions,
body.show-saves .start-container header,
body.show-saves .start-container .help { display: none; }

.panel { width: min(640px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
h1 { margin: 0; font-size: 28px; letter-spacing: -.01em; }
h2 { margin: 0; font-size: 17px; }
.sub, .muted { color: var(--muted); }
.sub { margin: 4px 0 0; font-size: 13px; }
.actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 20px 0 24px; }
.lang { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
select { background: #0f0f12; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; }

.btn { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: #222229; color: var(--text); padding: 8px 14px; }
.btn:hover:not(:disabled) { border-color: #4a4a55; background: #2a2a32; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; font-size: 17px; padding: 11px 26px; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 14px; }
.btn.danger:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); }

.saves-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.saves-head .muted { font-size: 13px; }
#saves-msg { white-space: pre-line; font-size: 13px; padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; border: 1px solid var(--ok); }
#saves-msg[data-state="error"] { border-color: var(--danger); }
#save-slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.slot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px dashed var(--line); border-radius: 8px; }
.slot.full { border-style: solid; background: #1b1b20; }
.slot-info { min-width: 0; font-size: 14px; }
.slot-btns { display: flex; gap: 6px; flex-shrink: 0; }
.saves-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.help { margin-top: 20px; color: var(--muted); font-size: 14px; }
.help summary { cursor: pointer; }

/* Barra durante la partida */
#game-hud-bar { position: fixed; top: 8px; right: 8px; z-index: 40; display: flex; gap: 6px; opacity: .25; transition: opacity .2s; }
#game-hud-bar:hover { opacity: 1; }
#game-hud-bar[hidden] { display: none; }
#game-hud-bar button { font-size: 16px; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: rgba(20,20,24,.85); color: var(--text); cursor: pointer; }

/* Trucos */
.cheats { margin-top: 22px; }
.cheats summary { cursor: pointer; }
.cheats summary h2 { display: inline; }
.cheats p { margin: 8px 0 10px; font-size: 13px; }
#cheat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cheat-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(0, 12em); gap: 10px; align-items: center; }
.cheat-key { font-weight: 700; font-size: 13px; text-align: center; padding: 5px 0; border: 1px solid var(--line); border-radius: 6px; background: #0f0f12; }
.cheat-row input { min-width: 0; background: #0f0f12; color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; font: 14px ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.cheat-row input:focus { outline: none; border-color: var(--accent); }
.cheat-desc { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) { .cheat-row { grid-template-columns: 44px minmax(0, 1fr); } .cheat-desc { display: none; } }
#cheat-toast { position: fixed; left: 50%; top: 14px; transform: translate(-50%, -8px); z-index: 50; pointer-events: none;
  padding: 6px 14px; border-radius: 8px; background: rgba(0,0,0,.8); border: 1px solid var(--accent); color: var(--accent);
  font: 700 14px ui-monospace, Menlo, monospace; opacity: 0; transition: opacity .2s, transform .2s; }
#cheat-toast.show { opacity: 1; transform: translate(-50%, 0); }
