/* =================================================================
   La Búsqueda del Tesoro en el Plano Cartesiano — Estilos
   Estética: HUD de videojuego, paneles azul marino con biseles,
   acentos dorados, madera y verde bosque. Fuentes del sistema
   (la app corre offline en Electron, sin fuentes externas).
   ================================================================= */

:root {
  --bg-deep:    #0a1230;
  --bg-deep-2:  #0d1a3e;
  --panel:      #14254f;
  --panel-2:    #0f1d40;
  --panel-edge: #2f6fd0;
  --panel-edge-soft: #1c3a70;
  --gold:       #ffce4d;
  --gold-deep:  #e8951f;
  --teal:       #36d6c4;
  --green:      #57c84a;
  --green-deep: #2f8a2a;
  --purple:     #7b5cff;
  --danger:     #e23c3c;
  --danger-deep:#a51e1e;
  --text:       #eaf2ff;
  --muted:      #8fa6cf;
  --wood-a:     #7a4a26;
  --wood-b:     #5a3417;
  --shadow:     rgba(0,0,0,.45);
  --q1: rgba(255, 214, 102, .07);
  --q2: rgba(80, 200, 255, .07);
  --q3: rgba(255, 140, 90, .07);
  --q4: rgba(170, 120, 255, .07);
  --font-ui: "Trebuchet MS", "Segoe UI", system-ui, "Verdana", sans-serif;
  --font-display: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.screen { position: fixed; inset: 0; }
.hidden { display: none !important; }

/* ---------- Botones base ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #2f6fd0, #1c3f86);
  box-shadow: 0 3px 0 #122a5a, 0 5px 10px var(--shadow);
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #122a5a; }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn-small { padding: 7px 10px; font-size: 12px; }
.btn-play {
  background: linear-gradient(180deg, #6fe05a, #2f8a2a);
  box-shadow: 0 3px 0 #1c5a16, 0 6px 14px var(--shadow);
  font-size: 18px; padding: 13px;
}
.btn-answer {
  width: 100%;
  background: linear-gradient(180deg, #6fe05a, #2f8a2a);
  box-shadow: 0 3px 0 #1c5a16, 0 5px 10px var(--shadow);
  margin-top: 8px;
  font-size: 13px; padding: 9px 14px;
}
.btn-answer:disabled { filter: grayscale(.6) brightness(.8); cursor: not-allowed; }

/* Estado deshabilitado genérico — gris apagado, sin hover, cursor bloqueado */
.btn:disabled {
  background: linear-gradient(180deg, #3a3a52, #252535) !important;
  box-shadow: 0 2px 0 #111120, 0 3px 8px rgba(0,0,0,.3) !important;
  color: #5a5a78 !important;
  cursor: not-allowed !important;
  filter: none !important;
  transform: none !important;
  opacity: 0.6;
}
.btn:disabled:hover { filter: none !important; }

/* Botón Acceder habilitado: brillo pulsante verde para llamar la atención */
#stu-close:not(:disabled) {
  animation: btn-acceder-pulse 1.6s ease-in-out infinite;
}
@keyframes btn-acceder-pulse {
  0%, 100% { box-shadow: 0 3px 0 #1c5a16, 0 6px 14px rgba(0,0,0,.4); }
  50%       { box-shadow: 0 3px 0 #1c5a16, 0 6px 28px rgba(111,224,90,.65), 0 0 16px rgba(111,224,90,.4); }
}
.btn-danger {
  background: linear-gradient(180deg, #ef5350, #a51e1e);
  box-shadow: 0 3px 0 #7a1414, 0 5px 10px var(--shadow);
}
.btn-new-student {
  width: 100%; margin-top: 6px;
  font-size: 12px; padding: 7px 10px;
  background: linear-gradient(180deg, #2f8fe0, #1c5fa6);
}

/* ============================= MENÚ ============================= */
#screen-menu {
  display: grid; place-items: center;
  overflow-y: auto;
  padding: 16px;
  background: radial-gradient(circle at 50% 35%, #16306a, var(--bg-deep) 70%);
}
.menu-forest { position: absolute; inset: 0; z-index: 0; }
#menu-bg { width: 100%; height: 100%; display: block; }
.menu-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 26px;
  text-align: center;
}
.menu-logo { position: relative; display: flex; align-items: center; gap: 8px; }
.logo-plank {
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 40px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--wood-a), var(--wood-b));
  border: 4px solid #3e2410;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.18), 0 8px 24px var(--shadow);
}
.logo-small { font-size: 16px; font-weight: 700; letter-spacing: 3px; color: #ffe9b8; }
.logo-big {
  font-size: 64px; font-weight: 800; letter-spacing: 4px;
  color: var(--gold);
  text-shadow: 0 3px 0 #7a4a10, 0 5px 8px rgba(0,0,0,.4);
}
#logo-spark { position: absolute; top: -10px; right: -28px; }

.menu-panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 3px solid var(--panel-edge);
  border-radius: 20px;
  padding: 22px 26px;
  width: 360px;
  box-shadow: inset 0 0 0 2px var(--panel-edge-soft), 0 10px 30px var(--shadow);
}
.menu-active-student {
  display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px;
  padding-bottom: 14px; border-bottom: 2px solid var(--panel-edge-soft);
}
.menu-active-student strong { font-size: 20px; color: var(--gold); }
.menu-buttons { display: grid; gap: 10px; }
.menu-footer { color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }

/* ============================= HUD ============================= */
.hud {
  position: absolute; inset: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 190px 1fr 230px;
  grid-template-rows: 48px minmax(220px, 1fr) 158px;
  grid-template-areas:
    "top    top    top"
    "left   center right"
    "bottom bottom bottom";
  gap: 6px;
  padding: 6px;
  background:
    radial-gradient(circle at 50% 0%, #16306a, transparent 60%),
    var(--bg-deep);
}

/* Panel genérico */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 2px solid var(--panel-edge);
  border-radius: 12px;
  box-shadow: inset 0 0 0 2px var(--panel-edge-soft), 0 4px 12px var(--shadow);
  padding: 7px 9px;
}
.panel-title {
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--teal); text-align: center; margin-bottom: 5px;
  display: flex; justify-content: center; align-items: center; gap: 6px;
}

/* ---------- Top bar ---------- */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 6px;
}
.title-banner {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  padding: 2px 10px; border-radius: 8px;
  background: linear-gradient(180deg, var(--wood-a), var(--wood-b));
  border: 2px solid #3e2410;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.15), 0 2px 6px var(--shadow);
  height: 100%;
}
.tb-small { font-size: 6px; letter-spacing: 1px; color: #ffe9b8; }
.tb-big { font-size: 15px; font-weight: 800; color: var(--gold); text-shadow: 0 2px 0 #7a4a10; line-height: 1.1; }

.stat-cards { display: flex; gap: 5px; flex: 1; justify-content: center; height: 100%; }
.stat-card {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px; min-width: 78px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 2px solid var(--panel-edge);
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px var(--panel-edge-soft);
}
.stat-icon { font-size: 14px; }
.stat-card div { display: flex; flex-direction: column; }
.stat-label { font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 13px; font-weight: 800; color: var(--gold); }

.topbar-actions { display: flex; align-items: center; gap: 5px; height: 100%; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; font-size: 14px; cursor: pointer; color: #fff;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 2px solid var(--panel-edge);
  box-shadow: inset 0 0 0 2px var(--panel-edge-soft);
}
.icon-btn:hover { filter: brightness(1.2); }
.icon-btn.off { filter: grayscale(1) brightness(.6); }
.btn-quit-game { padding: 6px 12px; font-size: 12px; }

/* ---------- Columnas ---------- */
.left-col { grid-area: left; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.center-col { grid-area: center; position: relative; min-height: 220px; }
.right-col { grid-area: right; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }

/* Estudiante activo */
.active-student { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.avatar {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  font-size: 22px; background: linear-gradient(180deg, #2f6fd0, #1c3f86);
  border: 2px solid var(--gold);
}
.active-student strong { display: block; font-size: 13px; }
.rank-tag { color: var(--teal); font-size: 10px; }
.stat-list { list-style: none; display: grid; gap: 3px; }
.stat-list li { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.stat-list b { color: var(--gold); font-size: 12px; }

/* Lista estudiantes */
.students-list { display: grid; gap: 4px; max-height: 110px; overflow-y: auto; }
.student-chip {
  display: flex; align-items: center; gap: 6px; justify-content: space-between;
  padding: 5px 8px; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 2px solid transparent;
}
.student-chip:hover { border-color: var(--panel-edge); }
.student-chip.active { border-color: var(--green); background: rgba(87,200,74,.12); }
.student-chip .sc-left { display: flex; align-items: center; gap: 6px; }
.student-chip .sc-name { font-size: 12px; font-weight: 700; }
.student-chip .sc-score { color: var(--gold); font-weight: 700; font-size: 12px; }
.student-chip .sc-edit { font-size: 11px; color: var(--muted); cursor: pointer; padding: 2px 5px; }
.student-chip .sc-edit:hover { color: var(--text); }

/* Controles */
.controls-keys { display: flex; justify-content: space-around; align-items: center; flex: 1; }
.arrow-pad, .wasd { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.arrow-row { display: flex; gap: 3px; }
.key {
  width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center;
  font-weight: 800; font-size: 11px; cursor: pointer; color: #fff;
  background: linear-gradient(180deg, #2f8fe0, #1c5fa6);
  border: 2px solid #14457e; box-shadow: 0 2px 0 #0e3358;
}
.key.small {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-color: var(--gold); color: var(--gold);
}
.key:active { transform: translateY(2px); box-shadow: none; }

/* Canvas del juego */
#game-canvas {
  width: 100%; height: 100%;
  border-radius: 14px;
  border: 3px solid var(--panel-edge);
  box-shadow: inset 0 0 0 2px var(--panel-edge-soft), 0 6px 18px var(--shadow);
  display: block;
}
.game-toast {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(10,18,48,.92); border: 2px solid var(--gold);
  color: var(--gold); font-weight: 700; padding: 10px 20px; border-radius: 12px;
  opacity: 0; transition: opacity .25s ease; pointer-events: none; font-size: 16px;
  box-shadow: 0 6px 16px var(--shadow); text-align: center; max-width: 70%;
}
.game-toast.show { opacity: 1; }

/* Pista / Pregunta */
.clue-card {
  position: relative;
  background: linear-gradient(180deg, #f3e2bd, #e3c98f);
  border: 2px solid #b8923f; border-radius: 10px;
  padding: 9px 40px 9px 11px; color: #4a3411; min-height: 52px;
}
.clue-text { font-size: 12px; font-weight: 600; line-height: 1.25; }
.clue-text b { color: #c0392b; font-size: 14px; }
.clue-owl { position: absolute; right: 6px; bottom: 4px; font-size: 22px; }
.clue-count {
  background: var(--panel-2); color: var(--gold); border-radius: 7px;
  padding: 1px 6px; font-size: 10px; border: 1px solid var(--panel-edge);
}

.question-text { font-size: 12px; font-weight: 700; text-align: center; margin-bottom: 6px; min-height: 16px; }
.options { display: grid; gap: 5px; }
.option {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 2px solid var(--panel-edge-soft);
  font-size: 12px; font-weight: 600; transition: border-color .12s, background .12s;
}
.option:hover { border-color: var(--panel-edge); }
.option .opt-key {
  width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  font-weight: 800; font-size: 11px; background: linear-gradient(180deg, var(--green), var(--green-deep)); color: #fff;
}
.option.selected { border-color: var(--gold); background: rgba(255,206,77,.12); }
.option.correct { border-color: var(--green); background: rgba(87,200,74,.22); }
.option.wrong { border-color: var(--danger); background: rgba(226,60,60,.2); }

.answer-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.answer-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.answer-dots { display: flex; gap: 6px; }
.answer-dots .dot {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--panel-edge); background: var(--panel-2);
}
.answer-dots .dot.on { background: var(--green); border-color: var(--green); }

.mini-stats { margin-top: auto; display: grid; gap: 5px; }
.mini-stat {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 10px; border-radius: 8px; background: var(--panel-2);
  border: 2px solid var(--danger-deep); font-size: 11px;
}
.mini-stat b { color: var(--gold); font-size: 14px; }

/* Bottom bar */
.bottombar { grid-area: bottom; display: grid; grid-template-columns: 0.8fr 1.1fr 1fr 1.3fr; gap: 8px; overflow: hidden; min-height: 0; }
.bottom-panel { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.recent-achievements { display: flex; gap: 10px; justify-content: center; align-items: center; flex: 1; overflow: hidden; }
.ach-badge { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 64px; text-align: center; }
.ach-icon {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-size: 22px; border: 2px solid var(--gold);
  background: radial-gradient(circle at 40% 30%, #2f6fd0, #14254f);
}
.ach-badge.locked .ach-icon { filter: grayscale(1) brightness(.5); border-color: var(--panel-edge-soft); }
.ach-name { font-size: 10px; color: var(--muted); line-height: 1.2; }

.inventory { display: flex; gap: 10px; justify-content: center; align-items: center; flex: 1; }
.inv-item {
  position: relative; width: 46px; height: 46px; border-radius: 9px; display: grid; place-items: center;
  font-size: 22px; background: var(--panel-2); border: 2px solid var(--panel-edge);
}
.inv-item b {
  position: absolute; right: -4px; bottom: -4px; background: var(--gold); color: #4a3411;
  border-radius: 7px; font-size: 11px; padding: 0 5px; border: 2px solid #b8923f;
}
#minimap { width: 100%; height: 100%; border-radius: 6px; background: var(--panel-2); min-height: 0; display: block; cursor: grab; }

/* Minimap panel layout */
.minimap-panel { display: flex; flex-direction: column; }
.minimap-body {
  display: flex; flex: 1; gap: 6px; min-height: 0; overflow: hidden;
}
.minimap-body canvas {
  flex: 1; min-width: 0; border-radius: 6px;
  background: var(--panel-2); display: block;
}
.minimap-legend {
  display: flex; flex-direction: column; justify-content: space-around;
  gap: 2px; min-width: 72px; padding: 2px 0;
}
.leg-item {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; color: var(--muted); white-space: nowrap;
}
.leg-icon { font-size: 13px; width: 18px; text-align: center; }
.leg-line { display: inline-block; width: 22px; height: 5px; border-radius: 3px; }
.river-line { background: #4aadeb; }
.path-line { background: transparent; border-top: 2px dashed #c4a46e; display: inline-block; }

/* ============================= MODALES ============================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4,8,22,.7); backdrop-filter: blur(3px);
  display: grid; place-items: center;
}
.modal {
  width: min(640px, 92vw); max-height: 86vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 3px solid var(--panel-edge); border-radius: 20px;
  box-shadow: inset 0 0 0 2px var(--panel-edge-soft), 0 16px 50px var(--shadow);
  padding: 24px;
}
.modal h2 { color: var(--gold); margin-bottom: 16px; text-align: center; font-size: 26px; }
.modal h2 .modal-emoji { font-size: 28px; }
.modal .field { display: grid; gap: 6px; margin-bottom: 14px; }
.modal label { font-size: 13px; color: var(--muted); }
.modal input[type="text"] {
  padding: 12px 14px; border-radius: 10px; border: 2px solid var(--panel-edge);
  background: var(--panel-2); color: var(--text); font-size: 16px; font-family: var(--font-ui);
}
.modal input:focus { outline: 2px solid var(--gold); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.level-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.level-btn {
  text-align: left; padding: 14px; border-radius: 12px; cursor: pointer;
  background: var(--panel-2); border: 2px solid var(--panel-edge); color: var(--text);
}
.level-btn:hover { border-color: var(--gold); }
.level-btn.locked { filter: grayscale(.7) brightness(.6); cursor: not-allowed; }
.level-btn b { color: var(--gold); display: block; font-size: 16px; }
.level-btn span { font-size: 12px; color: var(--muted); }

.ranking-table { width: 100%; border-collapse: collapse; }
.ranking-table th, .ranking-table td { padding: 10px 8px; text-align: left; font-size: 14px; }
.ranking-table thead th { color: var(--teal); border-bottom: 2px solid var(--panel-edge); text-transform: uppercase; font-size: 12px; }
.ranking-table tbody tr { border-bottom: 1px solid var(--panel-edge-soft); }
.ranking-table .pos { color: var(--gold); font-weight: 800; width: 36px; }
.ranking-table .score { color: var(--gold); font-weight: 700; }

.ach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ach-row {
  display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px;
  background: var(--panel-2); border: 2px solid var(--panel-edge-soft);
}
.ach-row.unlocked { border-color: var(--gold); }
.ach-row .ach-icon { width: 44px; height: 44px; font-size: 24px; flex-shrink: 0; }
.ach-row.locked .ach-icon { filter: grayscale(1) brightness(.5); }
.ach-row .ach-meta b { font-size: 14px; }
.ach-row .ach-meta span { font-size: 12px; color: var(--muted); }

.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--panel-edge-soft);
}
.settings-row label { font-size: 15px; }
.switch { position: relative; width: 56px; height: 30px; cursor: pointer; }
.switch input { display: none; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px; background: var(--panel-2);
  border: 2px solid var(--panel-edge); transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: var(--muted); top: 2px; left: 3px; transition: .2s;
}
.switch input:checked + .slider { background: rgba(87,200,74,.3); border-color: var(--green); }
.switch input:checked + .slider::before { background: var(--green); transform: translateX(26px); }
.range-row input[type="range"] { width: 160px; accent-color: var(--gold); }

.credits-body { text-align: center; line-height: 1.7; font-size: 15px; }
.credits-body strong { color: var(--gold); }

/* Resultado de partida */
.result-stats { display: grid; gap: 8px; margin: 16px 0; }
.result-stats .row { display: flex; justify-content: space-between; padding: 8px 12px; background: var(--panel-2); border-radius: 8px; }
.result-stats .row b { color: var(--gold); }
.result-total { text-align: center; font-size: 22px; color: var(--gold); font-weight: 800; margin: 10px 0; }

/* FX canvas */
.fx-canvas { position: fixed; inset: 0; z-index: 60; pointer-events: none; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--panel-2); border-radius: 8px; }
::-webkit-scrollbar-thumb { background: var(--panel-edge); border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Responsivo para portátiles / pantallas pequeñas */
@media (max-width: 1280px) {
  .hud { grid-template-columns: 170px 1fr 210px; }
  .stat-card { min-width: 76px; padding: 5px 10px; }
  .stat-value { font-size: 14px; }
  .logo-big { font-size: 48px; }
}

/* Ventanas con poca altura (navegador con barra de pestañas/URL, portátiles) */
@media (max-height: 700px) {
  .hud { grid-template-rows: 42px minmax(180px, 1fr) 130px; }
  .center-col { min-height: 160px; }
  .ach-name { display: none; }
  .ach-icon { width: 30px; height: 30px; font-size: 16px; }
  .key { width: 22px; height: 22px; font-size: 10px; }
  .inv-item { width: 34px; height: 34px; font-size: 16px; }
}

/* Ventanas extremadamente bajas: ocultar la barra inferior y priorizar el plano */
@media (max-height: 560px) {
  .hud {
    grid-template-rows: 40px minmax(160px, 1fr);
    grid-template-areas: "top top top" "left center right";
  }
  .active-student, .stat-list { display: none; }
  .bottombar { display: none; }
}

/* Menú principal en ventanas con poca altura */
@media (max-height: 760px) {
  .menu-content { gap: 14px; }
  .logo-big { font-size: 44px; }
  .logo-small { font-size: 12px; }
  .logo-plank { padding: 10px 28px; }
  .menu-panel { padding: 14px 20px; width: 320px; }
  .menu-buttons { gap: 7px; }
  .menu-buttons .btn { padding: 9px 14px; font-size: 14px; }
  .btn-play { font-size: 17px; padding: 11px; }
  .menu-footer { display: none; }
}

