/* ==========================================================================
   style.css — Visual pixel art. Área do jogo fixa em 800 × 600 e escalada
   por JavaScript (ui.js) para caber em qualquer tela, sem distorcer.
   Só usa fontes do sistema, então funciona offline.
   ========================================================================== */

:root {
  --ink: #12142b;
  --panel: #1d2244;
  --panel-hi: #2a3163;
  --chalk: #f5efdc;
  --gold: #f2c14e;
  --gold-deep: #b8862a;
  --leaf: #4fbf85;
  --leaf-deep: #25795a;
  --coral: #ef6a4c;
  --coral-deep: #a3392a;
  --sky: #7cc4e8;
  --font: "Lucida Console", "Consolas", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-weight: 700;
  color: var(--chalk);
}

.hidden { display: none !important; }

#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 800px;   /* o JavaScript ajusta para a janela inteira */
  height: 600px;
  transform-origin: 0 0;
  background: var(--ink);
  overflow: hidden;
  font-size: 16px;
  line-height: 1.4;
  user-select: none;
}

#world {
  position: absolute;
  left: 0;
  top: 60px;
  width: 100%;
  height: calc(100% - 60px);
  image-rendering: pixelated;
  z-index: 1;
}

:focus-visible { outline: 4px solid var(--sky); outline-offset: 2px; }

/* ---------- Painel com borda "de pixel" ---------- */
.px {
  background: var(--panel);
  box-shadow:
    0 -4px 0 0 var(--chalk),
    0 4px 0 0 var(--chalk),
    -4px 0 0 0 var(--chalk),
    4px 0 0 0 var(--chalk),
    inset 0 -6px 0 0 rgba(0, 0, 0, 0.3);
}

kbd {
  display: inline-block;
  min-width: 26px;
  padding: 0 6px;
  font: inherit;
  text-align: center;
  color: var(--ink);
  background: var(--gold);
  box-shadow: inset 0 -3px 0 0 var(--gold-deep);
}

/* ---------- Botões ---------- */
.btn {
  font: inherit;
  font-size: 20px;
  color: var(--ink);
  background: var(--gold);
  border: 0;
  padding: 14px 28px;
  margin: 10px 8px;
  cursor: pointer;
  box-shadow:
    0 -4px 0 0 var(--ink),
    0 4px 0 0 var(--ink),
    -4px 0 0 0 var(--ink),
    4px 0 0 0 var(--ink),
    inset 0 -6px 0 0 var(--gold-deep),
    inset 0 4px 0 0 rgba(255, 255, 255, 0.35);
}

.btn:hover { filter: brightness(1.1); }

.btn:active {
  transform: translateY(2px);
  box-shadow:
    0 -4px 0 0 var(--ink),
    0 4px 0 0 var(--ink),
    -4px 0 0 0 var(--ink),
    4px 0 0 0 var(--ink),
    inset 0 -3px 0 0 var(--gold-deep);
}

.btn.secondary {
  color: var(--chalk);
  background: var(--panel-hi);
  box-shadow:
    0 -4px 0 0 var(--chalk),
    0 4px 0 0 var(--chalk),
    -4px 0 0 0 var(--chalk),
    4px 0 0 0 var(--chalk),
    inset 0 -6px 0 0 rgba(0, 0, 0, 0.35);
}

.buttons { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.buttons.vertical { flex-direction: column; align-items: center; }
.buttons.vertical .btn { min-width: 300px; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 60px;
  z-index: 12;
  padding: 4px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--panel);
  border-bottom: 4px solid var(--gold);
  font-size: 15px;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 24px;
}

.heart { font-size: 18px; margin-right: 4px; }
.heart.lost { filter: grayscale(1) brightness(0.45); }

#hud-score { color: var(--gold); font-size: 17px; }

.hud-actions { display: flex; gap: 8px; }

.mini {
  font: inherit;
  font-size: 12px;
  color: var(--chalk);
  background: var(--panel-hi);
  border: 0;
  padding: 2px 10px;
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--chalk);
}
.mini:hover { background: #3a4380; }

/* ---------- Avisos sobre o mapa ---------- */
#objective {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  padding: 4px 14px;
  font-size: 14px;
  white-space: nowrap;
}

#interact-prompt {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  padding: 8px 18px;
  font-size: 18px;
  white-space: nowrap;
}

#toast {
  position: absolute;
  top: 118px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  padding: 10px 20px;
  color: var(--ink);
  background: var(--gold);
  font-size: 17px;
  white-space: nowrap;
  box-shadow:
    0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink),
    -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink);
}

/* ---------- Diálogo ---------- */
#dialog {
  position: absolute;
  left: 0;
  right: 0;
  width: min(720px, calc(100% - 80px));
  margin: 0 auto;
  bottom: 24px;
  z-index: 15;
  padding: 26px 26px 12px;
}

#dialog .speaker {
  position: absolute;
  top: -22px;
  left: 20px;
  padding: 2px 14px;
  color: var(--ink);
  background: var(--gold);
  font-size: 15px;
}

#dialog p { margin: 0; font-size: 19px; line-height: 1.5; }
#dialog .buttons { justify-content: flex-end; margin-top: 4px; }

/* ---------- Perguntas ---------- */
#quiz {
  position: absolute;
  left: 0;
  top: 60px;
  width: 100%;
  height: calc(100% - 60px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 30, 0.86);
}

.quiz-panel {
  width: 704px;
  max-height: 508px;
  overflow: auto;
  padding: 22px 28px 20px;
}

.quiz-phase {
  display: inline-block;
  padding: 0 10px;
  margin-bottom: 10px;
  color: var(--ink);
  background: var(--sky);
  font-size: 14px;
}

#quiz-text {
  margin: 0 0 18px;
  font-size: 26px;
  line-height: 1.3;
}

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.answer {
  --edge: var(--chalk);
  display: flex;
  align-items: center;
  gap: 12px;
  font: inherit;
  font-size: 20px;
  text-align: left;
  color: var(--chalk);
  background: var(--panel-hi);
  border: 0;
  padding: 14px 12px;
  cursor: pointer;
  box-shadow:
    0 -4px 0 0 var(--edge), 0 4px 0 0 var(--edge),
    -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge);
}

.answer .key {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--gold);
}

.answer:hover:not(:disabled) { background: #3a4380; }
.answer:disabled { cursor: default; }
.answer.correct { --edge: var(--leaf); background: var(--leaf-deep); }
.answer.wrong { --edge: var(--coral); background: var(--coral-deep); }
.answer.dim { opacity: 0.55; }

.feedback { margin-top: 20px; padding-top: 12px; border-top: 4px solid var(--panel-hi); }
.feedback p { margin: 0 0 6px; }
#feedback-title { font-size: 22px; }
#feedback-detail { font-size: 17px; }
.feedback.ok #feedback-title { color: var(--leaf); }
.feedback.bad #feedback-title { color: var(--coral); }
.feedback .btn { margin: 8px 0 0; }

/* ---------- Telas cheias ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px 60px;
  background: linear-gradient(var(--ink), var(--panel));
}

.screen h1 {
  margin: 8px 0 4px;
  font-size: 38px;
  line-height: 1.15;
  color: var(--gold);
  text-shadow: 4px 4px 0 #000;
}

.screen h2 {
  margin: 0 0 14px;
  font-size: 32px;
  line-height: 1.2;
  color: var(--gold);
  text-shadow: 3px 3px 0 #000;
}

.screen h2.bad { color: var(--coral); }

.subtitle { margin: 0 0 22px; font-size: 20px; color: var(--sky); }
.story { max-width: 620px; margin: 0 0 12px; font-size: 19px; line-height: 1.5; }
.score-final { margin: 6px 0 12px; font-size: 24px; color: var(--gold); }
.save-info { min-height: 22px; margin: 10px 0 0; font-size: 15px; color: var(--leaf); }
.footnote { position: absolute; bottom: 14px; margin: 0; font-size: 13px; opacity: 0.7; }

.chest { width: 132px; height: 132px; margin-bottom: 8px; image-rendering: pixelated; }
.chest.small { width: 84px; height: 84px; margin-bottom: 8px; }

.rules {
  max-width: 640px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  text-align: left;
  font-size: 16px;
  line-height: 1.5;
}

.rules li { margin-bottom: 8px; padding-left: 18px; position: relative; }
.rules li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 8px;
  height: 8px;
  background: var(--gold);
}

/* piso quadriculado decorativo no menu */
#screen-menu::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 70px;
  background: repeating-conic-gradient(#232a55 0 25%, #191e3f 0 50%) 0 0 / 32px 32px;
  pointer-events: none;
  z-index: -1;
}

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


/* ==========================================================================
   Login, ranking e área do professor
   ========================================================================== */
#stage input, #stage select { -webkit-user-select: text; user-select: text; }

.chest.medium { width: 96px; height: 96px; margin-bottom: 4px; }

.user-line { min-height: 22px; margin: 0 0 6px; font-size: 16px; color: var(--leaf); }

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 520px;
  margin-top: 4px;
}
.menu-grid .btn { margin: 8px; }
.menu-grid .wide { grid-column: 1 / -1; }

/* abas (Entrar/Cadastrar e bimestres) */
.tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 0 0 14px; }

.tab {
  font: inherit;
  font-size: 15px;
  color: var(--chalk);
  background: var(--panel-hi);
  border: 0;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--chalk);
}
.tab:hover { background: #3a4380; }
.tab.active { color: var(--ink); background: var(--gold); }

/* formulários */
.form { width: 100%; max-width: 620px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; text-align: left; }
.field label { display: block; margin-bottom: 5px; font-size: 13px; color: var(--sky); }

.field input, .field select, .tools select, .tools input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 18px;
  color: var(--chalk);
  background: var(--ink);
  border: 0;
  padding: 9px 10px;
  box-shadow: 0 0 0 3px var(--chalk);
}
.field input::placeholder, .tools input::placeholder { color: #6f77a8; }

.check { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }

.hint { margin: 8px 0 0; font-size: 13px; opacity: 0.8; }

.form-msg { min-height: 22px; margin: 8px 0 0; font-size: 15px; color: var(--coral); }
.form-msg.ok { color: var(--leaf); }

.link-btn {
  margin-top: 6px;
  font: inherit;
  font-size: 13px;
  color: var(--sky);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--gold); }

.btn.small { font-size: 14px; padding: 8px 12px; margin: 6px 5px; }
.btn.danger { color: #ffd9d0; background: var(--coral-deep); }

/* tabela do ranking */
.lb-info { max-width: 640px; margin: 0 0 10px; font-size: 14px; color: var(--sky); }
.lb-me { min-height: 22px; margin: 10px 0 0; font-size: 16px; color: var(--gold); }

.table-wrap {
  width: 100%;
  max-width: 660px;
  max-height: 268px;
  overflow-y: auto;
  background: var(--ink);
  box-shadow: 0 0 0 3px var(--chalk);
}
.table-wrap.short { max-height: 172px; }

.rank { width: 100%; border-collapse: collapse; font-size: 16px; text-align: left; }
.rank th {
  position: sticky;
  top: 0;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--gold);
  background: var(--panel-hi);
}
.rank td { padding: 6px 10px; border-top: 2px solid var(--panel); }
.rank .num { text-align: right; }
.rank tr.me td { color: var(--ink); background: var(--gold); }
.rank td.empty { padding: 18px; text-align: center; opacity: 0.7; }

/* área do professor */
#screen-teacher { overflow-y: auto; }
#screen-teacher.panel-open { justify-content: flex-start; padding-top: 16px; }
#screen-teacher.panel-open h2 { margin-bottom: 6px; font-size: 28px; }
#screen-teacher .tpanel .form-msg { min-height: 20px; margin: 6px 0 0; }
#screen-teacher .tpanel .buttons { margin-top: 4px; }
#screen-teacher .tpanel .btn { margin-top: 4px; margin-bottom: 4px; }
#screen-teacher .tabs { margin-bottom: 8px; }
#screen-teacher .lb-info { margin-bottom: 6px; font-size: 13px; }
#tp-warning:empty { display: none; }
#tp-warning { min-height: 0; margin: 0 0 6px; font-size: 13px; }

.tpanel { width: 100%; max-width: 680px; }
.tp-winner { margin: 0 0 6px; font-size: 16px; color: var(--gold); }

.tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; margin-top: 10px; }
.tools.manage { gap: 8px; }
.tools select { width: 215px; font-size: 15px; padding: 7px 8px; }
.tools input[type="text"] { width: 130px; font-size: 15px; padding: 7px 8px; }

label.btn { display: inline-block; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}
.sr-only:focus-visible + label { outline: 4px solid var(--sky); outline-offset: 2px; }


/* Seletor de salas/séries e adaptação para telas menores */
.room-intro { margin-bottom: 18px; }
.track-grid { display: grid; grid-template-columns: repeat(2, minmax(260px, 1fr)); gap: 22px; width: min(720px, 100%); }
.track-card { padding: 16px; background: rgba(42,49,99,.72); box-shadow: 0 0 0 3px var(--chalk); }
.track-card h3 { margin: 0 0 4px; color: var(--gold); font-size: 20px; }
.track-card p { margin: 0 0 14px; font-size: 14px; color: var(--sky); }
.series-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.series-btn { font: inherit; font-size: 14px; color: var(--chalk); background: var(--panel); border: 0; padding: 10px 6px; cursor: pointer; box-shadow: 0 0 0 2px var(--chalk); }
.series-btn:hover, .series-btn.active { color: var(--ink); background: var(--gold); }
@media (max-width: 700px) {
  .screen { padding: 22px 18px; overflow-y: auto; }
  .screen h1 { font-size: 28px; }
  .screen h2 { font-size: 25px; }
  .story { font-size: 16px; }
  .menu-grid { width: 100%; max-width: 420px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .track-grid { grid-template-columns: 1fr; gap: 16px; }
  .track-card { width: 100%; }
  .series-grid { grid-template-columns: repeat(3, 1fr); }
  .answers { grid-template-columns: 1fr; gap: 12px; }
  .quiz-panel { width: calc(100% - 30px); padding: 18px 16px; }
  #quiz-text { font-size: 21px; }
}
@media (min-width: 1100px) { body { background: var(--ink); } }
