/* ============================================================
   COME-COME — folha de estilo
   Tema fixo escuro: é um fliperama, não um documento.
   ============================================================ */

:root {
  /* Tema único, escuro, de propósito: é uma tela de fliperama, não um
     documento. Declarado aqui, e não só no cabeçalho da página, para
     continuar escuro quando o CSS viaja sozinho. */
  color-scheme: dark;
  background: #05060f;

  --fundo:      #05060f;
  --fundo-alto: #0c0f22;
  --parede:     #2b47ff;
  --parede-luz: #6f86ff;
  --amarelo:    #ffe11a;
  --texto:      #d8dcf5;
  --texto-fraco:#7b83b8;
  --borda:      #1b2145;
  --raio:       14px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(120% 90% at 50% -10%, #12173a 0%, var(--fundo) 60%);
  color: var(--texto);
  font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2vh, 24px);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.4vh, 14px);
  max-height: 100%;
  width: 100%;
}

/* ---------------------------------------------------------- placar */

.hud {
  display: flex;
  gap: clamp(14px, 4vw, 44px);
  align-items: flex-end;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  max-width: 640px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 62px;
}

.hud-label {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--texto-fraco);
}

.hud-item strong {
  font-size: clamp(1rem, 3.4vw, 1.35rem);
  font-variant-numeric: tabular-nums;
  color: var(--amarelo);
  font-weight: 700;
}

.lives {
  display: flex;
  gap: 5px;
  height: 1.35rem;
  align-items: center;
}

/* O desenho vem do SVG montado em `iconeVida()`. Aqui só o tamanho e a
   cor — e o `fill` precisa ser explícito porque este projeto não tem
   nenhuma outra regra para `svg path`. */
.vida {
  width: 15px;
  height: 15px;
  display: block;
  overflow: visible;
}
.vida path { fill: var(--amarelo); stroke: none; }

/* ---------------------------------------------------------- tabuleiro */

.stage {
  position: relative;
  line-height: 0;
  /* o canvas é 672x744; deixa ele ocupar a altura disponível */
  max-height: calc(100vh - 190px);
  aspect-ratio: 672 / 744;
}

canvas {
  display: block;
  height: 100%;
  width: 100%;
  max-width: 100%;
  border-radius: var(--raio);
  background: var(--fundo);
  border: 1px solid var(--borda);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  line-height: 1.4;
  border-radius: var(--raio);
  background: color-mix(in srgb, var(--fundo) 76%, transparent);
  backdrop-filter: blur(2px);
  padding: 20px;
}

.overlay[hidden] { display: none; }

.overlay-title {
  margin: 0;
  font-size: clamp(1.3rem, 5vw, 2.1rem);
  letter-spacing: 0.1em;
  color: var(--amarelo);
  text-shadow: 0 0 22px color-mix(in srgb, var(--amarelo) 45%, transparent);
}

.overlay-sub {
  margin: 0;
  font-size: clamp(0.72rem, 2.6vw, 0.9rem);
  color: var(--texto-fraco);
  max-width: 30ch;
}

/* ---------------------------------------------------------- direcional */

.pad {
  display: none;
  grid-template-areas:
    ".    cima   ."
    "esq  .      dir"
    ".    baixo  .";
  gap: 8px;
}

.pad-btn {
  width: 58px;
  height: 58px;
  font-size: 1.1rem;
  color: var(--texto);
  background: var(--fundo-alto);
  border: 1px solid var(--borda);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.pad-btn:active { background: var(--parede); border-color: var(--parede-luz); }

.pad-up    { grid-area: cima;  }
.pad-left  { grid-area: esq;   }
.pad-down  { grid-area: baixo; }
.pad-right { grid-area: dir;   }

/* só aparece onde o dedo é o ponteiro */
@media (pointer: coarse) {
  .pad { display: grid; }
  .keys { display: none; }
  .stage { max-height: calc(100vh - 320px); }
}

/* ---------------------------------------------------------- rodapé */

.keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(8px, 2.5vw, 22px);
  font-size: 0.68rem;
  color: var(--texto-fraco);
  margin: 0;
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 1px 5px;
  margin: 0 1px;
  font: inherit;
  font-size: 0.9em;
  text-align: center;
  color: var(--texto);
  background: var(--fundo-alto);
  border: 1px solid var(--borda);
  border-bottom-width: 2px;
  border-radius: 5px;
}

/* ---------------------------------------------------------- utilidades */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .overlay-title { text-shadow: none; }
  * { transition: none !important; }
}

/* telas baixas e largas: encolhe o resto para o labirinto caber */
@media (max-height: 620px) {
  .hud-label { display: none; }
  .keys { display: none; }
  .stage { max-height: calc(100vh - 90px); }
}
