:root {
  --bg: #0b0d10;
  --card: #13161a;
  --muted: #9aa4b2;
  --text: #e7edf5;
  --accent: #ff8a00;
  --accent-2: #3fb950;
  --danger: #ff5c5c;
  --border: #222831;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1200px 600px at 80% -10%, rgba(255,138,0,0.08), transparent),
              radial-gradient(1000px 500px at -10% 0%, rgba(63,185,80,0.12), transparent),
              var(--bg);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.header { margin-bottom: 16px; }
.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.home .title-row { justify-content: center; }
.league .title-row { 
  display: grid; 
  grid-template-columns: 1fr auto 1fr; 
  align-items: center; 
  gap: 24px;
}
.league .title-row h1 { 
  justify-self: center; 
  margin: 0; 
  text-align: center; 
  padding: 0 20px; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  white-space: nowrap; 
  font-size: 22px;
  line-height: 1.2;
  min-width: 0;
}
.league .logo-link { justify-self: start; }
.league .title-actions { justify-self: end; }
/* Thanks page header centered like league */
.thanks .title-row { 
  display: grid; 
  grid-template-columns: 1fr auto 1fr; 
  align-items: center; 
  gap: 24px;
}
.thanks .title-row h1 { 
  justify-self: center; 
  text-align: center; 
  margin: 0; 
  font-size: 22px;
  line-height: 1.2;
  min-width: 0;
}
.thanks .logo-link { justify-self: start; }
.thanks .title-actions { justify-self: end; }
/* Logo sizing - optimized to prevent overlap and maintain proportions */
.logo-img { 
  height: clamp(60px, 6vw, 120px); 
  width: auto; 
  border-radius: 0; 
  display: block; 
}

/* Slightly smaller logo on league pages to avoid crowding */
.league .logo-img { 
  height: clamp(40px, 5vw, 80px); 
}

/* Thanks page logo size */
.thanks .logo-img { 
  height: clamp(40px, 5vw, 80px); 
}

.title-row > * { min-width: 0; }
.logo-link { display: inline-flex; align-items: center; }
.title-actions { display: flex; gap: 8px; align-items: center; }
.header h1 { margin: 0; font-size: 22px; letter-spacing: 0.2px; }
.subtitle { margin: 6px 0 0; color: var(--muted); }
.brand { font-size: 28px; letter-spacing: 0.4px; }
.brand-accent { color: var(--accent); }
.hero { margin-top: 6px; background: linear-gradient(180deg, rgba(255,138,0,0.08), rgba(255,138,0,0) 70%); padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); }

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}
.grid > .card { grid-column: span 6; }
.grid-12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.col-7 { grid-column: span 7; }
.col-5 { grid-column: span 5; }
/* removed .full usage - candle now sits within Live Snapshot card */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.card-light {
  background: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
}
.card-light .card-header { border-bottom: 1px solid #e5e7eb; }
.card-light .card-footer { border-top: 1px solid #e5e7eb; color: #4b5563; }
.card-light .help-text, .card-light .small { color: #4b5563; }
.card-light input[type="text"],
.card-light input[type="email"],
.card-light input[type="number"] {
  background: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
}
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-header h2 { margin: 0; font-size: 16px; letter-spacing: 0.2px; }
.card-body { padding: 16px; }
.card-footer { padding: 10px 16px; border-top: 1px solid var(--border); color: var(--muted); }

.small { font-size: 12px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { border-color: #2a3240; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #000; }
.search-wrap { margin-bottom: 6px; }
.search-input { padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: #0f1216; color: var(--text); width: 100%; }
.cta-card .card-body { display: grid; gap: 8px; align-items: start; }
.cta-card .btn { justify-self: start; }
.btn.primary:hover { filter: brightness(0.95); }
.btn.ghost { background: rgba(255,255,255,0.03); }
.btn.danger { border-color: #3b1f1f; color: #ff9a9a; }

.address-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
}
.address-inputs { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; }
input[type="text"], input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1216;
  color: var(--text);
}
.actions { display: contents; }

.address-meta { display: grid; gap: 8px; }
.meta-row { display: flex; justify-content: space-between; gap: 10px; }
.meta-label { color: var(--muted); }
.meta-value { color: var(--text); text-decoration: none; }
.meta-value:hover { text-decoration: underline; }

.kpis { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.kpi { background: rgba(255,255,255,0.02); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.kpi-label { color: var(--muted); margin-bottom: 6px; }
.kpi-value { font-size: 24px; font-weight: 700; }
.kpi-value.accent { color: var(--accent-2); }
.kpi-sub { color: var(--muted); margin-top: 4px; font-size: 12px; }

/* KPI value row with delta */
.kpi-value-row { display: flex; align-items: baseline; gap: 8px; }
.delta-badge { font-size: 12px; padding: 2px 6px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.delta-up { background: rgba(63,185,80,0.12); color: #57d06e; border-color: rgba(63,185,80,0.35); }
.delta-down { background: rgba(255,92,92,0.12); color: #ff9a9a; border-color: rgba(255,92,92,0.35); }

.controls { display: grid; gap: 8px; margin-bottom: 8px; }
.control-label { color: var(--muted); font-size: 12px; }
.cagr-controls { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.cagr-number { display: flex; align-items: center; gap: 6px; }
.cagr-number input { width: 90px; text-align: right; }
.help-text { margin: 6px 0 0; color: var(--muted); }

.chart-wrap { background: rgba(255,255,255,0.02); border: 1px solid var(--border); border-radius: 12px; padding: 12px; height: 260px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; display: block; }

/* Removed candle container; using standard chart-wrap */

.horiz { height: 1px; background: var(--border); margin: 12px 0; }
.horiz-cards { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.mini-card { background: rgba(255,255,255,0.02); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.mini-label { color: var(--muted); margin-bottom: 4px; }
.mini-value { font-weight: 700; }

.table-wrap { background: rgba(255,255,255,0.02); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.proj-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.proj-table thead { background: #0f1216; color: var(--muted); }
.proj-table th, .proj-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: top; }
.proj-table th:first-child, .proj-table td:first-child { text-align: left; }

/* Specific styling for the payouts table */
.proj-table th:nth-child(1) { width: 25%; } /* Place */
.proj-table th:nth-child(2) { width: 20%; } /* Percent */
.proj-table th:nth-child(3) { width: 55%; } /* Payout (sats + USD) */

/* Ensure text doesn't get cut off in cells */
.proj-table td { word-wrap: break-word; overflow-wrap: break-word; }

.footer { margin-top: 20px; text-align: center; color: var(--muted); }

/* Make all grid cards full width like Fund Address */
.grid > .card { grid-column: span 12; }

/* Keep ability to tweak specific cards later if needed
.grid > .card.card-growth { }
.grid > .card.card-analyzer { }
.grid > .card.card-power { }
.grid > .card.card-payouts { }
*/

/* Hide AI analyzer by default (kept in DOM for future use) */
.card-analyzer { display: none; }

/* Mobile ordering remains the same */
@media (max-width: 920px) {
  .grid { grid-template-columns: 1fr; }
  .grid > .card { grid-column: 1 / -1; }
  .grid > .card:nth-child(1) { order: 1; }
  .grid > .card.card-analyzer { order: 2; }
  .grid > .card.card-payouts { order: 3; }
  .grid > .card.card-power { order: 4; }
  .grid > .card.card-growth { order: 5; }

  .address-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr; }
  .horiz-cards { grid-template-columns: 1fr; }
  /* Ensure long values like BTC addresses and timestamps don't get cut off */
  .meta-row { flex-direction: column; align-items: flex-start; }
  .meta-value { max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
  
  /* Mobile logo sizing - optimized to prevent overlap */
  .logo-img { height: clamp(60px, 10vw, 120px); }
  
  /* Stack logo above league name on mobile to avoid overlap */
  .league .logo-img { height: clamp(40px, 8vw, 64px); }
  .league .title-row { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 8px;
  }
  .league .logo-link { align-self: center; }
  .league .title-row h1 { 
    white-space: normal; 
    text-align: center; 
    font-size: 18px;
    line-height: 1.3;
    padding: 0 12px;
    margin: 0;
  }
  .league .title-actions { align-self: center; margin-top: 4px; }
  
  /* Stack thanks header on mobile */
  .thanks .logo-img { height: clamp(32px, 6vw, 48px); }
  .thanks .title-row { 
    display: grid; 
    grid-template-columns: 1fr; 
    grid-auto-rows: auto; 
    justify-items: center; 
    gap: 16px;
  }
  .thanks .logo-link { grid-column: 1; justify-self: center; }
  .thanks .title-row h1 { 
    grid-column: 1; 
    white-space: normal; 
    text-align: center; 
    font-size: 18px;
    line-height: 1.3;
    padding: 0 12px;
  }
  .thanks .title-actions { grid-column: 1; justify-self: center; margin-top: 6px; }
  
  /* Mobile table handling for payouts */
  .proj-table { font-size: 12px; }
  .proj-table th, .proj-table td { padding: 6px 8px; }
  .proj-table th:nth-child(1) { width: 25%; }
  .proj-table th:nth-child(2) { width: 20%; }
  .proj-table th:nth-child(3) { width: 55%; }
}

/* Upload Section Styles */
.upload-section {
  display: grid;
  gap: 16px;
}

.year-selector {
  display: grid;
  gap: 8px;
}

.year-selector select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1216;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.year-selector select:focus {
  outline: none;
  border-color: var(--accent);
}

.upload-section input[type="file"] {
  padding: 12px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-section input[type="file"]:hover {
  border-color: var(--accent);
  background: rgba(255, 138, 0, 0.05);
}

.upload-section .btn {
  justify-self: start;
  margin-top: 8px;
}

/* Debug JSON area */
.debug-wrap { display: grid; gap: 8px; }
.debug-header { display: flex; align-items: center; justify-content: space-between; }
#aiDebugJson { background: #0f1216; color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 12px; }


