/* Missao Abismo 2.0: Tripulacao da Ria (Estudio Ligne Claire HD + Campanha 12 Mergulhos)
 * Paleta costeira/abismo Ria Formosa, alto contraste para projetor (6 m).
 * Zero CDNs, zero fontes externas, transicoes explicitas (sem transicoes genericas).
 */

/* Andika v27 — SIL Open Font License 1.1 (SIL International) · 100% offline */
@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/andika-regular.woff2") format("woff2");
}
@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../assets/fonts/andika-bold.woff2") format("woff2");
}

:root {
  --abyss-deep: #071e2a;
  --abyss: #0c2f40;
  --abyss-mid: #124358;
  --abyss-line: #296178;
  --brass: #c98e27;
  --ink: #0e2433;
  --ink-muted: #2c4c5e;
  --ink-light: #f2f8fa;
  --ink-light-muted: #bdd8e3;
  --paper: #fafbf9;
  --parchment: #fdf8e6;
  --surface: #ffffff;
  --surface-tint: #ecf5f8;
  --line: #b9d1dc;
  --coral: #c93d24;
  --coral-soft: #fdebe7;
  --mare: #0c7489;
  --mare-soft: #def2f6;
  --pradaria: #0e704d;
  --pradaria-soft: #dbf4ea;
  --ambar: #a85f06;
  --ambar-soft: #fff3d4;
  --submarino: #0e2433;
  --submarino-soft: #e2ebf0;
  --gold: #f4a71d;
  --gold-dark: #945d00;
  --ok: #138a5e;
  --ok-soft: #d7f5e8;
  --err: #c93326;
  --err-soft: #fde8e6;
  --radius: 14px;
  --radius-sm: 10px;
  --font-main: "Segoe UI", "Trebuchet MS", Verdana, system-ui, -apple-system, sans-serif;
  --font-display: "Trebuchet MS", "Segoe UI", Verdana, system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-font="school"] {
  --font-main: "Andika", "Century Gothic", "Comic Sans MS", Verdana, sans-serif;
  --font-display: "Andika", "Century Gothic", "Comic Sans MS", Verdana, sans-serif;
}

body[data-contrast="high"] {
  --abyss-deep: #000000;
  --abyss: #0a1921;
  --abyss-mid: #102a36;
  --abyss-line: #ffffff;
  --ink: #000000;
  --ink-muted: #111111;
  --line: #000000;
  --coral: #a31900;
  --mare: #004e66;
  --pradaria: #005430;
  --ambar: #784200;
}

body[data-mode="home"] .teacher-only {
  display: none !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--abyss-deep);
  color: var(--ink-light);
  font-family: var(--font-main);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  overflow-x: hidden;
}

button, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.hidden { display: none !important; }

.ui-svg {
  display: inline-block;
  flex: 0 0 auto;
  vertical-align: middle;
}

.heading-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--abyss);
  border-bottom: 3px solid var(--brass);
  padding: 7px 16px;
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--mare);
  border: 2px solid #59c3d9;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.04rem, 1.75vw, 1.28rem);
  font-weight: 900;
  line-height: 1.1;
}

.brand small {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-light-muted);
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.btn {
  min-height: 40px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--abyss-line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-light);
  font-size: 0.85rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.17);
  border-color: #79d2e6;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn[aria-pressed="true"] {
  background: var(--gold);
  border-color: #ffd06d;
  color: var(--ink);
}

.btn-gold {
  background: var(--gold);
  border-color: #0e2433;
  color: var(--ink);
  box-shadow: 0 2px 0 #0e2433;
}

.btn-gold:hover:not(:disabled) {
  background: #ffbd42;
  border-color: #ffe094;
}

.btn-ok {
  background: var(--ok);
  border-color: #34d399;
  color: #ffffff;
}

.btn-ok:hover:not(:disabled) {
  background: #0e6f4b;
}

.btn-coral {
  background: var(--coral);
  border-color: #f28974;
  color: #ffffff;
}

.btn-coral:hover:not(:disabled) {
  background: #a32e19;
}

.btn-light {
  background: #ffffff;
  border-color: var(--ink);
  color: var(--ink);
}

.btn-light:hover:not(:disabled) {
  background: var(--surface-tint);
  border-color: var(--mare);
}

/* ---------- Slate 10s Timer Banner ---------- */
.slate-banner {
  max-width: 1320px;
  margin: 8px auto 0;
  padding: 8px 14px;
  border-radius: 12px;
  background: #0e3a52;
  border: 2px solid #59c3d9;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.slate-banner.is-done {
  background: #094d36;
  border-color: #34d399;
}

.slate-track {
  flex: 1 1 200px;
  height: 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.slate-fill {
  height: 100%;
  width: 100%;
  background: #59c3d9;
  transition: width 0.2s linear, background-color 0.2s ease;
}

.slate-banner.is-done .slate-fill {
  background: #34d399;
}

.slate-count {
  font-size: 1.25rem;
  font-weight: 900;
  min-width: 58px;
  text-align: center;
}

/* ---------- Shell & Mode Tabs ---------- */
.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px 16px 20px;
}

.mode-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.tab-btn {
  min-height: 40px;
  padding: 7px 15px;
  border-radius: 999px;
  border: 2px solid var(--abyss-line);
  background: var(--abyss);
  color: var(--ink-light-muted);
  font-weight: 800;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background-color 0.16s var(--ease), color 0.16s var(--ease), border-color 0.16s var(--ease);
}

.tab-btn:hover {
  border-color: #79d2e6;
  color: #ffffff;
}

.tab-btn.is-active {
  background: var(--gold);
  border-color: #ffe094;
  color: var(--ink);
}

/* ---------- Campaign Expedition Strip ---------- */
.campaign-strip {
  background: linear-gradient(90deg, #103b50 0%, #164f67 60%, #10394d 100%);
  border: 2px solid var(--brass);
  border-radius: var(--radius);
  padding: 6px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
}

.campaign-strip-left {
  display: flex;
  align-items: center;
  gap: 8px 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.dive-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--parchment);
  color: var(--ink);
  border: 2px solid var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.dive-pill.is-free {
  background: rgba(255, 255, 255, 0.15);
  color: #e4f6fa;
  border-color: #79d2e6;
}

.campaign-title {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 900;
  color: #fff8df;
}

.campaign-zone {
  font-size: 0.78rem;
  font-weight: 700;
  color: #9be4f0;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(7, 30, 42, 0.48);
  border: 1px solid rgba(121, 210, 230, 0.32);
}

/* ---------- Controls Strip ---------- */
.ctrl-strip {
  background: var(--abyss);
  border: 1.5px solid var(--abyss-line);
  border-radius: var(--radius);
  padding: 6px 12px;
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  flex-wrap: wrap;
}

.ctrl-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ctrl-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink-light-muted);
}

.ctrl-select {
  min-height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1.8px solid var(--abyss-line);
  background: var(--abyss-deep);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 700;
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.pill-badge.is-ok {
  background: rgba(19, 138, 94, 0.28);
  border-color: #34d399;
  color: #d7f5e8;
}

.pill-badge.is-warn {
  background: rgba(244, 167, 29, 0.24);
  border-color: var(--gold);
  color: #fff4d1;
}

/* ---------- MODE A: SUBMARINE CABIN TABLE ---------- */
.mode-a-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 14px;
  align-items: start;
}

.sonar-table {
  position: relative;
  background-color: #0b3345;
  background-image:
    linear-gradient(180deg, rgba(6, 26, 37, 0.4) 0%, rgba(7, 32, 46, 0.34) 52%, rgba(5, 21, 30, 0.62) 100%),
    url("assets/bg-abismo-cabina.webp");
  background-size: cover;
  background-position: center;
  border: 3px solid #0e2433;
  box-shadow: inset 0 0 0 2.5px rgba(201, 142, 39, 0.78), 0 10px 28px rgba(0, 0, 0, 0.42);
  border-radius: 20px;
  padding: 12px 14px;
  display: grid;
  grid-template-rows: auto minmax(140px, auto) auto;
  gap: 8px;
  overflow: hidden;
}

body[data-contrast="high"] .sonar-table {
  background-image: none;
  background-color: #000000;
  border-color: #ffffff;
  box-shadow: none;
}

.porthole-rivet {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe680, #b37412);
  border: 1.5px solid #0e2433;
  z-index: 3;
  pointer-events: none;
}
.rv-tl { top: 8px; left: 8px; }
.rv-tr { top: 8px; right: 8px; }
.rv-bl { bottom: 8px; left: 8px; }
.rv-br { bottom: 8px; right: 8px; }

body[data-contrast="high"] .porthole-rivet {
  display: none;
}

.sonar-rings {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  z-index: 1;
}

.sonar-pulse-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

.sonar-ripple {
  fill: none;
  stroke: #79d2e6;
  stroke-width: 3.2;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: sonarRipple 900ms var(--ease) forwards;
}

.sonar-ripple.is-secondary {
  stroke: #34d399;
  stroke-width: 2.2;
}

.sonar-ripple.is-sos {
  stroke: #ffd24a;
  stroke-width: 3.4;
}

.sonar-ripple.is-sos-inner {
  stroke: #f28974;
  stroke-width: 2.4;
}

@keyframes sonarRipple {
  0% {
    opacity: 0.9;
    transform: scale(0.25);
  }
  70% {
    opacity: 0.42;
  }
  100% {
    opacity: 0;
    transform: scale(4.6);
  }
}

.table-row-mid {
  display: grid;
  grid-template-columns: 174px minmax(0, 1fr) 174px;
  gap: 10px;
  align-items: center;
  position: relative;
  z-index: 2;
}

.seat-box {
  position: relative;
  z-index: 2;
  background: rgba(7, 28, 39, 0.84);
  border: 2px solid rgba(121, 210, 230, 0.36);
  border-radius: 14px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  backdrop-filter: blur(2px);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.seat-box.is-turn {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(244, 167, 29, 0.34);
}

.seat-top {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  flex-direction: row;
  justify-content: space-between;
  padding: 7px 14px;
}

.seat-identity {
  display: flex;
  align-items: center;
  gap: 8px;
}

.seat-box:not(.seat-top) .seat-identity {
  flex-direction: column;
  gap: 4px;
}

.crew-portrait-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 2px;
  border: 2.2px solid #79d2e6;
  background: #0e2433;
  flex-shrink: 0;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}

.crew-portrait-wrap[data-mood="turn"] {
  border-color: #ffd24a;
  box-shadow: 0 0 0 3px rgba(255, 210, 74, 0.28);
}

.crew-portrait-wrap[data-mood="happy"] {
  border-color: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.28);
}

.crew-portrait-wrap[data-mood="alert"] {
  border-color: #f28974;
  box-shadow: 0 0 0 3px rgba(242, 137, 116, 0.32);
}

.crew-portrait-svg {
  display: block;
  border-radius: 50%;
}

.seat-head {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 900;
  font-size: 0.86rem;
  flex-wrap: wrap;
  justify-content: center;
}

.cap-tag {
  background: var(--gold);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 6px;
}

.seat-meta {
  font-size: 0.74rem;
  color: var(--ink-light-muted);
  font-weight: 700;
}

.card-backs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}

.mini-back {
  width: 15px;
  height: 22px;
  border-radius: 4px;
  background: linear-gradient(155deg, #1b5870 0%, #0e3547 100%);
  border: 1.4px solid #79d2e6;
}

/* Sonar mini card shown on seat */
.sonar-mini-btn {
  min-height: 40px;
  padding: 4px 9px;
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.79rem;
  font-weight: 900;
  transition: transform 0.14s var(--ease), border-color 0.14s var(--ease);
}

.sonar-mini-btn:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
}

.sonar-mini-btn.is-used {
  opacity: 0.62;
  border-style: dashed;
}

.sonar-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: #0e704d;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 900;
}

.sonar-mini-btn.is-used .sonar-dot {
  background: #991b1b;
}

/* Center trick arena */
.trick-arena {
  min-height: 136px;
  border-radius: 16px;
  border: 2px dashed rgba(255, 210, 74, 0.42);
  background: rgba(7, 28, 39, 0.66);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  backdrop-filter: blur(2px);
}

.trick-status {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  color: #eef9fc;
  text-align: center;
}

.trick-slots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.played-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.played-slot.is-entering {
  animation: cardDropIn 220ms var(--ease) both;
}

@keyframes cardDropIn {
  from {
    opacity: 0;
    transform: translate(var(--drop-x, 0px), var(--drop-y, 18px)) scale(0.86);
  }
  to {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

.played-slot-who {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink-light-muted);
}

.played-slot.is-winner .played-slot-who {
  color: var(--gold);
}

/* Playing Cards (Dupla Codificacao DUA: Cor + Simbolo SVG + Padrao Sutil) */
.pcard {
  position: relative;
  width: 78px;
  min-height: 104px;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--suit-color, #0c7489);
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.32);
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease), opacity 0.14s var(--ease);
}

.pcard.is-sm {
  width: 66px;
  min-height: 86px;
  padding: 5px;
}

.pcard-suit-coral {
  --suit-color: var(--coral);
  background-color: #fff9f7;
  background-image: repeating-linear-gradient(-45deg, rgba(201, 61, 36, 0.055) 0 4px, transparent 4px 10px);
}
.pcard-suit-mare {
  --suit-color: var(--mare);
  background-color: #f5fbfd;
  background-image: radial-gradient(rgba(12, 116, 137, 0.1) 1.2px, transparent 1.2px);
  background-size: 10px 10px;
}
.pcard-suit-pradaria {
  --suit-color: var(--pradaria);
  background-color: #f4fbf8;
  background-image: repeating-linear-gradient(0deg, rgba(14, 112, 77, 0.06) 0 3px, transparent 3px 9px);
}
.pcard-suit-ambar {
  --suit-color: var(--ambar);
  background-color: #fffcf3;
  background-image:
    linear-gradient(rgba(168, 95, 6, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 95, 6, 0.06) 1px, transparent 1px);
  background-size: 10px 10px;
}
.pcard-suit-submarino {
  --suit-color: #0e2433;
  background-color: #e6eff4;
  border-width: 3.5px;
  box-shadow: inset 0 0 0 2px #c98e27, 0 5px 14px rgba(0, 0, 0, 0.34);
}

.pcard-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--suit-color);
}

.pcard-sym,
.sonar-suit-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1;
}

.suit-svg {
  display: block;
  flex: 0 0 auto;
}

.pcard-key {
  min-width: 19px;
  height: 19px;
  border-radius: 5px;
  background: var(--ink);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pcard-val {
  font-family: var(--font-display);
  font-size: 1.95rem;
  font-weight: 900;
  line-height: 1;
  color: var(--suit-color);
}

.pcard.is-sm .pcard-val {
  font-size: 1.55rem;
}

.pcard-name {
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--suit-color);
}

.pcard-suit-submarino .pcard-name {
  font-size: 0.56rem;
  letter-spacing: -0.01em;
}

/* Leque ergonomico na mao do jogador */
.hand-cards .pcard {
  transform: translateY(var(--fan-y, 0px)) rotate(var(--fan-angle, 0deg));
  transform-origin: center 138%;
}

.hand-cards.is-dense .pcard + .pcard {
  margin-left: -8px;
}

.hand-cards .pcard.is-playable:hover,
.hand-cards .pcard.is-playable:focus-visible {
  transform: translateY(-14px) rotate(0deg) scale(1.06);
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.44);
  z-index: 20;
}

.pcard.is-locked {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.pcard-lock {
  position: absolute;
  top: -8px;
  right: -7px;
  background: var(--ink);
  color: #ffffff;
  border-radius: 999px;
  font-size: 0.68rem;
  padding: 2px 5px;
  border: 1.5px solid #ffffff;
}

.pcard-sonar-pin {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--ok);
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 900;
  white-space: nowrap;
  border: 1.5px solid #ffffff;
}

.pcard-sonar-pin.pos-top { top: -9px; }
.pcard-sonar-pin.pos-mid { top: 50%; transform: translate(-50%, -50%); }
.pcard-sonar-pin.pos-bot { bottom: -9px; }

.hand-cards .pcard.is-selected,
.pcard.is-selected {
  box-shadow: 0 0 0 3px var(--gold), 0 12px 24px rgba(0, 0, 0, 0.4);
  transform: translateY(-12px) rotate(0deg) scale(1.04);
  z-index: 18;
}

.played-slot.is-winner .pcard {
  box-shadow: 0 0 0 3px var(--gold), 0 8px 18px rgba(0, 0, 0, 0.4);
}

/* Human hand dock */
.hand-dock {
  position: relative;
  z-index: 2;
  background: rgba(7, 28, 39, 0.88);
  border: 2px solid var(--abyss-line);
  border-radius: 16px;
  padding: 9px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hand-dock.is-turn {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(244, 167, 29, 0.25);
}

.hand-dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.human-head-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hand-cards {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 12px 6px 4px;
}

.action-banner {
  background: #fff4d1;
  color: var(--ink);
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* Sidebar: tasks & info */
.side-panel {
  background: var(--abyss);
  border: 2px solid var(--abyss-line);
  border-radius: 18px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.side-panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 900;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-card {
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-left: 6px solid var(--mare);
  border-radius: 12px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task-card.is-won {
  border-left-color: var(--ok);
  background: #edf9f3;
}

.task-card.is-failed {
  border-left-color: var(--err);
  background: #fef0ee;
}

.task-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 900;
}

.task-owner {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--mare-soft);
  color: #074754;
}

.task-order {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--ink);
  color: #ffffff;
  font-size: 0.72rem;
}

.task-label {
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.3;
}

.task-tag {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.belief-note {
  font-size: 0.8rem;
  color: var(--ink-light-muted);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* ---------- MODE B: CLASSROOM CENTRAL (5 TABLES) ---------- */
.mode-b-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr);
  gap: 14px;
  align-items: start;
}

.panel-card {
  background: var(--abyss);
  border: 1.8px solid var(--abyss-line);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-card h2, .panel-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
}

.big-tasks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.big-task-btn {
  text-align: left;
  background: var(--paper);
  color: var(--ink);
  border: 2.5px solid var(--line);
  border-top: 6px solid var(--mare);
  border-radius: 14px;
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 112px;
  transition: transform 0.14s var(--ease), border-color 0.14s var(--ease), background-color 0.14s var(--ease);
}

.big-task-btn:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
}

.big-task-btn.is-done {
  background: var(--ok-soft);
  border-top-color: var(--ok);
  border-color: var(--ok);
}

.big-task-badge {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--mare);
}

.big-task-btn.is-done .big-task-badge {
  color: var(--ok);
}

.big-task-text {
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.3;
}

.big-task-meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink-muted);
}

.phases-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.phase-btn {
  min-height: 46px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1.8px solid var(--abyss-line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink-light-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.phase-btn.is-active {
  background: #59c3d9;
  border-color: #ffffff;
  color: var(--ink);
}

.signal-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid #0e2433;
  vertical-align: middle;
}
.signal-dot.is-open { background: #34d399; }
.signal-dot.is-silent { background: #38bdf8; }
.signal-dot.is-noise { background: #f59e0b; }

.silence-box {
  border-radius: 14px;
  padding: 13px 14px;
  border: 2.5px solid #34d399;
  background: rgba(19, 138, 94, 0.22);
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.silence-box.state-silent {
  border-color: #59c3d9;
  background: rgba(12, 116, 137, 0.34);
}

.silence-box.state-noise {
  border-color: var(--gold);
  background: rgba(196, 108, 12, 0.36);
}

.silence-title {
  font-size: 1.1rem;
  font-weight: 900;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.silence-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.logbook-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
}

.logbook-item {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.mod-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 4px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--abyss-line);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- MODE C: DEMO & SONAR SIMULATOR ---------- */
.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.num-line {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin: 8px 0;
}

.nl-tile {
  width: 54px;
  min-height: 62px;
  padding: 4px 2px;
  border-radius: 10px;
  border: 2.5px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 900;
  font-size: 1.1rem;
  text-align: center;
}

.nl-tile small {
  font-size: 0.62rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.nl-tile.is-signal {
  background: var(--gold);
  border-color: #945d00;
  color: var(--ink);
}

.nl-tile.is-possible {
  background: var(--mare-soft);
  border-color: var(--mare);
  color: #074754;
}

.nl-tile.is-excluded {
  background: #e2e8f0;
  border-color: #94a3b8;
  border-style: dashed;
  color: #64748b;
  text-decoration: line-through;
  opacity: 0.68;
}

.ineq-box {
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 12px 14px;
}

.ineq-formula {
  font-size: 1.25rem;
  font-weight: 900;
  color: #074754;
  margin: 0 0 4px;
}

/* ---------- Modals & Campaign Logbook ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(4, 18, 26, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--parchment);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-campaign {
  width: min(880px, 100%);
}

.campaign-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.campaign-modal-sub {
  margin: 3px 0 0;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.campaign-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.dive-card {
  text-align: left;
  background: #ffffff;
  color: var(--ink);
  border: 2.2px solid var(--ink);
  border-radius: 13px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.14s var(--ease), background-color 0.14s var(--ease), border-color 0.14s var(--ease);
}

.dive-card:hover {
  transform: translateY(-2px);
  background: #f0f9fc;
}

.dive-card.is-active {
  background: #fff7dc;
  border-color: var(--brass);
  box-shadow: 0 0 0 2px var(--gold), 0 3px 0 var(--ink);
}

.dive-card.is-done {
  border-color: var(--ok);
  background: #edf9f3;
}

.dive-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 900;
}

.dive-depth-tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: #0e2433;
  color: #ffffff;
}

.dive-tier-tag {
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 900;
}
.dive-tier-tag.t-batismo { background: #dbf4ea; color: #085037; }
.dive-tier-tag.t-exploradores { background: #def2f6; color: #074f5e; }
.dive-tier-tag.t-abismo { background: #e6ecf8; color: #1e3a8a; }

.dive-card-title {
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.22;
}

.dive-card-zone {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.dive-card-note {
  margin: 2px 0 0;
  font-size: 0.74rem;
  line-height: 1.32;
  color: #1e3a4c;
  background: rgba(255, 244, 209, 0.7);
  border-left: 3px solid var(--brass);
  padding: 4px 6px;
  border-radius: 4px;
}

.dive-card-foot {
  margin-top: auto;
  padding-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--ink-muted);
}

.dive-done-stamp {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ok);
  color: #ffffff;
  font-weight: 900;
}

.sabias-box {
  background: #fff6d6;
  border: 2px solid var(--brass);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--ink);
}

.sabias-box strong {
  color: #7c4700;
}

.modal-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.28rem;
  color: var(--ink);
}

.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 11px;
  border-radius: 12px;
  background: var(--mare-soft);
  color: #074754;
  border: 2.5px dashed var(--mare);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .mode-a-grid,
  .mode-b-layout,
  .demo-grid {
    grid-template-columns: 1fr;
  }
  .table-row-mid {
    grid-template-columns: 1fr;
  }
  .phases-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .campaign-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar {
    padding: 7px 10px;
  }
  .shell {
    padding: 8px 10px 22px;
  }
  .campaign-grid {
    grid-template-columns: 1fr;
  }
  .seat-top {
    flex-direction: column;
    align-items: center;
  }
  .hand-cards {
    gap: 6px;
    padding: 8px 2px 2px;
  }
  .hand-cards .pcard {
    transform: none;
  }
  .hand-cards.is-dense .pcard + .pcard {
    margin-left: 0;
  }
  .pcard {
    width: 62px;
    min-height: 86px;
    padding: 4px;
  }
  .pcard-val {
    font-size: 1.48rem;
  }
  .sonar-table {
    padding: 10px 8px;
  }
}

@media (max-height: 660px) and (min-width: 981px) {
  .topbar { padding: 5px 14px; }
  .brand-icon { width: 34px; height: 34px; }
  .brand h1 { font-size: 1.04rem; }
  .brand small { font-size: 0.72rem; }
  .btn, .ctrl-select, .tab-btn { min-height: 35px; padding: 4px 10px; font-size: 0.8rem; }
  .shell { padding: 6px 14px 10px; }
  .mode-tabs, .campaign-strip, .ctrl-strip { margin-bottom: 6px; }
  .sonar-table { padding: 8px 10px; gap: 6px; grid-template-rows: auto minmax(114px, auto) auto; }
  .seat-box { padding: 5px 9px; gap: 3px; }
  .trick-arena { min-height: 112px; padding: 5px 8px; gap: 4px; }
  .pcard { width: 68px; min-height: 84px; padding: 4px 5px; }
  .pcard-val { font-size: 1.52rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
  .hand-cards .pcard {
    transform: none !important;
  }
}

/* ==================== VISTA LIMPA (?treino=1) & MERGULHO 0 ==================== */
.home-only { display: none; }
body[data-mode="home"] .home-only { display: inline-flex; }
body[data-mode="home"] .ctrl-strip:not(.is-open) { display: none; }

.tut-nudge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #fff8e2 0%, #fef3c7 100%);
  color: var(--ink);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 8px 14px;
  margin-bottom: 10px;
  box-shadow: 0 3px 0 rgba(14, 36, 51, 0.25);
}
.tut-nudge-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-size: 0.9rem;
}
.tut-nudge-copy strong { font-weight: 900; }

.modal-tutorial {
  max-width: 620px;
  width: 96%;
  background: #fdfcf7;
  color: var(--ink);
  border: 3px solid var(--ink);
}
.tut-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.tut-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tut-comic-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #eef7fa;
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 3px 0 rgba(14, 36, 51, 0.14);
}
.tut-comic-bubble {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.38;
  color: var(--ink);
}
.tut-comic-who {
  display: block;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0c7489;
  margin-bottom: 2px;
}
.tut-table-box {
  background: linear-gradient(180deg, #0b374a 0%, #072635 100%);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 12px;
  color: #f0f9fc;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.tut-table-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: #a6e3f0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tut-cards-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.tut-hand-prompt {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}
.tut-feedback {
  padding: 9px 12px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tut-feedback.is-ok {
  background: #dbf4ea;
  border-color: #0e704d;
  color: #094a33;
}
.tut-feedback.is-hint {
  background: #fff4d1;
  border-color: #d9820b;
  color: #5c3200;
}
.tut-celebrate {
  background: linear-gradient(135deg, #dbf4ea 0%, #eef7fa 100%);
  border: 2.5px solid #0e704d;
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.tut-crew-line {
  display: flex;
  justify-content: center;
  gap: 12px;
}

