/* Montanha: Zero Day — shell, HUD, touch pad, FF-style windows. Mobile first. */

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;
  --ink: #070914;
  --ink-2: #0d1124;
  --win-top: #22359a;
  --win-bot: #0a1145;
  --win-border: #e9edff;
  --text: #e9edff;
  --dim: #8d95c2;
  --cyan: #3df0ff;
  --magenta: #ff4fd8;
  --gold: #ffd23d;
  --red: #ff3b5c;
  --green: #7dff9b;
  --font-display: "Press Start 2P", ui-monospace, monospace;
  --font-body: "VT323", ui-monospace, monospace;
  --radius: 6px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --u: 1px; /* game pixel; JS sets it on #wrap to (width / 320)px */
  --hud-font: max(8px, calc(var(--u) * 6));
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.2;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

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

img { image-rendering: pixelated; }

/* ---------- Shared: FF window + bars ---------- */
.win, #card, #dialog, .pz-window {
  background: linear-gradient(180deg, var(--win-top), var(--win-bot));
  border: 3px solid var(--win-border);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .45), inset 0 6px 14px rgba(255, 255, 255, .08), 0 6px 18px rgba(0, 0, 0, .55);
}

.bar {
  position: relative;
  height: calc(var(--u) * 4);
  min-height: 5px;
  background: rgba(0, 0, 0, .65);
  border: max(1px, calc(var(--u) * .75)) solid var(--win-border);
  border-radius: 2px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 100%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  transition: width .15s linear;
}
.bar-hp  { color: var(--green); width: calc(var(--u) * 52); }
.bar-ep  { color: var(--cyan);  width: calc(var(--u) * 34); }
.bar-jet { color: var(--gold);  width: calc(var(--u) * 26); }

/* ---------- App layout (portrait phone default) ---------- */
#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  background: radial-gradient(120% 70% at 50% 0%, #121a3d 0%, var(--ink) 60%);
}

#wrap {
  position: relative;
  flex: none;
  align-self: center;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 2px #1a2150, 0 0 24px rgba(61, 240, 255, .18);
}

#cv {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------- In-game overlays (scale with --u) ---------- */
#hud {
  position: absolute;
  top: calc(var(--u) * 4);
  left: calc(var(--u) * 4);
  display: grid;
  gap: calc(var(--u) * 2);
  font: var(--hud-font)/1 var(--font-display);
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}
.hud-row { display: flex; align-items: center; gap: calc(var(--u) * 3); }
.hud-label { color: var(--dim); }
#hud-lv { color: var(--gold); font-weight: normal; }
#hud-xp { color: var(--cyan); font-variant-numeric: tabular-nums; }

#btn-pause {
  position: absolute;
  top: calc(var(--u) * 3);
  right: calc(var(--u) * 3);
  min-width: 44px;
  min-height: 44px;
  width: calc(var(--u) * 16);
  height: calc(var(--u) * 16);
  padding: 0;
  font: var(--hud-font)/1 var(--font-display);
  background: rgba(10, 17, 69, .7);
  border: 2px solid var(--win-border);
  border-radius: var(--radius);
}

#bossbar {
  position: absolute;
  top: calc(var(--u) * 22);
  left: 50%;
  width: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: calc(var(--u) * 2);
  text-align: center;
  font: var(--hud-font)/1 var(--font-display);
  color: var(--red);
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}
#bossbar .bar { color: var(--red); height: calc(var(--u) * 5); }
#bossbar.is-shielded, #bossbar.is-shielded .bar { color: var(--magenta); }
#bossbar.is-shielded .bar { border-color: var(--magenta); }

#toast {
  position: absolute;
  top: calc(var(--u) * 40);
  left: 50%;
  transform: translateX(-50%);
  max-width: 90%;
  padding: calc(var(--u) * 3) calc(var(--u) * 6);
  font: var(--hud-font)/1.4 var(--font-display);
  color: var(--gold);
  text-align: center;
  white-space: normal;
  text-wrap: balance;
  background: rgba(7, 9, 20, .82);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  pointer-events: none;
}
#toast.pop { animation: pop .35s ease-out; }

#card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  gap: calc(var(--u) * 4);
  min-width: 60%;
  padding: calc(var(--u) * 8) calc(var(--u) * 12);
  text-align: center;
  pointer-events: none;
  animation: card-in .4s ease-out;
}
#card-kicker { font: var(--hud-font)/1 var(--font-display); color: var(--cyan); }
#card-title { font: calc(var(--hud-font) * 1.5)/1.3 var(--font-display); color: var(--gold); font-weight: normal; }

/* ---------- Touch pad (portrait) ---------- */
#pad {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 150px;
  padding: 12px 16px;
  font-family: var(--font-display);
}

#dpad {
  position: relative;
  display: flex;
  width: 44vw;
  max-width: 220px;
  height: 30%;
  min-height: 110px;
  max-height: 160px;
  border: 3px solid #2a3570;
  border-radius: 18px;
  background: linear-gradient(180deg, #141c45, #0a0f2c);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .5);
  touch-action: none;
}
.dpad-half {
  flex: 1;
  display: grid;
  place-items: center;
  font-size: 22px;
  color: var(--dim);
  transition: color .08s, background .08s, text-shadow .08s;
}
.dpad-left { border-right: 2px solid #2a3570; border-radius: 15px 0 0 15px; }
.dpad-right { border-radius: 0 15px 15px 0; }
#dpad.is-left .dpad-left,
#dpad.is-right .dpad-right {
  color: var(--cyan);
  background: rgba(61, 240, 255, .16);
  text-shadow: 0 0 10px var(--cyan);
}

#btns {
  position: relative;
  flex: none;
  width: 180px;
  height: 170px;
}
#btns button {
  position: absolute;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  min-width: 56px;
  min-height: 56px;
  padding: 0;
  font: 8px/1 var(--font-display);
  border-radius: 50%;
  border: 3px solid currentColor;
  background: radial-gradient(circle at 35% 30%, #2a3a8f, #0a1145 70%);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .45), 0 3px 0 rgba(0, 0, 0, .5);
  touch-action: none;
  transition: transform .06s, box-shadow .06s;
}
.btn-jump { width: 84px; height: 84px; right: 0; bottom: 6px; color: var(--green); }
.btn-fire { width: 72px; height: 72px; right: 92px; bottom: 0; color: var(--gold); }
.btn-hack { width: 60px; height: 60px; right: 52px; top: 0; color: var(--magenta); }
#btns button.is-down {
  transform: scale(.94);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, .45), 0 0 18px currentColor, 0 0 4px currentColor;
}

/* ---------- Dialog ---------- */
#dialog {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(10px + var(--safe-b));
  z-index: 30;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 14px 18px;
  cursor: pointer;
}
#dlg-portrait {
  flex: none;
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  background: var(--ink);
  border: 2px solid var(--win-border);
  border-radius: 3px;
}
.dlg-body { min-width: 0; }
#dlg-name { display: block; margin-bottom: 6px; font: 10px/1 var(--font-display); color: var(--gold); font-weight: normal; }
#dlg-text { margin: 0; font: 24px/1.1 var(--font-body); }
.dlg-next {
  position: absolute;
  right: 12px;
  bottom: 4px;
  font-size: 14px;
  color: var(--gold);
  visibility: hidden;
}
.dlg-rest { visibility: hidden; }
#dialog.is-done .dlg-next { visibility: visible; animation: blink 1s steps(2, start) infinite; }

/* ---------- Puzzle ---------- */
#puzzle {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  padding: calc(8px + var(--safe-t)) var(--safe-r) calc(8px + var(--safe-b)) var(--safe-l);
  background: rgba(3, 4, 12, .82);
  overflow-y: auto;
}
.pz-window {
  width: min(420px, 100% - 32px);
  margin: auto;   /* centra quando cabe; quando não cabe, alinha ao topo e rola (o botão Sair fica alcançável) */
  padding: 16px;
  display: grid;
  gap: 12px;
  text-align: center;
}
#pz-title { margin: 0; font: 12px/1.4 var(--font-display); color: var(--gold); }
#pz-help { margin: 0; font-size: 20px; color: var(--text); }
#pz-timer {
  height: 6px;
  background: rgba(0, 0, 0, .6);
  border: 1px solid var(--win-border);
  border-radius: 2px;
  overflow: hidden;
}
#pz-timer i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--red), var(--gold) 40%, var(--cyan));
  background-size: 420px 100%;
  box-shadow: 0 0 8px var(--cyan);
}
#pz-body { display: grid; justify-items: center; gap: 14px; }
.pz-msg { min-height: 1.2em; margin: 0; font-size: 22px; }
#pz-msg.ok { color: var(--green); }
#pz-msg.bad { color: var(--red); }

.pz-window button, .menu button, .stage-btn {
  min-height: 56px;
  border: 2px solid var(--win-border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .3);
}
#pz-cancel { justify-self: center; min-width: 140px; font: 10px/1 var(--font-display); }

/* Sequence */
.seq-slots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.seq-slots i { width: 20px; height: 20px; border: 2px solid var(--dim); border-radius: 3px; }
.seq-slots i.ok { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.seq-pad { display: grid; grid-template-columns: repeat(2, 76px); gap: 12px; }
.seq-pad .sq {
  --c: var(--cyan);
  width: 76px;
  height: 76px;
  font-size: 28px;
  color: var(--c);
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, #050816);
  transition: transform .08s, box-shadow .08s, background .08s;
}
.sq-0 { --c: var(--cyan); }
.sq-1 { --c: var(--gold); }
.sq-2 { --c: var(--magenta); }
.sq-3 { --c: var(--green); }
.seq-pad .sq.lit {
  color: #fff;
  background: var(--c);
  transform: scale(1.08);
  box-shadow: 0 0 22px var(--c), 0 0 6px #fff;
}

/* Binary */
.bin-target { font: 10px/1 var(--font-display); color: var(--dim); }
.bin-target b { display: block; margin-top: 8px; font-size: 32px; color: var(--gold); font-weight: normal; text-shadow: 0 0 10px rgba(255, 210, 61, .5); }
.bin-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.bin-row .bit {
  display: grid;
  place-items: center;
  width: 56px;
  min-height: 64px;
  padding: 4px 0;
  color: var(--dim);
}
.bit span { font: 20px/1 var(--font-display); }
.bit small { font-size: 16px; }
.bin-row .bit.on { color: var(--ink); background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.bin-current { font-size: 22px; color: var(--cyan); font-variant-numeric: tabular-nums; }

/* Node grid */
.grid3 { display: grid; grid-template-columns: repeat(3, 64px); gap: 10px; }
.grid3 .node {
  position: relative;
  width: 64px;
  height: 64px;
  border-color: #6b2235;
  background: #2a0a14;
  transition: background .1s, box-shadow .1s;
}
.grid3 .node::before, .grid3 .node::after {
  content: "";
  position: absolute;
  inset: 50% 22%;
  height: 3px;
  margin-top: -1.5px;
  background: rgba(255, 59, 92, .5);
  transform: rotate(45deg);
}
.grid3 .node::after { transform: rotate(-45deg); }
.grid3 .node.on { background: var(--cyan); border-color: #fff; box-shadow: 0 0 16px var(--cyan); }
.grid3 .node.on::before, .grid3 .node.on::after { display: none; }
.grid3 .node.hint { animation: hintpulse 0.8s ease-in-out infinite; }
@keyframes hintpulse { 50% { border-color: var(--gold); box-shadow: 0 0 18px var(--gold); } }

/* ---------- Screens (menus) ---------- */
#screen {
  position: absolute;
  inset: 0;
  z-index: 35;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, rgba(7, 9, 20, .55), rgba(7, 9, 20, .9) 70%);
}
.screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 760px;
  min-height: 100%;
  margin: 0 auto;
  justify-content: center;
  text-align: center;
}

.emblem { width: 120px; height: auto; color: var(--cyan); filter: drop-shadow(0 0 10px rgba(61, 240, 255, .5)); }
.emblem svg { width: 100%; height: auto; display: block; }
.logo {
  margin: 0;
  font: clamp(22px, 7vw, 44px)/1.2 var(--font-display);
  color: #fff;
  text-shadow: 3px 0 0 var(--magenta), -3px 0 0 var(--cyan), 0 0 18px rgba(61, 240, 255, .35);
}
.logo small {
  display: block;
  margin-top: 10px;
  font-size: .55em;
  color: var(--gold);
  text-shadow: 2px 2px 0 #000;
}
.tagline { margin: 0; font-size: 24px; color: var(--text); }
.hint { margin: 0; font-size: 18px; color: var(--dim); }

.menu { display: grid; gap: 8px; width: min(340px, 100%); }
.menu button {
  position: relative;
  padding: 0 16px 0 34px;
  text-align: left;
  font: 11px/1.3 var(--font-display);
  background: linear-gradient(180deg, var(--win-top), var(--win-bot));
}
.menu button::before {
  content: "▶";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--gold);
  opacity: 0;
}
.menu button:hover::before, .menu button:focus-visible::before { opacity: 1; animation: nudge .6s ease-in-out infinite alternate; }
.menu button:hover, .menu button:focus-visible { color: var(--gold); outline: none; border-color: var(--gold); }
.menu .btn-ghost, .btn-ghost { background: rgba(0, 0, 0, .35); color: var(--dim); border-color: #4a5288; }

.win { width: 100%; padding: 14px; text-align: left; }
.win h3 { margin: 0 0 10px; font: 10px/1.3 var(--font-display); color: var(--gold); }
.map-grid { display: grid; grid-template-columns: 1fr; gap: 12px; width: 100%; }

.status { display: flex; gap: 14px; align-items: center; }
.status img { flex: none; width: 72px; height: 72px; image-rendering: pixelated; border: 2px solid var(--win-border); border-radius: 3px; background: var(--ink); }
dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; font-size: 22px; }
dt { color: var(--dim); }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.stage-btn {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  text-align: left;
  background: rgba(0, 0, 0, .3);
}
.stage-btn:hover, .stage-btn:focus-visible { border-color: var(--gold); outline: none; }
.stage-btn .num { font: 10px/1 var(--font-display); color: var(--cyan); }
.stage-btn .name { font-size: 22px; }
.stage-btn .state { font: 8px/1 var(--font-display); color: var(--gold); }
.stage-btn.is-done .state { color: var(--green); }
.stage-btn.is-locked { opacity: .45; cursor: not-allowed; border-style: dashed; }

.equip ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 20px; }
.equip b { color: var(--cyan); font-weight: normal; }

.result { width: min(420px, 100%); }

/* ---------- Breakpoints ---------- */
@media (min-width: 720px) and (orientation: landscape) and (max-height: 540px) {
  .map-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1.15fr); gap: 8px; }
}
@media (min-width: 720px) and (not (orientation: landscape)) {
  .map-grid { grid-template-columns: 1fr 1fr; }
}

/* Landscape phone: game centred, controls float over the bottom corners */
@media (orientation: landscape) and (max-height: 540px) {
  #app { justify-content: center; align-items: center; }
  #pad {
    position: absolute;
    inset: auto 0 0 0;
    z-index: 10;
    min-height: 0;
    padding: 0 calc(12px + var(--safe-r)) calc(10px + var(--safe-b)) calc(12px + var(--safe-l));
    align-items: flex-end;
    background: none;
    pointer-events: none;
  }
  #pad > * { pointer-events: auto; opacity: .75; }
  #dpad {
    width: 28vw;
    max-width: 190px;
    height: 72px;
    min-height: 72px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(20, 28, 69, 0.45), rgba(10, 15, 44, 0.45));
    border-color: rgba(42, 53, 112, 0.6);
  }
  .dpad-left { border-right-color: rgba(42, 53, 112, 0.6); border-radius: 11px 0 0 11px; }
  .dpad-right { border-radius: 0 11px 11px 0; }
  #btns { transform: scale(.85); transform-origin: bottom right; }
  #btns button {
    background: radial-gradient(circle at 35% 30%, rgba(42, 58, 143, 0.4), rgba(10, 17, 69, 0.4) 70%);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25), 0 2px 0 rgba(0, 0, 0, .3);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  /* Puzzles em paisagem: 2 colunas para caber na tela sem corte */
  #puzzle {
    padding: calc(4px + var(--safe-t)) calc(12px + var(--safe-r)) calc(4px + var(--safe-b)) calc(12px + var(--safe-l));
  }
  .pz-window {
    width: min(520px, 100% - 16px);
    margin: auto;
    padding: 8px 14px;
    display: grid;
    grid-template-columns: minmax(180px, 1.1fr) auto;
    grid-template-rows: auto auto auto auto auto;
    gap: 4px 16px;
    align-items: center;
    text-align: left;
  }
  #pz-title  { grid-column: 1; grid-row: 1; margin: 0; font-size: 10px; line-height: 1.2; }
  #pz-help   { grid-column: 1; grid-row: 2; margin: 0; font-size: 14px; line-height: 1.1; }
  #pz-timer  { grid-column: 1; grid-row: 3; height: 5px; }
  #pz-msg    { grid-column: 1; grid-row: 4; margin: 0; font-size: 14px; min-height: 1.1em; }
  #pz-cancel { grid-column: 1; grid-row: 5; justify-self: start; min-height: 44px; min-width: 100px; padding: 0 16px; font-size: 9px; }
  #pz-body   { grid-column: 2; grid-row: 1 / span 5; justify-self: center; align-self: center; gap: 6px; }

  .grid3 { grid-template-columns: repeat(3, 44px); gap: 4px; }
  .grid3 .node { width: 44px; height: 44px; }

  .seq-pad { grid-template-columns: repeat(2, 48px); gap: 6px; }
  .seq-pad .sq { width: 48px; height: 48px; font-size: 18px; }
  .seq-slots { gap: 4px; }
  .seq-slots i { width: 14px; height: 14px; }

  .bin-target { font-size: 8px; }
  .bin-target b { font-size: 18px; margin-top: 1px; }
  .bin-row { gap: 4px; }
  .bin-row .bit { width: 44px; min-height: 44px; padding: 2px 0; }
  .bit span { font-size: 14px; }
  .bit small { font-size: 11px; }
  .bin-current { font-size: 14px; }

  /* Ajustes da ficha e missões no mapa em paisagem */
  .win { padding: 8px 10px; }
  .win h3 { margin: 0 0 4px; font-size: 9px; }
  .status {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 4px 8px;
  }
  .status h3 { grid-column: 1 / -1; }
  .status img { width: 48px; height: 48px; }
  .status dl { font-size: 16px; gap: 1px 8px; }
  .stage-btn { margin-top: 4px; padding: 4px 8px; min-height: 44px; gap: 6px; }
  .stage-btn .name { font-size: 16px; line-height: 1.1; }
  .equip ul { font-size: 14px; gap: 4px; }

  /* Diálogo compacto: não cobre o herói. */
  #dialog { left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); bottom: calc(6px + var(--safe-b)); gap: 10px; padding: 8px 12px 14px; }
  #dlg-portrait { width: 52px; height: 52px; }
  #dlg-name { margin-bottom: 4px; font-size: 9px; }
  #dlg-text { font-size: 21px; }

  /* Menus cabem na altura curta sem rolar. */
  #screen { padding-top: calc(8px + var(--safe-t)); padding-bottom: calc(8px + var(--safe-b)); }
  .screen-inner { gap: 8px; }
  .emblem { width: 56px; }
  .logo { font-size: clamp(18px, 7vh, 30px); }
  .logo small { margin-top: 6px; }
  .tagline { font-size: 18px; }
  .menu { gap: 6px; }
  .menu button, .stage-btn { min-height: 44px; }
}

/* Com diálogo aberto o toque é do diálogo: esconde os botões para não aparecerem por cima dele. */
/* Oculta os controles virtuais sob menus, puzzles, dialogs ou card */
#app:has(#dialog:not([hidden])) #pad,
#app:has(#screen:not([hidden])) #pad,
#app:has(#puzzle:not([hidden])) #pad,
#app:has(#card:not([hidden])) #pad { visibility: hidden; }

/* Retrato em celular: o jogo é horizontal, então pede para girar (o jogo fica pausado). */
#rotate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b));
  text-align: center;
  color: var(--cyan);
  background: var(--ink);
}
#rotate strong { font: 14px/1.4 var(--font-display); color: var(--gold); font-weight: normal; }
#rotate p { margin: 0; font-size: 24px; color: var(--text); }
#rotate svg { animation: tilt 1.8s ease-in-out infinite; }
#rotate button { min-height: 48px; padding: 0 20px; font: 10px/1 var(--font-display); background: linear-gradient(180deg, var(--win-top), var(--win-bot)); border: 2px solid var(--win-border); border-radius: var(--radius); }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 820px) { #rotate { display: grid; } }

/* Desktop / fine pointer: keyboard play, no touch pad */
@media (hover: hover) and (pointer: fine) {
  #pad { display: none; }
  #app { justify-content: center; }
}

/* ---------- Motion ---------- */
@keyframes blink { to { visibility: hidden; } }
@keyframes pop { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 70% { transform: translateX(-50%) scale(1.08); opacity: 1; } 100% { transform: translateX(-50%) scale(1); } }
@keyframes card-in { from { transform: translate(-50%, -50%) scale(.85); opacity: 0; } }
@keyframes nudge { to { transform: translate(3px, -50%); } }
@keyframes tilt { 0%, 30% { transform: rotate(0); } 70%, 100% { transform: rotate(-90deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  #dialog.is-done .dlg-next { animation: none; }
}

/* Em telas de toque o atalho de teclado só ocupa espaço. */
@media (pointer: coarse) { .hint { display: none; } }

/* Arte HD: canvas e retratos sem pixelização forçada. */
#cv, #dlg-portrait, .status img { image-rendering: auto; }
#dlg-portrait, .status img { object-fit: cover; object-position: top; }

/* ---------- Legenda do teclado (só no computador; no celular os botões já dizem tudo) ---------- */
#keys {
  position: absolute;
  left: 50%;
  bottom: calc(var(--u) * 3);
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .3em 1.1em;
  width: max-content;
  max-width: 94%;
  padding: .35em .9em;
  border-radius: var(--radius);
  background: rgba(7, 9, 20, .72);
  color: var(--text);
  font: clamp(14px, calc(var(--u) * 6.5), 22px)/1.1 var(--font-body);
  pointer-events: none;
}
#keys span { white-space: nowrap; }
#keys small { color: var(--dim); font-size: 1em; }
#keys kbd {
  display: inline-block;
  min-width: 1.6em;
  margin-right: .25em;
  padding: .1em .35em;
  border: 1px solid var(--cyan);
  border-bottom-width: 3px;
  border-radius: 4px;
  color: var(--cyan);
  font: inherit;
  text-align: center;
}
@media (hover: none), (pointer: coarse) { #keys { display: none; } }

@media (orientation: landscape) and (max-height: 350px) {
  .emblem { width: 34px; }
  .logo { font-size: 18px; }
  .logo small { margin-top: 2px; font-size: 0.5em; }
  .tagline { font-size: 14px; }
  .screen-inner { gap: 4px; }
  .menu { gap: 4px; }
  .menu button { min-height: 40px; font-size: 10px; padding: 0 12px 0 28px; }
  .result { padding: 6px 10px; }
  .result h3 { margin-bottom: 4px; }
  .result dl { font-size: 16px; }
}

/* Crédito do autor: pequeno e apagado, no rodapé do título e do final */
.credit { margin: 0; font-size: 13px; letter-spacing: 0.04em; color: var(--dim); opacity: 0.7; }
.credit a { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }
.credit a:hover, .credit a:focus-visible { opacity: 1; color: var(--cyan, #3df0ff); }

/* Créditos no final do jogo */
.credits dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 15px; }
.credits dt { color: var(--dim); white-space: nowrap; }
.credits dd { margin: 0; }
.credits a { color: var(--cyan); text-decoration: none; border-bottom: 1px dotted currentColor; }
.credits .thanks { margin: 10px 0 0; text-align: center; color: var(--gold, #ffd23d); }
