/* ================================================
   MAURICIO DE SOUZA - PORTFOLIO
   Game World Styles
   ================================================ */

body {
  overflow: hidden;
  background: #0d0d0d;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#world-canvas {
  position: fixed;
  top: 0;
  left: 0;
  /* No celular a barra de endereço muda a altura da viewport. Sem uma
     medida explícita, a caixa CSS do canvas não bate com o bitmap e a
     cena sai esticada na vertical (moto "voando", sprite deformado). */
  width: 100%;
  height: 100%;
  z-index: 0;
  image-rendering: pixelated;
  display: block;
}

/* ================================================
   HUD
   ================================================ */
.hud {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-back {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.4rem;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 12px;
  text-decoration: none;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-back:hover {
  color: var(--red);
  border-color: var(--red);
}

/* ---- Progresso (direita) ---- */
.hud-right {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.prog-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.prog-label {
  font-size: 0.4rem;
  color: var(--yellow);
  letter-spacing: 0.12em;
  text-shadow: 2px 2px 0 #000;
}

.prog-bar {
  width: 148px;
  height: 12px;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.prog-fill {
  height: 100%;
  width: 0;
  background: var(--red);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35);
  transition: width 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.pet-label {
  font-size: 0.35rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.12em;
  text-shadow: 2px 2px 0 #000;
}

/* ================================================
   NOME DA ZONA
   ================================================ */
.zone-banner {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 28;
  font-size: clamp(0.6rem, 2vw, 1.05rem);
  color: var(--white);
  letter-spacing: 0.22em;
  text-align: center;
  text-shadow: 4px 4px 0 var(--red-dark), 0 0 22px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s, transform 0.45s;
  padding: 0 16px;
}

.zone-banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ================================================
   TOAST DE ITEM
   ================================================ */
.toast {
  position: fixed;
  top: 84px;
  right: 16px;
  z-index: 32;
  max-width: 260px;
  background: rgba(13, 13, 13, 0.94);
  border: 2px solid var(--yellow);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
  padding: 12px 14px;
  font-size: 0.4rem;
  line-height: 1.9;
  color: var(--white);
  letter-spacing: 0.06em;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast b { color: var(--yellow); }

/* ================================================
   DICA DE AÇÃO
   ================================================ */
.action-hint {
  position: fixed;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  font-size: 0.4rem;
  color: var(--yellow);
  letter-spacing: 0.15em;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(254, 202, 87, 0.4);
  padding: 7px 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.action-hint.show { opacity: 1; }

body.touch .action-hint { display: none; }

/* ================================================
   CAIXA DE DIÁLOGO
   ================================================ */
.dialog {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  padding: 0 16px 22px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 0.2s, transform 0.2s;
}

.dialog.show {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.dialog-box {
  position: relative;
  width: min(780px, 100%);
  background: rgba(10, 10, 14, 0.96);
  border: 3px solid var(--white);
  box-shadow:
    6px 6px 0 rgba(0, 0, 0, 0.7),
    inset 0 0 0 3px #1a1a22;
  padding: 20px 22px 30px;
  cursor: pointer;
}

.dialog-title {
  font-size: 0.5rem;
  color: var(--yellow);
  letter-spacing: 0.14em;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
}

.dialog-text {
  font-size: 0.52rem;
  line-height: 2.2;
  color: var(--white);
  letter-spacing: 0.04em;
  min-height: 4.4em;
}

.dialog-next {
  position: absolute;
  right: 16px;
  bottom: 10px;
  font-size: 0.5rem;
  color: var(--red);
  opacity: 0;
  animation: blink 1s step-end infinite;
}

.dialog-next.show { opacity: 1; }

.dialog-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.dialog-link {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.38rem;
  letter-spacing: 0.1em;
  color: var(--bg);
  background: var(--yellow);
  border: none;
  padding: 9px 13px;
  text-decoration: none;
  box-shadow: 3px 3px 0 #c9922a;
  transition: transform 0.08s, box-shadow 0.08s;
}

.dialog-link:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #c9922a;
}

.dialog-link.disabled {
  background: #3a3a3a;
  color: #777;
  box-shadow: 3px 3px 0 #222;
  cursor: not-allowed;
}

/* ================================================
   INVENTÁRIO
   ================================================ */
.inventory {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 5, 8, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.inventory.show {
  opacity: 1;
  pointer-events: all;
}

.inv-panel {
  width: min(860px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: #0d0d12;
  border: 3px solid var(--white);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.7), inset 0 0 0 3px #1a1a22;
  padding: 22px;
}

.inv-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
}

.inv-title {
  font-size: 0.62rem;
  color: var(--red);
  letter-spacing: 0.16em;
}

.inv-sub {
  font-size: 0.36rem;
  color: var(--gray);
  letter-spacing: 0.1em;
}

.inv-close {
  margin-left: auto;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  color: var(--gray);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

.inv-close:hover { color: var(--red); }

.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}

.inv-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #16161e;
  border: 2px solid rgba(255, 255, 255, 0.16);
  padding: 13px;
}

.inv-item.locked {
  border-color: rgba(255, 255, 255, 0.06);
  opacity: 0.4;
}

.inv-icon {
  font-family: system-ui, sans-serif;
  font-size: 1.35rem;
  line-height: 1;
}

.inv-name {
  font-size: 0.38rem;
  color: var(--yellow);
  letter-spacing: 0.08em;
  line-height: 1.7;
}

.inv-item.locked .inv-name { color: var(--gray); }

.inv-desc {
  font-size: 0.32rem;
  color: var(--gray);
  line-height: 1.9;
}

.inv-section {
  margin: 24px 0 12px;
  font-size: 0.44rem;
  color: var(--red);
  letter-spacing: 0.16em;
}

.inv-pets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pet-chip {
  font-size: 0.34rem;
  letter-spacing: 0.08em;
  color: var(--white);
  background: #16161e;
  border: 2px solid rgba(254, 202, 87, 0.45);
  padding: 8px 11px;
  line-height: 1.6;
}

.pet-chip.locked {
  color: #555;
  border-color: rgba(255, 255, 255, 0.08);
}

.inv-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 2px solid rgba(255, 255, 255, 0.14);
}

.btn-reset {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.34rem;
  letter-spacing: 0.1em;
  color: var(--gray);
  background: none;
  border: 2px solid rgba(255, 255, 255, 0.14);
  padding: 9px 12px;
  cursor: pointer;
}

.btn-reset:hover {
  color: var(--red);
  border-color: var(--red);
}

.inv-keys {
  margin-left: auto;
  font-size: 0.3rem;
  color: #444;
  letter-spacing: 0.1em;
}

/* ================================================
   CONTROLES TOUCH
   ================================================ */
.touch-controls { display: none; }

body.touch .touch-controls {
  display: block;
}

.dpad {
  position: fixed;
  left: 18px;
  bottom: 20px;
  z-index: 35;
  width: 156px;
  height: 156px;
}

.dbtn {
  position: absolute;
  width: 52px;
  height: 52px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(20, 20, 26, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  user-select: none;
}

.dbtn.down {
  background: var(--red);
  color: var(--bg);
}

.dbtn-up    { left: 52px; top: 0; }
.dbtn-left  { left: 0;    top: 52px; }
.dbtn-right { left: 104px; top: 52px; }
.dbtn-down  { left: 52px; top: 104px; }

.abtns {
  position: fixed;
  right: 22px;
  bottom: 34px;
  z-index: 35;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.abtn {
  width: 76px;
  height: 76px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  color: var(--bg);
  background: var(--red);
  border: none;
  box-shadow: 4px 4px 0 var(--red-dark);
  cursor: pointer;
  user-select: none;
}

.abtn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--red-dark);
}

.abtn-small {
  width: 54px;
  height: 54px;
  font-size: 0.6rem;
  background: var(--yellow);
  box-shadow: 4px 4px 0 #c9922a;
}

/* ================================================
   HINT DE CONTROLES
   ================================================ */
.controls-hint {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.3rem;
  color: rgba(255, 255, 255, 0.28);
  letter-spacing: 0.1em;
  z-index: 22;
  white-space: nowrap;
  pointer-events: none;
  animation: fadeIn 2s ease 1s both;
}

body.touch .controls-hint { display: none; }

/* ================================================
   RESPONSIVO
   ================================================ */
@media (max-width: 620px) {
  .prog-bar   { width: 104px; }
  .prog-label { font-size: 0.34rem; }
  .pet-label  { font-size: 0.3rem; }
  .toast      { top: 76px; max-width: 200px; font-size: 0.34rem; }

  .dialog       { padding: 0 10px 14px; }
  .dialog-box   { padding: 16px 16px 26px; }
  .dialog-title { font-size: 0.42rem; }
  .dialog-text  { font-size: 0.38rem; line-height: 2; }

  .dpad { width: 132px; height: 132px; left: 12px; }
  .dbtn { width: 44px; height: 44px; }
  .dbtn-up    { left: 44px; top: 0; }
  .dbtn-left  { left: 0;    top: 44px; }
  .dbtn-right { left: 88px; top: 44px; }
  .dbtn-down  { left: 44px; top: 88px; }

  .abtn       { width: 64px; height: 64px; }
  .abtn-small { width: 46px; height: 46px; }
}

/* Em telas com teclado, a caixa de diálogo não deve tapar o D-pad */
body.touch .dialog { padding-bottom: 200px; }

/* ================================================
   POPUP DE EMBED  (jogo jogavel / card da loja)
   ================================================ */
.embed {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(5, 5, 8, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.embed.show {
  opacity: 1;
  pointer-events: all;
}

.embed-panel {
  width: min(1000px, 100%);
  background: #0d0d12;
  border: 3px solid var(--white);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.7), inset 0 0 0 3px #1a1a22;
  padding: 16px;
}

.embed-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
}

.embed-title {
  font-size: 0.5rem;
  color: var(--yellow);
  letter-spacing: 0.12em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.embed-open {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.34rem;
  letter-spacing: 0.1em;
  color: var(--gray);
  text-decoration: none;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 2px;
}

.embed-open:hover { color: var(--white); }

.embed-close {
  flex-shrink: 0;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  color: var(--gray);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
}

.embed-close:hover { color: var(--red); }

/* O palco recebe o iframe no tamanho nativo declarado em
   world.js (w/h); o JS o reduz por transform ate caber.    */
.embed-stage {
  line-height: 0;
}

.embed-box {
  margin: 0 auto;
  overflow: hidden;
  background: #05050a;
}

.embed-box iframe {
  display: block;
  border: 0;
}

.embed-note {
  display: block;
  margin-top: 12px;
  font-size: 0.32rem;
  line-height: 1.9;
  color: var(--gray);
  letter-spacing: 0.08em;
}

@media (max-width: 640px) {
  .embed       { padding: 10px; }
  .embed-panel { padding: 12px; }
  .embed-title { font-size: 0.4rem; }
  .embed-open  { font-size: 0.3rem; }
}

/* ================================================
   POPUP DA ARVORE DE SKILLS
   ================================================ */
.skilltree {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(5, 5, 8, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.skilltree.show {
  opacity: 1;
  pointer-events: all;
}

.tree-panel {
  width: min(900px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: #0b0f10;
  border: 3px solid var(--white);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.7), inset 0 0 0 3px #141c1e;
  padding: 18px;
}

.tree-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 6px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
}

.tree-headline {
  font-size: 0.5rem;
  color: var(--green, #6bcB77);
  letter-spacing: 0.14em;
}

.tree-close {
  margin-left: auto;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  color: var(--gray);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
}

.tree-close:hover { color: var(--red); }

.tree-svg {
  display: block;
  width: 100%;
  height: auto;
}

/* --- fios --- */
.tree-wire {
  fill: none;
  stroke: #2f4f45;
  stroke-width: 4;
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: wire-draw 0.5s steps(12) forwards;
}

@keyframes wire-draw { to { stroke-dashoffset: 0; } }

/* --- nos --- */
.tree-node {
  opacity: 0;
  animation: node-pop 0.28s steps(4) forwards;
}

@keyframes node-pop {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.tree-shadow { fill: #000; }

.tree-box {
  fill: #16211f;
  stroke: #4f7d6d;
  stroke-width: 3;
}

/* Sem font-size aqui: quem manda é o atributo do <text>, que o
   JS usa para calcular a largura da caixa. Sem letter-spacing
   tambem — ele somaria largura que o calculo nao preve.        */
.tree-text {
  font-family: 'Press Start 2P', monospace;
  fill: #e8f3ee;
  text-anchor: middle;
}

.tree-root .tree-box   { fill: #3a2a10; stroke: var(--yellow); }
.tree-root .tree-text  { fill: var(--yellow); }
.tree-branch .tree-box { fill: #10261f; stroke: #6bcb77; }
.tree-branch .tree-text{ fill: #9ee6a6; }

.tree-note {
  margin-top: 14px;
  font-size: 0.34rem;
  line-height: 2;
  color: var(--gray);
  letter-spacing: 0.08em;
  text-align: center;
}

@media (max-width: 640px) {
  .skilltree  { padding: 10px; }
  .tree-panel { padding: 12px; }
  .tree-headline { font-size: 0.4rem; }
}

/* ================================================
   DICA DA MOTO
   ================================================ */
.moto-hint {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 32;
  font-size: 0.4rem;
  letter-spacing: 0.12em;
  color: var(--yellow);
  background: rgba(0, 0, 0, 0.78);
  border: 2px solid var(--yellow);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.6);
  padding: 8px 14px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.moto-hint.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body.touch .moto-hint { bottom: 200px; }

/* Botao da moto aceso enquanto voce esta pilotando */
.abtn.on {
  background: rgba(254, 202, 87, 0.28);
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px rgba(254, 202, 87, 0.35);
}
