:root {
  /* Academe */
  --academe: #8a2bdd;
  --academe-light: #b57cf0;
  --academe-dark: #5a1a96;
  --academe-ink: #181818;
  --academe-gray: #ececec;

  --bg1: #0c0618;
  --bg2: #2a0f52;
  --ink: var(--academe-gray);
  --muted: #9a8bb8;
  --line: #34205c;
  --panel: rgba(24, 12, 48, 0.8);
  --ok: #72d14b;
  --warn: #f7d038;
  --bad: #ff5a5f;
  --lvl: #72d14b;
  --lvl-dark: #2f9a45;
  --ui: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
  --title: "Pixelify Sans", system-ui, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 0%, var(--bg2), var(--bg1) 70%);
  color: var(--ink);
  font-family: var(--ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* ───────── fundo */
.sky { position: fixed; inset: 0; z-index: 0; }
#stars { width: 100%; height: 100%; display: block; }
.floor {
  position: fixed; left: -50%; right: -50%; bottom: -10vh; height: 55vh; z-index: 0;
  background-image:
    linear-gradient(rgba(138, 43, 221, 0.38) 2px, transparent 2px),
    linear-gradient(90deg, rgba(138, 43, 221, 0.38) 2px, transparent 2px);
  background-size: 64px 64px;
  transform: perspective(500px) rotateX(62deg);
  transform-origin: 50% 0;
  mask-image: linear-gradient(to bottom, transparent, #000 40%);
  animation: floor 6s linear infinite;
}
@keyframes floor { to { background-position: 0 64px; } }

.mute {
  position: fixed; right: 14px; bottom: 14px; z-index: 30;
  width: 38px; height: 38px; border: 2px solid var(--line); background: var(--panel); border-radius: var(--radius);
  font-size: 16px;
}
.mute.off { color: var(--muted); text-decoration: line-through; }

/* ───────── telas */
.screen {
  position: fixed; inset: 0; z-index: 2;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px;
}
.screen.active { display: flex; animation: screenIn .5s steps(6) both; }
#screen-menu, #screen-end { overflow-y: auto; justify-content: safe center; }
@keyframes screenIn { from { opacity: 0; transform: scale(1.04); } }

/* marca Academe */
.brand-word { height: 30px; width: auto; margin-bottom: 18px; opacity: .95; }
.brand-word.small { height: 22px; margin-bottom: 14px; }
.made-by { margin-top: 10px; display: flex; align-items: center; gap: 6px; font-size: 13px; color: #6f5f92; }
.made-by .mark { width: 14px; height: 14px; color: var(--academe-light); }
.hud-left { display: flex; align-items: center; gap: 10px; }
.hud-mark { width: 30px; height: 30px; flex: none; color: #fff; background: var(--academe); padding: 6px; border-radius: 8px; box-shadow: inset 0 -3px 0 var(--academe-dark); }

/* texto em bloco 3D estilo Minecraft */
.logo {
  margin: 0 0 6px; text-align: center; line-height: .95;
  font-family: var(--title); font-weight: 700; letter-spacing: 2px;
  font-size: clamp(40px, 9vw, 92px);
  color: #e9e4d8;
  text-shadow: 0 2px 0 #b9b3a3, 0 4px 0 #8f8a7c, 0 6px 0 #6b6759, 0 8px 0 #4a4740, 0 14px 18px rgba(0,0,0,.55);
  animation: logoFloat 4s ease-in-out infinite;
}
.logo span { display: block; }
.logo-ia {
  color: var(--academe-light) !important;
  text-shadow: 0 2px 0 #9a4fe6, 0 4px 0 var(--academe), 0 6px 0 #6c20b0, 0 8px 0 var(--academe-dark), 0 14px 18px rgba(0,0,0,.55) !important;
  font-size: 1.25em;
}
@keyframes logoFloat { 50% { transform: translateY(-6px) rotate(-1deg); } }
.tagline { font-size: 17px; color: var(--muted); margin: 10px 0 20px; text-align: center; max-width: 520px; line-height: 1.4; }

.panel {
  background: var(--panel); border: 2px solid var(--line);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.03), 0 8px 0 rgba(0,0,0,.35);
  padding: 18px; width: min(440px, 100%); border-radius: 14px;
  backdrop-filter: blur(6px);
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .08em; }
.field input {
  background: #0c0a1c; border: 2px solid var(--line); color: var(--ink); border-radius: 8px;
  font: 500 18px var(--ui); padding: 8px 12px; outline: none;
}
.field input:focus { border-color: var(--academe-light); }
.seg { display: flex; gap: 4px; }
.seg button {
  flex: 1; padding: 9px 0; background: #0c0a1c; border: 2px solid var(--line); border-radius: 8px;
  font-size: 15px; font-weight: 600; color: var(--muted);
}
.seg button.on { color: #fff; background: var(--academe); border-color: var(--academe); box-shadow: inset 0 -3px 0 var(--academe-dark); }

/* escolha de modo */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode {
  display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px;
  background: #0c0a1c; border: 2px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, background .15s, transform .08s;
}
.mode b { font-size: 17px; font-weight: 700; color: var(--ink); }
.mode small { font-size: 13px; line-height: 1.35; color: var(--muted); }
.mode:hover { border-color: var(--academe-light); }
.mode.on { border-color: var(--academe-light); background: rgba(138, 43, 221, .28); box-shadow: inset 0 -3px 0 var(--academe-dark); }
.mode.on small { color: #d9ccf2; }

.btn-play {
  width: 100%; margin-top: 4px; padding: 14px; border: 0; border-radius: var(--radius);
  background: var(--academe); color: #fff; font-size: 18px; font-weight: 800; letter-spacing: .04em;
  box-shadow: inset 0 -5px 0 var(--academe-dark), inset 0 3px 0 var(--academe-light);
  transition: transform .08s;
}
.btn-play:hover { filter: brightness(1.08); }
.btn-play:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 var(--academe-dark); }
.engine { margin-top: 12px; font-size: 13px; color: var(--muted); text-align: center; }
.engine b { color: var(--academe-light); font-weight: 600; }
.engine b.off { color: var(--warn); }
.link-rank { margin-top: 14px; font-size: 14px; color: var(--muted); text-decoration: none; }
.link-rank:hover { color: var(--ink); }

/* ───────── HUD */
#screen-game { justify-content: flex-start; padding-top: 12px; }
.hud {
  width: min(760px, 100%); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
}
.hud-label { font-size: 15px; font-weight: 700; }
.hud-sub { font-size: 12px; color: var(--muted); }
.hud-right { justify-self: end; text-align: right; }
.hud-score { display: flex; align-items: center; gap: 6px; justify-content: flex-end; font-size: 20px; font-weight: 800; }
.hud-score.bump { animation: bump .4s steps(4); }
@keyframes bump { 50% { transform: scale(1.35); color: var(--warn); } }
.hud-streak { font-size: 14px; color: var(--muted); }
.hud-streak.hot { color: var(--warn); }

.timer {
  position: relative; width: 220px; height: 14px; border: 2px solid var(--line); background: #0c0a1c; border-radius: 99px; overflow: visible;
}
.timer-fill {
  height: 100%; width: 100%; background: var(--ok); transform-origin: left; border-radius: 99px;
  background-image: repeating-linear-gradient(90deg, transparent 0 8px, rgba(0,0,0,.35) 8px 10px);
  transition: background-color .3s;
}
.timer.low .timer-fill { background-color: var(--bad); animation: blink .5s steps(2) infinite; }
.timer.mid .timer-fill { background-color: var(--warn); }
@keyframes blink { 50% { opacity: .55; } }
#timer-num { position: absolute; top: 16px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); }

/* ───────── palco + card 3D */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 16px; width: 100%; min-height: 0; overflow-y: auto; padding: 12px 0; }
.scene { --sh: 330px; position: relative; width: 250px; height: var(--sh); perspective: 900px; flex: none; transition: transform .35s ease, margin .35s ease; }
/* Na hora de mostrar a resposta certa, o card encolhe para dar espaço à explicação. */
.stage.reveal .scene:not(.ctx) { transform: scale(.5); margin: calc(var(--sh) * -0.25) 0; }
.card {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform .15s ease-out;
  --rx: 0deg; --ry: 0deg;
}
.card.idle { animation: cardFloat 4.5s ease-in-out infinite; }
@keyframes cardFloat {
  0%, 100% { transform: translateY(0) rotateX(var(--rx)) rotateY(var(--ry)); }
  50% { transform: translateY(-10px) rotateX(calc(var(--rx) + 3deg)) rotateY(calc(var(--ry) - 4deg)); }
}
.card.enter { animation: cardEnter 1s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes cardEnter {
  0% { transform: translateY(-120vh) rotateY(180deg) rotateZ(-25deg) scale(.6); }
  60% { transform: translateY(14px) rotateY(-12deg) rotateZ(2deg) scale(1.02); }
  100% { transform: translateY(0) rotateY(0) rotateZ(0) scale(1); }
}
/* Acerto: o card pula, gira e fica na tela com brilho verde, ao lado da resposta certa. */
.card.win { animation: cardWin .9s cubic-bezier(.3, 1.3, .5, 1) both; }
.card.win .card-front { box-shadow: 0 0 0 4px var(--ok), 0 18px 0 rgba(0,0,0,.35), 0 0 46px rgba(114, 209, 75, .55); }
@keyframes cardWin {
  0% { transform: none; }
  35% { transform: translateY(-26px) scale(1.06) rotateY(180deg); }
  100% { transform: none; }
}
.card.shake { animation: cardShake .5s steps(8) both; }
@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px) rotateZ(-3deg); }
  40% { transform: translateX(10px) rotateZ(2deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
.card.bad .card-front { box-shadow: 0 0 0 4px var(--bad), 0 18px 0 rgba(0,0,0,.35), 0 0 40px rgba(255,90,95,.45); }
.card.almost .card-front { box-shadow: 0 0 0 4px var(--warn), 0 18px 0 rgba(0,0,0,.35), 0 0 40px rgba(247,208,56,.35); }
.card.leave { animation: cardLeave .6s ease-in both; }
@keyframes cardLeave { to { transform: translateX(80vw) rotateY(-120deg) rotateZ(18deg); opacity: 0; } }

.card-face {
  position: absolute; inset: 0; backface-visibility: hidden; overflow: hidden;
  border: 4px solid #0c0a1c;
}
.card-front {
  display: flex; flex-direction: column; align-items: center; padding: 14px 14px 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.07), transparent 40%),
    repeating-linear-gradient(0deg, transparent 0 7px, rgba(255,255,255,.025) 7px 8px),
    #1f1238;
  box-shadow: 0 0 0 4px var(--lvl), inset 0 0 0 3px var(--lvl-dark), 0 18px 0 rgba(0,0,0,.35), 0 0 50px color-mix(in srgb, var(--lvl) 30%, transparent);
  transition: box-shadow .3s;
}
.card-back {
  transform: rotateY(180deg);
  background: var(--academe);
  box-shadow: 0 0 0 4px var(--lvl), inset 0 0 0 6px var(--academe-dark);
  display: grid; place-items: center;
}
.back-grid {
  position: absolute; inset: 0;
  background:
    linear-gradient(45deg, rgba(0,0,0,.18) 25%, transparent 25% 75%, rgba(0,0,0,.18) 75%),
    linear-gradient(45deg, rgba(0,0,0,.18) 25%, transparent 25% 75%, rgba(0,0,0,.18) 75%);
  background-size: 28px 28px; background-position: 0 0, 14px 14px;
}
.back-mark { position: relative; width: 46%; height: 46%; color: #fff; filter: drop-shadow(0 6px 0 rgba(0,0,0,.35)); }

.card-top { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.lvl-badge { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 6px; background: var(--lvl); color: #0c0a1c; box-shadow: inset 0 -2px 0 var(--lvl-dark); }
.card-num { font-size: 12px; font-weight: 600; color: var(--muted); }

.icon-wrap { position: relative; margin: 18px 0 8px; transform: translateZ(40px); }
.icon-wrap canvas { display: block; animation: iconBob 2.6s ease-in-out infinite; filter: drop-shadow(0 6px 0 rgba(0,0,0,.35)); }
@keyframes iconBob { 50% { transform: translateY(-8px) rotate(3deg); } }
.icon-shadow { width: 70%; height: 8px; margin: 10px auto 0; background: rgba(0,0,0,.35); animation: shadowBob 2.6s ease-in-out infinite; }
@keyframes shadowBob { 50% { transform: scaleX(.7); opacity: .6; } }

.term {
  margin-top: auto; text-align: center; font-family: var(--title); font-weight: 700; line-height: 1.02;
  font-size: 30px; color: #f4f1ea;
  text-shadow: 0 2px 0 #9e98ba, 0 4px 0 #5f5980, 0 6px 10px rgba(0,0,0,.6);
  transform: translateZ(30px);
  overflow-wrap: anywhere;
}
.term.long { font-size: 22px; }
.term.xlong { font-size: 18px; }
.term-en { margin-top: 6px; font-size: 15px; color: var(--muted); text-align: center; }
.card-foot { margin-top: 10px; font-size: 11px; font-weight: 700; color: var(--lvl); letter-spacing: .08em; text-align: center; }

/* card de situação (Modo Descobrir) */
.card-ask, .situation { display: none; }
.scene.ctx { --sh: 250px; width: min(560px, 100%); }
.scene.ctx .icon-wrap, .scene.ctx .term, .scene.ctx .term-en { display: none; }
.scene.ctx .card-front { align-items: stretch; padding: 16px 20px 14px; }
.scene.ctx .card-ask { display: block; margin-top: 10px; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--lvl); }
.scene.ctx .situation {
  display: flex; align-items: center; flex: 1; margin-top: 6px;
  font-size: 20px; line-height: 1.42; font-weight: 500; color: #f4f1ea;
}
.scene.ctx .situation.long { font-size: 17px; }
.scene.ctx .card-foot { text-align: left; }
.sheen {
  position: absolute; inset: -40%; pointer-events: none; mix-blend-mode: screen;
  background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.16) 48%, transparent 56%);
  transform: translateX(var(--sx, -30%));
  transition: transform .2s;
}

/* partículas */
.burst { position: absolute; left: 50%; top: 45%; width: 0; height: 0; pointer-events: none; z-index: 5; }
.burst i {
  position: absolute; width: 10px; height: 10px; left: -5px; top: -5px;
  box-shadow: inset -2px -2px 0 rgba(0,0,0,.3), inset 2px 2px 0 rgba(255,255,255,.35);
  animation: pop 0.9s cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes pop {
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.2); opacity: 0; }
}

/* ───────── campo de digitação */
.answer { position: relative; width: min(560px, 100%); flex: none; }
.prompt-line {
  min-height: 40px; padding: 6px 10px; font-size: 20px; line-height: 1.35;
  border-bottom: 2px solid var(--line); cursor: text; word-break: break-word; position: relative;
  transition: border-color .2s;
}
.answer.focus .prompt-line { border-color: var(--lvl); }
.answer.locked { opacity: .55; pointer-events: none; }
.caret-prefix { color: var(--lvl); margin-right: 8px; }
.typed .ch { display: inline; white-space: pre-wrap; }
.typed .ch.new { display: inline-block; white-space: pre; animation: chPop .22s steps(3) both; }
@keyframes chPop {
  0% { transform: translateY(-10px) scale(1.8); color: var(--lvl); text-shadow: 0 0 10px var(--lvl); }
  100% { transform: none; }
}
.cursor {
  display: inline-block; width: 3px; height: 22px; margin-left: 2px; vertical-align: -4px; border-radius: 2px;
  background: var(--lvl); animation: blink 1s steps(2) infinite;
}
.placeholder { position: absolute; left: 34px; top: 7px; color: #6a6390; pointer-events: none; font-size: 18px; }
.answer.has-text .placeholder { display: none; }
#input { position: absolute; opacity: 0; pointer-events: none; left: 0; top: 0; width: 1px; height: 1px; resize: none; }
.keys { margin-top: 8px; font-size: 12px; color: #6a6390; text-align: center; }
.keys b { color: var(--muted); font-weight: 600; }

.answer.thinking .prompt-line::after {
  content: "corrigindo…"; position: absolute; right: 0; bottom: -22px;
  font-size: 12px; font-weight: 600; color: var(--lvl);
  animation: blink 1s steps(2) infinite;
}

/* ───────── feedback: veredito → explicação → resposta certa; pontos pequenos */
.feedback {
  width: min(560px, 100%); flex: none; padding: 14px 18px 16px; background: rgba(20, 10, 40, .92);
  border: 2px solid var(--line); border-radius: 14px; backdrop-filter: blur(6px);
  animation: fbIn .3s ease-out both;
}
.feedback[hidden] { display: none; }
@keyframes fbIn { from { transform: translateY(8px); opacity: 0; } }
.feedback.ok { border-color: var(--ok); --tone: var(--ok); }
.feedback.mid { border-color: var(--warn); --tone: var(--warn); }
.feedback.bad { border-color: var(--bad); --tone: var(--bad); }
.fb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fb-status { font-size: 22px; font-weight: 800; color: var(--tone, var(--ink)); line-height: 1.2; }
.fb-points {
  flex: none; font-size: 13px; font-weight: 700; color: var(--warn); white-space: nowrap;
  background: rgba(247, 208, 56, .1); border: 1px solid rgba(247, 208, 56, .3); border-radius: 99px; padding: 3px 10px;
}
.fb-points.chances { color: var(--muted); background: rgba(255,255,255,.05); border-color: var(--line); }
.fb-points:empty, .fb-def:empty, .fb-choices:empty, .fb-text:empty { display: none; }
.fb-text { margin-top: 6px; font-size: 17px; line-height: 1.45; color: #ddd6ee; min-height: 1.45em; }
.fb-def {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--radius);
  background: rgba(255, 255, 255, .06); border-left: 4px solid var(--tone, var(--ok));
}
.fb-def-label { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--tone, var(--ok)); }
.fb-def-term { margin-top: 4px; font-size: 24px; font-weight: 800; color: #fff; line-height: 1.2; }
.fb-def-term small { font-size: 15px; font-weight: 500; color: var(--muted); }
.fb-def-text { margin-top: 4px; font-size: 18px; line-height: 1.45; font-weight: 500; color: #fff; }
.fb-ideas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.fb-ideas em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--muted); align-self: center; margin-right: 2px; }
.fb-ideas span { font-size: 13px; padding: 3px 9px; border-radius: 99px; background: rgba(255, 255, 255, .08); color: #ddd6ee; }
.fb-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.fb-choices button {
  padding: 12px 10px; border: 2px solid var(--line); border-radius: var(--radius); background: #0c0a1c;
  font-size: 16px; font-weight: 700; color: var(--ink);
}
.fb-choices button:hover { border-color: var(--warn); background: rgba(247, 208, 56, .08); }
.fb-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.fb-actions:empty { display: none; }
.fb-actions button {
  flex: 1; min-width: 120px; padding: 11px 10px; border: 2px solid var(--line); background: #0c0a1c; border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
}
.fb-actions button:hover { border-color: var(--ink); }
.fb-actions button.primary { background: var(--lvl); color: #0c0a1c; border-color: var(--lvl); font-weight: 800; box-shadow: inset 0 -3px 0 var(--lvl-dark); }
.fb-actions button[data-act=hint] { border-color: rgba(247, 208, 56, .55); color: var(--warn); }

/* ───────── hotbar */
.hotbar { display: flex; gap: 4px; padding: 4px; background: rgba(0,0,0,.45); border: 2px solid #0c0a1c; border-radius: 8px; margin: 6px 0 6px; flex: none; }
.slot {
  width: 40px; height: 40px; display: grid; place-items: center; position: relative;
  background: #8b8b8b22; border: 2px solid #3a3558; box-shadow: inset 2px 2px 0 rgba(0,0,0,.35);
}
.slot.current { border-color: var(--ink); }
.slot.filled { animation: slotIn .5s steps(5); }
@keyframes slotIn { 0% { transform: scale(1.8); background: var(--ok); } }
.slot .pts { position: absolute; right: 1px; bottom: -1px; font-size: 9px; font-weight: 800; color: #fff; text-shadow: 1px 1px 0 #000; }

/* pontos flutuantes */
.float-pts {
  position: fixed; z-index: 40; font-size: 24px; font-weight: 800; color: var(--warn);
  text-shadow: 0 3px 0 #7a5a00; pointer-events: none; animation: floatUp 1.3s ease-out forwards;
}
@keyframes floatUp { to { transform: translateY(-80px); opacity: 0; } }

/* ───────── fim */
.end-title { font-size: 22px; font-weight: 800; letter-spacing: .06em; margin: 0 0 18px; color: var(--muted); }
.end-score { font-family: var(--title); font-weight: 700; font-size: clamp(48px, 10vw, 80px); line-height: 1; color: var(--warn); text-shadow: 0 5px 0 #8a6a0a, 0 12px 18px rgba(0,0,0,.5); display: flex; flex-direction: column; align-items: center; }
.end-score small { font-family: var(--ui); font-size: 14px; font-weight: 600; color: var(--muted); text-shadow: none; margin-top: 8px; }
.end-stats { display: flex; gap: 22px; margin: 22px 0; font-size: 13px; color: var(--muted); flex-wrap: wrap; justify-content: center; text-align: center; }
.end-stats b { display: block; font-size: 22px; font-weight: 800; color: var(--ink); margin-bottom: 2px; }
.end-rank { width: min(420px, 100%); }
.rank-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; padding: 8px 4px; font-size: 16px; border-bottom: 1px dashed var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-row .pos { font-size: 14px; font-weight: 700; align-self: center; color: var(--muted); }
.rank-row.me { color: var(--ok); }
.rank-row .pts { font-size: 15px; font-weight: 800; align-self: center; }
.end-actions { width: min(360px, 100%); margin-top: 18px; display: flex; flex-direction: column; align-items: center; }

/* níveis */
[data-level="1"] { --lvl: #72d14b; --lvl-dark: #2f9a45; }
[data-level="2"] { --lvl: #4fd8e8; --lvl-dark: #1f8ea0; }
[data-level="3"] { --lvl: #f7d038; --lvl-dark: #b08a12; }
[data-level="4"] { --lvl: #a64df0; --lvl-dark: #5a1a96; }
[data-level="5"] { --lvl: #ff5a5f; --lvl-dark: #a32328; }

@media (max-height: 900px) {
  .logo { font-size: clamp(36px, 7vw, 64px); }
  .brand-word { height: 24px; margin-bottom: 10px; }
  .tagline { margin: 6px 0 14px; }
}
@media (max-height: 760px) {
  .scene { width: 210px; height: 280px; }
  .term { font-size: 25px; }
  .icon-wrap { margin: 10px 0 4px; }
}
@media (max-width: 520px) {
  .hud { grid-template-columns: 1fr 1fr; }
  .modes { grid-template-columns: 1fr; }
  .scene.ctx .situation { font-size: 17px; }
  .fb-choices button { padding: 10px 6px; font-size: 15px; }
  .timer { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .slot { width: 28px; height: 28px; }
  .keys { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .floor, .logo, .card.idle, .icon-wrap canvas, .icon-shadow { animation: none !important; }
}
.fb-choices .n {
  display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; border-radius: 6px;
  background: rgba(255, 255, 255, .1); font-size: 12px; color: var(--muted);
}

/* ───────── menu e formulários */
.panel.menu { display: flex; flex-direction: column; gap: 10px; }
.menu-btn {
  display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left; text-decoration: none; color: var(--ink);
  padding: 14px 16px; background: #0c0a1c; border: 2px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, transform .08s, background .15s;
}
.menu-btn b { font-size: 18px; font-weight: 700; }
.menu-btn small { font-size: 13px; line-height: 1.35; color: var(--muted); }
.menu-btn:hover { border-color: var(--academe-light); transform: translateY(-1px); }
.menu-btn.primary { background: var(--academe); border-color: var(--academe); box-shadow: inset 0 -4px 0 var(--academe-dark); }
.menu-btn.primary small { color: #e6d6fb; }
.menu-btn.danger:hover { border-color: var(--bad); }
.resume { display: flex; flex-direction: column; gap: 8px; }
.resume[hidden] { display: none; }
.resume-btn { border-color: var(--ok); background: rgba(114, 209, 75, .1); }
.resume-btn b { color: var(--ok); }
.menu-link { text-align: center; color: var(--muted); text-decoration: none; font-size: 15px; padding: 4px; }
.menu-link:hover { color: var(--ink); }
.back { align-self: flex-start; background: none; border: 0; color: var(--muted); font-size: 14px; padding: 0 0 10px; }
.back:hover { color: var(--ink); }
.back.center { align-self: center; padding: 14px 0 0; }
.panel-title { margin: 0 0 6px; font-size: 22px; font-weight: 800; }
.panel-sub { margin: 0 0 16px; font-size: 15px; line-height: 1.45; color: var(--muted); }
.panel-sub b { color: var(--ink); }
.center { text-align: center; }
.best { margin: -4px 0 12px; font-size: 14px; color: var(--muted); }
.best b { color: var(--warn); }
.hint-line { margin: -6px 0 12px; font-size: 13px; color: var(--muted); line-height: 1.4; }
.form-error { min-height: 0; margin-bottom: 10px; color: var(--bad); font-size: 14px; font-weight: 600; }
.form-error:empty { display: none; }
.field input.code-input { font-size: 30px; font-weight: 800; letter-spacing: .3em; text-transform: uppercase; text-align: center; }
#screen-solo, #screen-join, #screen-lobby, #screen-reveal { overflow-y: auto; justify-content: safe center; }
#screen-solo form, #screen-join form { display: flex; flex-direction: column; }
.link-btn { margin-top: 12px; background: none; border: 0; color: var(--muted); font-size: 15px; text-decoration: underline; }
.link-btn:hover { color: var(--ink); }

/* ───────── sala de espera */
.lobby { text-align: center; width: min(520px, 100%); }
.lobby-code { font-size: 15px; color: var(--muted); }
.lobby-code b { display: block; font-family: var(--title); font-size: 52px; letter-spacing: .12em; color: var(--ink); line-height: 1.1; }
.lobby-me { margin-bottom: 14px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chip { padding: 5px 12px; border-radius: 99px; background: rgba(138, 43, 221, .25); border: 1px solid var(--academe); font-size: 14px; font-weight: 600; }
.chip.away { opacity: .45; border-style: dashed; }

/* ───────── HUD: menu, vidas, progresso de nível */
.hud-menu {
  width: 36px; height: 36px; flex: none; border-radius: 8px; border: 2px solid var(--line); background: var(--panel);
  font-size: 18px; line-height: 1;
}
.hud-menu:hover { border-color: var(--ink); }
.hud-menu[hidden] { display: none; }
.hearts { letter-spacing: 1px; color: #ff5a6e; }
.progress { flex: none; margin: 4px 0 8px; min-height: 28px; display: flex; justify-content: center; }
.lvl-progress {
  display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 99px;
  background: rgba(0, 0, 0, .45); border: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.lvl-progress b { color: var(--lvl); font-weight: 800; font-size: 14px; }
.pips { display: flex; gap: 4px; }
.pips i { width: 12px; height: 12px; border-radius: 3px; background: rgba(255, 255, 255, .12); border: 1px solid var(--line); }
.pips i.on { background: var(--lvl); border-color: var(--lvl); box-shadow: 0 0 8px var(--lvl); }
.float-pts.level { color: var(--lvl, var(--ok)); font-size: 30px; }
.float-pts.life { color: #ff5a6e; }

/* ───────── revelação da sala */
.reveal-panel { width: min(600px, 100%); }
.reveal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.reveal-status { font-size: 26px; font-weight: 800; }
.reveal-status.ok { color: var(--ok); }
.reveal-status.bad { color: var(--warn); }
.rv-situation { font-size: 16px; line-height: 1.45; color: #ddd6ee; padding: 10px 12px; border-radius: var(--radius); background: rgba(0, 0, 0, .25); }
.rv-situation span { display: block; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.rv-situation:empty { display: none; }
.rv-rank { margin-top: 14px; }

/* ───────── fim */
.end-badge { margin: -8px 0 14px; font-size: 18px; font-weight: 700; color: var(--warn); min-height: 1em; }
.end-badge:empty { display: none; }

/* ───────── pausa */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(8, 4, 20, .72); backdrop-filter: blur(4px); }
.overlay[hidden] { display: none; }
.pause-panel { display: flex; flex-direction: column; gap: 10px; text-align: center; }
.pause-panel .menu-btn { text-align: left; }

/* sem conexão com a sala */
body.offline::after {
  content: "reconectando…"; position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60;
  padding: 6px 14px; border-radius: 99px; background: var(--warn); color: #0c0a1c; font-size: 13px; font-weight: 700;
}
.mode.wide { grid-column: 1 / -1; }
