/* ==========================================================
   MENU — mesa de plantão em pixel art
   Palco 100u × 50,6u (u = 1% da largura, limitado pela altura) logo
   abaixo do cabeçalho. A prancheta (#play-panel) e os objetos usam as
   mesmas unidades, então ficam sempre alinhados.
   Só aparece com body[data-cena="menu"]; no plantão volta o cenário.
   ========================================================== */
:root {
  --topo: 84px;
  --u: min(1vw, calc((100vh - var(--topo)) / 50.6));
}
@supports (height: 100dvh) {
  :root { --u: min(1vw, calc((100dvh - var(--topo)) / 50.6)); }
}

body:not([data-cena="menu"]) .menu-cena,
body:not([data-cena="menu"]) .menu-tabs { display: none; }
body[data-cena="menu"] .cenario { display: none; }

/* ---------- mesa e objetos ---------- */
.menu-cena { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background: #7fbfa4; }
.menu-cena::after {
  position: absolute; inset: 0; content: ""; pointer-events: none;
  background: radial-gradient(ellipse 85% 80% at 38% 52%, transparent 55%, rgba(0, 54, 54, .30));
}
.menu-mesa { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.menu-palco {
  position: absolute; top: var(--topo); left: 50%;
  width: calc(var(--u) * 100); height: calc(var(--u) * 50.6); transform: translateX(-50%);
}
.obj {
  --x: 0; --y: 0; --w: 10; --d: 4;
  position: absolute; left: calc(var(--x) * var(--u)); top: calc(var(--y) * var(--u)); width: calc(var(--w) * var(--u));
  translate: calc(var(--mx, 0) * var(--d) * -1.5px) calc(var(--my, 0) * var(--d) * -1.5px);
  pointer-events: auto; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.obj img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.corpo {
  position: relative;
  filter: drop-shadow(0 calc(var(--u) * .5) 0 rgba(0, 62, 60, .26)) drop-shadow(0 calc(var(--u) * 1) calc(var(--u) * .8) rgba(0, 50, 50, .22));
  transition: scale .16s, rotate .16s, filter .16s;
}
.obj:hover .corpo {
  scale: 1.045; rotate: -1.6deg;
  filter: brightness(1.07) drop-shadow(0 calc(var(--u) * .9) 0 rgba(0, 62, 60, .22)) drop-shadow(0 calc(var(--u) * 1.6) calc(var(--u) * 1.1) rgba(0, 50, 50, .26));
}
.corpo.balanca { animation: obj-balanca .55s ease-out; }
@keyframes obj-balanca { 0% { rotate: 0deg; } 22% { rotate: -7deg; } 55% { rotate: 5deg; } 80% { rotate: -2deg; } 100% { rotate: 0deg; } }

/* respiro suave de alguns objetos */
.o-planta .corpo, .o-caneta .corpo, .o-estetoscopio .corpo, .o-frasco .corpo, .o-postit .corpo { animation: obj-flutua 7s ease-in-out infinite; }
.o-caneta .corpo { animation-duration: 5.5s; animation-delay: -2s; }
.o-frasco .corpo { animation-duration: 6.2s; animation-delay: -3s; }
.o-postit .corpo { animation-duration: 8s; animation-delay: -4s; }
.o-estetoscopio .corpo { animation-duration: 9s; animation-delay: -1s; }
@keyframes obj-flutua { 50% { transform: translateY(calc(var(--u) * -.4)); } }
.corpo.balanca { animation: obj-balanca .55s ease-out; }

/* vapor da caneca */
.vapor { position: absolute; top: 14%; left: 34%; width: 7%; aspect-ratio: 1; background: rgba(255, 255, 255, .78); opacity: 0; animation: obj-vapor 3.4s ease-in infinite; pointer-events: none; }
.vapor.v2 { left: 48%; width: 6%; animation-delay: -1.1s; }
.vapor.v3 { left: 60%; width: 5%; animation-delay: -2.2s; }
@keyframes obj-vapor {
  0% { opacity: 0; transform: translate(0, 0); }
  25% { opacity: .75; transform: translate(60%, calc(var(--u) * -.9)); }
  60% { opacity: .45; transform: translate(-40%, calc(var(--u) * -2)); }
  100% { opacity: 0; transform: translate(40%, calc(var(--u) * -3.2)); }
}

/* monitor com ECG vivo */
.o-monitor .tela { position: absolute; left: 7.4%; top: 15.3%; width: 71.6%; height: 66.9%; }
.o-monitor .tela > img { position: absolute; inset: 0; width: 100%; height: 100%; }
.onda { position: absolute; inset: 10% 6% 10% 8%; overflow: hidden; }
.onda svg { position: absolute; left: 0; top: 0; width: 200%; height: 100%; overflow: visible; animation: obj-ecg 5.5s linear infinite; filter: drop-shadow(0 0 4px rgba(125, 255, 106, .75)); }
.onda path { fill: none; stroke: #8df46a; stroke-width: 3px; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
@keyframes obj-ecg { to { transform: translateX(-50%); } }
.o-monitor .led { position: absolute; left: 80.6%; top: 71.4%; width: 7.4%; height: 11.2%; border-radius: 12%; animation: obj-led 1.4s steps(2) infinite; pointer-events: none; }
@keyframes obj-led { 0% { box-shadow: 0 0 0 0 rgba(255, 120, 60, .0); } 50% { box-shadow: 0 0 calc(var(--u) * 1.2) calc(var(--u) * .35) rgba(255, 120, 60, .75); } }

/* leque de cartas: abre ao passar o mouse, inicia o plantão ao clicar */
.o-leque { aspect-ratio: 410 / 250; }
.o-leque .corpo { width: 100%; height: 100%; }
.o-leque img { position: absolute; transform-origin: 50% 100%; transition: transform .28s cubic-bezier(.34, 1.56, .64, 1); }
.o-leque .c-e { left: 0; top: 12%; width: 33.7%; transform: rotate(-12deg); }
.o-leque .c-d { left: 66.3%; top: 12%; width: 33.7%; transform: rotate(12deg); }
.o-leque .c-c { left: 32.9%; top: 0; width: 34.6%; z-index: 2; }
.o-leque:hover .c-e { transform: translate(-7%, 3%) rotate(-24deg); }
.o-leque:hover .c-d { transform: translate(7%, 3%) rotate(24deg); }
.o-leque:hover .c-c { transform: translateY(-9%) scale(1.04); }
.o-leque:hover .corpo { scale: 1; rotate: 0deg; }

/* ---------- cabeçalho do menu ---------- */
body[data-cena="menu"] .topbar { background: #043f3e; border-bottom: 4px solid #022f30; }
body[data-cena="menu"] .topbar-inner { min-height: calc(var(--topo) - 4px); }
body[data-cena="menu"] .brand, body[data-cena="menu"] .solo { display: none; }
.menu-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 0; }
body[data-cena="menu"] .menu-tabs [role="tab"] {
  min-height: 44px; padding: 12px 24px; border: 3px solid transparent; border-radius: 10px;
  background: #e8a63a; color: #12383a; text-shadow: none; font: 400 11px/1 var(--pixel);
  box-shadow: 0 4px 0 #0a2c2d;
}
body[data-cena="menu"] .menu-tabs [role="tab"]:hover { filter: brightness(1.08); }
body[data-cena="menu"] .menu-tabs [role="tab"][aria-selected="true"] { background: transparent; border-color: #f6ead0; color: #fff4dc; box-shadow: none; }
body[data-cena="menu"] .top-actions { gap: 0; }
body[data-cena="menu"] .top-actions .quiet { background: transparent; color: #fff4dc; text-shadow: none; box-shadow: none; font-size: 11px; }
body[data-cena="menu"] #open-help { order: 1; margin-right: 14px; padding-right: 22px; border-radius: 0; border-right: 2px solid rgba(255, 244, 220, .24); }
body[data-cena="menu"] #open-help span {
  display: inline-grid; place-items: center; width: 30px; height: 30px; margin-right: 10px;
  border-radius: 6px; background: #e4772e; color: #fff;
}
body[data-cena="menu"] #open-account { order: 2; border: 3px solid #f6ead0; border-radius: 10px; }
body[data-cena="menu"] .top-actions .quiet:hover { filter: brightness(1.15); }

/* ---------- a prancheta (painel de início) ---------- */
main#menu.wrap { width: calc(var(--u) * 100); min-height: calc(var(--u) * 50.6); position: relative; pointer-events: none; }
main#menu.wrap > * { pointer-events: auto; }
main#menu.wrap > .panel.clipboard { margin: 22px auto; max-width: min(860px, 94%); }
main#menu.wrap > .prancheta {
  position: absolute; left: calc(var(--u) * 12.26); top: calc(var(--u) * -.5); width: calc(var(--u) * 46.05);
  aspect-ratio: 1540 / 1694; container-type: inline-size;
  max-width: none; margin: 0; padding: 0; border: 0; background: none; box-shadow: none; text-align: left;
}
.prancheta > * { position: absolute; margin: 0; }
.prancheta-fundo {
  inset: 0; width: 100%; height: 100%; pointer-events: none; user-select: none;
  filter: drop-shadow(0 1.3cqw 0 rgba(0, 62, 60, .30)) drop-shadow(0 3.2cqw 3.4cqw rgba(0, 45, 45, .28));
}
.prancheta-logo { left: 18.2%; top: 13.2%; width: 63.6%; height: auto; image-rendering: auto; }
.prancheta-jogador { left: 20%; right: 20%; top: 48%; text-align: center; color: #12494a !important; font: 400 1.9cqw/1.4 var(--pixel); overflow-wrap: anywhere; }
.prancheta-sep { left: 19.5%; right: 19.5%; top: 50.4%; height: 3cqw; display: flex; align-items: center; gap: 2cqw; }
.prancheta-sep::before, .prancheta-sep::after { flex: 1; height: .55cqw; content: ""; background: #7fb8a8; }
.prancheta-sep span {
  width: 3cqw; height: 3cqw;
  background: linear-gradient(#c8432a, #c8432a) center / 100% 36% no-repeat, linear-gradient(#c8432a, #c8432a) center / 36% 100% no-repeat;
}
.prancheta-jogador:not([hidden]) ~ .prancheta-sep { display: none; }
.prancheta-iniciar {
  left: 16.2%; top: 55%; width: 67.5%; height: 11.9cqw; min-height: 0; padding: 0;
  border: .9cqw solid #0b4a49; border-radius: 2cqw;
  background: linear-gradient(#f2bb3d, #dc9c23 55%, #c68419);
  color: #fff8e3; font: 400 3.3cqw/1 var(--pixel); text-shadow: .45cqw .45cqw 0 rgba(96, 54, 0, .6);
  box-shadow: inset 0 .7cqw 0 rgba(255, 238, 178, .55), 0 1.1cqw 0 #08403f;
}
.prancheta-iniciar:not(:disabled):hover { transform: translateY(-.35cqw); filter: brightness(1.08); }
.prancheta-iniciar:active:not(:disabled) { transform: translateY(.8cqw); box-shadow: inset 0 .7cqw 0 rgba(255, 238, 178, .55), 0 .3cqw 0 #08403f; }
.prancheta-iniciar:disabled { filter: saturate(.55) brightness(.92); }
.prancheta-atalhos { left: 23.8%; top: 69.2%; width: 52.5%; display: grid; gap: 1.6cqw; }
.prancheta-botao {
  height: 6.75cqw; padding: 0; border: .7cqw solid #0b4a49; border-radius: 1.7cqw;
  background: #fdf1d8; color: #12494a; font: 400 2.3cqw/1 var(--pixel);
  box-shadow: 0 .6cqw 0 rgba(8, 64, 63, .28); transition: transform .1s, filter .15s, background .15s;
}
.prancheta-botao:hover { transform: translateY(-.25cqw); background: #fff8e8; }
.prancheta-botao:active { transform: translateY(.4cqw); box-shadow: 0 .15cqw 0 rgba(8, 64, 63, .28); }
.prancheta button:focus-visible { outline: .7cqw solid #0b4a49; outline-offset: .5cqw; }

/* ---------- telas estreitas: só a mesa e a prancheta ---------- */
@media (max-width: 820px) {
  .menu-palco { display: none; }
  body[data-cena="menu"] .topbar-inner { flex-wrap: wrap; justify-content: center; gap: 8px 12px; padding-block: 10px; }
  .menu-tabs { width: 100%; justify-content: center; gap: 8px; }
  body[data-cena="menu"] .menu-tabs [role="tab"] { flex: 1 1 0; min-height: 40px; padding: 10px 6px; font-size: 8px; }
  body[data-cena="menu"] .top-actions { flex-wrap: wrap; justify-content: center; }
  body[data-cena="menu"] .top-actions .quiet { font-size: 9px; padding: 8px 12px; min-height: 36px; }
  main#menu.wrap { width: 100%; min-height: 0; padding: 18px 12px 34px; pointer-events: auto; }
  main#menu.wrap > .prancheta { position: relative; left: auto; top: auto; width: min(94vw, 470px); margin: 0 auto; }
  main#menu.wrap > .panel.clipboard { margin: 6px auto; max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .corpo, .vapor, .onda svg, .o-monitor .led { animation: none !important; }
  .obj { translate: none; }
  .corpo, .o-leque img { transition: none; }
}
@media print { .menu-cena { display: none; } }

/* painéis das abas Prancheta e Sala de Revisão: opacos para ler por cima dos objetos */
main#menu.wrap > .panel.clipboard { background: linear-gradient(145deg, #1c5958, #0f4546); box-shadow: 0 8px 0 rgba(4, 45, 45, .4), 0 18px 40px rgba(0, 40, 40, .35); }
/* cabeçalho alinhado às bordas da mesa */
@media (min-width: 821px) {
  body[data-cena="menu"] .topbar-inner { width: min(calc(var(--u) * 97), calc(100% - 32px)); }
}

/* ==========================================================
   BARRA SUPERIOR DO PLANTÃO
   Moldura em três camadas (miolo esticado + pontas fixas) e botões
   em 9 fatias. Só vale fora do menu (no menu o cabeçalho é a barra escura).
   ========================================================== */
body:not([data-cena="menu"]) .topbar { background: none; border: 0; padding: 12px 0 2px; }
body:not([data-cena="menu"]) .topbar-inner { position: relative; isolation: isolate; min-height: 92px; padding-inline: 78px; gap: 14px; }
body:not([data-cena="menu"]) .topbar-inner::before {
  position: absolute; inset: 0; z-index: -1; content: ""; pointer-events: none; image-rendering: pixelated;
  background:
    url(menu/barra-esq.png) left center / auto 100% no-repeat,
    url(menu/barra-dir.png) right center / auto 100% no-repeat,
    url(menu/barra-vazia.png) center / 100% 100% no-repeat;
  filter: drop-shadow(0 4px 0 rgba(0, 45, 45, .38));
}
.brand-icone { width: auto; height: 58px; }
.brand h1 { font-size: 0; line-height: 0; }
.brand .brand-nome { width: auto; height: 46px; animation: none; filter: none; }
.circuito { flex: 1 1 60px; min-width: 0; height: 60px; align-self: flex-start; margin-top: 8px; overflow: visible; }
.circuito path { fill: none; stroke: #f0a229; stroke-width: 3px; vector-effect: non-scaling-stroke; stroke-linejoin: miter; filter: drop-shadow(0 0 3px rgba(240, 162, 41, .45)); }
.circuito .pontos { stroke-width: 6px; }
body[data-cena="menu"] .circuito { display: none; }

body:not([data-cena="menu"]) .solo {
  padding: 11px 16px; border: 3px solid #2f8173; border-radius: 12px; background: #0a3f3d; color: #e7fff6;
  box-shadow: inset 0 0 0 2px #072f2f, 0 3px 0 rgba(0, 40, 40, .4); font-size: 10px; text-shadow: none; white-space: nowrap;
}
.solo span { width: 10px; height: 10px; background: #7dff5a; box-shadow: 0 0 7px #7dff5a; }
body:not([data-cena="menu"]) .top-actions { flex-wrap: nowrap; gap: 12px; }
body:not([data-cena="menu"]) .top-actions .quiet {
  --pele: url(menu/botao-ouro.png);
  min-height: 46px; padding: 0 10px; border: solid transparent; border-width: 10px 12px 15px; border-radius: 0;
  border-image: var(--pele) 16 20 24 20 fill / 10px 12px 15px 12px stretch; image-rendering: pixelated;
  background: none; box-shadow: none; color: #12383a; text-shadow: none; font: 400 10px/1 var(--pixel); white-space: nowrap;
}
body:not([data-cena="menu"]) #open-help { --pele: url(menu/botao-contorno.png); color: #fff4dc; }
body:not([data-cena="menu"]) #end-shift { --pele: url(menu/botao-vermelho.png); color: #fff4dc; text-shadow: 2px 2px 0 rgba(90, 20, 10, .5); }
body:not([data-cena="menu"]) .top-actions .quiet:not(:disabled):hover { filter: brightness(1.12); }
body:not([data-cena="menu"]) .top-actions .quiet:active { transform: translateY(3px); box-shadow: none; }
body:not([data-cena="menu"]) #open-help span {
  display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 8px; border-radius: 4px; background: #f6ead0; color: #12383a;
}
@media (max-width: 1000px) { .circuito { display: none; } }
@media (max-width: 820px) {
  body:not([data-cena="menu"]) .topbar-inner { min-height: 0; padding: 12px 56px; flex-wrap: wrap; justify-content: center; }
  .brand-icone { height: 42px; }
  .brand .brand-nome { height: 32px; }
  body:not([data-cena="menu"]) .top-actions { flex-wrap: wrap; justify-content: center; gap: 8px; }
  body:not([data-cena="menu"]) .top-actions .quiet { min-height: 38px; font-size: 8px; border-width: 8px 10px 12px; }
}
@media (prefers-reduced-motion: reduce) { .solo span { animation: none; } }
