/* ELEMENTAL BOYS — paleta extraída del arte de referencia del cliente */
:root {
  --eb-fire:      #E23A1E;
  --eb-fire-2:    #FF8A1C;
  --eb-gold:      #FFD23F;
  --eb-water:     #2E7BFF;
  --eb-cyan:      #5FD3FF;
  --eb-ice:       #DFF4FF;
  --eb-night:     #0B1530;
  --eb-ink:       #0A1024;
  --eb-panel:     rgba(10, 16, 36, .92);
  --radius:       10px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[data-theme="light"] {
  --bg-primary: #FFFFFF; --bg-secondary: #F2F7FC; --bg-tertiary: #E3EEF8;
  --text-primary: #0A1024; --text-secondary: #34405E; --text-muted: #5F6B85;
  --border: #C9D6E6; --accent: #1F5FD6; --accent-text: #FFFFFF;
  --danger: #C0392B; --success: #1A7A4A; --warning: #B8650A;
  --surface: #FFFFFF; --shadow: rgba(10,16,36,.18);
}
[data-theme="dark"] {
  --bg-primary: #0E1428; --bg-secondary: #141C36; --bg-tertiary: #1C2648;
  --text-primary: #EEF4FF; --text-secondary: #A9B6D3; --text-muted: #7D89A6;
  --border: #2A3560; --accent: #5FA0FF; --accent-text: #0A1024;
  --danger: #E05252; --success: #3DBE7A; --warning: #E8900A;
  --surface: #141C36; --shadow: rgba(0,0,0,.5);
}

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

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--eb-night); color: var(--text-primary);
  font: 15px/1.6 var(--font);
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; }

#game-container {
  position: absolute; inset: 0;
  touch-action: none; overflow: hidden;
  background: var(--eb-night);
}
#game-container canvas { image-rendering: pixelated; }

/* Barra superior */
#topbar {
  position: fixed; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  display: flex; gap: 8px; align-items: center; z-index: 50;
}
[hidden] { display: none !important; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px; border-radius: 18px;
  background: var(--eb-panel); color: var(--eb-ice);
  border: 2px solid var(--eb-ink); box-shadow: inset 0 0 0 1px rgba(95,211,255,.35);
  font-size: 13px; font-weight: 600;
}
.chip svg { width: 16px; height: 16px; color: var(--eb-gold); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--eb-ink);
  background: var(--eb-panel); color: var(--eb-ice);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform .1s ease;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; }
[data-theme="light"] .icon-dark, [data-theme="dark"] .icon-light { display: none; }

/* Modal — reglas skill 02 */
.modal-wrapper {
  position: fixed; inset: 0; z-index: 1000; padding: 1rem;
  background: rgba(5, 9, 22, .72);
  display: flex; align-items: center; justify-content: center;
}
.modal-wrapper[hidden] { display: none; }
.modal {
  width: 100%; max-width: 440px; max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--bg-primary); color: var(--text-primary);
  border: 3px solid var(--eb-ink); border-radius: 14px;
  box-shadow: 0 0 0 2px var(--eb-cyan), 0 18px 50px var(--shadow);
  animation: pop .22s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  position: relative; padding: 14px 16px 0;
  background: linear-gradient(135deg, var(--eb-night) 0%, #16306A 100%);
  border-radius: 11px 11px 0 0; text-align: center;
}
.modal-logo { height: 70px; display: block; margin: 0 auto 6px; filter: drop-shadow(0 3px 0 var(--eb-ink)); }
.modal-close { position: absolute; top: 8px; right: 8px; }
.tabs { display: flex; gap: 4px; }
.tab {
  flex: 1; min-height: 44px; border: 0; cursor: pointer;
  font: 700 13px var(--font); letter-spacing: .06em; text-transform: uppercase;
  color: var(--eb-ice); background: transparent; border-radius: 10px 10px 0 0;
}
.tab.active { background: var(--bg-primary); color: var(--text-primary); }
.modal-body { flex: 1; overflow-y: auto; padding: 1.25rem 1.5rem; }
.modal-body h2 { margin: 0 0 1rem; font-size: 18px; font-weight: 600; }
.modal-footer {
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
  display: flex; gap: .75rem; justify-content: flex-end;
  background: var(--bg-primary); border-radius: 0 0 11px 11px;
}
.field { display: block; margin-bottom: .9rem; }
.field > span { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.field input {
  width: 100%; height: 46px; padding: 0 .9rem;
  border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--bg-secondary); color: var(--text-primary);
  font: 15px var(--font); outline: none;
}
.field input:focus { border-color: var(--eb-water); box-shadow: 0 0 0 3px rgba(46,123,255,.2); }
.password-field { position: relative; }
.password-field input { padding-right: 52px; }
.password-field .toggle-password {
  position: absolute; right: 2px; top: 1px; border: 0; background: none; color: var(--text-muted);
}
.hint { font-size: 12px; color: var(--text-muted); margin: 0; }
.btn {
  min-height: 46px; padding: 0 1.25rem; border-radius: var(--radius); cursor: pointer;
  font: 700 14px var(--font); letter-spacing: .04em; text-transform: uppercase;
  border: 2px solid var(--eb-ink); transition: transform .1s ease, filter .15s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { filter: grayscale(.6) brightness(.85); cursor: wait; }
.btn-fire { color: #fff; background: linear-gradient(180deg, var(--eb-fire-2), var(--eb-fire)); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); text-shadow: 0 1px 0 var(--eb-ink); }
.btn-ghost { color: var(--text-primary); background: var(--bg-secondary); border-color: var(--border); }

/* Toasts — nunca alert() */
#toasts { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  padding: .7rem 1.2rem; border-radius: 10px; font-size: 14px; font-weight: 600; color: #fff;
  border: 2px solid var(--eb-ink); box-shadow: 0 6px 18px rgba(0,0,0,.35);
  animation: toastIn .25s ease; max-width: 90vw; text-align: center;
}
.toast-error { background: var(--danger); }
.toast-success { background: var(--success); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--eb-water); }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 768px) {
  .modal-wrapper { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; border-radius: 16px 16px 0 0; }
  .modal-footer { border-radius: 0; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Juego SOLO horizontal: overlay "girá el celular" en dispositivos táctiles en vertical */
#rotate-overlay { display: none; }
@media (orientation: portrait) and (pointer: coarse), (orientation: portrait) and (max-width: 900px) {
  #rotate-overlay {
    position: fixed; inset: 0; z-index: 20000;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    padding: 2rem; text-align: center; color: var(--eb-ice);
    background: radial-gradient(ellipse at 50% 35%, #1B3A7A 0%, var(--eb-night) 70%);
  }
  #rotate-overlay p { margin: 0; font-size: 20px; font-weight: 700; color: #fff; text-shadow: 0 2px 0 var(--eb-ink); }
  #rotate-overlay span { font-size: 13px; color: var(--eb-cyan); letter-spacing: .06em; text-transform: uppercase; }
  .rotate-logo { width: min(70vw, 320px); filter: drop-shadow(0 4px 0 var(--eb-ink)); }
  .rotate-phone { width: 72px; height: 72px; color: var(--eb-gold); animation: rotarTel 2.2s ease-in-out infinite; }
  .rotate-phone svg { width: 72px; height: 72px; }
  #topbar, #toasts { display: none; }
}
@keyframes rotarTel { 0%, 30% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
