* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #000;
  color: #cfd8dc;
  font-family: "Courier New", monospace;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#stage {
  position: fixed;
  top: 0;
  left: 0;
  width: 800px;
  height: 448px;
  transform-origin: top left;   /* fit.js setea translate()+scale() desde acá */
  box-shadow: 0 0 60px rgba(0,0,0,0.9);
}

#screen {
  display: block;
  width: 800px;
  height: 448px;
  background: #111;
  cursor: crosshair;
}

/* ---- HUD ---- */
#hud {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0.1));
  font-size: 13px;
  letter-spacing: 1px;
  pointer-events: none;
  text-shadow: 0 0 6px #000;
}
.hud-label { color: #7a8a99; font-size: calc(10px * var(--ui-font-scale, 1)); display: block; }
.hud-val { color: #7CFC00; font-size: calc(22px * var(--ui-font-scale, 1)); font-weight: bold; }
.hud-right { display: flex; gap: 16px; }
.hud-right .stat { text-align: center; }
.hud-right #ammo { color: #FFD54F; }
.hud-right #coins { color: #FFC107; }
.hud-right #forros { color: #FF8FC7; }
.hud-right #caramelos { color: #FF7043; }
.hud-msg {
  color: #ff5252; font-size: calc(14px * var(--ui-font-scale, 1)); font-weight: bold; text-align: center;
  transition: opacity var(--ui-msg-fade, 150ms) linear;   /* aparecer/desaparecer suave */
}

#floorName {
  position: absolute;
  top: 8px; left: 0; right: 0;
  text-align: center;
  font-size: calc(12px * var(--ui-font-scale, 1));
  letter-spacing: 3px;
  color: #4FC3F7;
  text-shadow: 0 0 8px #000;
  pointer-events: none;
}

#prompt {
  position: absolute;
  left: 0; right: 0; bottom: 56px;
  text-align: center;
  font-size: calc(13px * var(--ui-font-scale, 1));
  letter-spacing: 1px;
  color: #FFE082;
  text-shadow: 0 0 8px #000;
  pointer-events: none;
}
#prompt .key {
  display: inline-block;
  padding: 1px 7px;
  margin-right: 6px;
  border: 1px solid #FFE082;
  border-radius: 3px;
  color: #fff;
  font-weight: bold;
}

/* ---- Overlays ---- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 12, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.panel {
  width: 90%;
  max-width: 560px;
  max-height: 94%;          /* nunca más alto que el stage */
  overflow-y: auto;         /* si no entra, scrollea adentro (el botón siempre alcanzable) */
  padding: 16px 24px;
  border: 1px solid #1f3a4d;
  background: rgba(6, 14, 22, 0.96);
  box-shadow: inset 0 0 40px rgba(0, 60, 90, 0.25);
}
.panel h1 {
  font-size: 28px;
  letter-spacing: 4px;
  color: #FFB300;
  text-shadow: 0 0 14px rgba(255,140,0,0.6);
  margin-bottom: 3px;
}
.panel h2 {
  font-size: 13px;
  color: #4FC3F7;
  letter-spacing: 2px;
  margin-bottom: 10px;
}
.panel p { font-size: 12px; line-height: 1.42; margin-bottom: 7px; color: #b0bec5; }
.panel p.controls { color: #80cbc4; font-size: 11px; margin-top: 12px; }
.panel strong { color: #fff; }

.online-badge {
  display: inline-block;
  margin-bottom: 12px;
  padding: 3px 10px;
  border: 1px solid #2e7d32;
  border-radius: 12px;
  background: rgba(20, 60, 25, 0.5);
  color: #9ccc65;
  font-size: 11px;
  letter-spacing: 1px;
}
.gh-line { font-size: 10.5px; color: #607d8b; margin-top: 10px; margin-bottom: 0; }
.homenaje { font-size: 10.5px; color: #8a7f6a; margin-top: 12px; margin-bottom: 0; line-height: 1.45; }
.homenaje strong { color: #FFD54F; }
.gh-link { color: #4FC3F7; text-decoration: none; }
.gh-link:hover { text-decoration: underline; }

button {
  margin-top: 12px;
  padding: 10px 20px;
  background: #FFB300;
  color: #0a0a0a;
  border: none;
  font-family: inherit;
  font-weight: bold;
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover { background: #ffd54f; }
/* "Continuar" (guardado): bloque propio arriba de ENTRAR, con tinte verde de "retomar" */
#continueBtn { display: block; margin: 0 auto 4px; background: #7CFC00; }
#continueBtn:hover { background: #9dff4a; }

/* ---- resumen de la partida (pantalla de fin) ---- */
.end-stats:empty { display: none; }
.end-stats-title { font-size: 11px; letter-spacing: 2px; color: #9fd3ff; margin: 10px 0 4px; }
.end-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; margin-bottom: 8px; }
.end-stat { display: flex; justify-content: space-between; font-size: 12px; gap: 8px;
  border-bottom: 1px dotted rgba(255,255,255,0.15); padding-bottom: 2px; }
.end-stat b { color: #FFD54F; }
.end-hitos { list-style: none; padding: 0; margin: 4px 0 0; font-size: 11px; text-align: left;
  columns: 2; column-gap: 18px; }
.end-hitos li { padding: 1px 0; break-inside: avoid; }
.end-hitos li.done { color: #7CFC00; }
.end-hitos li.miss { color: #6a6a6a; }

/* ---- Storm flash ---- */
#flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 9;
}

/* ---- Opciones ---- */
#optBtn {
  position: absolute; top: 6px; right: 8px; z-index: 11;
  width: 26px; height: 26px; margin: 0; padding: 0;
  font-size: 15px; line-height: 24px; text-align: center;
  background: rgba(6,14,22,0.8); color: #cfd8dc;
  border: 1px solid #1f3a4d; border-radius: 4px; cursor: pointer;
}
#optBtn:hover { background: rgba(20,40,55,0.95); color: #fff; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 9px 0; font-size: 12px; }
.opt-row > span:first-child { flex: 1; text-align: left; color: #b0bec5; }
.opt-btn {
  width: 26px; height: 24px; margin: 0; padding: 0; font-size: 15px; line-height: 22px;
  background: #1f3a4d; color: #fff; border: none; border-radius: 3px; cursor: pointer;
}
.opt-btn:hover { background: #2e587a; }
.opt-val { min-width: 58px; text-align: center; color: #FFE082; }
.opt-select { font-family: inherit; font-size: 12px; padding: 5px 8px; cursor: pointer;
  background: #0a141c; color: #e8eef2; border: 1px solid #1f3a4d; border-radius: 3px; }
.opt-select:focus { outline: none; border-color: #4FC3F7; }
.opt-aikey-label { margin-top: 14px; border-top: 1px solid #1f3a4d; padding-top: 12px; }
.opt-aikey-label > span { color: #80cbc4; }
#opt-aikey { width: 100%; padding: 8px 10px; font-family: inherit; font-size: 12px;
  background: #0a141c; color: #e8eef2; border: 1px solid #1f3a4d; border-radius: 3px; }
#opt-aikey:focus { outline: none; border-color: #4FC3F7; }
.opt-note { font-size: 10.5px; color: #90a4ae; margin: 6px 0 2px; line-height: 1.4; }
#opt-aimodel { flex: 1; padding: 8px 10px; font-family: inherit; font-size: 11px;
  background: #0a141c; color: #e8eef2; border: 1px solid #1f3a4d; border-radius: 3px; }
#opt-aimodel:focus { outline: none; border-color: #4FC3F7; }
.opt-validate-btn { width: auto; padding: 0 12px; }
.opt-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.opt-actions button { margin-top: 0; padding: 8px 14px; font-size: 12px; }

/* ---- Chat con NPC ---- */
.chat-panel { max-width: 600px; }
#chat-title { color: #FFB300; }
#chat-log {
  height: 200px; max-height: 46vh; overflow-y: auto;
  margin: 10px 0; padding: 8px 10px;
  border: 1px solid #1f3a4d; background: rgba(2,8,14,0.7);
  font-size: 12px; line-height: 1.45;
}
#chat-log .you { color: #80cbc4; margin: 4px 0; }
#chat-log .npc { color: #ffe082; margin: 4px 0; }
#chat-log .sys { color: #607d8b; font-style: italic; margin: 4px 0; }
.chat-input-row { display: flex; gap: 8px; }
#chat-input {
  flex: 1; padding: 9px 10px; font-family: inherit; font-size: 13px;
  background: #0a141c; color: #e8eef2; border: 1px solid #1f3a4d; border-radius: 3px;
}
#chat-input:focus { outline: none; border-color: #4FC3F7; }
.chat-input-row button { margin-top: 0; padding: 9px 14px; font-size: 12px; }

.hidden { display: none !important; }
