/* Woody Man — página do fliperama (tema único escuro). */

:root {
  color-scheme: dark;

  /* Neutros: ameixa-noite puxando para o azul do labirinto */
  --bg: #0b0814;
  --floor: #100c1c;
  --panel: #161127;
  --panel-2: #1e1834;
  --line: #2a2347;
  --line-2: #3b3266;
  --shadow: #05030a;

  /* Texto */
  --ink: #efe6d4;
  --ink-dim: #b3a9c7;
  --ink-faint: #7a7198;

  /* Pelo do Woody */
  --honey: #e8a33d;
  --honey-light: #f6cf7a;
  --honey-deep: #8f5514;
  --honey-ink: #1d1105;

  /* Bolinha de tênis: destaque de interação */
  --ball: #d4f03c;

  /* Outros */
  --maze: #6fc3ff;
  --danger: #ff6a5c;
  --kibble: #d9a066;
  --scrim: rgba(11, 8, 20, 0.86);
  --glow: rgba(111, 195, 255, 0.10);
  --lamp: rgba(232, 163, 61, 0.07);

  --font-pixel: "Press Start 2P", ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --font-text: "Pixelify Sans", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;

  --gutter: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 70% 55% at 50% 38%, var(--lamp), transparent 70%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
}

img,
canvas {
  display: block;
}

.pixel,
.app img,
.app canvas {
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

button {
  font: inherit;
}

a {
  color: var(--honey-light);
}

a:focus-visible,
.screen:focus-visible {
  outline: 3px solid var(--ball);
  outline-offset: 3px;
}

kbd {
  display: inline-block;
  font-family: var(--font-pixel);
  font-size: 0.62em;
  line-height: 1;
  letter-spacing: 0.06em;
  padding: 0.45em 0.5em 0.4em;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  box-shadow: 0 2px 0 var(--shadow);
  vertical-align: 0.15em;
}

code {
  font-family: var(--font-pixel);
  font-size: 0.7em;
  color: var(--honey-light);
}

/* ---------- Marquise (topo) ---------- */

.marquee {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  padding: 12px max(var(--gutter), env(safe-area-inset-right)) 12px max(var(--gutter), env(safe-area-inset-left));
  background: var(--panel);
  border-bottom: 2px solid var(--line);
  box-shadow: inset 0 -4px 0 -2px var(--honey-deep);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo-icon img,
.logo-icon canvas {
  width: 48px;
  height: 48px;
}

.logo-text {
  margin: 0;
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  color: var(--honey-light);
  text-shadow: 3px 3px 0 var(--honey-deep), 6px 6px 0 var(--shadow);
  white-space: nowrap;
}

.hud {
  display: flex;
  gap: 20px;
  margin: 0;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.hud dt {
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

.hud dd {
  margin: 0;
  min-width: 6ch;
  text-align: right;
  font-family: var(--font-pixel);
  font-size: 14px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.hud-cell--hi dd {
  color: var(--honey-light);
}

.hud-cell:last-child dd {
  min-width: 2ch;
}

/* FASE n em cima, nome do cômodo embaixo (cor da fase vem do main.js) */
.hud-cell--level dt span {
  color: var(--ink-dim);
}

.hud-cell--level dd {
  min-width: 10ch;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--maze);
  white-space: nowrap;
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  padding: 16px max(var(--gutter), env(safe-area-inset-right)) 32px max(var(--gutter), env(safe-area-inset-left));
  max-width: 1440px;
  margin: 0 auto;
}

.play {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  --dpad-side: 0;
}

/* ---------- Gabinete e tela ---------- */

.cabinet {
  position: relative;
  max-width: 100%;
  padding: 10px;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.055) 1px, transparent 1.4px) 0 0 / 4px 4px,
    linear-gradient(180deg, #211a3c 0%, #151027 100%);
  border: 2px solid var(--line-2);
  border-top-color: var(--honey-deep);
  box-shadow:
    0 0 0 2px var(--shadow),
    6px 6px 0 2px var(--shadow),
    0 40px 90px -30px var(--glow);
}

.screen {
  --u: 2;
  position: relative;
  width: min(448px, 100%);
  aspect-ratio: 224 / 248;
  overflow: hidden;
  background: var(--floor);
  box-shadow: 0 0 0 2px #000, 0 0 28px var(--glow);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.screen:focus {
  outline: none;
}

.screen canvas {
  width: 100%;
  height: 100%;
}

/* Linhas de varredura só em escala inteira, alinhadas ao pixel lógico */
.screen.is-int::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--u) * 1px - 1px),
    rgba(0, 0, 0, 0.16) calc(var(--u) * 1px - 1px),
    rgba(0, 0, 0, 0.16) calc(var(--u) * 1px)
  );
}

/* ---------- Overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: calc(var(--u) * 8px) calc(var(--u) * 8px);
  background: var(--scrim);
  text-align: center;
}

.ov-inner {
  margin: auto;
  width: 100%;
  max-width: calc(var(--u) * 190px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 5px);
}

.ov-inner > * {
  margin: 0;
}

.ov-title {
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: max(12px, calc(var(--u) * 8px));
  line-height: 1.3;
  letter-spacing: 0.08em;
  color: var(--honey-light);
  text-shadow: calc(var(--u) * 1px) calc(var(--u) * 1px) 0 var(--honey-deep);
}

.ov-text,
.ov-pitch {
  font-size: max(13px, calc(var(--u) * 6.5px));
  line-height: 1.35;
  color: var(--ink);
  max-width: 32ch;
}

.ov-pitch {
  font-size: max(14px, calc(var(--u) * 7.5px));
}

.ov-text--dim,
.ov-hint {
  color: var(--ink-dim);
}

.ov-hint {
  font-size: max(12px, calc(var(--u) * 5.5px));
}

.parade {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 3px);
}

.parade img,
.parade canvas {
  width: calc(var(--u) * 16px);
  height: calc(var(--u) * 16px);
}

.parade .parade-woody {
  width: calc(var(--u) * 24px);
  height: calc(var(--u) * 24px);
  margin-right: calc(var(--u) * 6px);
}

.ov-controls {
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 2px);
  font-size: max(12px, calc(var(--u) * 5.5px));
  color: var(--ink-dim);
}

.ov-controls p {
  margin: 0;
}

.ov-link {
  font-size: max(12px, calc(var(--u) * 5.5px));
}

.ov-score {
  font-family: var(--font-pixel);
  font-size: max(14px, calc(var(--u) * 9px));
  line-height: 1.2;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.ov-score-label {
  display: block;
  margin-bottom: calc(var(--u) * 2px);
  font-size: max(8px, calc(var(--u) * 3.5px));
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

.ov-record {
  font-family: var(--font-pixel);
  font-size: max(10px, calc(var(--u) * 5px));
  letter-spacing: 0.08em;
  color: var(--ball);
  animation: blink 0.9s steps(2, jump-none) infinite;
}

.ov-level {
  font-size: max(13px, calc(var(--u) * 6px));
  color: var(--ink-dim);
}

.ov-sub {
  margin-top: calc(var(--u) * 2px) !important;
  font-family: var(--font-text);
  font-weight: 600;
  font-size: max(13px, calc(var(--u) * 6px));
  color: var(--honey);
}

.ate {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: calc(var(--u) * 3px) calc(var(--u) * 6px);
}

.ate li,
.haul li {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-pixel);
  font-size: max(9px, calc(var(--u) * 4px));
  color: var(--ink);
}

.ate img,
.ate canvas {
  width: calc(var(--u) * 12px);
  height: calc(var(--u) * 12px);
}

.ate .ate-empty {
  font-family: var(--font-text);
  font-size: max(13px, calc(var(--u) * 6px));
  color: var(--ink-faint);
}

.ate-stats {
  list-style: none;
  padding: 0;
  font-size: max(13px, calc(var(--u) * 6px));
  color: var(--ink-dim);
}

.ate-stats b {
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 0.75em;
  color: var(--ink);
}

.overlay--error {
  background: rgba(11, 8, 20, 0.95);
}

.overlay--error .ov-title {
  color: var(--danger);
  text-shadow: none;
}

.error-list {
  list-style: none;
  padding: 0;
  font-family: var(--font-pixel);
  font-size: max(9px, calc(var(--u) * 4px));
  line-height: 1.8;
  color: var(--honey-light);
}

/* Na tela de título o link para o elenco só faz sentido quando o elenco não está ao lado */
@media (min-width: 1100px) {
  .ov-link {
    display: none;
  }
}

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 12px;
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.1em;
  white-space: nowrap;
  color: var(--ink);
  background: var(--panel-2);
  border: 2px solid var(--line-2);
  border-radius: 0;
  box-shadow: 0 4px 0 var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) {
  color: var(--honey-light);
  border-color: var(--honey);
}

.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--shadow);
}

.btn:focus-visible,
.dpad-btn:focus-visible {
  outline: 3px solid var(--ball);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn[aria-pressed="false"] {
  color: var(--ink-faint);
}

.btn--primary {
  color: var(--honey-ink);
  background: var(--honey);
  border-color: var(--honey-light);
  box-shadow: 0 4px 0 var(--honey-deep), 0 4px 0 2px var(--shadow);
}

.btn--primary:hover:not(:disabled) {
  color: var(--honey-ink);
  background: var(--honey-light);
  border-color: #fff1c9;
}

.btn--primary:active:not(:disabled) {
  box-shadow: 0 1px 0 var(--honey-deep), 0 1px 0 2px var(--shadow);
}

.btn--big {
  min-height: 0;
  padding: max(12px, calc(var(--u) * 5px)) max(18px, calc(var(--u) * 11px));
  font-size: max(11px, calc(var(--u) * 6px));
}

/* ---------- Bandeja sob a tela ---------- */

.tray {
  width: 100%;
  max-width: max(var(--cab-w, 472px), 340px);
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.toast {
  margin: 0;
  min-height: 1.45em;
  text-align: center;
  font-size: 16px;
  color: var(--honey-light);
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

.toast.is-on {
  opacity: 1;
}

.toast .toast-pts {
  margin-left: 0.6em;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--ball);
  white-space: nowrap;
}

.toast.is-life {
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ball);
}

.tray-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.tray-label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

.lives {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
}

.lives img,
.lives canvas {
  width: 32px;
  height: 32px;
}

.lives .lives-more {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--ink-dim);
}

.tray-buttons {
  display: flex;
  gap: 10px;
  flex: none;
}

.haul-wrap {
  padding-top: 10px;
  border-top: 2px dotted var(--line);
}

.haul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  min-height: 24px;
}

.haul li {
  font-size: 9px;
}

.haul img,
.haul canvas {
  width: 24px;
  height: 24px;
}

.haul .haul-empty {
  font-family: var(--font-text);
  font-size: 14px;
  color: var(--ink-faint);
}

/* ---------- Direcional (só em telas de toque) ---------- */

.dpad {
  display: none;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(3, 60px);
  gap: 4px;
  margin-top: 16px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

@media (pointer: coarse) {
  .dpad {
    display: grid;
  }
}

@media (pointer: coarse) and (max-height: 760px) {
  .dpad {
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 52px);
    margin-top: 12px;
  }
}

.dpad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--panel-2);
  border: 2px solid var(--line-2);
  border-radius: 0;
  box-shadow: 0 4px 0 var(--shadow);
  color: var(--honey);
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.dpad-btn.is-down,
.dpad-btn:active {
  background: var(--line-2);
  color: var(--ball);
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--shadow);
}

.dpad-btn--up { grid-area: 1 / 2; }
.dpad-btn--left { grid-area: 2 / 1; }
.dpad-btn--right { grid-area: 2 / 3; }
.dpad-btn--down { grid-area: 3 / 2; }

.dpad-hub {
  grid-area: 2 / 2;
  background: var(--panel);
  border: 2px solid var(--line);
}

.arrow {
  width: 20px;
  height: 14px;
  background: currentColor;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.dpad-btn--down .arrow { transform: rotate(180deg); }
.dpad-btn--left .arrow { transform: rotate(-90deg); }
.dpad-btn--right .arrow { transform: rotate(90deg); }

.only-coarse {
  display: none;
}

@media (pointer: coarse) {
  .only-coarse {
    display: block;
  }

  .only-fine {
    display: none;
  }
}

/* ---------- Cartões: elenco e cardápio ---------- */

.card {
  min-width: 0;
  padding: 18px 18px 16px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: 4px 4px 0 var(--shadow);
}

.card-title {
  margin: 0 0 14px;
  padding-bottom: 10px;
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--honey);
  border-bottom: 2px dotted var(--line-2);
}

.card-note {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--ink-dim);
  max-width: 44ch;
}

.cast,
.menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.cast {
  gap: 12px;
}

.cast li {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 2px 12px;
  align-items: start;
}

.cast img,
.cast canvas {
  width: 32px;
  height: 32px;
  grid-row: span 2;
}

.cast-name {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  color: var(--ink);
}

.cast-desc {
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink-dim);
}

.cast li.is-hero .cast-name {
  color: var(--honey-light);
}

.menu {
  gap: 4px;
}

.menu li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 4px 0;
}

.menu img,
.menu canvas {
  width: 24px;
  height: 24px;
}

.menu .kibble {
  justify-self: center;
  width: 6px;
  height: 6px;
  background: var(--kibble);
}

.menu-name {
  font-size: 15px;
  line-height: 1.25;
  color: var(--ink);
}

.menu-name small {
  display: block;
  font-size: 13px;
  color: var(--ink-dim);
}

.menu-pts {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--honey-light);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.menu li.is-ball .menu-pts {
  color: var(--ball);
}

/* Cômodos: amostra da parede com o número da fase, nome + recado, petiscos favoritos */
.rooms li {
  padding: 6px 0;
}

.room-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1;
  color: var(--maze);
  background: var(--panel-2);
  border: 2px solid currentColor;
  box-shadow: 2px 2px 0 var(--shadow);
}

.room-fav {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}

/* ---------- Pontos de quebra ---------- */

@media (min-width: 720px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .play {
    grid-column: 1 / -1;
  }

  .card--rooms {
    grid-column: 1 / -1;
  }

  .rooms {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 28px;
  }
}

@media (min-width: 1100px) {
  .layout {
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) minmax(240px, 300px);
    /* linha 1 = altura do elenco; a linha 2 estica para acompanhar a tela */
    grid-template-rows: auto 1fr;
    gap: 32px;
    padding-top: 20px;
  }

  .play {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .card--cast {
    grid-column: 1;
    grid-row: 1;
  }

  .card--rooms {
    grid-column: 1;
    grid-row: 2;
  }

  .card--menu {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  .rooms {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  .marquee {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .logo {
    gap: 8px;
  }

  .logo-icon img,
  .logo-icon canvas {
    width: 32px;
    height: 32px;
  }

  .logo-text {
    font-size: 15px;
    text-shadow: 2px 2px 0 var(--honey-deep), 4px 4px 0 var(--shadow);
  }

  .hud {
    gap: 14px;
  }

  .hud dd {
    font-size: 12px;
  }

  .hud-cell--level dd {
    font-size: 10px;
  }

  .layout {
    padding-top: 12px;
  }

  .cabinet {
    padding: 6px;
  }

  .tray {
    margin-top: 14px;
  }

  .btn {
    padding: 10px 9px;
    font-size: 9px;
  }
}

@media (max-width: 400px) {
  .marquee {
    justify-content: center;
  }
}

/* Celular deitado: direcional ao lado da tela */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  .marquee {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .logo-icon img,
  .logo-icon canvas {
    width: 32px;
    height: 32px;
  }

  .logo-text {
    font-size: 14px;
  }

  .layout {
    padding-top: 8px;
  }

  .play {
    --dpad-side: 1;
    display: grid;
    grid-template-columns: auto auto;
    justify-content: center;
    align-items: center;
    column-gap: 24px;
  }

  .cabinet {
    grid-column: 1;
    grid-row: 1;
  }

  .tray {
    grid-column: 1;
    grid-row: 2;
  }

  .dpad {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin-top: 0;
  }
}

/* ---------- Movimento ---------- */

@keyframes blink {
  0% { opacity: 1; }
  100% { opacity: 0.25; }
}

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

  .btn:active:not(:disabled),
  .dpad-btn:active,
  .dpad-btn.is-down {
    transform: none;
  }
}
