/* ==========================================================================
   7. MODALS, FULL-BLEED SPLIT MAIN MENU, TROPHY CASE & RULES
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 29, 0.92);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding:
    max(12px, calc(env(safe-area-inset-top, 0px) + 6px))
    max(12px, calc(env(safe-area-inset-right, 0px) + 8px))
    max(12px, calc(env(safe-area-inset-bottom, 0px) + 6px))
    max(12px, calc(env(safe-area-inset-left, 0px) + 8px));
  box-sizing: border-box;
}

.modal-backdrop.open {
  display: flex;
}

.victory-card {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  width: 100%;
  max-width: 760px;
  max-height: calc(92vh / var(--ui-scale, 1));
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  box-shadow: 0 22px 60px #000;
  box-sizing: border-box;
}

.brand-logo {
  display: block;
}

.victory-title {
  color: var(--accent);
  font-weight: 900;
}

.victory-sub {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  margin: 0;
}

.menu-mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--primary-950);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  max-width: 620px;
  margin: 0 auto 10px auto;
}

.menu-tab-btn {
  flex: 1;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 8px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}

.menu-tab-btn svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.tab-icon-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.menu-tab-btn.soft-gated:not(.active) {
  opacity: 0.48;
  color: rgba(208, 189, 148, 0.78);
}

.menu-tab-btn.soft-gated:not(.active):hover {
  opacity: 0.82;
  color: var(--text);
}

.menu-tab-btn.active {
  background: var(--accent);
  color: var(--primary-950);
}

.menu-section {
  background: var(--primary-950);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-sizing: border-box;
}

.menu-mode-desc {
  margin: 0 0 10px 0;
  font-size: 0.74rem;
  line-height: 1.38;
  color: var(--text);
  opacity: 0.9;
  text-align: center;
}

.menu-mode-desc strong,
.ability-coach-banner .acb-text strong,
.ability-coach-banner .acb-text b,
.lss-metrics-row b,
.summary-local-stats-row b {
  color: var(--accent);
  font-weight: 800;
}

.modal-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb-box {
  background: var(--primary-900);
  border: 1px solid var(--primary-900);
  border-radius: 12px;
  padding: 10px 12px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(229, 169, 60, 0.25) transparent;
}

.lb-box::-webkit-scrollbar,
.trophies-scroll-area::-webkit-scrollbar,
#startModal #accountMenuPanel::-webkit-scrollbar {
  width: 4px;
}

.lb-box::-webkit-scrollbar-track,
.trophies-scroll-area::-webkit-scrollbar-track,
#startModal #accountMenuPanel::-webkit-scrollbar-track {
  background: transparent;
  margin-block: 6px;
}

.lb-box::-webkit-scrollbar-thumb,
.trophies-scroll-area::-webkit-scrollbar-thumb,
#startModal #accountMenuPanel::-webkit-scrollbar-thumb {
  background: rgba(229, 169, 60, 0.28);
  border-radius: 999px;
}

.lb-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
  margin-bottom: 3px;
}

.lb-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  padding: 3px 6px;
  border-radius: 5px;
  color: var(--text);
}

.lb-row.is-me {
  background: rgba(229, 169, 60, 0.16);
  color: var(--accent);
  font-weight: 800;
}

.lb-time {
  font-family: 'Courier New', Courier, monospace;
  font-weight: 800;
}

.cta-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.cta-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   8. CONTAINED GAME-SIZED SPLIT-VIEW MAIN MENU (#startModal)
   ========================================================================== */
#startModal.modal-backdrop,
#rulesModal.modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: var(--primary-800);
  border-radius: inherit;
  z-index: 100;
}

#rulesModal.modal-backdrop {
  z-index: 160;
}

#startModal > .victory-card,
#rulesModal > .rules-card {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  background: var(--panel);
  border: none;
  border-radius: inherit;
  box-shadow: none;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

#startModal > .victory-card {
  padding: 14px 20px 10px 20px;
}

.start-brand-logo {
  max-width: 210px;
  margin: 0 auto 4px auto;
  display: block;
}

#startSub {
  margin-bottom: 10px;
}

#startModal #dailyMenuPanel,
#startModal #eternalMenuPanel,
#startModal #accountMenuPanel,
#startModal #trophiesMenuPanel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
}

#startModal #accountMenuPanel {
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(229, 169, 60, 0.28) transparent;
}

#startModal .menu-section.account-col-card {
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
}

.account-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--primary-800);
  padding-bottom: 6px;
}

.account-eyebrow {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.account-signed-pill,
.account-guest-pill {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
}

.account-signed-pill {
  background: rgba(60, 168, 97, 0.18);
  border: 1px solid var(--earth);
  color: #5ce68b;
}

.account-guest-pill {
  background: var(--primary-900);
  border: 1px solid var(--primary-700);
  color: var(--muted);
}

.account-handle-box {
  background: var(--primary-900);
  border: 1px solid var(--primary-700);
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.account-field-lbl {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.account-handle-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.account-handle-preview {
  flex: 1;
  min-width: 0;
  background: var(--primary-950);
  border: 1px solid rgba(229, 169, 60, 0.65);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 0.86rem;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-handle-row .action-btn {
  padding: 7px 10px;
  font-size: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.account-help-note {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.32;
  color: var(--muted);
  opacity: 0.88;
}

.account-inline-msg {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 6px;
}

.account-inline-msg.ok {
  background: rgba(60, 168, 97, 0.16);
  border: 1px solid var(--earth);
  color: #5ce68b;
}

.account-inline-msg.err {
  background: rgba(214, 54, 56, 0.16);
  border: 1px solid var(--danger);
  color: #ff8787;
}

.account-email-line {
  font-size: 0.73rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-email-line strong {
  color: var(--text);
}

.account-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: auto;
}

.account-actions-stack .action-btn {
  width: 100%;
  font-size: 0.76rem;
  padding: 8px 12px;
}

.conn-status-card {
  background: var(--primary-900);
  border: 1px solid var(--primary-700);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conn-status-card.is-online {
  border-color: rgba(60, 168, 97, 0.45);
}

.conn-status-card.is-offline {
  border-color: rgba(229, 169, 60, 0.45);
}

.conn-status-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text);
}

.conn-status-desc {
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--muted);
}

.account-app-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.action-btn.app-install-btn {
  width: 100%;
  justify-content: space-between;
  padding: 9px 12px;
  font-size: 0.78rem;
}

.action-btn.app-install-btn.coming-soon:disabled,
.action-btn.app-install-btn.installed:disabled {
  opacity: 0.78;
}

.app-btn-left {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.app-pill-tag {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(229, 169, 60, 0.16);
  border: 1px solid rgba(229, 169, 60, 0.45);
  color: var(--accent);
  white-space: nowrap;
}

.app-pill-tag.ok {
  background: rgba(60, 168, 97, 0.2);
  border-color: var(--earth);
  color: #5ce68b;
}

.app-pill-tag.dark {
  background: rgba(20, 14, 29, 0.22);
  border-color: rgba(20, 14, 29, 0.4);
  color: #140E1D;
}

.app-pill-tag.soon {
  background: var(--primary-950);
  border-color: var(--primary-700);
  color: var(--muted);
}

#startModal #trophiesMenuPanel {
  gap: 8px;
}

.trophies-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--primary-950);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.trophies-menu-header.guest-gate-banner {
  border-color: rgba(229, 169, 60, 0.55);
  background: rgba(229, 169, 60, 0.1);
  color: var(--text);
  padding: 8px 12px;
}

.trophies-menu-header.guest-gate-banner > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  font-weight: 600;
}

.action-btn.trophies-signin-cta {
  padding: 5px 12px;
  font-size: 0.72rem;
  white-space: nowrap;
  margin-left: auto;
}

.trophies-scroll-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(229, 169, 60, 0.28) transparent;
}

#startModal .menu-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  justify-content: safe center;
  min-height: 0;
  overflow-y: auto;
}

#startModal .lb-box {
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Hide background board elements while Main Menu or Contained How-to-Play Deck is open */
#bc-arcade-root.overlay-modal-open>.bc-header,
#bc-arcade-root.overlay-modal-open>.loom-wrapper,
#bc-arcade-root.overlay-modal-open>.right-play-area,
#bc-arcade-root.overlay-modal-open>.footer-btns,
#bc-arcade-root.overlay-modal-open>.inline-summary-panel {
  visibility: hidden !important;
  pointer-events: none !important;
}

.board-loading-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(20, 14, 29, 0.96);
  border-radius: inherit;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, visibility 0.16s ease;
}

.board-loading-overlay.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.board-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 22px 28px;
  background: var(--primary-950);
  border: 1px solid rgba(229, 169, 60, 0.45);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.75);
  text-align: center;
}

.board-loading-spinner {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

.board-loading-title {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.bc-btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(20, 14, 29, 0.25);
  border-top-color: var(--primary-950);
  border-radius: 50%;
  display: inline-block;
  animation: bcSpin 0.75s linear infinite;
  flex-shrink: 0;
}

.menu-inline-sync {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: auto 0;
  padding: 12px 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}

.menu-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border, #3d2f2a);
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}

.menu-bottom-bar .cta-box {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.menu-bottom-bar .bc-version-tag {
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.8;
  white-space: nowrap;
  font-weight: 700;
}

/* ==========================================================================
   9. TROPHY CASE BADGES GRID
   ========================================================================== */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}

.badge-item {
  background: var(--primary-950);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.badge-item.locked {
  opacity: 0.45;
  filter: grayscale(0.8);
}

.badge-item.earned.tier-gold {
  border-color: #e5a93c;
}

.badge-item.earned.tier-silver {
  border-color: #b0bec5;
}

.badge-item.earned.tier-bronze {
  border-color: #cd7f32;
}

.badge-item.earned.tier-prismatic {
  border-color: #9b51e0;
  box-shadow: 0 0 12px rgba(155, 81, 224, 0.3);
}

.badge-crest {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-800);
  border: 2px solid var(--border);
}

.badge-crest.tier-gold {
  background: linear-gradient(135deg, #e5a93c, #9e6b14);
  border-color: #ffe082;
}

.badge-crest.tier-silver {
  background: linear-gradient(135deg, #90a4ae, #546e7a);
  border-color: #eceff1;
}

.badge-crest.tier-bronze {
  background: linear-gradient(135deg, #cd7f32, #804a14);
  border-color: #ffccbc;
}

.badge-crest.tier-prismatic {
  background: linear-gradient(135deg, #9b51e0, #2b7de9);
  border-color: #e1bee7;
}

.badge-date {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--earth);
  display: flex;
  flex-direction: column;
}

.badge-date span {
  font-size: 0.6rem;
  color: var(--muted);
}

