@import url("../assets/nb-theme.css");

:root {
  --lab-ink: #10242b;
  --lab-muted: #4a6670;
  --lab-bg: #eef6f4;
  --lab-surface: rgba(255, 255, 255, 0.78);
  --lab-line: rgba(16, 36, 43, 0.1);
  --lab-teal: #0b6e6a;
  --lab-teal-bright: #14b8a6;
  --lab-copper: #c46b3a;
  --lab-amber: #e8a317;
  --font-display: "Outfit", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --topbar-h: 4.1rem;
  --cell: 48px;
  --gap: 3px;
  --cat-alcalino: #f07167;
  --cat-alcalino-terroso: #f4a261;
  --cat-transicao: #7eb8da;
  --cat-pos-transicao: #90be6d;
  --cat-semimetal: #43aa8b;
  --cat-nao-metal: #577590;
  --cat-halogenio: #4d908e;
  --cat-gas-nobre: #277da1;
  --cat-lantanideo: #9a6bb8;
  --cat-actinideo: #7a5cae;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-display);
  color: var(--lab-ink);
  background: var(--lab-bg);
  overflow-x: hidden;
}
body.is-playing {
  overflow: hidden;
  height: 100dvh;
}

[hidden] {
  display: none !important;
}

.game-opening {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: #10242b;
  display: grid;
  place-items: center;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.32s ease, visibility 0.32s ease;
}
.game-opening.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.game-opening picture,
.game-opening img {
  width: 100%;
  height: 100%;
  display: block;
}
.game-opening img {
  object-fit: contain;
  object-position: center;
}
@media (prefers-reduced-motion: reduce) {
  .game-opening { transition: none; }
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.45;
  animation: drift 18s ease-in-out infinite alternate;
}
.orb-a {
  width: 42vw;
  height: 42vw;
  left: -8%;
  top: -10%;
  background: radial-gradient(circle, #9be7d8 0%, transparent 70%);
}
.orb-b {
  width: 36vw;
  height: 36vw;
  right: -6%;
  bottom: 5%;
  background: radial-gradient(circle, #f6c89f 0%, transparent 70%);
  animation-delay: -6s;
}
.grid-fade {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(16, 36, 43, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 36, 43, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(4%, 6%) scale(1.08); }
}

.topbar, main, .sheet, .overlay, .toast { position: relative; z-index: 1; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 3vw, 1.75rem);
  border-bottom: 1px solid var(--lab-line);
  backdrop-filter: blur(12px);
  background: rgba(238, 246, 244, 0.72);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-start {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.85rem;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--lab-teal), #063f3d);
  color: #e8fffb;
  font-weight: 800;
  font-family: var(--font-mono);
  box-shadow: 0 10px 24px rgba(11, 110, 106, 0.28);
  flex-shrink: 0;
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-copy strong { font-size: 1rem; }
.brand-copy span { font-size: 0.78rem; color: var(--lab-muted); }
.back-btn {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.85rem;
  border: 1px solid var(--lab-line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--lab-teal);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.back-btn:hover,
.back-btn:focus-visible {
  background: rgba(11, 110, 106, 0.08);
  border-color: rgba(11, 110, 106, 0.28);
  outline: none;
}
body.is-playing .brand-mark { display: none; }
body.is-playing .brand { pointer-events: none; }

.icon-btn, .ghost-btn, .primary-btn, .secondary-btn {
  font-family: inherit;
  cursor: pointer;
  border: none;
}
.icon-btn {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--lab-line);
  font-weight: 700;
}
.ghost-btn {
  background: transparent;
  color: var(--lab-teal);
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
}
.ghost-btn:hover { background: rgba(11, 110, 106, 0.08); }
.primary-btn {
  background: linear-gradient(135deg, var(--lab-teal), #0a8f88);
  color: #fff;
  font-weight: 700;
  padding: 0.85rem 1.35rem;
  border-radius: 999px;
  box-shadow: 0 12px 28px rgba(11, 110, 106, 0.28);
}
.secondary-btn {
  background: #fff;
  border: 1px solid var(--lab-line);
  color: var(--lab-ink);
  font-weight: 600;
  padding: 0.75rem 1.2rem;
  border-radius: 999px;
}

.loading {
  text-align: center;
  color: var(--lab-muted);
  margin: 1rem;
  min-height: 1.4em;
}
.loading.is-done { display: none; }

.screen { display: none; padding: 1rem clamp(1rem, 3vw, 2rem) 2.5rem; }
.screen.is-active { display: block; animation: rise 0.45s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.hub-hero { max-width: 40rem; margin-bottom: 1.75rem; }
.kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--lab-teal);
  margin: 0 0 0.6rem;
}
.hub-hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.8rem);
  line-height: 1.02;
  margin: 0 0 0.85rem;
  letter-spacing: -0.03em;
}
.hub-hero h1 em {
  font-style: normal;
  background: linear-gradient(120deg, var(--lab-teal-bright), var(--lab-copper));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead { color: var(--lab-muted); margin: 0; max-width: 38rem; line-height: 1.55; }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.mode-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.mode-card {
  text-align: left;
  padding: 1.25rem 1.2rem 1.35rem;
  border-radius: 1.25rem;
  border: 1px solid var(--lab-line);
  background: var(--lab-surface);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 40px rgba(16, 36, 43, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  color: inherit;
}
.mode-card:hover, .mode-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(11, 110, 106, 0.35);
  box-shadow: 0 20px 48px rgba(11, 110, 106, 0.14);
  outline: none;
}
.mode-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.7rem;
  display: grid;
  place-items: center;
  background: rgba(11, 110, 106, 0.1);
  color: var(--lab-teal);
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}
.mode-card strong { font-size: 1.2rem; }
.mode-card span:last-child { color: var(--lab-muted); font-size: 0.92rem; line-height: 1.45; }

.credit-foot {
  font-size: 0.85rem;
  color: var(--lab-muted);
}

body.is-playing .ambient { opacity: 0.25; }
body.is-playing .topbar {
  position: relative;
  flex-shrink: 0;
}
body.is-playing {
  display: flex;
  flex-direction: column;
}
body.is-playing main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.screen-play.is-active {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  padding: 0.15rem 0.4rem 0.35rem;
  box-sizing: border-box;
  overflow: hidden;
}

.play-meta { flex: 1; min-width: 12rem; }
.play-meta h2 { margin: 0; font-size: 1.35rem; }
.play-hint { margin: 0.2rem 0 0; color: var(--lab-muted); font-size: 0.9rem; }
.play-stats {
  display: flex;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
}
.play-stats span {
  background: #fff;
  border: 1px solid var(--lab-line);
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
}

.filter-row,
.tray {
  display: none !important;
}

.quiz-hud {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.quiz-hud-stats {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: auto;
  flex-wrap: wrap;
}
.lives {
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  color: #c4465a;
  line-height: 1;
  user-select: none;
}
.lives.is-low {
  animation: shake 0.4s ease;
  color: #b73242;
}
.quiz-score {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  background: #fff;
  border: 1px solid var(--lab-line);
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
}
.timer--ring {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.05rem;
  background: #fff;
  border: 3px solid var(--lab-teal);
  color: var(--lab-teal);
}
.timer--ring.is-low {
  border-color: #b73242;
  color: #b73242;
  animation: pulseLow 0.6s ease infinite;
}
@keyframes pulseLow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.timer-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(16, 36, 43, 0.08);
  overflow: hidden;
  margin-bottom: 1rem;
}
.timer-bar span {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lab-teal-bright), var(--lab-teal));
  transition: width 0.05s linear;
}
.timer-bar span.is-low {
  background: linear-gradient(90deg, #ff7b37, #b73242);
}
.result-sub {
  margin: 0 0 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--lab-muted);
  font-weight: 600;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.table-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  overflow: hidden;
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--lab-line);
  padding: 0.35rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  position: relative;
}

.table-viewport {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  align-items: center;
  justify-content: center;
}

.table-wrap.is-pannable .table-viewport {
  align-items: flex-start;
  justify-content: flex-start;
  touch-action: pan-x pan-y;
}

.table-wrap.is-pannable::before,
.table-wrap.is-pannable::after {
  content: "";
  position: absolute;
  left: 0.35rem;
  right: 0.35rem;
  height: 1.4rem;
  pointer-events: none;
  z-index: 4;
  opacity: 0.85;
  transition: opacity 0.35s ease;
}

.table-wrap.is-pannable::before {
  top: 1.6rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), transparent);
}

.table-wrap.is-pannable::after {
  bottom: 2.6rem;
  background: linear-gradient(0deg, rgba(255, 255, 255, 0.92), transparent);
}

.table-wrap.is-pannable.is-scrolled::before,
.table-wrap.is-pannable.is-scrolled-end::after {
  opacity: 0;
}

.table-pan-hint {
  margin: 0 0 0.25rem;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--lab-teal);
  flex-shrink: 0;
}

.table-wrap.is-scrolled .table-pan-hint {
  opacity: 0.45;
}

.table-detail-line {
  margin: 0.35rem 0 0;
  padding: 0.45rem 0.65rem;
  border-radius: 0.65rem;
  background: rgba(11, 110, 106, 0.08);
  border: 1px solid rgba(11, 110, 106, 0.14);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--lab-ink);
  text-align: center;
  line-height: 1.35;
  flex-shrink: 0;
  min-height: 2.2em;
}

.ptable {
  display: grid;
  grid-template-columns: repeat(18, var(--cell));
  grid-template-rows: repeat(9, var(--cell));
  gap: var(--gap);
  width: max-content;
  margin: 0 auto;
  user-select: none;
  flex: 0 0 auto;
}

.table-wrap.is-pannable .ptable {
  margin: 0.25rem;
}

.cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  border-radius: max(4px, calc(var(--cell) * 0.12));
  border: 1px solid transparent;
  background: #dfe8e6;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.cell.is-empty {
  background: transparent;
  border: none;
  pointer-events: none;
}
.cell.is-spacer {
  background: transparent;
  border: none;
  pointer-events: none;
}
.cell .z {
  position: absolute;
  top: max(2px, calc(var(--cell) * 0.05));
  left: max(2px, calc(var(--cell) * 0.06));
  font-size: max(0.5rem, calc(var(--cell) * 0.18));
  font-family: var(--font-mono);
  opacity: 0.9;
  font-weight: 600;
  max-width: 92%;
  overflow: hidden;
  line-height: 1;
}
.cell .z.is-long {
  font-size: max(0.42rem, calc(var(--cell) * 0.14));
  letter-spacing: -0.04em;
}
.cell .sym {
  font-weight: 800;
  font-size: max(0.85rem, calc(var(--cell) * 0.44));
  letter-spacing: -0.02em;
}
.cell .mass {
  font-size: max(0.38rem, calc(var(--cell) * 0.13));
  opacity: 0.9;
  margin-top: max(1px, calc(var(--cell) * 0.03));
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
  max-width: 96%;
  overflow: hidden;
  white-space: nowrap;
  line-height: 1.05;
}
.ptable.is-compact .cell .mass {
  display: none;
}

.cell.cat-alcalino { background: var(--cat-alcalino); }
.cell.cat-alcalino-terroso { background: var(--cat-alcalino-terroso); }
.cell.cat-transicao { background: var(--cat-transicao); color: #10242b; }
.cell.cat-pos-transicao { background: var(--cat-pos-transicao); color: #10242b; }
.cell.cat-semimetal { background: var(--cat-semimetal); }
.cell.cat-nao-metal { background: var(--cat-nao-metal); }
.cell.cat-halogenio { background: var(--cat-halogenio); }
.cell.cat-gas-nobre { background: var(--cat-gas-nobre); }
.cell.cat-lantanideo { background: var(--cat-lantanideo); }
.cell.cat-actinideo { background: var(--cat-actinideo); }

.cell:hover:not(.is-empty):not(.is-slot),
.cell:focus-visible:not(.is-empty) {
  transform: scale(1.12);
  z-index: 3;
  box-shadow: 0 10px 24px rgba(16, 36, 43, 0.22);
  outline: none;
}
.cell.is-dim { opacity: 0.22; filter: grayscale(0.4); transform: none; }
.cell.is-related { outline: 2px solid rgba(232, 163, 23, 0.9); z-index: 2; }
.cell.is-slot {
  background: rgba(255, 255, 255, 0.35);
  border: 2px dashed rgba(11, 110, 106, 0.45);
  color: transparent;
}
.cell.is-slot.is-over {
  border-color: var(--lab-teal);
  background: rgba(20, 184, 166, 0.2);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.2);
}
.cell.is-locked { animation: popIn 0.4s cubic-bezier(0.2, 0.9, 0.2, 1.2) both; }
.cell.is-wrong-flash { animation: shake 0.4s ease; }
@keyframes popIn {
  from { transform: scale(0.7); filter: brightness(1.4); }
  to { transform: scale(1); filter: none; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.piece {
  width: calc(var(--cell) * 1.55);
  height: calc(var(--cell) * 1.55);
  border-radius: 0.7rem;
  border: none;
  color: #fff;
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  box-shadow: 0 14px 30px rgba(16, 36, 43, 0.22);
  touch-action: none;
  transition: transform 0.2s ease;
  position: relative;
}
.piece:active { cursor: grabbing; transform: scale(1.05); }
.piece .z {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: 0.65rem;
  font-family: var(--font-mono);
}
.piece .sym { font-size: 1.35rem; font-weight: 800; }
.piece .name {
  font-size: 0.62rem;
  margin-top: 0.2rem;
  opacity: 0.9;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.piece.is-dragging { opacity: 0.35; }
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 80;
  width: calc(var(--cell) * 1.55);
  height: calc(var(--cell) * 1.55);
  border-radius: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.35rem;
  box-shadow: 0 18px 40px rgba(16, 36, 43, 0.3);
  transform: translate(-50%, -50%) scale(1.08);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.65rem;
  margin-top: 0.35rem;
  justify-content: center;
  flex-shrink: 0;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  color: var(--lab-muted);
  font-weight: 600;
}
.legend i {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 0.2rem;
  display: inline-block;
}

#examScreen.is-active {
  display: flex !important;
  flex-direction: column;
  min-height: calc(100dvh - var(--topbar-h));
  padding: 0.75rem clamp(0.75rem, 2vw, 1.5rem) 1.25rem;
  box-sizing: border-box;
}
#examScreen .exam-card {
  width: min(44rem, 100%);
  margin: auto;
  max-height: none;
}
#resultScreen.is-active {
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--topbar-h));
}
.streak-pill {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  background: linear-gradient(135deg, rgba(232, 163, 23, 0.2), rgba(196, 107, 58, 0.15));
  border: 1px solid rgba(196, 107, 58, 0.35);
  color: var(--lab-copper);
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
}
.streak-pill.is-hot {
  animation: popIn 0.35s ease;
  background: linear-gradient(135deg, #e8a317, #c46b3a);
  color: #fff;
  border-color: transparent;
}
.exam-card {
  max-width: 44rem;
  margin: 0 auto;
  background: var(--lab-surface);
  border: 1px solid var(--lab-line);
  border-radius: 1.4rem;
  padding: 1.5rem clamp(1rem, 3vw, 1.75rem);
  box-shadow: 0 18px 48px rgba(16, 36, 43, 0.08);
}
.exam-card--fun {
  text-align: center;
  padding-top: 1.25rem;
}
.exam-type {
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--lab-copper);
}
.exam-prompt {
  display: grid;
  place-items: center;
  gap: 0.35rem;
  min-height: 8.5rem;
  margin: 0 auto 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: 1.4rem;
  background: linear-gradient(160deg, rgba(11, 110, 106, 0.12), rgba(196, 107, 58, 0.12));
  border: 1px solid rgba(11, 110, 106, 0.18);
  animation: rise 0.35s ease;
}
.exam-prompt-main {
  font-size: clamp(3.2rem, 12vw, 5.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--lab-ink);
  font-family: var(--font-mono);
}
.exam-prompt.is-name .exam-prompt-main {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  letter-spacing: -0.03em;
}
.exam-prompt-sub {
  font-size: 0.95rem;
  color: var(--lab-muted);
  font-weight: 600;
}
.exam-options { display: grid; gap: 0.65rem; }
.exam-options--grid {
  grid-template-columns: 1fr 1fr;
}
.exam-opt {
  text-align: center;
  padding: 1rem 0.85rem;
  border-radius: 1rem;
  border: 1px solid var(--lab-line);
  background: #fff;
  font-family: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.exam-opt:hover:not(:disabled) {
  border-color: var(--lab-teal);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(11, 110, 106, 0.12);
}
.exam-opt.is-symbol {
  font-family: var(--font-mono);
  font-size: 1.45rem;
}
.exam-opt.is-correct {
  background: #eaf8f1;
  border-color: #177f58;
  color: #177f58;
}
.exam-opt.is-wrong {
  background: #fff0f1;
  border-color: #b73242;
  color: #b73242;
}
.exam-feedback {
  min-height: 1.5em;
  margin: 1rem 0 0;
  font-weight: 700;
  color: var(--lab-muted);
}
.exam-feedback.is-good { color: #177f58; }
.exam-feedback.is-bad { color: #b73242; }

.exam-next-btn {
  width: 100%;
  margin-top: 0.85rem;
}

.result-card {
  max-width: 28rem;
  margin: 2rem auto;
  text-align: center;
  background: var(--lab-surface);
  border: 1px solid var(--lab-line);
  border-radius: 1.5rem;
  padding: 2rem 1.5rem;
}
.result-score {
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 800;
  font-family: var(--font-mono);
  margin: 0.5rem 0 0.75rem;
  background: linear-gradient(120deg, var(--lab-teal), var(--lab-copper));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  margin-top: 1.4rem;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  visibility: hidden;
}
.sheet.is-open {
  pointer-events: auto;
  visibility: visible;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 28, 32, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sheet.is-open .sheet-backdrop { opacity: 1; }
.sheet-panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(420px, 100%);
  background: linear-gradient(180deg, #f7fcfb 0%, #eef6f4 100%);
  border-left: 1px solid var(--lab-line);
  padding: 1.25rem 1.25rem 2rem;
  overflow: auto;
  transform: translateX(104%);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: -20px 0 60px rgba(16, 36, 43, 0.18);
}
.sheet.is-open .sheet-panel { transform: none; }
.sheet-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  border: 1px solid var(--lab-line);
  background: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}
.sheet-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}
#orbitCanvas {
  width: 100%;
  max-width: 200px;
  height: auto;
  justify-self: center;
}
.sheet-id { padding-right: 1.5rem; }
.sheet-z {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--lab-teal);
  background: rgba(11, 110, 106, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  margin-bottom: 0.35rem;
}
.sheet-symbol {
  display: block;
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}
.sheet-id h2 {
  margin: 0.2rem 0 0.25rem;
  font-size: 1.35rem;
}
.sheet-cat {
  margin: 0;
  color: var(--lab-muted);
  font-weight: 600;
  font-size: 0.9rem;
}
.sheet-uso {
  font-size: 1.05rem;
  line-height: 1.45;
  margin: 0 0 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  background: rgba(196, 107, 58, 0.1);
  border: 1px solid rgba(196, 107, 58, 0.2);
}
.sheet-curiosidade {
  margin: 0 0 1rem;
  color: var(--lab-muted);
  font-size: 0.92rem;
  font-style: italic;
}
.sheet-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 0 0 1.25rem;
}
.sheet-facts div {
  background: #fff;
  border: 1px solid var(--lab-line);
  border-radius: 0.85rem;
  padding: 0.65rem 0.75rem;
}
.sheet-facts dt {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--lab-muted);
  font-weight: 700;
}
.sheet-facts dd {
  margin: 0.2rem 0 0;
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.92rem;
}
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 28, 32, 0.5);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.overlay.is-hidden { display: none; }
.overlay-card {
  background: #fff;
  border-radius: 1.25rem;
  padding: 1.5rem;
  max-width: 28rem;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}
.overlay-card ul {
  padding-left: 1.1rem;
  color: var(--lab-muted);
  line-height: 1.5;
}
.overlay-card li { margin-bottom: 0.5rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--lab-ink);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  z-index: 60;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  animation: rise 0.3s ease;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

@media (max-width: 900px) {
  .mode-grid,
  .mode-grid--3 { grid-template-columns: 1fr; }
  .exam-options--grid { grid-template-columns: 1fr; }
  .sheet-hero { grid-template-columns: 1fr; text-align: center; }
  .sheet-id { padding-right: 0; }
  #orbitCanvas { max-width: 160px; }
  .sheet-panel {
    top: auto;
    bottom: 0;
    height: min(88vh, 640px);
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--lab-line);
    border-radius: 1.25rem 1.25rem 0 0;
    transform: translateY(104%);
  }
  .sheet.is-open .sheet-panel { transform: none; }
  body.is-playing .legend { display: none; }
  .quiz-hud-stats { margin-left: 0; width: 100%; justify-content: flex-end; }
}

@media (max-width: 640px) {
  .topbar { padding: 0.55rem 0.7rem; }
  .brand-copy span { display: none; }
  .screen-play.is-active { padding: 0.15rem 0.25rem 0.3rem; }
  .table-pan-hint { display: block; }
  .table-detail-line { font-size: 0.78rem; }
}

@media (min-width: 769px) {
  .table-pan-hint { display: none; }
}
