/* Microgame Mayhem — página /play. Usa as fontes e os tokens de site.css; o jogo em si é desenhado no canvas. */

html:has(.mm-page) { height: 100%; overflow: hidden; }
.mm-page {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.mm { position: fixed; inset: 0; background: var(--bg); }

/* Área útil, respeitando o notch e as barras do sistema. */
.mm-stage {
  position: absolute;
  top: env(safe-area-inset-top, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px);
  left: env(safe-area-inset-left, 0px);
}
.mm-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
  cursor: default;
}
.mm[data-screen="game"] .mm-canvas { cursor: crosshair; }

/* ---------- botões do topo ---------- */

.mm-bar {
  position: absolute;
  z-index: 5;
  top: calc(env(safe-area-inset-top, 0px) + (var(--mm-top, 56px) - 40px) / 2);
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  display: flex;
  gap: 8px;
}
.mm-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid var(--line-2);
  border-radius: 10px;
  background: var(--ink, #0d0d0b);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  color: var(--text);
  cursor: pointer;
}
.mm-icon svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; }
.mm-icon:hover { border-color: var(--text); }
.mm-icon[hidden] { display: none; }
.mm-icon .mm-mute { display: none; }
.mm-icon[data-on="false"] .mm-mute { display: inline; }
.mm-icon[data-on="false"] .mm-wave { display: none; }
.mm-icon[data-on="false"] { color: var(--faint); }

/* ---------- telas ---------- */

.mm-screen {
  position: absolute;
  z-index: 4;
  top: env(safe-area-inset-top, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px);
  left: env(safe-area-inset-left, 0px);
  -webkit-user-select: text;
  user-select: text;
}
.mm-screen[hidden] { display: none; }

.mm-back {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-family: var(--mono);
  font-size: .8125rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: .5rem 0;
}
.mm-back::before {
  content: "";
  width: 1em;
  height: 1em;
  background: currentColor;
  -webkit-mask: var(--arrow) center / contain no-repeat;
  mask: var(--arrow) center / contain no-repeat;
  transform: rotate(180deg);
}
.mm-back:hover { color: var(--text); }

/* Tela inicial */
.mm-title {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 14px clamp(16px, 4vw, 40px) 18px;
  background: radial-gradient(ellipse at 50% 55%, color-mix(in srgb, var(--bg) 35%, transparent), color-mix(in srgb, var(--bg) 80%, transparent) 70%);
}
.mm-title .mm-back { justify-self: start; }
.mm-hero {
  align-self: center;
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: clamp(.9rem, 2.4vh, 1.6rem);
  text-align: center;
  max-width: 40rem;
}
.mm-kicker {
  margin: 0;
  font-family: var(--mono);
  font-size: .8125rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.mm-logo {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-stretch: 62%;
  text-transform: uppercase;
  line-height: .82;
  font-size: clamp(4rem, min(19vw, 17vh), 11rem);
  letter-spacing: -.01em;
  color: var(--text);
  -webkit-text-stroke: 0;
  text-shadow: .045em .055em 0 var(--accent);
}
.mm-logo span { display: block; }
.mm-logo span:last-child { color: var(--accent); text-shadow: .045em .055em 0 var(--text); transform: rotate(-3deg); }
.mm-logo i { font-style: normal; }
.mm-controls { margin: 0; color: var(--muted); font-size: .9375rem; }
/* crédito das vozes do SPEED UP */
.mm-credit { margin: 0; color: var(--muted); font-family: var(--mono); font-size: .8125rem; letter-spacing: .04em; }
.mm-credit strong { color: var(--text); font-weight: 700; }
.mm-credit a { color: var(--accent); text-underline-offset: .2em; }
.mm-credit a:hover, .mm-credit a:focus-visible { color: inherit; }
.mm-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .5rem 1.5rem;
}
.mm-note { margin: 0; color: var(--faint); font-family: var(--mono); font-size: .75rem; letter-spacing: .04em; }
.mm-noscript { text-align: center; color: var(--accent); }

/* Botões grandes de fliperama */
.mm-btn {
  font-family: var(--display);
  font-weight: 900;
  font-stretch: 70%;
  text-transform: uppercase;
  letter-spacing: .02em;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  line-height: 1;
  padding: .45em 1.6em .5em;
  border: 4px solid var(--bg);
  border-radius: 18px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.mm-btn--play {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--text), 7px 8px 0 3px var(--text);
}
.mm-btn--play:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 0 0 0 3px var(--text), 9px 10px 0 3px var(--text); }
.mm-btn--play:active:not(:disabled) { transform: translate(4px, 5px); box-shadow: 0 0 0 3px var(--text), 2px 2px 0 3px var(--text); }
.mm-btn:disabled { opacity: .6; cursor: progress; }
.mm-btn--ghost {
  font-size: 1rem;
  font-family: var(--sans);
  font-stretch: 100%;
  font-weight: 600;
  text-transform: none;
  padding: .8em 1.4em;
  background: transparent;
  color: var(--text);
  border: 2px solid var(--line-2);
}
.mm-btn--ghost:hover { border-color: var(--text); }
@media (prefers-reduced-motion: reduce) {
  .mm-btn { transition: none; }
}

/* Cartões de pausa e fim de jogo */
.mm-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  text-align: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}
.mm-h {
  margin: 0 0 .5rem;
  font-family: var(--display);
  font-weight: 900;
  font-stretch: 62%;
  text-transform: uppercase;
  font-size: clamp(3rem, 12vw, 6.5rem);
  line-height: .85;
  color: var(--text);
}
#mm-over .mm-h { color: var(--accent); }
.mm-label {
  display: block;
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.mm-score { margin: 0; }
.mm-score strong {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(2.5rem, 9vw, 4rem);
  line-height: 1.1;
  color: var(--text);
}
.mm-newbest {
  margin: 0;
  padding: .3rem .8rem;
  border-radius: 999px;
  background: var(--yellow, #ffc83d);
  color: var(--bg);
  font-weight: 800;
}
.mm-newbest[hidden] { display: none; }
.mm-stats { display: flex; gap: clamp(1rem, 5vw, 2.5rem); margin: .25rem 0; }
.mm-stats div { display: grid; gap: .2rem; }
.mm-stats dt { font-family: var(--mono); font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.mm-stats dd { margin: 0; font-family: var(--mono); font-size: 1.5rem; font-weight: 700; }
.mm-lostto { margin: 0 0 .5rem; color: var(--text); font-weight: 700; font-size: 1.125rem; }

@media (max-height: 520px) and (orientation: landscape) {
  .mm-logo { font-size: clamp(3rem, 15vh, 6rem); }
  .mm-hero { gap: .6rem; }
  .mm-card { gap: .5rem; }
  .mm-h { font-size: 3rem; }
}

/* Aviso e botão das métricas de jogo (só aparece com a telemetria ligada) */
.mm-metrics { margin: 0.4rem 0 0; font-size: 0.78rem; display: flex; flex-wrap: wrap; gap: 0.2rem 0.7rem; align-items: center; }
.mm-metrics-btn { font: inherit; color: inherit; background: none; border: 1px solid currentColor; border-radius: 999px; padding: 0.25rem 0.75rem; cursor: pointer; opacity: 0.85; }
.mm-metrics-btn:hover, .mm-metrics-btn:focus-visible { opacity: 1; }
.mm-metrics-btn[data-state="off"] { border-style: dashed; }
.mm-metrics-btn:disabled { cursor: default; opacity: 0.6; }
.mm-metrics a { color: inherit; opacity: 0.85; }

/* ---------- Game Over: frase do narrador e perfil de habilidades da partida ---------- */
/* Retrato: uma coluna (frase, placar, radar, botões). Paisagem: resultado à esquerda, radar à direita.
   O botão de jogar de novo fica sempre visível sem rolar; se a tela for pequena demais, o cartão rola. */
#mm-over {
  gap: .55rem;
  overflow-y: auto;
  justify-content: safe center;
  padding-block: 1rem;
}
.mm-over-main { display: contents; }
#mm-over .mm-h { margin: 0; font-size: clamp(2.5rem, 10vw, 5.5rem); }
#mm-over .mm-lostto { margin: 0; }
#mm-over .mm-skills { order: 1; }
#mm-over #mm-again, #mm-over .mm-back { order: 2; }
#mm-over #mm-again { margin-top: .35rem; }

.mm-quip {
  margin: 0 0 .2rem;
  max-width: 30ch;
  padding: .3em .55em .35em;
  border-radius: 10px;
  background: var(--yellow, #ffc83d);
  color: var(--bg);
  box-shadow: 4px 5px 0 var(--text);
  font-family: var(--display);
  font-weight: 900;
  font-stretch: 70%;
  text-transform: uppercase;
  font-size: clamp(1.1rem, 4.6vw, 1.85rem);
  line-height: 1.02;
  letter-spacing: .01em;
  text-wrap: balance;
  transform: rotate(-2deg);
  animation: mm-quip-in .55s cubic-bezier(.2, 1.6, .4, 1) .12s both;
}
.mm-quip[hidden] { display: none; }
@keyframes mm-quip-in {
  0% { opacity: 0; transform: scale(2.3) rotate(-9deg); }
  60% { opacity: 1; transform: scale(.94) rotate(1deg); }
  100% { opacity: 1; transform: scale(1) rotate(-2deg); }
}

.mm-skills { margin: 0; display: grid; justify-items: center; gap: .3rem; width: min(100%, 26rem); }
.mm-skills[hidden] { display: none; }
.mm-radar { width: 100%; display: grid; justify-items: center; }
.mm-radar[data-kind="none"] { display: none; }
.mm-radar-svg { display: block; width: min(100%, 22rem); height: auto; max-height: 29dvh; overflow: visible; }
.mm-radar-grid polygon, .mm-radar-grid line { fill: none; stroke: var(--line-2); stroke-width: 1; }
.mm-radar-shape { animation: mm-radar-in .5s cubic-bezier(.2, 1.4, .4, 1) .3s both; }
.mm-radar-shape polygon { fill: color-mix(in srgb, var(--accent) 32%, transparent); stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.mm-radar-shape circle { fill: var(--accent); stroke: var(--bg); stroke-width: 1.5; }
@keyframes mm-radar-in { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1) rotate(0); } }
.mm-radar-name { fill: var(--text); font-family: var(--display); font-weight: 800; font-stretch: 80%; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.mm-radar-val { fill: var(--muted); font-family: var(--mono); font-size: 11px; }

.mm-skill-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; width: min(100%, 21rem); }
.mm-skill-bars li { display: grid; grid-template-columns: 7rem 1fr 4.2rem; align-items: center; gap: .55rem; font-size: .8rem; }
.mm-skill-bar-name { text-align: right; font-weight: 700; }
.mm-skill-bar { height: .6rem; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.mm-skill-bar-fill { display: block; height: 100%; width: var(--v, 0%); border-radius: inherit; background: var(--accent); transform-origin: left; animation: mm-bar-in .5s ease-out .3s both; }
@keyframes mm-bar-in { from { transform: scaleX(0); } }
.mm-skill-bar-val { text-align: left; font-family: var(--mono); color: var(--muted); }

.mm-skill-sum { margin: 0; font-weight: 700; font-size: .95rem; }
.mm-skill-thin, .mm-skill-note { margin: 0; max-width: 36ch; color: var(--faint); font-family: var(--mono); font-size: .6875rem; line-height: 1.35; }

@media (orientation: landscape) and (min-width: 640px) {
  #mm-over { flex-direction: row; align-items: center; justify-content: safe center; gap: clamp(1rem, 4vw, 3.5rem); }
  .mm-over-main { display: flex; flex-direction: column; align-items: center; gap: .55rem; min-width: 0; flex: 0 1 30rem; }
  #mm-over .mm-skills { flex: 0 1 28rem; width: auto; }
  .mm-radar-svg { width: min(100%, 26rem); max-height: 58dvh; }
}
/* Telas baixas: tudo mais compacto para o botão de jogar de novo caber sem rolar. */
@media (orientation: portrait) and (max-height: 740px) {
  #mm-over { gap: .38rem; padding-block: .6rem; }
  #mm-over .mm-h { font-size: clamp(2.1rem, 9vw, 3rem); }
  .mm-quip { font-size: clamp(.95rem, 4.3vw, 1.25rem); }
  #mm-over .mm-score strong { font-size: 2.1rem; line-height: 1; }
  #mm-over .mm-newbest { font-size: .8rem; padding: .15rem .65rem; }
  #mm-over .mm-stats dd { font-size: 1.15rem; }
  #mm-over .mm-lostto { font-size: .95rem; }
  .mm-radar-svg { max-height: 23dvh; }
  .mm-radar-name { font-size: 17px; }
  .mm-radar-val { font-size: 15px; }
  .mm-skill-sum { font-size: .85rem; }
  .mm-skill-note { display: none; }
  #mm-over #mm-again { font-size: 1.6rem; margin-top: .15rem; }
}
@media (orientation: portrait) and (max-height: 600px) {
  #mm-over { gap: .3rem; padding-block: .4rem; }
  #mm-over .mm-h { font-size: 2rem; }
  #mm-over .mm-score .mm-label, #mm-over .mm-skills > .mm-label { display: none; }
  #mm-over .mm-score strong { font-size: 1.9rem; }
  #mm-over .mm-stats dd { font-size: 1.05rem; }
  .mm-radar-svg { max-height: 22dvh; }
  .mm-skill-sum { font-size: .8rem; }
  #mm-over #mm-again { font-size: 1.45rem; }
}
@media (orientation: portrait) and (max-width: 340px) {
  .mm-radar-name { font-size: 15px; }
  .mm-radar-val { font-size: 13px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #mm-over { padding-block: .35rem; }
  #mm-over, .mm-over-main { gap: .28rem; }
  #mm-over .mm-h { font-size: 2.1rem; }
  .mm-quip { font-size: .95rem; box-shadow: 3px 3px 0 var(--text); }
  #mm-over .mm-score strong { font-size: 2rem; line-height: 1; }
  #mm-over .mm-newbest { font-size: .75rem; padding: .1rem .6rem; }
  #mm-over .mm-stats dt { font-size: .6rem; }
  #mm-over .mm-stats dd { font-size: 1.1rem; }
  #mm-over .mm-lostto { font-size: .95rem; }
  #mm-over #mm-again { font-size: 1.4rem; margin-top: .1rem; }
  .mm-skill-note { display: none; }
  .mm-radar-svg { max-height: 72dvh; }
}
}
@media (prefers-reduced-motion: reduce) {
  .mm-quip, .mm-radar-shape, .mm-skill-bar-fill { animation: none; }
}
