:root {
  --pergaminho: #F2E8D5;
  --marino: #1B2A4A;
  --dourado: #D4A24C;
  --laranja: #E8722C;
  --verde: #4CAF6D;
  --vinho: #8B2E2E;
}

body.app-body {
  background:
    radial-gradient(ellipse at 50% 0%, #2a3d66 0%, #0f1a30 55%),
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,.15) 3px, rgba(0,0,0,.15) 6px);
  background-attachment: fixed;
  color: var(--marino);
  min-height: 100vh;
  font-family: "Pixelify Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 1.05rem;
  line-height: 1.55;
}

/* Shell GM: tipografia limpa (sem pixel) + espaço para hotbar */
body.gm-shell {
  --gm-font: "Nunito", "Segoe UI", system-ui, sans-serif;
  --gm-hotbar-h: 5.75rem;
  font-family: var(--gm-font);
  font-size: 1.12rem;
  padding-bottom: calc(var(--gm-hotbar-h) + env(safe-area-inset-bottom, 0px));
  overflow-x: clip;
}
body.gm-shell .pixel-font,
body.gm-shell .brand-title,
body.gm-shell .btn-game,
body.gm-shell .gm-brand,
body.gm-shell .gm-hot-label {
  font-family: var(--gm-font) !important;
  letter-spacing: normal;
  line-height: 1.3;
}
body.gm-shell .text-muted { color: #4a5568 !important; }
body.gm-shell .small { font-size: .95rem; }
body.gm-shell .form-label { font-weight: 700; color: var(--marino); }
body.gm-shell .form-control,
body.gm-shell .form-select {
  font-family: var(--gm-font);
  font-size: 1.05rem;
  min-height: 2.75rem;
  padding: .55rem .75rem;
}
body.gm-shell .table { font-size: 1.02rem; }
body.gm-shell .brand-title {
  font-size: clamp(1.15rem, 2.6vw, 1.45rem);
  font-weight: 800;
}
body.gm-shell .btn-game {
  font-size: .95rem;
  font-weight: 800;
  letter-spacing: .01em;
  text-transform: none;
}

body.pixel-rpg .pixel-font,
body.pixel-rpg .brand-title,
body.pixel-rpg .hud-bar strong {
  font-family: "Press Start 2P", monospace;
  letter-spacing: 0;
  line-height: 1.5;
}

.brand-title {
  font-weight: 800;
  color: var(--marino);
  line-height: 1.35;
  text-wrap: balance;
  font-size: clamp(0.75rem, 2.2vw, 1.1rem);
}

code, .codigo-destaque {
  color: var(--marino) !important;
  background: rgba(27, 42, 74, .08);
  padding: .1rem .35rem;
  border-radius: 0;
  font-weight: 700;
  white-space: nowrap;
}

.demo-hint { line-height: 1.45; }
.demo-hint .codigo-destaque {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .95em;
}

.lead-flavor { color: #4a5568; font-size: 1.05rem; }

/* —— Telas de entrada (home + login) centradas —— */
body.auth-gate {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body.auth-gate .auth-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 32rem;
  margin-left: auto;
  margin-right: auto;
  padding: 1.25rem .9rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}
body.auth-gate .auth-flash {
  width: 100%;
  margin-bottom: .85rem;
}

.auth-card {
  width: 100%;
  max-width: 26rem;
  margin: 0 auto;
  padding: 1.75rem 1.35rem 1.5rem;
  text-align: center;
}
.auth-back {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  align-self: flex-start;
  margin: 0 0 .85rem;
  font-size: .92rem;
  font-weight: 700;
  color: var(--marino);
  text-decoration: none;
  opacity: .75;
}
.auth-back:hover { opacity: 1; color: var(--laranja); }
.auth-card .auth-back { display: flex; }

.auth-kicker {
  margin: 0 0 .35rem;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #6a7385;
}
.auth-brand {
  margin: 0 0 .65rem;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(.92rem, 3.6vw, 1.2rem);
  font-weight: 400;
  line-height: 1.45;
  color: var(--marino);
  text-wrap: balance;
}
.auth-brand-sm {
  font-size: clamp(.78rem, 3vw, .95rem);
  margin-bottom: .4rem;
  line-height: 1.5;
}
.auth-lead {
  margin: 0 0 1.35rem;
  font-size: 1.02rem;
  line-height: 1.4;
  color: #4a5568;
}
.auth-actions {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  width: 100%;
}
.auth-actions-row {
  flex-direction: row;
  flex-wrap: wrap;
}
.auth-actions-row .auth-btn { flex: 1 1 8rem; }
.auth-btn {
  width: 100%;
  min-height: 3.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-size: 1.02rem;
  font-weight: 800;
}
.auth-foot {
  margin: 1.25rem 0 0;
  font-size: .9rem;
  color: #6a7385;
  line-height: 1.35;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-bottom: 1.15rem;
}
.auth-tabs .btn {
  min-height: 2.75rem;
  font-weight: 800;
  border-radius: 0;
}

.auth-form {
  text-align: left;
  display: grid;
  gap: .9rem;
}
.auth-field { margin: 0; }
.auth-field .form-label {
  margin-bottom: .35rem;
  font-weight: 700;
  color: var(--marino);
}
.auth-form .auth-btn { margin-top: .15rem; }
.auth-qr-hint {
  margin: 0 0 .75rem;
  font-size: .98rem;
  color: #4a5568;
  line-height: 1.4;
}

@media (min-width: 480px) {
  .auth-card { padding: 2rem 1.75rem 1.65rem; }
}

.hud-bar {
  background: var(--marino);
  color: #fff;
  border-bottom: 4px solid var(--dourado);
}

.hud-bar a { color: #fff; text-decoration: none; opacity: .9; transition: color .15s, transform .15s; }
.hud-bar a:hover, .hud-bar a.active { opacity: 1; color: var(--dourado); transform: translateY(-1px); }

/* —— GM top brand + hotbar inferior (estilo aluno) —— */
.gm-topbar {
  background: var(--marino);
  color: #fff;
  border-bottom: 4px solid var(--dourado);
  padding: .55rem 0;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.gm-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-width: 0;
}
.gm-brand {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: clamp(.95rem, 2vw, 1.1rem);
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  min-width: 0;
}
.gm-brand:hover { color: var(--dourado); }
.gm-brand-short { display: none; }
.gm-topbar-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-shrink: 0;
}
.gm-user-label {
  font-size: .95rem;
  opacity: .85;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gm-sair,
.gm-top-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: .95rem;
  min-height: 2.5rem;
  padding: .35rem .65rem;
  border: 2px solid rgba(255,255,255,.35);
}
.gm-sair:hover,
.gm-top-link:hover { color: var(--dourado); border-color: var(--dourado); }

.gm-main {
  padding-top: 1rem;
  padding-bottom: calc(var(--gm-hotbar-h) + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  max-width: 100%;
}

/* Hub com pista: preenche o vão entre topbar e hotbar */
body.gm-shell:has(.gm-race) {
  height: 100dvh;
  overflow: hidden;
}
body.gm-shell:has(.gm-race) .gm-main {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 3.45rem);
  max-height: calc(100dvh - 3.45rem);
  padding-top: .55rem;
  overflow: hidden;
}

.gm-hotbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1040;
  background: linear-gradient(180deg, #16233f 0%, #0f1a30 100%);
  border-top: 4px solid var(--dourado);
  box-shadow: 0 -6px 0 rgba(10, 16, 32, .35);
  padding: .45rem .4rem calc(.45rem + env(safe-area-inset-bottom, 0px));
}
.gm-hotbar-track {
  display: flex;
  gap: .35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 .15rem;
  overscroll-behavior-x: contain;
}
.gm-hotbar-track::-webkit-scrollbar { display: none; }

.gm-hot-btn {
  flex: 1 0 auto;
  min-width: 4.6rem;
  max-width: 6.5rem;
  min-height: 4.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  padding: .4rem .3rem;
  text-decoration: none;
  color: #d8e0ee;
  background: #1b2a4a;
  border: 3px solid #2a3d66;
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, border-color .12s ease, color .12s ease, background .12s ease;
}
.gm-hot-btn i {
  font-size: 1.45rem;
  line-height: 1;
}
.gm-hot-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}
.gm-hot-btn:hover {
  color: #fff;
  border-color: var(--dourado);
  transform: translateY(-2px);
}
.gm-hot-btn.is-active {
  color: #1b2a4a;
  background: var(--dourado);
  border-color: #f0d08a;
  box-shadow: inset 0 0 0 2px rgba(27, 42, 74, .25);
}
.gm-hot-btn.is-active:hover { color: #1b2a4a; }

@media (min-width: 768px) {
  .gm-hot-btn {
    min-width: 5.4rem;
    min-height: 4.85rem;
    max-width: 7.2rem;
  }
  .gm-hot-btn i { font-size: 1.65rem; }
  .gm-hot-label { font-size: .78rem; }
}

.panel-game {
  background: var(--pergaminho);
  border: 4px solid var(--marino);
  border-radius: 0;
  box-shadow: 0 0 0 4px var(--dourado), 8px 8px 0 rgba(10,16,32,.45);
  transition: transform .15s ease, box-shadow .15s ease;
  color: #1a2438;
}
body.gm-shell .panel-game p,
body.gm-shell .panel-game li {
  font-size: 1.05rem;
  line-height: 1.55;
}
a.panel-game:hover {
  transform: translate(-2px, -2px);
  box-shadow: 0 0 0 4px var(--dourado), 12px 12px 0 rgba(10,16,32,.45);
}

.btn-game {
  background: var(--laranja);
  border-color: var(--marino);
  color: #fff;
  font-weight: 700;
  border-width: 3px;
  border-radius: 0;
  font-family: "Press Start 2P", monospace;
  font-size: .65rem;
  transition: transform .1s ease;
}
.btn-game:hover { background: #d45f1a; color: #fff; transform: scale(1.03); }
.btn-game:active { transform: scale(.96); }
.btn-marino { background: var(--marino); color: #fff; border: 3px solid var(--marino); border-radius: 0; }
.btn-marino:hover { background: #0f1a30; color: #fff; }
.btn-verde { background: var(--verde); color: #fff; border: 3px solid var(--marino); border-radius: 0; }
.btn-vinho { background: var(--vinho); color: #fff; border: 3px solid var(--marino); border-radius: 0; }

.alert { border-radius: 0; border-width: 3px; animation: pixelFlash .45s ease; }
@keyframes pixelFlash {
  0% { transform: scale(.98); opacity: .6; }
  100% { transform: scale(1); opacity: 1; }
}

.form-control, .form-select {
  border-radius: 0;
  border-width: 3px;
  border-color: var(--marino);
}

.qr-box img, .qr-box canvas, .qr-box table {
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
}

.qr-reader-box {
  width: 100%;
  min-height: 220px;
  border: 3px solid var(--marino);
  background: #0a1224;
  overflow: hidden;
}
.qr-reader-box video { width: 100% !important; }
.gm-profile-qr {
  background: #fff;
  border: 3px solid var(--marino);
  padding: .75rem;
}

.aluno-qr-card .text-break,
.aluno-qr-card a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.xp-bar { height: 1rem; background: #d9cbb3; border: 3px solid var(--marino); border-radius: 0; overflow: hidden; }
.xp-bar > span { display: block; height: 100%; background: var(--dourado); transition: width .6s ease; }
.xp-bar.fidelidade > span { background: var(--verde); }
.xp-bar.missao > span { background: var(--laranja); }

.avatar-pc {
  --pc-color: var(--marino);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--pc-color);
  background: #fff;
  color: var(--pc-color);
  border-radius: 0;
  box-shadow: inset 0 0 0 3px #fff, 0 0 0 2px var(--dourado);
  flex-shrink: 0;
}
.avatar-pc.avatar-sm { width: 2.5rem; height: 2.5rem; font-size: 1.1rem; }
.avatar-pc.avatar-md { width: 4rem; height: 4rem; font-size: 1.65rem; }
.avatar-pc.avatar-lg { width: 5.5rem; height: 5.5rem; font-size: 2.4rem; }
.avatar-pc.avatar-xl { width: 7rem; height: 7rem; font-size: 3rem; }
.avatar-empty { opacity: .55; }

/*
 * Spritesheet real (4 frames × 48px, ~6fps) — igual Phaser.
 * Usa px (não %) para o background-position; % fazia efeito de carrossel.
 */
.avatar-pc.avatar-sprite {
  --frame: 48px;
  --sheet: calc(var(--frame) * 4);
  display: inline-block;
  width: var(--frame);
  height: var(--frame);
  background-color: #eef2f8;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: var(--sheet) var(--frame);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  animation: avatar-idle .666s steps(4) infinite;
  overflow: hidden;
}
.avatar-pc.avatar-sprite.avatar-sm { --frame: 40px; width: 40px; height: 40px; }
.avatar-pc.avatar-sprite.avatar-md { --frame: 64px; width: 64px; height: 64px; }
.avatar-pc.avatar-sprite.avatar-lg { --frame: 88px; width: 88px; height: 88px; }
.avatar-pc.avatar-sprite.avatar-xl { --frame: 112px; width: 112px; height: 112px; }

@keyframes avatar-idle {
  from { background-position: 0 0; }
  to { background-position: calc(var(--sheet) * -1) 0; }
}
@media (prefers-reduced-motion: reduce) {
  .avatar-pc.avatar-sprite { animation: none; }
}

.card-personagem {
  cursor: pointer;
  border: 3px solid var(--marino);
  border-radius: 0;
  transition: transform .15s ease, box-shadow .15s ease;
  background: #fff;
}
.card-personagem:hover { transform: translateY(-2px); }
.card-personagem.selected {
  border-color: var(--dourado);
  box-shadow: 0 0 0 3px rgba(212,162,76,.45);
}
.card-personagem.ocupado {
  opacity: .38;
  border-style: dashed;
  filter: grayscale(0.55);
}
.card-personagem.ocupado .avatar-sprite {
  animation-play-state: paused;
}

.licao-chip {
  border: 3px solid var(--marino);
  border-radius: 0;
  min-width: 2.5rem;
  text-align: center;
  font-weight: 700;
  padding: .35rem .4rem;
  background: #fff;
}
.licao-chip.done { background: var(--verde); color: #fff; }
.licao-chip.miss { background: #ccc; }

/* Presença: grade táctil (2×2 móvel / 4 colunas desktop) */
.presenca-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
}
.presenca-btns .btn {
  min-height: 2.85rem;
  font-size: .82rem;
  font-weight: 700;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .45rem .35rem;
  margin: 0;
  width: 100%;
}
@media (min-width: 576px) {
  .presenca-btns { grid-template-columns: repeat(4, 1fr); }
  .presenca-btns .btn { font-size: .8rem; }
}

.gm-aluno-head {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  min-width: 0;
}
.gm-aluno-head-text {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .5rem;
  min-width: 0;
}
.gm-aluno-head-text strong {
  word-break: break-word;
}

.gm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.gm-actions > .btn,
.gm-actions > form {
  flex: 1 1 auto;
  min-width: min(100%, 10rem);
}
.gm-actions > form .btn { width: 100%; }

.gm-sticky-save {
  position: sticky;
  bottom: .5rem;
  z-index: 20;
  box-shadow: 0 0 0 3px var(--pergaminho), 0 8px 18px rgba(10, 16, 32, .28);
}

.attr-bar { height: .85rem; background: #e5d8c4; border: 2px solid var(--marino); border-radius: 0; overflow: hidden; }
.attr-bar > span { display: block; height: 100%; background: var(--marino); }

.star-diff { color: var(--dourado); }
.badge-lendaria { background: var(--vinho); }

.nivel-trilha { display: grid; gap: .65rem; }
.nivel-passo {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: .65rem .75rem;
  border: 3px solid #cfc3ae;
  background: #fff;
}
.nivel-passo.alcancado { border-color: var(--verde); }
.nivel-passo.atual {
  border-color: var(--dourado);
  box-shadow: 0 0 0 3px rgba(212,162,76,.28);
}
.nivel-passo.pendente { opacity: .72; }
.nivel-icone {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #ebe2d3;
  color: var(--marino);
  font-weight: 700;
}
.nivel-passo.alcancado .nivel-icone { background: var(--verde); color: #fff; }
.nivel-passo.atual .nivel-icone { background: var(--dourado); color: #fff; }

.lista-comparativo { display: grid; gap: .5rem; }
.comparativo-row {
  display: grid;
  grid-template-columns: 2.2rem 2.5rem 1fr auto;
  gap: .55rem;
  align-items: center;
  padding: .55rem .65rem;
  border: 3px solid #d9cdba;
  background: #fff;
}
.comparativo-row.sou-eu {
  border-color: var(--dourado);
  background: #fff8ea;
  animation: youPulse 1.4s ease-in-out infinite;
}
@keyframes youPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,162,76,.35); }
  50% { box-shadow: 0 0 0 4px rgba(212,162,76,.15); }
}
.comparativo-rank { font-weight: 800; color: var(--marino); text-align: center; }
.comparativo-xp { white-space: nowrap; text-align: right; }

@media (max-width: 576px) {
  .comparativo-row { grid-template-columns: 1.8rem 2.25rem 1fr; }
  .comparativo-xp { grid-column: 2 / -1; text-align: left; }
}

/* Ranking projetável — resumo + lista igual para todos (sem pódio) */
.gm-rank-board {
  display: grid;
  gap: 1rem;
}
.gm-rank-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.25rem 1.35rem;
  align-items: flex-end;
}
.gm-rank-hero-copy {
  flex: 1 1 16rem;
  max-width: 40rem;
}
.gm-rank-hero-copy p {
  font-size: 1.05rem;
}
.gm-rank-summary {
  display: flex;
  gap: .65rem;
  flex-wrap: wrap;
}
.gm-rank-stat {
  min-width: 5.75rem;
  padding: .75rem .9rem;
  background: #fff;
  border: 3px solid var(--marino);
  text-align: center;
}
.gm-rank-stat-val {
  display: block;
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--marino);
  line-height: 1.1;
}
.gm-rank-stat-lab {
  display: block;
  font-size: .82rem;
  color: #5a6578;
  font-weight: 700;
  margin-top: .15rem;
}

.gm-rank-panel { padding: 1.15rem 1.2rem 1.35rem; }

.gm-nivel-pill {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  font-size: .82rem;
  font-weight: 800;
  border: 2px solid #cfc3ae;
  background: #fff;
  color: var(--marino);
  white-space: nowrap;
}
.gm-nivel-pill.tone-prata { border-color: #8aa0b8; background: #eef3f8; }
.gm-nivel-pill.tone-bronze { border-color: #c4843a; background: #fff1e4; }
.gm-nivel-pill.tone-ouro { border-color: #d4a24c; background: #fff4d4; }
.gm-nivel-pill.tone-base { border-color: #9aa8bc; background: #eef2f8; }

.gm-rank-list {
  display: grid;
  gap: .7rem;
}
.gm-rank-item {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1.2fr);
  gap: .8rem 1rem;
  align-items: center;
  padding: 1rem 1.05rem;
  background: #fff;
  border: 3px solid #d9cdba;
  text-decoration: none;
  color: inherit;
  transition: border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.gm-rank-item:hover {
  border-color: var(--dourado);
  transform: translateX(2px);
  box-shadow: 5px 5px 0 rgba(10, 16, 32, .12);
  color: inherit;
}
.gm-rank-pos span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6rem;
  min-height: 2.6rem;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--marino);
  background: #eef2f8;
  border: 2px solid #c8d0de;
}
.gm-rank-who {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}
.gm-rank-who-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.gm-rank-who-text strong {
  font-size: 1.15rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gm-rank-who-text span {
  font-size: .9rem;
  color: #5a6578;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gm-rank-mid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  grid-column: 1 / -1;
}
.gm-rank-racha {
  font-weight: 700;
  color: var(--laranja);
  font-size: .95rem;
}
.gm-rank-bars {
  display: grid;
  gap: .5rem;
  grid-column: 1 / -1;
}
.gm-rank-bar-split {
  display: grid;
  gap: .5rem;
}
.gm-rank-bar-row .xp-bar { height: .65rem; }
.gm-rank-bar-lab {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  margin-bottom: .18rem;
  color: #5a6578;
  font-weight: 700;
}
.gm-rank-bar-lab strong { color: var(--marino); font-size: .95rem; }
.gm-rank-cta {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: .25rem;
  font-weight: 800;
  font-size: .92rem;
  color: var(--marino);
  white-space: nowrap;
}

@media (min-width: 900px) {
  .gm-rank-item {
    grid-template-columns: 3.2rem minmax(12rem, 1.1fr) auto minmax(14rem, 1.4fr) auto;
    gap: .9rem 1.1rem;
  }
  .gm-rank-mid,
  .gm-rank-bars { grid-column: auto; }
  .gm-rank-bar-split {
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
  }
  .gm-rank-cta { display: inline-flex; }
}


.gm-fontes-table th {
  font-size: .85rem;
  white-space: nowrap;
}
.gm-fontes-total td {
  background: #fff4d8;
  border-top: 3px solid var(--dourado) !important;
}

.gm-stat-box {
  border: 2px solid #d9cdba;
  background: #fff;
  padding: .55rem .65rem;
  height: 100%;
}

.gm-licao-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .1rem;
  min-width: 4.5rem;
  padding: .4rem .55rem;
  border-width: 2px !important;
  border-radius: 0;
  font-size: .85rem;
  line-height: 1.2;
}
.gm-licao-chip.text-bg-light {
  color: #4a5568 !important;
  background: #f3efe6 !important;
}

/* Missões no tabuleiro — cards legíveis com estado */
.gm-missao-grid {
  display: grid;
  gap: .75rem;
}
@media (min-width: 768px) {
  .gm-missao-grid { grid-template-columns: 1fr 1fr; }
}
.gm-missao-card {
  border: 3px solid #d9cdba;
  background: #fff;
  padding: .85rem .9rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  min-height: 100%;
}
.gm-missao-card.is-ok { border-color: var(--verde); background: #f3faf5; }
.gm-missao-card.is-pendente { border-color: #e0a800; background: #fff9e8; box-shadow: 0 0 0 2px rgba(224,168,0,.18); }
.gm-missao-card.is-refazer { border-color: #0d6efd; background: #f3f7ff; }
.gm-missao-card.is-rejeitada { border-color: var(--vinho); background: #fdf2f2; }
.gm-missao-card.is-idle { opacity: .92; }

.gm-missao-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
}
.gm-missao-status {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .85rem;
  font-weight: 700;
  color: var(--marino);
}
.gm-missao-card.is-ok .gm-missao-status { color: #2f6b45; }
.gm-missao-card.is-pendente .gm-missao-status { color: #9a6b00; }
.gm-missao-card.is-rejeitada .gm-missao-status { color: var(--vinho); }

.gm-missao-xp {
  font-weight: 800;
  font-size: .9rem;
  white-space: nowrap;
  color: var(--marino);
  background: rgba(27, 42, 74, .06);
  padding: .15rem .45rem;
}
.gm-missao-nome { font-size: 1.05rem; line-height: 1.25; }
.gm-missao-diff {
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.gm-missao-diff span { color: #5a6578; text-transform: capitalize; }
.gm-missao-desc {
  margin: 0;
  font-size: .92rem;
  color: #4a5568;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gm-missao-nota {
  margin-top: .25rem;
  padding: .45rem .55rem;
  border-left: 3px solid var(--marino);
  background: rgba(27, 42, 74, .04);
  font-size: .92rem;
  line-height: 1.35;
}

/* —— Hub GM: corrida de obstáculos (espelha o hub do aluno) —— */
.gm-hub-intro {
  flex: 0 0 auto;
  margin-bottom: .45rem !important;
  padding: .55rem .85rem .5rem;
}
.gm-hub-intro-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem .85rem;
}
.gm-hub-intro-title {
  margin: 0;
  font-size: 1.05rem !important;
  line-height: 1.2 !important;
}
.gm-hub-intro-hi {
  font-size: .95rem;
  color: #3a4558;
}
.gm-hub-intro-meta {
  margin-top: .2rem;
  font-size: .88rem;
  color: #4a5568;
  line-height: 1.25;
}

.gm-race {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: #141c2e;
  color: #e8f0f8;
  border-color: #2a3a55;
}

.gm-race-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.1rem .55rem;
  border-bottom: 1px solid rgba(200, 212, 228, .12);
}

.gm-race-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .02em;
  color: #f2e8d5;
}

.gm-race-sub {
  display: block;
  margin-top: .2rem;
  font-size: .92rem;
  color: #a8b4c2;
  font-weight: 600;
}

.gm-race-meta-lab {
  font-weight: 800;
  color: #d4a24c;
  white-space: nowrap;
  padding-top: .15rem;
}

.gm-race-scroll {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: .65rem .75rem .35rem;
}

/* Campo centrado: largura = raias; altura = espaço disponível */
.gm-race-field {
  --lane-w: clamp(56px, 12vw, 78px);
  --label-h: 48px;
  display: flex;
  flex-direction: column;
  width: max-content;
  min-width: min(100%, calc(var(--lanes) * var(--lane-w)));
  height: 100%;
  margin: 0 auto;
  padding-bottom: var(--label-h);
  box-sizing: border-box;
}

.gm-race-track {
  --run-top: 20px;
  --run-bot: 10px;
  position: relative;
  flex: 1 1 auto;
  width: calc(var(--lanes) * var(--lane-w));
  min-height: 180px;
  height: 100%;
  margin: 0 auto;
  background: #243a52;
  border: 3px solid #7a9bb8;
  box-shadow: inset 0 0 0 1px rgba(10, 18, 36, .35);
}

.gm-race-finish {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 14px;
  z-index: 3;
  background:
    repeating-linear-gradient(
      90deg,
      #fff 0 6px,
      #1a2438 6px 12px
    ),
    repeating-linear-gradient(
      0deg,
      #fff 0 6px,
      #1a2438 6px 12px
    );
  background-size: 12px 12px;
  background-blend-mode: difference;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.gm-race-finish span {
  position: absolute;
  top: -18px;
  font-size: .78rem;
  font-weight: 800;
  color: #d4a24c;
  letter-spacing: .04em;
}

.gm-race-lanes {
  position: absolute;
  top: var(--run-top);
  right: 0;
  bottom: var(--run-bot);
  left: 0;
  display: flex;
  z-index: 4;
}

/* Obstáculos: mesma fórmula vertical dos corredores */
.gm-race-hurdle {
  --h: 50;
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: calc(var(--run-bot) + (100% - var(--run-top) - var(--run-bot)) * var(--h) / 100);
  height: 6px;
  z-index: 8;
  border-radius: 2px;
  pointer-events: none;
}
.gm-race-hurdle::before,
.gm-race-hurdle::after {
  content: '';
  position: absolute;
  bottom: -5px;
  width: 5px;
  height: 16px;
  background: inherit;
}
.gm-race-hurdle::before { left: 0; }
.gm-race-hurdle::after { right: 0; }
.gm-race-hurdle.tone-bronze {
  background: rgba(196, 132, 58, .32);
  box-shadow: 0 0 0 1px rgba(224, 160, 96, .4);
}
.gm-race-hurdle.tone-prata {
  background: rgba(168, 184, 200, .32);
  box-shadow: 0 0 0 1px rgba(232, 238, 244, .4);
}
.gm-race-hurdle.tone-ouro {
  background: rgba(212, 168, 32, .32);
  box-shadow: 0 0 0 1px rgba(255, 232, 96, .4);
}

.gm-race-lane {
  position: relative;
  flex: 0 0 var(--lane-w);
  width: var(--lane-w);
  text-decoration: none;
  color: inherit;
  background: rgba(42, 69, 95, .72);
  border-right: 1px solid rgba(142, 176, 204, .35);
  transition: background .12s ease, filter .12s ease;
}
.gm-race-lane:nth-child(even) { background: rgba(49, 80, 108, .72); }
.gm-race-lane:hover {
  background: rgba(58, 52, 32, .88);
  filter: brightness(1.06);
}

.gm-race-run {
  position: absolute;
  inset: 0;
}
/* Tracejado vertical no centro da raia */
.gm-race-run::before {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, .22) 0 6px,
    transparent 6px 12px
  );
  pointer-events: none;
}

.gm-race-runner {
  /* Pés do sprite na marca de XP; --p unitless 0–100 (= obstáculos) */
  --rise: calc(100% * var(--p, 6) / 100);
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  animation: gm-race-rise .95s cubic-bezier(.2, .8, .2, 1) forwards;
  z-index: 9;
  will-change: bottom;
}
/* Só o sprite na pista — sem moldura quadrada */
.gm-race-runner .avatar-pc,
.gm-race-runner .avatar-pc.avatar-sprite {
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0;
  width: 58px;
  height: 58px;
  --frame: 58px;
}

.gm-race-xp {
  display: inline-block;
  min-width: 2rem;
  padding: .08rem .3rem;
  font-size: .72rem;
  font-weight: 800;
  color: #e8f0f8;
  background: rgba(10, 18, 32, .82);
  border: 1px solid rgba(42, 58, 80, .7);
  text-align: center;
  line-height: 1.15;
  /* Fica acima da cabeça, sem empurrar os pés da marca */
  position: relative;
  margin-bottom: 2px;
}

.gm-race-foot {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: var(--label-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: .25rem;
  gap: .05rem;
  background: #1a2e28;
  border-right: 1px solid rgba(142, 176, 204, .2);
}

.gm-race-place {
  font-size: .85rem;
  font-weight: 800;
  color: #d0dce8;
}
.gm-race-place.tone-gold { color: #ffe860; }
.gm-race-place.tone-silver { color: #e8eef4; }
.gm-race-place.tone-bronze { color: #f0ac58; }

.gm-race-name {
  font-size: .8rem;
  font-weight: 700;
  color: #c5d4e8;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 .15rem;
}

@keyframes gm-race-rise {
  from { bottom: 0; }
  to { bottom: var(--rise); }
}

@media (max-width: 700px) {
  .gm-race-field { --lane-w: 62px; }
  .gm-race-runner .avatar-pc,
  .gm-race-runner .avatar-pc.avatar-sprite {
    width: 50px;
    height: 50px;
    --frame: 50px;
  }
}

/* —— GM Panel: adaptabilidade móvel —— */
@media (max-width: 767.98px) {
  body.gm-shell {
    --gm-hotbar-h: 5.15rem;
    font-size: 1.05rem;
  }

  body.gm-shell .container.gm-main,
  body.gm-shell .gm-topbar .container {
    --bs-gutter-x: .9rem;
    padding-left: max(.7rem, env(safe-area-inset-left, 0px));
    padding-right: max(.7rem, env(safe-area-inset-right, 0px));
  }

  body.gm-shell .panel-game {
    box-shadow: 0 0 0 3px var(--dourado), 4px 4px 0 rgba(10, 16, 32, .35);
  }
  body.gm-shell .panel-game.p-3,
  body.gm-shell .panel-game.p-4 {
    padding: .85rem !important;
  }

  .gm-brand-full { display: none; }
  .gm-brand-short { display: inline; }
  .gm-user-label { display: none; }
  .gm-top-txt { display: none; }
  .gm-sair,
  .gm-top-link {
    min-width: 2.6rem;
    min-height: 2.6rem;
    padding: .4rem;
    font-size: 1.15rem;
  }

  .gm-main { padding-top: .7rem; }

  body.gm-shell:has(.gm-race) .gm-main {
    height: calc(100dvh - 3.05rem);
    max-height: calc(100dvh - 3.05rem);
    padding-top: .4rem;
  }

  .gm-hub-intro { padding: .45rem .7rem .4rem; }
  .gm-hub-intro-title { font-size: .95rem !important; }
  .gm-hub-intro-meta { font-size: .82rem; }

  .gm-hotbar {
    padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom, 0px));
  }
  .gm-hot-btn {
    min-width: 3.85rem;
    max-width: 5.1rem;
    min-height: 3.95rem;
    padding: .3rem .2rem;
    border-width: 2px;
  }
  .gm-hot-btn i { font-size: 1.3rem; }
  .gm-hot-label { font-size: .64rem; line-height: 1.1; }

  .gm-actions {
    flex-direction: column;
  }
  .gm-actions > .btn,
  .gm-actions > form {
    width: 100%;
    min-width: 0;
  }
  .gm-actions .btn {
    min-height: 2.75rem;
    font-weight: 700;
  }

  body.gm-shell .btn-sm {
    min-height: 2.55rem;
    padding: .45rem .7rem;
    font-size: .92rem;
  }

  .gm-rank-hero {
    padding: .9rem .85rem;
    gap: .85rem;
  }
  .gm-rank-summary { width: 100%; }
  .gm-rank-stat {
    flex: 1 1 30%;
    min-width: 0;
    padding: .55rem .4rem;
  }
  .gm-rank-stat-val { font-size: 1.25rem; }
  .gm-rank-panel { padding: .85rem; }
  .gm-rank-item {
    padding: .8rem .75rem;
    gap: .55rem .65rem;
  }
  .gm-rank-who-text strong {
    font-size: .98rem;
    word-break: break-word;
  }

  .gm-missao-card { padding: .85rem; }
  .aluno-qr-card .d-flex.flex-wrap.gap-2 > .btn,
  .aluno-qr-card .d-flex.flex-wrap.gap-2 > form {
    flex: 1 1 100%;
  }
  .aluno-qr-card .d-flex.flex-wrap.gap-2 > form .btn {
    width: 100%;
  }

  body.gm-shell .table { font-size: .92rem; }
  body.gm-shell .form-control,
  body.gm-shell .form-select {
    font-size: 1rem;
    min-height: 2.85rem;
  }

  /* Salvar presença fixo acima da hotbar (evita overlap) */
  .gm-sticky-save {
    position: fixed;
    left: max(.7rem, env(safe-area-inset-left, 0px));
    right: max(.7rem, env(safe-area-inset-right, 0px));
    bottom: calc(var(--gm-hotbar-h) + .45rem + env(safe-area-inset-bottom, 0px));
    width: auto;
    margin: 0;
    z-index: 1035;
    box-shadow: 0 6px 18px rgba(10, 16, 32, .35);
  }
  body.gm-shell:has(.gm-sticky-save) .gm-main {
    padding-bottom: calc(var(--gm-hotbar-h) + 4.5rem + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 379.98px) {
  .gm-hot-btn {
    min-width: 3.45rem;
    max-width: 4.4rem;
    min-height: 3.7rem;
  }
  .gm-hot-label { font-size: .58rem; }
  .presenca-btns .btn { font-size: .74rem; min-height: 2.7rem; }
}
