/* ============================================================================
   BuxFlip - Google Material 3 Expressive Theme
   Official Material You / M3 Expressive (2024-2026 Specification)
   Features:
     - Tonal Palette (Deep Surface Container, Primary Purple #D0BCFF)
     - Signature M3 Undulating Wavy Animated Progress Bars
     - Expressive High-Radius Geometry (28px-32px rounded containers)
     - State-layer transitions & tonal elevation shadows
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Google+Sans+Flex:wght@400;500;600;700;800&family=Google+Sans+Text:wght@400;500;700&family=Roboto+Flex:wght@400;500;600;700;800&display=swap');

html[data-theme="material3"],
body[data-theme="material3"] {
  /* ---- M3 Dark Color Tokens (Baseline Purple Tonal Palette) ---- */
  --md-sys-color-primary: #D0BCFF;
  --md-sys-color-on-primary: #381E72;
  --md-sys-color-primary-container: #4F378B;
  --md-sys-color-on-primary-container: #EADDFF;

  --md-sys-color-secondary: #CCC2DC;
  --md-sys-color-on-secondary: #332D41;
  --md-sys-color-secondary-container: #4A4458;
  --md-sys-color-on-secondary-container: #E8DEF8;

  --md-sys-color-tertiary: #EFB8C8;
  --md-sys-color-on-tertiary: #492532;
  --md-sys-color-tertiary-container: #633B48;
  --md-sys-color-on-tertiary-container: #FFD8E4;

  --md-sys-color-background: #141218;
  --md-sys-color-on-background: #E6E1E5;

  --md-sys-color-surface: #141218;
  --md-sys-color-on-surface: #E6E1E5;
  --md-sys-color-surface-variant: #49454F;
  --md-sys-color-on-surface-variant: #CAC4D0;
  --md-sys-color-outline: #938F99;
  --md-sys-color-outline-variant: rgba(202, 196, 208, 0.16);

  --md-sys-color-surface-container-lowest: #0F0D13;
  --md-sys-color-surface-container-low: #1D1B20;
  --md-sys-color-surface-container: #211F26;
  --md-sys-color-surface-container-high: #2B2930;
  --md-sys-color-surface-container-highest: #36343B;

  /* ---- Map M3 to existing site CSS variables ---- */
  --bg: #141218;
  --bg-deep: #0F0D13;
  --surface: #1D1B20;
  --surface-2: #2B2930;
  --surface-3: #36343B;
  --line: rgba(202, 196, 208, 0.14);
  --line-hi: rgba(208, 188, 255, 0.28);

  --vio: #D0BCFF;
  --vio-2: #4F378B;
  --cy: #A8C7FA;
  --gold: #FFD978;
  --grn: #8CD888;
  --red: #F2B8B5;

  --txt: #E6E1E5;
  --mut: #CAC4D0;
  --dim: #938F99;

  /* M3 Expressive High-Radius Geometry */
  --rad: 28px;
  --rad-sm: 16px;
  --rad-lg: 32px;

  /* M3 Elevation Box Shadows */
  --shadow-card: 0 1px 3px 1px rgba(0,0,0,0.22), 0 1px 2px 0 rgba(0,0,0,0.3);
  --glow-vio: 0 4px 16px rgba(208, 188, 255, 0.22);
  --glow-cy: 0 4px 16px rgba(168, 199, 250, 0.2);
  --tr: 0.24s cubic-bezier(0.2, 0, 0, 1);

  --fd: 'Google Sans Flex', 'Google Sans Text', 'Roboto Flex', -apple-system, sans-serif;
  --fb: 'Google Sans Text', 'Roboto Flex', -apple-system, sans-serif;
  background: var(--bg) !important;
  color: #E6E1E5 !important;
}

/* ────────────────────────────────────────────────────────────────────────────
   M3 EXPRESSIVE SIGNATURE: UNDULATING WAVY ANIMATED PROGRESS BARS & SLIDERS
   True continuous sinusoidal wave — gradient fills a sliding wave-shaped mask
   ──────────────────────────────────────────────────────────────────────────── */
@keyframes m3WaveScroll {
  0%   { background-position: 0 center; }
  100% { background-position: 80px center; }
}

/* Wavy fill applied to Level Progress, Quests, Daily Rewards, Limbo & Rain */
body[data-theme="material3"] #acct-level-pbar,
body[data-theme="material3"] #daily-pbar-fill,
body[data-theme="material3"] .bar > i,
body[data-theme="material3"] .lb-stage .bar i,
body[data-theme="material3"] #lv-pool-prog-bar,
body[data-theme="material3"] #rain-fund-bar,
body[data-theme="material3"] .bw-prog-bar {
  position: relative !important;
  height: 14px !important;
  background-color: transparent !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='14' viewBox='0 0 80 14'%3E%3Cdefs%3E%3ClinearGradient id='wg' x1='0%25' y1='0%25' x2='100%25' y2='0%25'%3E%3Cstop offset='0%25' stop-color='%23D0BCFF'/%3E%3Cstop offset='33%25' stop-color='%23A8C7FA'/%3E%3Cstop offset='66%25' stop-color='%23C6EFFF'/%3E%3Cstop offset='100%25' stop-color='%23D0BCFF'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M0,7 Q10,2 20,7 T40,7 T60,7 T80,7' fill='none' stroke='url(%23wg)' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: repeat-x !important;
  background-size: 80px 14px !important;
  background-position: 0 center !important;
  -webkit-mask-image: none !important;
  mask-image: none !important;
  animation: m3WaveScroll 1.2s linear infinite !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  filter: drop-shadow(0 0 8px rgba(208, 188, 255, 0.55)) !important;
  min-width: 14px !important;
  overflow: visible !important;
}

/* Track container: NO empty border, NO dark background underneath */
body[data-theme="material3"] .bar,
body[data-theme="material3"] #acct-level-pbar-wrap,
body[data-theme="material3"] #daily-pbar-wrap,
body[data-theme="material3"] .lb-stage .bar,
body[data-theme="material3"] .bw-prog,
body[data-theme="material3"] #lv-rain-progress-wrap > div:last-child {
  height: 14px !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 0 !important;
  overflow: visible !important;
}

/* Material 3 Expressive Header */
body[data-theme="material3"] .hdr,
body[data-theme="material3"] header.nav {
  background: rgba(29, 27, 32, 0.92) !important;
  backdrop-filter: blur(20px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(160%) !important;
  border-bottom: 1px solid var(--line) !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3) !important;
}

body[data-theme="material3"] header.nav::after {
  background: linear-gradient(90deg, transparent, #D0BCFF, #CCC2DC, transparent) !important;
  opacity: 0.6 !important;
}

/* Material 3 Expressive Rounded Cards & Surfaces */
body[data-theme="material3"] .card,
body[data-theme="material3"] .tbl,
body[data-theme="material3"] .panel,
body[data-theme="material3"] .modal-card {
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--rad) !important;
  box-shadow: var(--shadow-card) !important;
  transition: transform var(--tr), box-shadow var(--tr), background var(--tr);
}

body[data-theme="material3"] .card:hover,
body[data-theme="material3"] .tbl:hover {
  background: var(--surface-2) !important;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35), 0 0 16px rgba(208, 188, 255, 0.15) !important;
}

/* Material 3 Game Deck Tiles */
body[data-theme="material3"] .tile {
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  border-radius: 26px !important;
  box-shadow: var(--shadow-card) !important;
  transition: transform var(--tr), box-shadow var(--tr), border-color var(--tr) !important;
}

body[data-theme="material3"] .tile:hover {
  transform: translateY(-4px) !important;
  background: var(--surface-2) !important;
  border-color: var(--vio) !important;
  box-shadow: 0 12px 28px rgba(0,0,0,0.4), 0 0 20px rgba(208, 188, 255, 0.22) !important;
}

/* Material 3 Tonal Pill Buttons */
body[data-theme="material3"] .btn {
  border-radius: 999px !important;
  font-family: var(--fd) !important;
  font-weight: 600 !important;
  letter-spacing: 0.15px !important;
  padding: 10px 24px !important;
  background: var(--vio) !important;
  color: #381E72 !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25) !important;
  transition: all var(--tr) !important;
}

body[data-theme="material3"] .btn:hover {
  transform: translateY(-1.5px) !important;
  box-shadow: 0 6px 16px rgba(208, 188, 255, 0.38) !important;
  filter: brightness(1.06) !important;
}

body[data-theme="material3"] .btn.gh,
body[data-theme="material3"] .btn.ghost {
  background: rgba(255,255,255,0.06) !important;
  color: var(--txt) !important;
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
}

body[data-theme="material3"] .btn.gh:hover {
  background: rgba(255,255,255,0.12) !important;
  border-color: var(--vio) !important;
}

/* Material 3 Expressive Chips & Pills */
body[data-theme="material3"] .chip,
body[data-theme="material3"] .pill,
body[data-theme="material3"] .tag {
  border-radius: 12px !important;
  border: 1px solid var(--line) !important;
  background: var(--surface-2) !important;
  color: var(--txt) !important;
  padding: 6px 14px !important;
  font-weight: 500 !important;
}

/* Material 3 Inputs with Focus Indicator */
body[data-theme="material3"] input,
body[data-theme="material3"] select,
body[data-theme="material3"] textarea {
  border-radius: 16px !important;
  background: var(--surface-2) !important;
  border: 1px solid var(--line) !important;
  color: var(--txt) !important;
  padding: 12px 18px !important;
  transition: border-color var(--tr), box-shadow var(--tr) !important;
}

body[data-theme="material3"] input:focus,
body[data-theme="material3"] select:focus,
body[data-theme="material3"] textarea:focus {
  border-color: var(--vio) !important;
  box-shadow: 0 0 0 2px rgba(208, 188, 255, 0.35) !important;
  outline: none !important;
}

/* ────────────────────────────────────────────────────────────────────────────
   GAME-SPECIFIC MATERIAL 3 EXPRESSIVE RENDERING
   Transforms games (Coinflip, Limbo, Mines, Towers, Blackjack)
   into Google Material 3 Tonal Containers & Expressive Motion
   ──────────────────────────────────────────────────────────────────────────── */

/* Coinflip: Official M3 Tonal Medallion */
body[data-theme="material3"] .cf-heads {
  background: #4F378B !important;
  color: #D0BCFF !important;
  border: 3px solid #D0BCFF !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 20px rgba(208, 188, 255, 0.3) !important;
  text-shadow: none !important;
}

body[data-theme="material3"] .cf-heads .cf-emboss {
  color: #EADDFF !important;
}

body[data-theme="material3"] .cf-tails {
  background: #4A4458 !important;
  color: #CCC2DC !important;
  border: 3px solid #CCC2DC !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 20px rgba(204, 194, 220, 0.3) !important;
  text-shadow: none !important;
}

body[data-theme="material3"] .cf-tails .cf-emboss {
  color: #E8DEF8 !important;
}

/* Limbo: M3 Tonal Stage */
body[data-theme="material3"] .lb-stage {
  background: #2B2930 !important;
  border: 1.5px solid rgba(202, 196, 208, 0.2) !important;
  border-radius: 28px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3) !important;
}

body[data-theme="material3"] .lb-stage .mult {
  color: #D0BCFF !important;
  font-family: 'Google Sans Flex', -apple-system, sans-serif !important;
  text-shadow: 0 0 20px rgba(208, 188, 255, 0.35) !important;
}

/* Towers & Mines: M3 Pill Tonal Tiles */
body[data-theme="material3"] .tw-t,
body[data-theme="material3"] .mn-t {
  background: #211F26 !important;
  border: 1.5px solid rgba(202, 196, 208, 0.15) !important;
  border-radius: 16px !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2) !important;
  transition: transform 0.2s ease, background 0.2s ease !important;
}

body[data-theme="material3"] .tw-row.active .tw-t:hover,
body[data-theme="material3"] .mn-t:hover {
  background: #2B2930 !important;
  border-color: #D0BCFF !important;
  transform: translateY(-2px) !important;
}

body[data-theme="material3"] .tw-t.safe,
body[data-theme="material3"] .mn-t.safe {
  background: #1D3B23 !important;
  border-color: #8CD888 !important;
  color: #8CD888 !important;
  box-shadow: 0 4px 14px rgba(140, 216, 136, 0.3) !important;
}

body[data-theme="material3"] .tw-t.trap,
body[data-theme="material3"] .mn-t.trap {
  background: #4E1A1A !important;
  border-color: #F2B8B5 !important;
  color: #F2B8B5 !important;
  box-shadow: 0 4px 14px rgba(242, 184, 181, 0.3) !important;
}

/* Blackjack: M3 Tonal Surface Cards */
body[data-theme="material3"] .cardp {
  background: #E6E1E5 !important;
  color: #141218 !important;
  border: 1px solid rgba(20,18,24,0.15) !important;
  border-radius: 14px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
}

body[data-theme="material3"] .cardp.back {
  background: #4F378B !important;
  border: 1px solid #D0BCFF !important;
  box-shadow: 0 4px 12px rgba(79, 55, 139, 0.4) !important;
}

/* Navigation & Rails */
body[data-theme="material3"] .bfx-left-rail,
body[data-theme="material3"] .g-rail,
body[data-theme="material3"] .mobile-menu-drawer {
  background: rgba(29, 27, 32, 0.96) !important;
  border: 1px solid var(--line) !important;
  border-radius: 28px !important;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6) !important;
}

body[data-theme="material3"] .nav-theme-btn {
  background: var(--surface-2) !important;
  border-color: var(--line-hi) !important;
  color: var(--vio) !important;
}


/* ============================================================================
   ACCOUNT PAGE & SECONDARY PAGES — Material 3 Expressive full coverage
   kpis, kpi, .row, .notice, .ptab, .hero, .big, .skel, .foot,
   about/announcements/fairness, theme selector cards
   ============================================================================ */

/* ── KPI Grid ── */
body[data-theme="material3"] .kpis {
  background: transparent !important;
  border: 1px solid rgba(202, 196, 208, 0.15) !important;
  border-radius: 28px !important;
  overflow: hidden !important;
}

body[data-theme="material3"] .kpi {
  background: #1D1B20 !important;
  border: 0 !important;
  border-right: 1px solid rgba(202, 196, 208, 0.10) !important;
  transition: background .2s ease !important;
}

body[data-theme="material3"] .kpi:hover {
  background: #2B2930 !important;
}

body[data-theme="material3"] .kpi .k {
  color: #CAC4D0 !important;
  font-size: 10px !important;
  letter-spacing: .14em !important;
}

body[data-theme="material3"] .kpi .v {
  color: #E6E1E5 !important;
  font-weight: 700 !important;
}

body[data-theme="material3"] .kpi.hot .v {
  color: #D0BCFF !important;
}

/* ── Rows (label / value pairs inside cards) ── */
body[data-theme="material3"] .row {
  border-bottom-color: rgba(202, 196, 208, 0.12) !important;
}

body[data-theme="material3"] .row .l {
  color: #CAC4D0 !important;
  font-size: 13.5px !important;
}

body[data-theme="material3"] .row .r {
  color: #E6E1E5 !important;
}

/* ── Notice / dashed info boxes ── */
body[data-theme="material3"] .notice {
  background: rgba(208, 188, 255, 0.06) !important;
  border: 1px dashed rgba(208, 188, 255, 0.3) !important;
  border-radius: 20px !important;
  color: #CAC4D0 !important;
}

/* ── Hero section (account top) ── */
body[data-theme="material3"] .hero .big {
  color: #E6E1E5 !important;
}

body[data-theme="material3"] .hero .big small {
  color: #CAC4D0 !important;
  font-size: .34em !important;
}

body[data-theme="material3"] .kicker {
  color: #D0BCFF !important;
  letter-spacing: .16em !important;
}

/* ── Skeleton loader ── */
body[data-theme="material3"] .skel {
  background: linear-gradient(90deg, #211F26 25%, #2B2930 37%, #211F26 63%) !important;
  background-size: 400% 100% !important;
  border: 1px solid rgba(202,196,208,0.08) !important;
  border-radius: 20px !important;
  animation: shim 1.4s linear infinite !important;
}

/* ── Data table for recent rounds ── */
body[data-theme="material3"] .ptab th {
  color: #CAC4D0 !important;
  border-bottom-color: rgba(202,196,208,0.18) !important;
  font-size: 10.5px !important;
}

body[data-theme="material3"] .ptab td {
  border-bottom-color: rgba(202,196,208,0.08) !important;
  color: #E6E1E5 !important;
}

body[data-theme="material3"] .ptab tbody tr:hover td {
  background: rgba(208,188,255,0.05) !important;
}

body[data-theme="material3"] .ptab td.g {
  color: #D0BCFF !important;
}

/* ── Win / Loss colours ── */
body[data-theme="material3"] .win { color: #8CD888 !important; }
body[data-theme="material3"] .loss { color: #F2B8B5 !important; }

/* ── Chip/badge labels ── */
body[data-theme="material3"] .chip {
  background: #2B2930 !important;
  border: 1px solid rgba(202,196,208,0.2) !important;
  color: #CAC4D0 !important;
  border-radius: 999px !important;
  padding: 3px 12px !important;
  font-size: 12px !important;
}

/* ── Theme selector cards on account page ── */
body[data-theme="material3"] [data-set-theme] {
  background: rgba(208,188,255,0.04) !important;
  border: 1.5px solid rgba(202,196,208,0.14) !important;
  border-radius: 28px !important;
  transition: border-color .25s, background .25s !important;
}

body[data-theme="material3"] [data-set-theme]:hover {
  background: rgba(208,188,255,0.09) !important;
  border-color: #D0BCFF !important;
}

/* ── Footer ── */
body[data-theme="material3"] .foot {
  border-top-color: rgba(202,196,208,0.12) !important;
  color: #6A6572 !important;
}

body[data-theme="material3"] .foot a:hover { color: #D0BCFF !important; }


/* ── About / Announcements / Fairness prose ── */
body[data-theme="material3"] .prose p,
body[data-theme="material3"] .about-body p,
body[data-theme="material3"] article p,
body[data-theme="material3"] .page-body p {
  color: #CAC4D0 !important;
  line-height: 1.65 !important;
}

body[data-theme="material3"] .prose h2,
body[data-theme="material3"] .prose h3,
body[data-theme="material3"] article h2,
body[data-theme="material3"] article h3 {
  color: #E6E1E5 !important;
}

body[data-theme="material3"] .prose a,
body[data-theme="material3"] article a {
  color: #D0BCFF !important;
}

body[data-theme="material3"] .ann-card,
body[data-theme="material3"] .fair-block,
body[data-theme="material3"] .faq-item {
  background: #211F26 !important;
  border: 1px solid rgba(202,196,208,0.15) !important;
  border-radius: 28px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35) !important;
}

/* ── Nav links (M3 active style) ── */
body[data-theme="material3"] .nav-links a[aria-current] {
  background: rgba(208,188,255,0.12) !important;
  color: #D0BCFF !important;
  border-radius: 999px !important;
}

body[data-theme="material3"] .nav-links a:hover {
  color: #E6E1E5 !important;
  background: rgba(208,188,255,0.07) !important;
}

/* ── PORTFOLIO / WALLET MODAL (Material 3 Expressive) ── */
body[data-theme="material3"] .bw-modal {
  background: #1D1B20 !important;
  border: 1px solid rgba(202, 196, 208, 0.18) !important;
  border-radius: 28px !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.75) !important;
}

body[data-theme="material3"] .bw-head {
  background: #25232A !important;
  border-bottom: 1px solid rgba(202, 196, 208, 0.12) !important;
}

body[data-theme="material3"] .bw-tabs {
  border-bottom: 1px solid rgba(202, 196, 208, 0.12) !important;
}

body[data-theme="material3"] .bw-tab {
  color: #CAC4D0 !important;
  border-radius: 999px 999px 0 0 !important;
}

body[data-theme="material3"] .bw-tab:hover {
  color: #E6E1E5 !important;
  background: rgba(208, 188, 255, 0.06) !important;
}

body[data-theme="material3"] .bw-tab[aria-selected="true"] {
  color: #D0BCFF !important;
  border-bottom-color: #D0BCFF !important;
  font-weight: 700 !important;
}

body[data-theme="material3"] .bw-card,
body[data-theme="material3"] .bw-box {
  background: #211F26 !important;
  border: 1px solid rgba(202, 196, 208, 0.14) !important;
  border-radius: 20px !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25) !important;
}

body[data-theme="material3"] .bw-card:hover {
  background: #2B2930 !important;
  border-color: #D0BCFF !important;
  transform: translateY(-2px) !important;
}

body[data-theme="material3"] .bw-shine-box {
  background: #2B2930 !important;
  border: 1px solid rgba(208, 188, 255, 0.3) !important;
  border-radius: 24px !important;
}

body[data-theme="material3"] .bw-btn.primary {
  background: #D0BCFF !important;
  color: #381E72 !important;
  border-radius: 999px !important;
  box-shadow: 0 4px 16px rgba(208, 188, 255, 0.3) !important;
}

body[data-theme="material3"] .bw-btn.primary:hover {
  filter: brightness(1.08) !important;
}

body[data-theme="material3"] .bw-btn.ghost {
  border-radius: 999px !important;
  border-color: rgba(202, 196, 208, 0.25) !important;
}

body[data-theme="material3"] .bw-f input,
body[data-theme="material3"] .bw-f select {
  background: #211F26 !important;
  border: 1px solid rgba(202, 196, 208, 0.2) !important;
  border-radius: 16px !important;
  color: #E6E1E5 !important;
}

body[data-theme="material3"] .bw-f input:focus,
body[data-theme="material3"] .bw-f select:focus {
  border-color: #D0BCFF !important;
  box-shadow: 0 0 12px rgba(208, 188, 255, 0.25) !important;
}

