/* ==========================================================================
   BINARY COCOA ARCADE — ELEMENTAL TAPESTRY STYLESHEET (v2.2.96)
   ========================================================================== */

:root {
  --primary-700: #35234A;
  --primary-800: #2C1D3E;
  --primary-900: #20152D;
  --primary-950: #140E1D;

  --panel: var(--primary-800);
  --border: var(--primary-800);
  --text: #f7efe6;
  --muted: #d0bd94;
  --accent: #e5a93c;
  --danger: #ff6b6b;
  --earth: #3ca861;
  --dynamic-cell: 46px;
  --dynamic-gap: 6px;
  --ui-scale: 1;
}

html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--primary-950);
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: var(--primary-950);
  color: #f7efe6;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

/* Center the game board vertically & respect mobile safe-area insets */
#bc-stage-wrap {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(env(safe-area-inset-top, 0px) + 8px)
    calc(env(safe-area-inset-right, 0px) + 12px)
    calc(env(safe-area-inset-bottom, 0px) + 10px)
    calc(env(safe-area-inset-left, 0px) + 12px);
  box-sizing: border-box;
}

/* Preserve smooth vertical scrolling inside modals, leaderboards & trophy/account panels */
.bc-modal-overlay,
.bc-auth-card,
.victory-card,
.lb-box,
.trophies-scroll-area,
.rules-slide-stage,
#startModal #accountMenuPanel,
#startModal .menu-section {
  touch-action: pan-y;
}

/* Universal Account Modal — Uses visibility/opacity instead of display:none so Google GIS pre-renders in the background */
.bc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 9, 8, 0.88);
  z-index: 15000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(12px, calc(env(safe-area-inset-top, 0px) + 6px))
    max(14px, calc(env(safe-area-inset-right, 0px) + 8px))
    max(12px, calc(env(safe-area-inset-bottom, 0px) + 6px))
    max(14px, calc(env(safe-area-inset-left, 0px) + 8px));
  box-sizing: border-box;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    visibility 0.15s ease;
}

.bc-modal-overlay::-webkit-scrollbar,
.bc-auth-card::-webkit-scrollbar,
.victory-card::-webkit-scrollbar,
.rules-slide-stage::-webkit-scrollbar {
  display: none;
}

.bc-modal-overlay.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.bc-auth-card {
  --eff-modal-scale: var(--bc-modal-scale, var(--ui-scale, 1));
  background: var(--primary-800);
  border: 2px solid var(--primary-700);
  border-radius: 16px;
  padding: 22px 24px;
  width: 100%;
  max-width: min(400px, calc((100vw - 28px) / var(--eff-modal-scale)));
  max-height: calc((100dvh - 24px) / var(--eff-modal-scale));
  zoom: var(--eff-modal-scale);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  color: #ffffff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
  text-align: center;
  box-sizing: border-box;
}

.bc-auth-card.bc-manage-card {
  max-width: min(420px, calc((100vw - 28px) / var(--eff-modal-scale)));
  text-align: left;
}

.bc-auth-card.bc-confirm-card {
  max-width: min(380px, calc((100vw - 28px) / var(--eff-modal-scale)));
}

.bc-manage-grid {
  display: flex;
  flex-direction: column;
}

.bc-manage-confirm-col {
  display: flex;
  flex-direction: column;
}

.bc-auth-card h3 {
  margin: 0 0 6px 0;
  color: #f7efe6;
  font-size: 1.15rem;
  line-height: 1.3;
}

.bc-auth-card p {
  margin: 0 0 16px 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Streamlined Choice Section */
.bc-google-oauth-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 6px;
}

.bc-google-slot {
  position: relative;
  min-height: 44px;
  min-width: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Neutral Loading Spinner (Sibling to #bcGoogleButtonMount) */
.bc-oauth-spinner-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 42px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.bc-oauth-spinner-wrap.hidden {
  display: none !important;
}

.bc-oauth-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(229, 169, 60, 0.25);
  border-top-color: #e5a93c;
  border-radius: 50%;
  animation: bcSpin 0.75s linear infinite;
}

.bc-modal-overlay:not(.open) .bc-oauth-spinner,
.board-loading-overlay:not(.open) .board-loading-spinner {
  animation: none;
}

@keyframes bcSpin {
  to {
    transform: rotate(360deg);
  }
}

.bc-oauth-or {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 12px 0 8px 0;
  font-weight: 800;
}

.bc-email-toggle-link {
  background: transparent;
  border: none;
  color: #e5a93c;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
}

.bc-email-toggle-link:hover {
  filter: brightness(1.12);
}

/* Collapsible Email/Username Drawer */
#bcManualAuthSection {
  display: none;
  text-align: left;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px solid var(--primary-700);
}

#bcManualAuthSection.open {
  display: block;
}

/* Sign In / Create Account Mode Tabs */
.bc-auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: var(--primary-950);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--primary-800);
}

.bc-auth-tab {
  flex: 1;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}

.bc-auth-tab.active {
  background: #e5a93c;
  color: var(--primary-950);
}

.bc-auth-field {
  margin-bottom: 10px;
  text-align: left;
}

.bc-auth-field label {
  display: block;
  font-size: 0.73rem;
  font-weight: 700;
  color: #cbbba8;
  margin-bottom: 4px;
}

.bc-auth-field input {
  width: 100%;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--primary-700);
  background: #140f0d;
  color: #f7efe6;
  font-size: 0.86rem;
  box-sizing: border-box;
}

.bc-auth-field input:focus {
  outline: none;
  border-color: #e5a93c;
}

/* Invisible Honeypot Trap */
.bc-hp-trap {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.bc-auth-error {
  color: #ff6b6b;
  background: rgba(214, 54, 56, 0.14);
  border: 1px solid rgba(214, 54, 56, 0.45);
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: none;
  text-align: left;
}

.bc-auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.bc-modal-btn {
  padding: 9px 14px;
  touch-action: manipulation;
  border-radius: 8px;
  border: 1px solid var(--primary-700);
  background: var(--primary-950);
  color: #f7efe6;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}

.bc-modal-btn:hover:not(:disabled) {
  border-color: #e5a93c;
  color: #e5a93c;
  background: var(--primary-900);
}

.bc-modal-btn.gold {
  background: #e5a93c;
  border-color: #e5a93c;
  color: #181210;
  font-weight: 800;
}

.bc-modal-btn.gold:hover:not(:disabled) {
  background: #e5a93c;
  border-color: #e5a93c;
  filter: brightness(1.08);
  color: #181210;
}

.bc-modal-btn.danger {
  background: #d63638;
  border-color: #ff6b6b;
  color: #ffffff;
  font-weight: 800;
  width: 100%;
}

.bc-modal-btn.danger:hover:not(:disabled) {
  background: #e04345;
  border-color: #ff8787;
  color: #ffffff;
}

.bc-modal-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

/* 3-Tier Deletion Option Radio Cards */
.bc-del-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--primary-950);
  border: 1px solid var(--primary-700);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 7px;
  cursor: pointer;
  text-align: left;
}

.bc-del-option input[type="radio"] {
  margin-top: 3px;
  accent-color: #e5a93c;
}

.bc-del-option strong {
  display: block;
  font-size: 0.78rem;
  margin-bottom: 2px;
}

.bc-del-option span {
  display: block;
  font-size: 0.71rem;
  color: #cbbba8;
  line-height: 1.3;
}

.bc-impact-box {
  background: rgba(214, 54, 56, 0.14);
  border: 1px solid #d63638;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 8px 0 10px 0;
  font-size: 0.74rem;
  color: #f7efe6;
  line-height: 1.35;
  text-align: left;
}

#bc-arcade-root,
.floating-card-clone,
.floating-piece-clone,
.cascade-flying-clone {
  --loom-cell: var(--dynamic-cell, 46px);
  --loom-gap: var(--dynamic-gap, 6px);
}

#bc-arcade-root {
  position: relative;
  width: 100%;
  max-width: 432px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 12px 16px;
  color: var(--text);
  box-sizing: border-box;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.65);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
  zoom: var(--ui-scale, 1);
}

@media (hover: none) and (pointer: coarse) {
  #bc-arcade-root {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55);
  }
}

/* ==========================================================================
   1. TOP HEADER BAR & CONTROLS
   ========================================================================== */
.bc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0;
  width: 100%;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mode-badge {
  display: inline-flex;
  touch-action: manipulation;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--primary-950);
  border: 1px solid var(--primary-950);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: border-color 0.15s ease;
}

.mode-badge:hover {
  border-color: var(--accent);
}

.mode-badge.practice-clickable {
  border-color: rgba(229, 169, 60, 0.35);
}

.mode-seed-tag {
  color: var(--accent);
  font-family: 'Courier New', Courier, monospace;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.seed-input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.seed-dialog-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--primary-700);
  background: var(--primary-950);
  color: var(--accent);
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.12em;
  box-sizing: border-box;
  outline: none;
}

.seed-dialog-input:focus {
  border-color: var(--accent);
}

.seed-copy-link-btn {
  padding: 8px 12px;
  font-size: 0.76rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.mode-badge.ranked {
  border-color: rgba(229, 169, 60, 0.55);
  color: var(--accent);
}

.mode-badge.unranked {
  border-color: rgba(208, 189, 148, 0.45);
  color: var(--muted);
}

.unranked-daily-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(229, 169, 60, 0.11);
  border: 1px solid rgba(229, 169, 60, 0.45);
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
}

.unranked-daily-banner.visible {
  display: flex;
}

.unranked-daily-banner strong,
.trophies-menu-header.guest-gate-banner strong,
.vis-caption b,
.vis-tip-row b {
  color: var(--accent);
}

.menu-split-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
}

.menu-split-row .action-btn {
  min-width: 0;
  padding: 8px 6px;
  font-size: 0.73rem;
  white-space: nowrap;
}

.menu-secondary-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.menu-secondary-row .action-btn {
  flex: 1;
  padding: 8px 8px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.mode-badge.endless {
  border-color: var(--primary-950);
  color: #d6b4fc;
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.mode-badge.endless.score-absorb-pop {
  border-color: var(--accent);
  color: #ffe8a3;
  box-shadow: 0 0 14px rgba(229, 169, 60, 0.55);
  animation: bcScoreAbsorbPulse 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes bcScoreAbsorbPulse {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.score-flying-tile {
  position: fixed;
  top: 0;
  left: 0;
  width: calc(var(--loom-cell) * var(--ui-scale, 1));
  height: calc(var(--loom-cell) * var(--ui-scale, 1));
  pointer-events: none;
  z-index: 9500;
  will-change: transform, opacity;
}

.score-flying-tile .tile {
  border-radius: calc(8px * var(--ui-scale, 1));
  box-shadow:
    0 0 calc(14px * var(--ui-scale, 1)) rgba(229, 169, 60, 0.65),
    0 calc(6px * var(--ui-scale, 1)) calc(14px * var(--ui-scale, 1)) rgba(0, 0, 0, 0.6);
  outline: calc(1.5px * var(--ui-scale, 1)) solid rgba(255, 232, 163, 0.85);
}

.bc-top-right-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.timer-pill {
  background: var(--primary-950);
  border: 1px solid var(--border);
  padding: 5px 11px;
  border-radius: 8px;
  font-family: 'Courier New', Courier, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--accent);
  min-width: 68px;
  text-align: center;
}

.header-btn {
  display: inline-flex;
  touch-action: manipulation;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #191311;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}

.header-btn:hover,
.action-btn:hover:not(:disabled),
.ability-coach-banner .acb-dismiss:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.header-btn.icon-btn {
  width: 32px;
  padding: 0;
}

.header-btn svg,
.action-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.header-btn svg {
  stroke-linecap: round;
  stroke-linejoin: round;
}

