/* A Ilha Escondida da Ria (v0.1) - CSS offline, 16:9, zero CDNs, zero transition:all */
/* Andika v27 — SIL Open Font License 1.1 (SIL International) · 100% offline */
@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/andika-regular.woff2") format("woff2");
}
@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../assets/fonts/andika-bold.woff2") format("woff2");
}

:root {
  --ink: #0e2433;
  --ink-soft: #2e4d5e;
  --sky-bg: #d9eef5;
  --sand-bg: #f6f2e6;
  --surface: #ffffff;
  --teal: #0c7489;
  --teal-dark: #074f5e;
  --ok: #0e704d;
  --ok-soft: #dbf4ea;
  --amber: #d9820b;
  --amber-bright: #f4b62a;
  --amber-soft: #fff4d1;
  --coral: #c93d24;
  --line: #b4ced9;
  --font-main: "Segoe UI", "Trebuchet MS", Verdana, system-ui, sans-serif;
  --font-display: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
}

body[data-font="school"] {
  --font-main: "Andika", "Century Gothic", "Comic Sans MS", Verdana, sans-serif;
  --font-display: "Andika", "Century Gothic", "Comic Sans MS", Verdana, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: linear-gradient(180deg, #0b3a4a 0%, #0e2433 100%);
  color: var(--ink);
  font-family: var(--font-main);
  overflow: hidden;
  user-select: none;
}

button, a, input {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--amber-bright);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

/* Barra superior compacta (1 linha) */
.hud-bar {
  width: 100%;
  max-width: 1220px;
  min-height: 50px;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #f4fbfe;
  flex: 0 0 auto;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.hud-btn {
  min-height: 38px;
  padding: 4px 10px;
  border-radius: 9px;
  border: 1.8px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.65);
}

.hud-btn:active {
  transform: translateY(1px);
}

.hud-btn.is-active {
  background: var(--amber-bright);
  color: var(--ink);
  border-color: var(--amber-bright);
}

.hud-pill {
  min-height: 34px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(8, 28, 38, 0.65);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  font-size: 12.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tool-chip {
  min-height: 32px;
  padding: 2px 9px;
  border-radius: 8px;
  border: 1.6px dashed rgba(255, 255, 255, 0.32);
  color: rgba(255, 255, 255, 0.45);
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.tool-chip.is-owned {
  border-style: solid;
  border-color: #f4b62a;
  background: rgba(244, 182, 42, 0.2);
  color: #fff6d2;
}

/* Dock compacto de ferramentas na barra superior */
.tools-dock {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 5px;
  border-radius: 10px;
  background: rgba(6, 20, 28, 0.62);
  border: 1.5px solid rgba(255, 255, 255, 0.24);
}

.tool-dot {
  width: 30px;
  height: 30px;
  padding: 0;
  background: rgba(255, 255, 255, 0.08);
  font-family: inherit;
  border-radius: 8px;
  border: 1.8px dashed rgba(255, 255, 255, 0.45);
  color: rgba(255, 248, 214, 0.88);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  opacity: 0.78;
  cursor: pointer;
  transition: opacity 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.14s ease;
}

.tool-dot .tool-icon-real {
  display: none;
  align-items: center;
  justify-content: center;
}

.tool-dot .tool-icon-mystery {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.tool-dot:hover {
  opacity: 1;
  border-color: #ffd24a;
  background: rgba(255, 210, 74, 0.18);
  transform: translateY(-1px);
}

.tool-dot:focus-visible {
  outline: 2px solid #ffd24a;
  outline-offset: 2px;
  opacity: 1;
}

.tool-dot.is-owned {
  opacity: 1;
  border-style: solid;
  border-color: #f4b62a;
  background: rgba(244, 182, 42, 0.28);
}

.tool-dot.is-owned .tool-icon-mystery {
  display: none;
}

.tool-dot.is-owned .tool-icon-real {
  display: inline-flex;
}

.tool-dot.is-owned:hover {
  background: rgba(244, 182, 42, 0.44);
}

@keyframes toolPop {
  0% { transform: scale(0.72) rotate(-10deg); }
  50% { transform: scale(1.34) rotate(6deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.tool-dot.is-just-got {
  animation: toolPop 0.58s cubic-bezier(0.22, 1, 0.36, 1);
}

.win-scene-box {
  width: 100%;
  display: flex;
  justify-content: center;
}

.win-scene-svg {
  width: 100%;
  max-width: 420px;
  height: auto;
  display: block;
  border-radius: 12px;
}

.hud-svg {
  width: 20px;
  height: 20px;
  display: block;
  flex: 0 0 auto;
}

.hud-svg-sm {
  width: 17px;
  height: 17px;
}

.menu-utils {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.util-pill {
  flex: 1 1 86px;
  min-height: 38px;
  padding: 4px 8px;
  border-radius: 9px;
  border: 1.8px solid var(--line);
  background: #f1f6f8;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.util-pill:hover {
  background: #e2eef3;
  border-color: var(--teal);
}

.util-pill.is-active {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal-dark);
}

@media (max-width: 480px) {
  .menu-utils { grid-template-columns: repeat(2, 1fr); }
}

.shell-pill {
  background: rgba(244, 182, 42, 0.18);
  border-color: rgba(244, 182, 42, 0.72);
  color: #fff4c4;
}

/* Minimapa 4x3 embutido na barra */
.minimap-mini {
  display: grid;
  grid-template-columns: repeat(4, 11px);
  grid-template-rows: repeat(3, 8px);
  gap: 2px;
  padding: 4px 5px;
  border-radius: 7px;
  background: rgba(6, 20, 28, 0.72);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
}

.mm-cell {
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
}

.mm-cell.is-v01 {
  background: rgba(125, 211, 205, 0.45);
}

.mm-cell.is-visited {
  background: #3bc1a8;
}

.mm-cell.is-current {
  background: #ffd24a;
  box-shadow: 0 0 0 1px #ffffff;
}

/* Palco 16:9 */
.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  max-width: 1220px;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px 6px;
}

.canvas-frame {
  position: relative;
  width: 100%;
  height: auto;
  max-height: 100%;
  max-width: calc((100dvh - 70px) * 16 / 9);
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  border: 3px solid #081822;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.42);
  background: #8fd3e8;
}

body.has-touch .canvas-frame {
  max-width: calc((100dvh - 142px) * 16 / 9);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: none;
}

/* Toast curto visual (sem frases longas) */
.toast-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  opacity: 0;
  pointer-events: none;
  background: rgba(14, 36, 51, 0.92);
  color: #fff9e3;
  border: 2px solid var(--amber-bright);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  z-index: 12;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-banner.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Overlays (Titulo, Skins, Vitoria) */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(9, 29, 41, 0.64);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.overlay[hidden],
.btn-row[hidden] {
  display: none !important;
}

.panel {
  width: 100%;
  max-width: 510px;
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  background: #fdfcf7;
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 15px 20px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.36);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.panel-kicker {
  display: inline-block;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--ok-soft);
  color: #084d35;
  border: 1.5px solid var(--ok);
  border-radius: 999px;
  padding: 2px 10px;
}

.panel h1, .panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  font-weight: 900;
  line-height: 1.1;
  color: var(--ink);
}

.panel-sub {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  font-weight: 600;
}

.row-ctrl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.ctrl-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.seg-group {
  display: inline-flex;
  background: #e6f0f4;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
}

.seg-btn {
  min-height: 36px;
  padding: 4px 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.seg-btn.is-selected {
  background: var(--teal);
  color: #ffffff;
}

.seed-input {
  width: 96px;
  min-height: 38px;
  padding: 4px 8px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  color: var(--ink);
  background: #ffffff;
}

.btn-big {
  min-height: 46px;
  padding: 9px 16px;
  border-radius: 12px;
  border: 2.5px solid var(--ink);
  background: var(--ok);
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: 0 3px 0 var(--ink);
  transition: background-color 0.14s ease, transform 0.1s ease;
}

.btn-big:hover { background: #0a5a3d; }
.btn-big:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

.btn-big.is-alt {
  background: #ffffff;
  color: var(--ink);
}
.btn-big.is-alt:hover { background: #eef6f9; }

.btn-big.is-amber {
  background: var(--amber-bright);
  color: var(--ink);
}
.btn-big.is-amber:hover { background: #e3a318; }

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-row > * { flex: 1 1 150px; }

.keys-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding-top: 4px;
  border-top: 1.5px dashed var(--line);
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-soft);
}

.keys-legend kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1.5px solid var(--ink);
  border-radius: 5px;
  background: #ffffff;
  color: var(--ink);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
}

/* Grelha de Skins */
.skins-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.skin-card {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 7px 10px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  min-height: 54px;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.skin-card.is-equipped {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.skin-card.is-locked {
  opacity: 0.62;
  background: #f1f5f9;
}

.skin-swatch {
  width: 64px;
  height: 52px;
  border-radius: 11px;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, #cbeefa 0%, #ebf9fd 64%, #f3e0b0 100%);
  box-shadow: inset 0 -2px 0 rgba(14, 36, 51, 0.12);
  flex: 0 0 64px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.skin-swatch svg {
  display: block;
  width: 62px;
  height: 50px;
}

.skin-name {
  font-size: 12.5px;
  font-weight: 900;
  color: var(--ink);
}

.skin-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* Mapa expandido 4x3 */
.map-big {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.map-tile {
  border: 2px solid var(--line);
  border-radius: 9px;
  padding: 7px 6px;
  font-size: 10.5px;
  font-weight: 800;
  text-align: center;
  background: #eef2f5;
  color: #64748b;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.map-tile.is-v01 {
  background: #e6f6f2;
  border-color: var(--teal);
  color: var(--ink);
}

.map-tile.is-current {
  background: var(--amber-soft);
  border-color: var(--amber);
  box-shadow: 0 0 0 2px var(--amber-bright);
}

/* Codigo de recompensa Aquario */
.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 2.5px dashed var(--teal);
  background: #ecf9fb;
  border-radius: 12px;
  padding: 10px 12px;
}

.code-value {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--ink);
  user-select: text;
}

.copy-btn {
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: var(--teal);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 900;
  cursor: pointer;
}

/* Controlos tateis (tablet / telemovel / quadro interativo) - 1 botao dedicado Mola! */
.touch-bar {
  display: none;
  width: 100%;
  max-width: 1220px;
  padding: 4px 14px 10px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
}

body.has-touch .touch-bar {
  display: flex;
}

.touch-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tpad-btn {
  min-width: 58px;
  min-height: 54px;
  padding: 0 14px;
  border-radius: 14px;
  border: 2.5px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: 18px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  touch-action: manipulation;
  cursor: pointer;
}

.tpad-btn:active,
.tpad-btn.is-down {
  background: rgba(255, 255, 255, 0.36);
  transform: scale(0.96);
}

.tpad-btn.is-action {
  background: rgba(14, 112, 77, 0.85);
  border-color: #7ee2be;
  font-size: 15px;
}

.tpad-btn.is-spring {
  background: rgba(244, 182, 42, 0.92);
  border-color: #fff4c4;
  color: var(--ink);
  font-size: 15px;
}

.tpad-btn.is-down-ctx {
  background: rgba(12, 116, 137, 0.88);
  border-color: #a5e6f2;
  color: #ffffff;
}

.tpad-btn[hidden] {
  display: none !important;
}

/* Rodape teclado discreto em desktop */
.desktop-hint {
  width: 100%;
  max-width: 1220px;
  padding: 0 14px 5px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: rgba(232, 246, 251, 0.72);
  flex: 0 0 auto;
}

body.has-touch .desktop-hint {
  display: none;
}

@media (max-width: 1120px) {
  .hud-bar { padding: 4px 8px; gap: 4px; }
  .hud-btn { padding: 3px 8px; font-size: 12px; min-height: 36px; }
  .hud-btn .lbl { display: none; }
  .tool-chip { padding: 2px 7px; }
  .tool-chip .lbl { display: none; }
  .hud-pill { font-size: 11.5px; padding: 2px 8px; min-height: 32px; }
}

@media (max-width: 640px) {
  .hud-bar {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 4px;
    padding: 5px 6px;
  }
  .hud-group {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }
  .hud-btn { min-height: 34px; padding: 2px 6px; font-size: 11.5px; }
  .tool-dot { width: 24px; height: 24px; }
  .tool-dot .hud-svg { width: 16px; height: 16px; }
  .hud-svg-sm { width: 15px; height: 15px; }
  .hud-pill { padding: 2px 6px; }
  .minimap-mini { grid-template-columns: repeat(4, 9px); grid-template-rows: repeat(3, 7px); }
  .stage-wrap { padding: 4px 6px; }
  .touch-bar { padding: 6px 10px 14px; }
  .tpad-btn { min-width: 54px; min-height: 56px; padding: 0 11px; font-size: 16px; }
  .tpad-btn.is-action,
  .tpad-btn.is-spring { font-size: 13.5px; padding: 0 10px; }
  .panel { padding: 14px 14px; gap: 8px; }
  .panel h1, .panel h2 { font-size: 1.25rem; }
  .skins-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .touch-bar { padding: 6px 8px 14px; gap: 5px; }
  .touch-cluster { gap: 5px; }
  .tpad-btn { min-width: 48px; min-height: 52px; padding: 0 7px; font-size: 15px; border-radius: 12px; gap: 3px; }
  .tpad-btn.is-action,
  .tpad-btn.is-spring { font-size: 12.5px; padding: 0 7px; }
}

@media (max-height: 440px) {
  .hud-bar { min-height: 38px; padding: 2px 8px; }
  .hud-btn { min-height: 32px; padding: 2px 7px; }
  .stage-wrap { padding: 2px 8px; }
  .touch-bar { padding: 2px 12px 5px; }
  .tpad-btn { min-height: 44px; min-width: 50px; padding: 0 11px; font-size: 15px; }
  body.has-touch .canvas-frame {
    max-width: calc((100dvh - 96px) * 16 / 9);
  }
}

/* ---------- Alto Contraste (◐ · Projetor com sol / DUA) ---------- */
body[data-contrast="high"] {
  --ink: #000000;
  --ink-soft: #111111;
  --line: #000000;
  --teal: #004e66;
  --teal-dark: #002b38;
  --ok: #005530;
  --amber: #9a5200;
  --amber-bright: #ffd24a;
  --coral: #a31900;
  background: #000000;
}

body[data-contrast="high"] .hud-bar {
  background: #000000;
  border-bottom: 2px solid #ffffff;
}

body[data-contrast="high"] .hud-btn,
body[data-contrast="high"] .hud-pill,
body[data-contrast="high"] .tools-dock,
body[data-contrast="high"] .minimap-mini {
  background: #000000;
  color: #ffffff;
  border: 2px solid #ffffff;
}

body[data-contrast="high"] .hud-btn.is-active,
body[data-contrast="high"] .tool-dot.is-owned {
  background: #ffd24a;
  color: #000000;
  border: 2.2px solid #ffffff;
}

body[data-contrast="high"] .tool-dot {
  border-color: #ffffff;
  color: #ffffff;
  opacity: 1;
}

body[data-contrast="high"] .canvas-frame {
  border: 3px solid #ffffff;
  box-shadow: none;
}

body[data-contrast="high"] .panel {
  background: #ffffff;
  color: #000000;
  border: 3px solid #000000;
  box-shadow: none;
}

body[data-contrast="high"] .util-pill,
body[data-contrast="high"] .seg-btn,
body[data-contrast="high"] .skin-card,
body[data-contrast="high"] .map-tile {
  background: #ffffff;
  color: #000000;
  border: 2.2px solid #000000;
}

body[data-contrast="high"] .util-pill.is-active,
body[data-contrast="high"] .seg-btn.is-selected {
  background: #000000;
  color: #ffffff;
  border-color: #000000;
}

body[data-contrast="high"] .tpad-btn {
  background: #000000;
  color: #ffffff;
  border: 2.5px solid #ffffff;
}

body[data-contrast="high"] .tpad-btn.is-spring {
  background: #ffd24a;
  color: #000000;
  border-color: #ffffff;
}

body[data-contrast="high"] .desktop-hint {
  color: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
  .tool-dot,
  .tool-dot.is-just-got,
  .hud-btn,
  .util-pill {
    animation: none !important;
    transition: none !important;
  }
}
