/* Cortes de Wythoff: cores das três famílias de planos e componentes desta página. */
:root { --fa: var(--roxo); --fb: var(--laranja); --fc: var(--ax-y); }

.corte span:first-child { min-width: 92px; }
.corte input { width: 150px; }
.sw.fa { background: var(--fa); } .sw.fb { background: var(--fb); } .sw.fc { background: var(--fc); }
.legend .sw { width: 12px; height: 12px; border-radius: 2px; }

/* o toque é decidido em JS (touchstart): dentro do triângulo segura a página; fora, rola */
#mapa { width: 100%; height: auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#mapa .tri { fill: var(--stage); stroke: var(--rule); stroke-width: 1; }
#mapa .lado { stroke-width: 2.5; }
#mapa .canto { font: 500 11.5px var(--body); fill: var(--fg); }
#mapa .uni { fill: var(--panel); stroke: var(--muted); stroke-width: 1.5; cursor: pointer; }
#mapa .uni.achado { fill: var(--fg); stroke: var(--fg); }
#mapa .uni.atual { stroke: var(--roxo); stroke-width: 3; }
#mapa .p { fill: var(--roxo); stroke: var(--panel); stroke-width: 2; cursor: grab; }
#mapa .rot { font: 10.5px var(--mono); fill: var(--muted); pointer-events: none; }

.censo { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.censo div { display: flex; align-items: center; gap: 8px; }
.censo .sw { width: 12px; height: 12px; border-radius: 2px; flex: none; }
.censo .mono { margin-left: auto; }

.contagem { font-size: 12px; letter-spacing: 0; text-transform: none; margin-left: 6px; }
.colecao { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 6px; }
.carta {
  font: 500 11.5px var(--body); line-height: 1.25; text-align: left; color: var(--muted);
  background: transparent; border: 1px dashed var(--rule); border-radius: 4px; padding: 6px 7px; cursor: pointer;
  min-height: 46px; display: flex; flex-direction: column; justify-content: space-between; gap: 3px;
}
.carta .cfg { font: 10.5px var(--mono); }
.carta.achada { color: var(--fg); border-style: solid; background: var(--stage); }
.carta.atual { border-color: var(--roxo); box-shadow: inset 0 0 0 1px var(--roxo); }
.carta.trancada { border-style: solid; border-color: var(--warn); color: var(--warn); opacity: .85; }
.carta:focus-visible { outline: 2px solid var(--roxo); outline-offset: 2px; }

/* o texto da base tem altura reservada: a câmara de Wythoff abaixo não se move */
#licao { min-height: 4.6em; }
#leitura { min-height: 4.6em; }

/* Coluna única (celular, tablet em pé): o palco fica preso no topo e a câmara de Wythoff,
   o controle principal, vem logo abaixo dele; o resto rola por baixo do palco. */
@media (max-width: 960px) {
  .app { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .stage-col, .panel { display: contents; }
  .stage { order: 1; position: sticky; top: 0; z-index: 5; box-shadow: 0 6px 14px -10px rgba(0,0,0,.45); }
  .stage > svg { max-height: 46vh; }
  #sec-mapa { order: 2; } .transport { order: 3; } #sec-base { order: 4; }
  #sec-estado { order: 5; } .legend { order: 6; } #sec-colecao { order: 7; }
  .panel section { background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; }
  .panel section + section { border-top: 1px solid var(--rule); }
  #mapa { max-width: 420px; margin: 0 auto; }
}

/* celular: o mesmo formato do viewBox apertado (poliedros.js, enquadrar) */
@media (max-width: 640px) {
  /* só o círculo circunscrito ao sólido pega o dedo (decidido em JS); fora dele, a página rola */
  .stage > svg { aspect-ratio: 600 / 575; touch-action: manipulation; -webkit-user-select: none; -webkit-touch-callout: none; }
}
