:root {
  /* MINING SIMULATOR — mineshaft palette
     Variable names preserved (used widely in inline styles).
     Values shift to warm browns + lantern amber + iron grey. */
  --bg-primary:    #0d0907;       /* deepest tunnel — coal black with brown */
  --bg-secondary:  #1d130c;       /* support beam shadow */
  --bg-tertiary:   #2a1d12;       /* lit stone */
  --bg-card:       #3a2a1c;       /* parchment-on-wood (poster) */
  --bg-card-hover: #4a3624;
  --bg-surface:    #1a120a;       /* cave floor */
  --text-primary:  #f3e0bf;       /* lantern-lit cream */
  --text-secondary:#c8a77a;       /* dusty parchment ink */
  --text-muted:    #8a6d4a;       /* shadow brown */
  --accent-orange: #ff8a3a;       /* torch flame (a touch warmer) */
  --accent-orange-glow: rgba(255,138,58,.45);
  --accent-gold:   #f6c25a;       /* brass lantern */
  --accent-gold-glow: rgba(246,194,90,.35);
  --accent-blue:   #6da7ff;       /* gemstone vein */
  --accent-blue-glow: rgba(109,167,255,.3);
  --accent-purple: #a86bff;       /* amethyst */
  --accent-purple-glow: rgba(168,107,255,.3);
  --accent-teal:   #5dd6b0;       /* copper-patina */
  --accent-teal-glow: rgba(93,214,176,.3);
  --accent-green:  #7ed957;       /* moss / fern */
  --accent-green-glow: rgba(126,217,87,.3);
  --accent-red:    #e5544c;       /* danger / dynamite */
  --accent-pink:   #e76a9b;
  --border:        rgba(255,210,150,.10);
  --border-light:  rgba(255,210,150,.18);
  --border-accent: rgba(255,138,58,.35);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.55);
  --shadow-md: 0 4px 16px rgba(0,0,0,.65);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.75);
  --shadow-glow-orange: 0 0 20px rgba(255,138,58,.18);
  --shadow-glow-gold:   0 0 20px rgba(246,194,90,.18);

  /* New mineshaft-only tokens */
  --wood-dark:     #2d1d10;
  --wood-mid:      #4a2f18;
  --wood-light:    #6b4226;
  --wood-grain:    rgba(0,0,0,.45);
  --stone-base:    #1a1208;
  --stone-tint:    rgba(255,180,90,.04);
  --parchment:     #e8d5a8;
  --parchment-dark:#c8a878;
  --parchment-ink: #2c1c0a;
  --iron-dark:     #2a2118;
  --iron-mid:      #4a3e30;
  --iron-light:    #6a5a48;
  --rivet:         radial-gradient(circle at 35% 35%, #b8a884 0%, #6b5a3e 40%, #2a1d10 100%);
  --lantern-flame: radial-gradient(ellipse at 50% 60%, #fff5b8 0%, #ff8a3a 50%, #7a3508 100%);

  --font-display: 'Exo 2', sans-serif;
  --font-body: 'Chakra Petch', sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}
*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent;user-select:none;-webkit-user-select:none}
html,body,#root{width:100%;height:100%;overflow:hidden}
html{height:-webkit-fill-available;background:#0d0907}
body{
  background:
    /* warm lantern light from the centre */
    radial-gradient(ellipse at 50% 38%, rgba(255,170,80,.10), transparent 55%),
    /* dirt floor at the bottom */
    radial-gradient(ellipse at 50% 110%, rgba(80,40,16,.55), transparent 55%),
    /* fine "stone speckle" via repeating dots */
    radial-gradient(circle at 17% 33%, rgba(255,200,140,.04) 0 1.5px, transparent 2px),
    radial-gradient(circle at 82% 62%, rgba(255,200,140,.03) 0 1.5px, transparent 2px),
    radial-gradient(circle at 28% 78%, rgba(255,200,140,.04) 0 1.5px, transparent 2px),
    radial-gradient(circle at 64% 18%, rgba(255,200,140,.03) 0 1.5px, transparent 2px),
    /* base cave-stone gradient */
    linear-gradient(180deg, #1c130b 0%, #0e0805 70%, #060302 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height:100dvh; min-height:-webkit-fill-available;
  touch-action:manipulation; overscroll-behavior:none;
  position: relative;
}
/* Faint cave vignette + tunnel-edge shadow rails */
body::before{
  content:"";
  position: fixed; inset:0;
  pointer-events:none; z-index:0;
  background:
    /* left rail of darkness */
    linear-gradient(90deg, rgba(0,0,0,.55) 0%, transparent 14%, transparent 86%, rgba(0,0,0,.55) 100%),
    /* top dark cap */
    linear-gradient(180deg, rgba(0,0,0,.55) 0%, transparent 18%);
}
#root { position: relative; z-index: 1; }
button{touch-action:manipulation;font-family:var(--font-body);cursor:pointer;border:none;outline:none}
img{-webkit-user-drag:none}
::-webkit-scrollbar{width:5px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:rgba(255,255,255,.12);border-radius:10px}
::-webkit-scrollbar-thumb:hover{background:rgba(255,255,255,.2)}
input[type=range]{-webkit-appearance:none;appearance:none;background:transparent;cursor:pointer;width:100%}
input[type=range]::-webkit-slider-track{height:4px;background:var(--bg-tertiary);border-radius:2px}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;border-radius:50%;background:var(--accent-orange);margin-top:-6px;box-shadow:0 0 6px var(--accent-orange-glow)}

/* Loading screen — lantern in a tunnel */
#loader{
  position:fixed; inset:0; z-index:9999;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255,180,80,.15), transparent 50%),
    linear-gradient(180deg, #1c130b, #060302);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:20px; transition:opacity .5s;
}
#loader.done{opacity:0;pointer-events:none}
#loader .gear-spin{
  width:80px; height:80px;
  transform-origin: 50% 6%; /* swing from chain top */
  animation: lanternSwing 2.4s ease-in-out infinite;
  filter: drop-shadow(0 0 14px rgba(255,170,80,.55));
}
#loader .bar{
  width:220px; height:6px;
  background: linear-gradient(180deg, #2a1d12, #1a1208);
  border:1px solid var(--wood-mid);
  border-radius: 3px;
  overflow:hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.6);
}
#loader .bar-fill{height:100%;background:linear-gradient(90deg,var(--accent-orange),var(--accent-gold));border-radius:2px;animation:loaderBar 1.5s ease-in-out infinite}
#loader .title{
  font-family: var(--font-display);
  font-size: 30px; font-weight: 900;
  background: linear-gradient(180deg, #fff5b8 0%, var(--accent-gold) 50%, #7a4a08 100%);
  -webkit-background-clip:text; -webkit-text-fill-color:transparent;
  letter-spacing: 4px;
  text-shadow: 0 2px 0 rgba(0,0,0,.6);
  filter: drop-shadow(0 0 10px rgba(246,194,90,.35));
}
@keyframes loaderSpin{to{transform:rotate(360deg)}}
@keyframes lanternSwing{
  0%,100% { transform: rotate(-12deg); }
  50%     { transform: rotate( 12deg); }
}
@keyframes loaderBar{0%{width:0}50%{width:100%}100%{width:0;margin-left:100%}}

/* Animations */
@keyframes fadeIn{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}
@keyframes fadeInUp{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
@keyframes slideDown{from{opacity:0;transform:translateY(-20px)}to{opacity:1;transform:translateY(0)}}
@keyframes slideUp{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}
@keyframes scaleIn{from{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}
@keyframes clickFloat{0%{opacity:1;transform:translateY(0) scale(1)}100%{opacity:0;transform:translateY(-50px) scale(1.3)}}
@keyframes pulseGlow{0%,100%{box-shadow:0 0 8px var(--accent-orange-glow)}50%{box-shadow:0 0 20px var(--accent-orange-glow)}}
@keyframes shakeX{0%,100%{transform:translateX(0)}10%,30%,50%,70%,90%{transform:translateX(-2px)}20%,40%,60%,80%{transform:translateX(2px)}}
/* Phase 3: cargo-full shake — fired by tapMineCell/autoMineCell when a break would overflow cargoMax(). */
@keyframes cargoShake{0%,100%{transform:translateX(0)}15%{transform:translateX(-4px)}30%{transform:translateX(4px)}45%{transform:translateX(-3px)}60%{transform:translateX(3px)}80%{transform:translateX(-1px)}}
.cargo-shake{animation:cargoShake .3s ease-in-out;box-shadow:0 0 14px rgba(239,68,68,.7);}
/* Phase 6: tap juice — floating "+N ORE" / "+N CR" numbers spawned on rock break, fade upward & out. */
@keyframes floatUp{0%{opacity:0;transform:translate(-50%,0) scale(.85)}15%{opacity:1;transform:translate(-50%,-8px) scale(1.05)}100%{opacity:0;transform:translate(-50%,-46px) scale(1)}}
.float-num{position:absolute;left:50%;top:50%;pointer-events:none;z-index:55;
  font-family:var(--font-display);font-weight:900;font-size:clamp(10px,2.4vw,11px);letter-spacing:.5px;
  text-shadow:0 1px 2px rgba(0,0,0,.85),0 0 8px rgba(0,0,0,.5);
  animation:floatUp .6s ease-out forwards;white-space:nowrap}
/* Phase 6: crit screen-shake — body translates ±2px for 80ms when a crit lands. Disabled under prefers-reduced-motion. */
@keyframes critShake{0%,100%{transform:translate(0,0)}25%{transform:translate(-2px,1px)}50%{transform:translate(2px,-1px)}75%{transform:translate(-1px,2px)}}
.crit-shake{animation:critShake 80ms ease-in-out;}
@media (prefers-reduced-motion: reduce) {
  .crit-shake{animation:none !important;}
  .float-num{animation:none !important;opacity:0 !important;}
}
@keyframes goldenRain{0%{opacity:1;transform:translateY(0) rotate(0deg)}100%{opacity:0;transform:translateY(100vh) rotate(720deg)}}
@keyframes cosmicWarp{0%{transform:scale(1) rotate(0);filter:hue-rotate(0deg)}50%{transform:scale(1.5) rotate(180deg);filter:hue-rotate(180deg)}100%{transform:scale(0) rotate(360deg);filter:hue-rotate(360deg)}}
@keyframes notifPulse{0%,100%{transform:scale(1)}50%{transform:scale(1.2)}}
@keyframes borderGlow{0%,100%{border-color:rgba(255,109,46,.3)}50%{border-color:rgba(255,109,46,.7)}}
@keyframes floatY{0%,100%{transform:translateY(0)}50%{transform:translateY(-4px)}}
@keyframes spinSlow{to{transform:rotate(360deg)}}

/* SPAWN button — idle halo + press impact. The button itself owns a chunky
   layered box-shadow stack, so the halo lives on a ::after pseudo to avoid
   clobbering it. .full state suppresses the halo and tightens the cursor. */
#tap-card{position:relative}
#tap-card::after{
  content:'';position:absolute;inset:-4px;border-radius:20px;
  pointer-events:none;box-shadow:0 0 8px 0 var(--accent-orange-glow);
  opacity:0;transition:opacity .25s
}
#tap-card[data-state="ready"]::after{opacity:1;animation:spawnHalo 2.4s ease-in-out infinite}
#tap-card[data-state="ready"]:hover{transform:translateY(-1px)}
#tap-card[data-state="full"]{cursor:not-allowed}
#tap-card .tap-pip.on{animation:pipPop .22s ease-out}
@keyframes spawnHalo{
  0%,100%{box-shadow:0 0 8px 0 var(--accent-orange-glow)}
  50%    {box-shadow:0 0 24px 6px var(--accent-orange-glow)}
}
@keyframes spawnPunch{
  0%   {transform:translateY(0)}
  35%  {transform:translateY(5px) scale(.985)}
  65%  {transform:translateY(-2px) scale(1.01)}
  100% {transform:translateY(0)}
}
@keyframes pipPop{
  0%  {transform:scale(.6)}
  60% {transform:scale(1.18)}
  100%{transform:scale(1)}
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Particle container */
.particles{position:fixed;inset:0;pointer-events:none;z-index:1000;overflow:hidden}
.particle{position:absolute;border-radius:50%;animation:goldenRain linear forwards}

/* Toast */
.toast{position:fixed;top:70px;left:50%;transform:translateX(-50%);z-index:800;
  background:var(--bg-card);border:1px solid var(--accent-teal);border-radius:var(--radius-md);
  padding:8px 20px;font-weight:600;font-size:clamp(10px,2.4vw,11px);color:var(--accent-teal);
  box-shadow:var(--shadow-md),0 0 12px var(--accent-teal-glow);
  animation:slideDown .3s ease-out;pointer-events:none;white-space:nowrap}

/* Achievement popup */
.ach-popup{position:fixed;top:70px;left:50%;transform:translateX(-50%);z-index:900;
  background:linear-gradient(135deg,#2a1f00,#1a1500);border:2px solid var(--accent-gold);
  border-radius:var(--radius-lg);padding:12px 28px;
  box-shadow:var(--shadow-lg),0 0 30px var(--accent-gold-glow);
  display:flex;align-items:flex-start;gap:12px;animation:slideDown .4s ease-out;pointer-events:none}

/* Modal overlay */

/* Notification dot */
.notif-dot{position:absolute;top:-2px;right:-2px;width:8px;height:8px;border-radius:50%;
  background:var(--accent-red);border:2px solid var(--bg-secondary);animation:notifPulse 1.5s infinite}

/* ============================================================
   MINESHAFT AESTHETIC POLISH (v9.1)
   Surface treatments only — no layout changes. Adds lantern-lit
   highlights, faint stone/wood grain, and brass-rivet accents to
   existing `.panel-card`, `#tabs-bar`, `#mine-cargo-bar`, etc.
   ============================================================ */

/* Panel cards: warm parchment-on-wood with a top lantern highlight and
   a faint "old paper" grain. The ::before pseudo paints a thin gold
   sheen at the top edge so cards feel lit from above. */
.panel-card{
  background:
    /* faint stone speckle */
    radial-gradient(circle at 22% 18%, rgba(255,210,150,.04) 0 1px, transparent 2px),
    radial-gradient(circle at 78% 72%, rgba(255,210,150,.035) 0 1px, transparent 2px),
    /* warm vertical fade — top is "lit", bottom recedes */
    linear-gradient(180deg, rgba(255,180,90,.05) 0%, transparent 30%),
    /* base card colour */
    var(--bg-card) !important;
  border-color: rgba(255,180,90,.14) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.10),
    inset 0 -1px 0 rgba(0,0,0,.45),
    0 4px 14px rgba(0,0,0,.55);
}
.panel-card::before{
  content:''; position:absolute; left:10px; right:10px; top:0; height:1px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,200,140,.55) 50%, transparent 100%);
  pointer-events:none; opacity:.7;
}
.panel-card-title{
  text-shadow: 0 1px 0 rgba(0,0,0,.55), 0 0 8px rgba(246,194,90,.25);
}

/* Tab bar — wooden support beam */
#tabs-bar{
  background:
    /* subtle wood-grain via thin diagonals */
    repeating-linear-gradient(96deg, rgba(0,0,0,.18) 0 1px, transparent 1px 6px),
    linear-gradient(180deg, var(--wood-mid) 0%, var(--wood-dark) 100%) !important;
  border: 1px solid rgba(0,0,0,.55);
  box-shadow:
    inset 0 1px 0 rgba(255,200,140,.12),
    inset 0 -2px 4px rgba(0,0,0,.45),
    0 2px 6px rgba(0,0,0,.55);
}
#tabs-bar [data-tab]{
  position:relative;
  text-shadow: 0 1px 0 rgba(0,0,0,.55);
}
/* Active tab: brass-plate look with a thin gold underline */
#tabs-bar [data-tab][style*="bg-card"],
#tabs-bar [data-tab][style*="background: var(--bg-card)"]{
  background:
    linear-gradient(180deg, #4a3624 0%, #2a1d12 100%) !important;
  border: 1px solid rgba(246,194,90,.45) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.20),
    inset 0 -1px 0 rgba(0,0,0,.55),
    0 0 10px rgba(246,194,90,.18);
}
/* Brass rivets in the corners of every tab — small radial highlights */
#tabs-bar [data-tab]::before,
#tabs-bar [data-tab]::after{
  content:''; position:absolute; width:3px; height:3px; border-radius:50%;
  background: var(--rivet);
  box-shadow: 0 1px 0 rgba(0,0,0,.55);
  pointer-events:none; opacity:.55;
}
#tabs-bar [data-tab]::before{ top:3px; left:3px; }
#tabs-bar [data-tab]::after{ bottom:3px; right:3px; }

/* v18 — #mine-cargo-bar is now a transparent wrapper around "The Mine"
   panel-card (its old job as a standalone cargo-bar widget went away when
   Sell was folded into Mine). We only keep:
     - position: relative so children can absolutely-position against it
     - border-radius matching the panel-card so the cargo-full glow + shake
       box-shadow read as a rounded halo, not a square box around it
   The rail-car gradient / border / floating rivets were removed: the
   panel-card inside already provides the visible surface, and the rivets
   weren't connecting to any edge that read as a display. */
#mine-cargo-bar{
  position: relative;
  border-radius: var(--radius-lg);
}

/* Goal Tracker compact strip — chevron-style label glow */
.goal-tracker{
  position:relative;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.10),
    0 1px 4px rgba(0,0,0,.45);
}
.goal-tracker > span:first-child{
  text-shadow: 0 1px 0 rgba(0,0,0,.55), 0 0 6px rgba(246,194,90,.35);
}

/* HUD top strip / header bar treatments — the currency strip at the top
   of the screen. Targets common ids/classes used by the renderer. */
#hud, #hud-bar, .hud-bar, [data-role="hud"]{
  background:
    repeating-linear-gradient(96deg, rgba(0,0,0,.15) 0 1px, transparent 1px 7px),
    linear-gradient(180deg, var(--wood-mid) 0%, var(--wood-dark) 100%) !important;
  border-bottom: 1px solid rgba(0,0,0,.55) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.12),
    inset 0 -2px 6px rgba(0,0,0,.55);
}

/* Modals — lantern-lit parchment with a thin gold frame */
.modal{
  background:
    radial-gradient(ellipse at 50% -20%, rgba(255,180,90,.10), transparent 60%),
    var(--bg-card) !important;
  border: 1.5px solid rgba(246,194,90,.35) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.18),
    0 12px 40px rgba(0,0,0,.75),
    0 0 24px rgba(246,194,90,.18);
}

/* Mining grid cells — slight inner shadow so rocks "sit in" the cell. */
#mining-grid [data-cell]{
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.06),
    inset 0 -2px 6px rgba(0,0,0,.55);
}

/* Buttons feel pressed against wood — chunky 3D bevel */
button{
  text-shadow: 0 1px 0 rgba(0,0,0,.45);
}


/* Tooltip */
.tip{position:absolute;z-index:600;background:var(--bg-primary);border:1px solid var(--border-light);
  border-radius:var(--radius-sm);padding:8px 12px;font-size:clamp(10px,2.4vw,11px);color:var(--text-secondary);
  box-shadow:var(--shadow-md);pointer-events:none;white-space:nowrap;animation:fadeIn .15s ease-out}

/* Locked tab — greyed-out tab button + chunky cartoon lock tooltip on hover.
   The tooltip sits below the tab so it doesn't clip against the top header,
   centred horizontally with a triangle pointer aimed up at the tab. Wood-card
   surface, thick gold border, display-font heading. */
.tab-locked{ position:relative; }
.tab-locked:hover{ opacity:.6 !important; }
.tab-lock-tip{
  position:absolute; left:50%; top:calc(100% + 8px); transform:translateX(-50%);
  z-index:900; min-width:160px; max-width:240px;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255,180,90,.12), transparent 60%),
    var(--bg-card);
  border:2px solid #f6c25a;
  border-radius:var(--radius-md);
  padding:8px 10px 8px;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.18),
    0 6px 18px rgba(0,0,0,.65),
    0 0 12px rgba(246,194,90,.25);
  color:var(--text-secondary);
  font-size:clamp(10px,2.3vw,11px);
  text-align:center;
  pointer-events:none;
  animation:fadeIn .12s ease-out;
  white-space:normal;
  line-height:1.35;
}
.tab-lock-tip::before{
  content:'';
  position:absolute; left:50%; top:-7px; transform:translateX(-50%) rotate(45deg);
  width:10px; height:10px;
  background:var(--bg-card);
  border-left:2px solid #f6c25a;
  border-top:2px solid #f6c25a;
  border-top-left-radius:2px;
}
/* Floating variant — body-attached via position:fixed in JS so it escapes
   ancestor stacking contexts / overflow:hidden. The pointer triangle's X
   position is driven by --tip-arrow-x set in placeTip() so the arrow stays
   centred on the tab even when the tooltip is clamped against a viewport edge. */
.tab-lock-tip-floating{ left:0; top:0; transform:none; z-index:9999 !important; }
.tab-lock-tip-floating::before{
  left:var(--tip-arrow-x, 50%);
  transform:translateX(-50%) rotate(45deg);
}
.tab-lock-tip-title{
  font-family:var(--font-display);
  font-weight:800;
  font-size:clamp(10px,2.5vw,12px);
  color:#f6c25a;
  letter-spacing:.6px;
  text-transform:uppercase;
  text-shadow:0 1px 0 rgba(0,0,0,.65);
  margin-bottom:3px;
}
.tab-lock-tip-line{
  color:var(--text-secondary);
  font-weight:600;
}
.tab-lock-tip-line + .tab-lock-tip-line{
  margin-top:2px;
  color:var(--accent-orange);
  font-variant-numeric:tabular-nums;
}

/* Phase 1 UX overhaul — "DO THIS NEXT" pill.
   Pinned to the top of the Mine card. Chunky-cartoon: thick gold border,
   warm radial top-glow, inner highlight + drop shadow. Pulse-arrow on the
   left keeps the eye drawn to the goal label; the bar at the bottom fills
   left→right with the orange→gold income gradient as credits accrue. */
.next-goal-pill{
  display:flex; flex-direction:column; gap:4px;
  margin:0 0 8px;
  padding:7px 10px;
  background:
    radial-gradient(ellipse at 50% -20%, rgba(255,180,90,.10), transparent 60%),
    var(--bg-card);
  border:2px solid #f6c25a;
  border-radius:var(--radius-md);
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.18),
    0 2px 6px rgba(0,0,0,.45),
    0 0 10px rgba(246,194,90,.18);
}
.next-goal-label{
  display:flex; align-items:center; gap:6px;
  font-family:var(--font-display); font-weight:800;
  font-size:clamp(10px,2.4vw,12px);
  color:#f6c25a; letter-spacing:.5px;
  text-shadow:0 1px 0 rgba(0,0,0,.6);
}
.next-goal-arrow{ color:var(--accent-orange); animation:pillArrow 1.4s ease-in-out infinite; }
/* Category chip — colour-coded per goal type. Mirrors the rarity-chip pattern
   (dark backdrop + tinted border + tinted text) so the prefix reads as a tag
   distinct from the goal label that follows. */
.next-goal-cat{
  display:inline-block;
  padding:1px 6px;
  border-radius:4px;
  font-family:var(--font-display); font-weight:800;
  font-size:clamp(10px,2.2vw,11px);
  letter-spacing:.6px;
  background:rgba(0,0,0,.45);
  border:1px solid rgba(255,255,255,.18);
  text-shadow:0 1px 0 rgba(0,0,0,.6);
  flex:0 0 auto;
}
.next-goal-cat[data-cat="DEPTH"]   { color:var(--accent-teal);   border-color:var(--accent-teal); }
.next-goal-cat[data-cat="DRILL"]   { color:var(--accent-blue);   border-color:var(--accent-blue); }
.next-goal-cat[data-cat="PICKAXE"] { color:var(--accent-orange); border-color:var(--accent-orange); }
.next-goal-cat[data-cat="UPGRADE"] { color:var(--accent-purple); border-color:var(--accent-purple); }
.next-goal-cat[data-cat="PRESTIGE"]{ color:#5ee9d3;              border-color:#5ee9d3; }
.next-goal-text{ flex:1; color:var(--text-primary); text-transform:uppercase; }
.next-goal-cost{ color:var(--accent-gold); font-variant-numeric:tabular-nums; }
.next-goal-bar{ height:5px; background:rgba(0,0,0,.5); border-radius:3px; overflow:hidden;
  border:1px solid rgba(0,0,0,.6); box-shadow:inset 0 1px 1px rgba(0,0,0,.5); }
.next-goal-bar-fill{ height:100%;
  background:linear-gradient(90deg, var(--accent-orange), var(--accent-gold));
  transition:width .2s; }
@keyframes pillArrow{ 0%,100%{ transform:translateX(0); } 50%{ transform:translateX(3px); } }

/* v20 — Welcome-back modal. Fires on return after ≥30 min of absence with
   per-ore breakdown and total. Wood-card surface + thick gold border to
   match the chunky-cartoon aesthetic; cinematicBloom ring behind the title
   for a scaled-down version of the reset cinematics. */
.welcome-back-overlay{
  position:fixed; inset:0; z-index:8000;
  background:rgba(0,0,0,.78);
  display:flex; align-items:center; justify-content:center;
  animation:fadeIn .25s ease-out;
  padding:16px;
}
.welcome-back-card{
  position:relative; z-index:2;
  width:min(360px, 100%);
  background:
    radial-gradient(ellipse at 50% -20%, rgba(255,180,90,.18), transparent 65%),
    var(--bg-card);
  border:3px solid #f6c25a;
  border-radius:var(--radius-lg);
  padding:22px 22px 18px;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.22),
    0 16px 50px rgba(0,0,0,.75),
    0 0 28px rgba(246,194,90,.30);
  text-align:center;
  animation:scaleIn .35s cubic-bezier(0.34,1.56,0.64,1);
}
.welcome-back-bloom{
  position:absolute;
  left:50%; top:50%;
  width:240px; height:240px;
  border:3px solid rgba(246,194,90,.55);
  border-radius:50%;
  transform:translate(-50%,-50%) scale(0);
  animation:cinematicBloom 1.4s ease-out forwards;
  pointer-events:none;
  z-index:1;
}
.welcome-back-title{
  font-family:var(--font-display);
  font-weight:800;
  font-size:clamp(18px,5vw,26px);
  color:#f6c25a;
  letter-spacing:1.5px;
  text-shadow:0 2px 0 rgba(0,0,0,.6), 0 0 12px rgba(246,194,90,.35);
  margin-bottom:4px;
}
.welcome-back-sub{
  color:var(--text-secondary);
  font-size:clamp(10px,2.6vw,12px);
  margin-bottom:14px;
}
.welcome-back-chips{
  display:flex; flex-wrap:wrap; gap:5px; justify-content:center;
  margin:0 0 14px;
  max-height:90px; overflow:hidden;
}
.welcome-back-chip{
  position:static !important;
  top:auto !important; left:auto !important;
  white-space:nowrap;
}
.welcome-back-total{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 14px;
  background:rgba(0,0,0,.4);
  border:1px solid rgba(246,194,90,.35);
  border-radius:var(--radius-md);
  margin-bottom:14px;
}
.welcome-back-total-label{
  font-family:var(--font-display); font-weight:700;
  font-size:clamp(10px,2.5vw,12px);
  color:var(--text-secondary);
  letter-spacing:.8px;
}
.welcome-back-total-value{
  font-family:var(--font-display); font-weight:800;
  font-size:clamp(16px,4vw,22px);
  color:var(--accent-gold);
  text-shadow:0 1px 0 rgba(0,0,0,.6);
  font-variant-numeric:tabular-nums;
}
.welcome-back-claim{
  width:100%;
  padding:12px 18px;
  background:linear-gradient(135deg, var(--accent-orange), #e85d1e);
  color:#fff;
  border:none; border-radius:var(--radius-md);
  font-family:var(--font-display); font-weight:800;
  font-size:clamp(12px,3vw,15px);
  letter-spacing:1.2px;
  cursor:pointer;
  box-shadow:0 4px 0 #b84a1a, 0 6px 18px rgba(232,93,30,.4);
  transition:transform .08s, box-shadow .08s;
}
.welcome-back-claim:active{
  transform:translateY(2px);
  box-shadow:0 2px 0 #b84a1a, 0 3px 10px rgba(232,93,30,.4);
}

/* v20 — Prestige intro modal. Reuses the welcome-back chunky-cartoon shell
   (gold border + wood card + cinematicBloom ring behind the title) and adds
   a teal glyph header + three explainer bullets. Same overlay class so the
   fade + scaleIn animations are shared. */
.prestige-intro-card{
  width:min(420px, 100%);
  border-color:#5ee9d3;
  box-shadow:
    inset 0 1px 0 rgba(210,255,245,.22),
    0 16px 50px rgba(0,0,0,.75),
    0 0 28px rgba(94,233,211,.35);
}
.prestige-intro-overlay .welcome-back-bloom{
  border-color:rgba(94,233,211,.55);
}
.prestige-intro-glyph{
  width:54px; height:54px;
  margin:0 auto 6px;
  filter:drop-shadow(0 4px 10px rgba(94,233,211,.5));
}
.prestige-intro-title{
  color:#5ee9d3 !important;
  text-shadow:0 2px 0 rgba(0,0,0,.6), 0 0 14px rgba(94,233,211,.45) !important;
}
.prestige-intro-bullets{
  display:flex; flex-direction:column; gap:10px;
  margin:14px 0;
  text-align:left;
}
.prestige-intro-bullet{
  display:flex; gap:10px;
  padding:9px 11px;
  background:rgba(0,0,0,.35);
  border:1px solid rgba(94,233,211,.25);
  border-radius:var(--radius-md);
}
.prestige-intro-bullet-icon{
  flex:0 0 auto;
  width:28px; height:28px;
  display:inline-flex; align-items:center; justify-content:center;
  font-family:var(--font-display); font-weight:900;
  font-size:18px;
  color:#5ee9d3;
  background:rgba(94,233,211,.12);
  border:1.5px solid #5ee9d3;
  border-radius:50%;
  text-shadow:0 1px 0 rgba(0,0,0,.5);
}
.prestige-intro-bullet-title{
  font-family:var(--font-display); font-weight:800;
  font-size:clamp(10px,2.4vw,12px);
  color:#5ee9d3;
  letter-spacing:.6px;
  margin-bottom:2px;
}
.prestige-intro-bullet-body{
  font-size:clamp(10px,2.4vw,12px);
  color:var(--text-secondary);
  line-height:1.4;
}

/* v20 — Streak-at-risk pulse for the HUD daily gift button. Triggered when
   ≥18h since last claim and streak ≥2. Red glow draws the eye without
   blocking the icon. */
[data-urgent="1"]{
  animation:streakUrgent 1.2s ease-in-out infinite;
  box-shadow:0 0 0 0 rgba(239,68,68,.55);
}
@keyframes streakUrgent{
  0%,100%{ box-shadow:0 0 0 0 rgba(239,68,68,.0); }
  50%{ box-shadow:0 0 14px 4px rgba(239,68,68,.65); }
}

/* Drag ghost */
[draggable=true]{cursor:grab}
[draggable=true]:active{cursor:grabbing;opacity:.6}

/* Rewarded ad button style */
.ad-btn{background:linear-gradient(135deg,var(--accent-gold),var(--accent-orange));color:#fff;
  border-radius:var(--radius-md);padding:8px 12px;font-weight:700;font-size:clamp(10px,2.4vw,11px);
  display:flex;align-items:center;justify-content:center;gap:4px;
  box-shadow:0 2px 0 rgba(0,0,0,.2);transition:transform .1s}
.ad-btn:active{transform:scale(.96)}

/* Connection lines between spinning gears */
.grid-line{position:absolute;background:var(--accent-teal);opacity:.15;pointer-events:none;z-index:0;border-radius:1px}
#loader .subtitle{font-family:var(--font-display);font-size:clamp(10px,2.4vw,11px);font-weight:600;color:#64748b;letter-spacing:4px;text-transform:uppercase;margin-top:-2px}

/* Side banner slide animation */
@keyframes slideRight{from{transform:translateY(-50%) translateX(-100%);opacity:0}to{transform:translateY(-50%) translateX(0);opacity:1}}

/* Mobile landscape: ensure left area fits without vertical scroll */
@media (max-height:500px) and (orientation:landscape){
  .modal{padding:16px 20px;max-height:95dvh}
  .modal-overlay{align-items:flex-start;padding-top:8px}
}

/* Mobile portrait: prevent horizontal overflow */
@media (max-width:480px){
  body{overflow-x:hidden;max-width:100vw}
  .modal{width:96%;padding:20px 16px;max-height:85dvh}
}

/* Ensure main container never overflows */
html,body{overflow-x:hidden;max-width:100vw}

/* ============================================================
   RESPONSIVE LAYOUT — keep side-by-side at every width.
   Tabs/Upgrades panel always stays on the RIGHT. The LEFT cluster
   (tap card + mining grid) shrinks as the viewport narrows so the
   pair always fits in a single horizontal row.
   ============================================================ */

/* Wide viewports (≥1200px) — scale the mining grid UP so the gap between
   grid and tabs panel shrinks. The base JS sets cellPx to 131 / 96 / 76 for
   3 / 4 / 5 cols, tuned for the ~800-1000px embed range; at desktop fullscreen
   that left dead space alongside the right column. These rules grow the grid
   in two tiers and also lift the tabs panel's max-width so it can come closer. */
@media (min-width: 1200px) {
  #main-row {
    padding: 10px 24px !important;
    gap: 24px !important;
    justify-content: flex-start !important;
  }
  #main-row > div:last-child {
    max-width: 640px !important;
  }
  #mining-grid[data-cols="3"] {
    grid-template-columns: repeat(3, 160px) !important;
    grid-template-rows:    repeat(3, 160px) !important;
  }
  #mining-grid[data-cols="3"] > [data-cell] { width: 160px !important; height: 160px !important; }
  #mining-grid[data-cols="4"] {
    grid-template-columns: repeat(4, 122px) !important;
    grid-template-rows:    repeat(3, 122px) !important;
  }
  #mining-grid[data-cols="4"] > [data-cell] { width: 122px !important; height: 122px !important; }
  #mining-grid[data-cols="5"] {
    grid-template-columns: repeat(5, 98px) !important;
    grid-template-rows:    repeat(4, 98px) !important;
  }
  #mining-grid[data-cols="5"] > [data-cell] { width: 98px !important; height: 98px !important; }
  #mining-grid .rock-svg { width: 134px !important; height: 134px !important; }
  #mining-grid[data-cols="4"] .rock-svg { width: 100px !important; height: 100px !important; }
  #mining-grid[data-cols="5"] .rock-svg { width: 80px !important; height: 80px !important; }
}

@media (min-width: 1500px) {
  #main-row {
    padding: 12px 32px !important;
    gap: 32px !important;
  }
  #main-row > div:last-child {
    max-width: 760px !important;
  }
  #mining-grid[data-cols="3"] {
    grid-template-columns: repeat(3, 184px) !important;
    grid-template-rows:    repeat(3, 184px) !important;
  }
  #mining-grid[data-cols="3"] > [data-cell] { width: 184px !important; height: 184px !important; }
  #mining-grid[data-cols="4"] {
    grid-template-columns: repeat(4, 142px) !important;
    grid-template-rows:    repeat(3, 142px) !important;
  }
  #mining-grid[data-cols="4"] > [data-cell] { width: 142px !important; height: 142px !important; }
  #mining-grid[data-cols="5"] {
    grid-template-columns: repeat(5, 112px) !important;
    grid-template-rows:    repeat(4, 112px) !important;
  }
  #mining-grid[data-cols="5"] > [data-cell] { width: 112px !important; height: 112px !important; }
  #mining-grid .rock-svg { width: 154px !important; height: 154px !important; }
  #mining-grid[data-cols="4"] .rock-svg { width: 116px !important; height: 116px !important; }
  #mining-grid[data-cols="5"] .rock-svg { width: 92px !important; height: 92px !important; }
}

/* CrazyGames 800-960px embed range — tighten paddings and shrink LEFT
   cluster slightly so it leaves room for the tabs panel. */
@media (max-width: 960px) {
  #main-row { padding: 6px 8px !important; gap: 8px !important; }
  #main-row > div:last-child {
    min-width: 220px !important;
    max-width: 320px !important;
  }
  #tap-card { width: 172px !important; padding: 12px 12px 10px !important; }
  #tap-card #tap-card-pips { grid-template-columns: repeat(var(--pip-cols, 3), 12px) !important; grid-template-rows: repeat(var(--pip-rows, 3), 12px) !important; gap: 3px !important; }
  #tap-card #tap-card-pips > div { width: 12px !important; height: 12px !important; }
  #mining-grid[data-cols="3"] {
    grid-template-columns: repeat(3, 88px) !important;
    grid-template-rows:    repeat(3, 88px) !important;
  }
  #mining-grid[data-cols="3"] > [data-cell] { width: 88px !important; height: 88px !important; }
  #mining-grid[data-cols="4"] {
    grid-template-columns: repeat(4, 66px) !important;
    grid-template-rows:    repeat(3, 66px) !important;
  }
  #mining-grid[data-cols="4"] > [data-cell] { width: 66px !important; height: 66px !important; }
  #mining-grid[data-cols="5"] {
    grid-template-columns: repeat(5, 52px) !important;
    grid-template-rows:    repeat(4, 52px) !important;
  }
  #mining-grid[data-cols="5"] > [data-cell] { width: 52px !important; height: 52px !important; }
  #mining-grid .rock-svg { width: 76px !important; height: 76px !important; }
  #mining-grid[data-cols="4"] .rock-svg { width: 56px !important; height: 56px !important; }
  #mining-grid[data-cols="5"] .rock-svg { width: 44px !important; height: 44px !important; }
}

/* 720-800px — tighter still, panel shrinks to ~200px. */
@media (max-width: 800px) {
  #main-row > div:last-child {
    min-width: 200px !important;
    max-width: 280px !important;
  }
  #tap-card { width: 152px !important; padding: 10px 10px 8px !important; }
  #tap-card #tap-card-pips { grid-template-columns: repeat(var(--pip-cols, 3), 11px) !important; grid-template-rows: repeat(var(--pip-rows, 3), 11px) !important; gap: 3px !important; margin-bottom: 7px !important; }
  #tap-card #tap-card-pips > div { width: 11px !important; height: 11px !important; }
  #tap-card > div:nth-child(3) { font-size: 20px !important; letter-spacing: 2px !important; }
  #mining-grid[data-cols="3"] {
    grid-template-columns: repeat(3, 76px) !important;
    grid-template-rows:    repeat(3, 76px) !important;
  }
  #mining-grid[data-cols="3"] > [data-cell] { width: 76px !important; height: 76px !important; }
  #mining-grid[data-cols="4"] {
    grid-template-columns: repeat(4, 56px) !important;
    grid-template-rows:    repeat(3, 56px) !important;
  }
  #mining-grid[data-cols="4"] > [data-cell] { width: 56px !important; height: 56px !important; }
  #mining-grid[data-cols="5"] {
    grid-template-columns: repeat(5, 44px) !important;
    grid-template-rows:    repeat(4, 44px) !important;
  }
  #mining-grid[data-cols="5"] > [data-cell] { width: 44px !important; height: 44px !important; }
  #mining-grid .rock-svg { width: 64px !important; height: 64px !important; }
  #mining-grid[data-cols="4"] .rock-svg { width: 48px !important; height: 48px !important; }
  #mining-grid[data-cols="5"] .rock-svg { width: 38px !important; height: 38px !important; }
  /* Drop the connector line — it's purely decorative and saves 10px. */
  #main-row > div:first-child > div:nth-child(2) { display: none !important; }
}

/* 540-640px — mobile landscape / small embed — shrink further. */
@media (max-width: 640px) {
  #main-row > div:last-child {
    min-width: 180px !important;
    max-width: 240px !important;
  }
  #tap-card { width: 124px !important; padding: 8px 8px 7px !important; }
  #tap-card #tap-card-pips { grid-template-columns: repeat(var(--pip-cols, 3), 9px) !important; grid-template-rows: repeat(var(--pip-rows, 3), 9px) !important; gap: 2px !important; margin-bottom: 6px !important; }
  #tap-card #tap-card-pips > div { width: 9px !important; height: 9px !important; }
  #tap-card > div:nth-child(3) { font-size: 17px !important; letter-spacing: 1.5px !important; margin-bottom: 5px !important; }
  #tap-card #tap-card-timer { font-size: clamp(10px, 2.4vw, 11px) !important; letter-spacing: .3px !important; }
  #mining-grid[data-cols="3"] {
    grid-template-columns: repeat(3, 64px) !important;
    grid-template-rows:    repeat(3, 64px) !important;
  }
  #mining-grid[data-cols="3"] > [data-cell] { width: 64px !important; height: 64px !important; }
  #mining-grid[data-cols="4"] {
    grid-template-columns: repeat(4, 48px) !important;
    grid-template-rows:    repeat(3, 48px) !important;
  }
  #mining-grid[data-cols="4"] > [data-cell] { width: 48px !important; height: 48px !important; }
  #mining-grid[data-cols="5"] {
    grid-template-columns: repeat(5, 38px) !important;
    grid-template-rows:    repeat(4, 38px) !important;
  }
  #mining-grid[data-cols="5"] > [data-cell] { width: 38px !important; height: 38px !important; }
  #mining-grid .rock-svg { width: 54px !important; height: 54px !important; }
  #mining-grid[data-cols="4"] .rock-svg { width: 40px !important; height: 40px !important; }
  #mining-grid[data-cols="5"] .rock-svg { width: 32px !important; height: 32px !important; }
}

/* Mobile portrait ≤480px — tap card stacks ABOVE grid inside the LEFT
   cluster (column layout) so total cluster width = grid width. Right panel
   gets ~150-180px which is enough for upgrade cards to read. */
@media (max-width: 480px) {
  #main-row > div:first-child {
    flex-direction: column !important;
    gap: 4px !important;
  }
  #main-row > div:last-child {
    min-width: 150px !important;
    max-width: 220px !important;
  }
  #tap-card { width: 100% !important; max-width: 240px !important; padding: 10px 12px 8px !important; }
  #tap-card #tap-card-pips { grid-template-columns: repeat(var(--pip-cols, 3), 12px) !important; grid-template-rows: repeat(var(--pip-rows, 3), 12px) !important; gap: 3px !important; }
  #tap-card #tap-card-pips > div { width: 12px !important; height: 12px !important; }
  #mining-grid[data-cols="3"] {
    grid-template-columns: repeat(3, 56px) !important;
    grid-template-rows:    repeat(3, 56px) !important;
  }
  #mining-grid[data-cols="3"] > [data-cell] { width: 56px !important; height: 56px !important; }
  #mining-grid .rock-svg { width: 48px !important; height: 48px !important; }
}

@media (max-width: 380px) {
  #main-row > div:last-child {
    min-width: 130px !important;
    max-width: 180px !important;
  }
  #mining-grid[data-cols="3"] {
    grid-template-columns: repeat(3, 48px) !important;
    grid-template-rows:    repeat(3, 48px) !important;
  }
  #mining-grid[data-cols="3"] > [data-cell] { width: 48px !important; height: 48px !important; }
  #mining-grid .rock-svg { width: 40px !important; height: 40px !important; }
}

/* Short viewports (CrazyGames embed at 16:9 or rotated landscape phones).
   Tightens vertical spacing so the bottom of the tabs panel isn't clipped. */
@media (max-height: 620px) {
  #main-row { padding-top: 4px !important; padding-bottom: 4px !important; gap: 8px !important; }
  /* Short viewports — pip grid + chunky title already auto-fit; nothing to clamp here */
}

@media (max-height: 480px) {
  #tap-card { padding: 8px 10px 6px !important; }
  #tap-card #tap-card-pips { margin-bottom: 5px !important; }
  #tap-card > div:nth-child(3) { font-size: 18px !important; margin-bottom: 4px !important; }
}

/* Header (top bar) — tighter padding on narrow screens so credits + buttons
   don't overflow on a 360px wide phone. (Longhand !important + placed after the
   safe-area block below so it wins per-sub-property while still honoring insets.) */

/* ============================================================
   v23 — Top-bar banner + mobile/Chromebook scroll affordances.
   ============================================================ */

/* CrazyGames banner — sits in the top bar between the title and the coins.
   Background matches the top bar's brown (--bg-secondary) so the side gaps around
   a narrower ad blend into the bar instead of showing grey; the injected ad
   wrapper is transparent so that brown shows through its margins. */
.cg-banner-inline {
  background: var(--bg-secondary);
  max-height: 90px;
}
.cg-banner-inline iframe,
.cg-banner-inline > div { margin: 0 auto !important; background: transparent !important; }
/* Keep the banner INLINE between the title and coins on normal/preview widths
   ([title · banner · coins]). Only on genuinely tiny phones — where a 320px
   banner can't fit beside the title + coins — drop it to its own full-width line
   (.top-bar is flex-wrap:wrap; order:3 + 100% basis wraps it cleanly to line 2). */
/* Below here even logo + 320 banner + coins can't share a line, so the banner
   (priority 2) drops to its own full-width row — coins (priority 1) stay on top. */
@media (max-width: 680px) {
  .cg-banner-inline {
    order: 3;
    flex: 1 0 100% !important;
    max-width: 100% !important;
    margin: 6px 0 0 !important;
  }
}

/* Top-bar priority: coins (1) > banner (2) > title (3). The title is the only
   shrinkable element, so the coins are never pushed off the top line. As width
   tightens the wordmark shrinks, then hides (logo-only) BEFORE the banner has to
   wrap, so coins never get bumped. */
.top-title { flex: 0 1 auto; min-width: 0; overflow: hidden; }
@media (max-width: 960px) { .top-title-text { font-size: 15px !important; } }
@media (max-width: 820px) { .top-title-text { font-size: 13px !important; } }
@media (max-width: 780px) { .top-title-text { display: none !important; } }

/* Mobile safe-area insets (notch / rounded corners / home indicator). The
   viewport is viewport-fit=cover, so without this the top bar (title/coins/
   banner) and the bottom status bar can be cropped by the device's unsafe edges.
   max() keeps the original padding on normal screens and only grows it where an
   inset exists; !important is needed to beat the inline padding set via el(). */
.top-bar {
  padding-top: max(10px, env(safe-area-inset-top, 0px)) !important;
  padding-left: max(16px, env(safe-area-inset-left, 0px)) !important;
  padding-right: max(16px, env(safe-area-inset-right, 0px)) !important;
}
#status-bar {
  padding-bottom: max(5px, env(safe-area-inset-bottom, 0px)) !important;
  padding-left: max(16px, env(safe-area-inset-left, 0px)) !important;
  padding-right: max(16px, env(safe-area-inset-right, 0px)) !important;
}

/* Narrow-screen top-bar tightening — placed AFTER the safe-area block so its
   equal-specificity !important longhands win per sub-property, while still
   floored by the device inset. Restores 6px/8px on a ~360px phone. */
@media (max-width: 480px) {
  .top-bar {
    gap: 4px !important;
    padding-top: max(6px, env(safe-area-inset-top, 0px)) !important;
    padding-left: max(8px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(8px, env(safe-area-inset-right, 0px)) !important;
    padding-bottom: 6px !important;
  }
}

/* Visible, themed scrollbars so players on Chromebook / desktop can SEE that the
   side panels scroll (default thin overlay bars were nearly invisible). */
.scroll-area { scrollbar-width: thin; scrollbar-color: var(--accent-orange) transparent; }
.scroll-area::-webkit-scrollbar { width: 8px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.scroll-area::-webkit-scrollbar-thumb {
  background: var(--accent-orange); border-radius: 8px;
  border: 2px solid transparent; background-clip: padding-box;
}

/* Right-panel "more below" chevron — pinned to the bottom of #right-column,
   fades in via updateScrollHint() when content runs past the fold. */
.scroll-hint {
  position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%);
  z-index: 30; pointer-events: none;
  width: 24px; height: 24px; line-height: 24px; text-align: center;
  font-size: 16px; color: var(--accent-orange);
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: 50%; box-shadow: 0 2px 8px rgba(0,0,0,.4);
  opacity: 0; transition: opacity .2s ease;
  animation: scrollHintBob 1.4s ease-in-out infinite;
}
@keyframes scrollHintBob {
  0%, 100% { margin-bottom: 0; }
  50%      { margin-bottom: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .scroll-hint { animation: none !important; }
}

/* ---- Landscape (incl. Chromebook): keep both columns inside the viewport and
   let them scroll internally so nothing gets clipped off the bottom. ---- */
@media (orientation: landscape) and (max-height: 760px) {
  #main-row { overflow: hidden !important; align-items: stretch !important; }
  #left-column { max-height: 100% !important; overflow-y: auto !important; }
  #right-column { max-height: 100% !important; }
}

/* ---- Portrait: stack grid over the tabs panel so the panel gets the FULL
   width and a comfortable scroll height instead of a cramped narrow column. The
   whole row scrolls as one (no tiny nested scroll box). ---- */
@media (orientation: portrait) and (max-width: 640px) {
  /* flex-direction:column + align-items:stretch are declared once in the
     broader (max-width:640px) stack rule below; this portrait-only block adds
     the single-page scroll + spacing on top so the two rules don't compete. */
  #main-row {
    overflow-y: auto !important;
    gap: 10px !important;
  }
  #main-row > #left-column,
  #main-row > div:first-of-type { align-self: center !important; flex: 0 0 auto !important; }
  #right-column {
    max-width: 100% !important; min-width: 0 !important; width: 100% !important;
    max-height: none !important; flex: 1 1 auto !important;
  }
  /* Panel grows with its content; the page scrolls, so no inner clip. */
  #right-column #tab-content { overflow-y: visible !important; flex: 0 0 auto !important; }
  /* In this single-scroll layout the chevron isn't meaningful — hide it. */
  #right-scroll-hint { display: none !important; }
}
/* Modal overlay - position modals in bottom-left */
/* Modal overlay */
.modal-overlay{position:fixed;inset:0;z-index:700;background:rgba(0,0,0,.7);
  backdrop-filter:blur(8px);display:flex;align-items:center;justify-content:center;
  animation:fadeIn .2s ease-out}
.modal{background:var(--bg-card);border:1px solid var(--border-light);
  border-radius:var(--radius-xl);padding:28px 32px;max-width:440px;width:94%;
  box-shadow:var(--shadow-lg);text-align:center;animation:scaleIn .3s ease-out;
  max-height:calc(100dvh - 20px);overflow-y:auto;overflow-x:hidden;
  overscroll-behavior:contain}

/* Small screens (Chromebooks and below): reduce padding so modal content fits without cropping */
@media (max-height:720px){
  .modal{padding:18px 20px}
  .modal-overlay{align-items:center;padding:8px}
}
@media (max-height:520px){
  .modal{padding:14px 16px;max-height:calc(100dvh - 12px)}
}

/* Ad popup entrance - dramatic pulse + slide */
@keyframes adPulseGlow{0%,100%{box-shadow:var(--shadow-lg)}50%{box-shadow:var(--shadow-lg),0 0 40px rgba(255,215,0,.5)}}
@keyframes adShake{0%,100%{transform:translateX(0)}25%{transform:translateX(-2px)}75%{transform:translateX(2px)}}
@keyframes adBounce{0%{transform:translateY(40px) scale(.85);opacity:0}60%{transform:translateY(-8px) scale(1.03);opacity:1}100%{transform:translateY(0) scale(1);opacity:1}}
@keyframes adIconSpin{0%{transform:rotate(-10deg) scale(.8)}50%{transform:rotate(8deg) scale(1.1)}100%{transform:rotate(0) scale(1)}}
@keyframes adShine{0%{transform:translateX(-100%)}100%{transform:translateX(200%)}}

/* Pickaxe swing animation */
@keyframes pickSwing{
  0%  { transform: rotate(-55deg) scale(1.15); opacity:1; }
  60% { transform: rotate(18deg)  scale(1);    opacity:1; }
  85% { transform: rotate(8deg)   scale(.95);  opacity:.85; }
  100%{ transform: rotate(14deg)  scale(.9);   opacity:0; }
}

/* ============================================================
   MINING SIMULATOR — extra effects
   ============================================================ */

/* #10: Ore particle animation */
@keyframes oreParticle {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  70%  { opacity: 0.8; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0.3); opacity: 0; }
}

/* #12 / #18: Scale-in modal animation */
@keyframes scaleIn {
  0%   { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

/* Achievement slide-up */
@keyframes slideUp {
  0%   { transform: translateX(-50%) translateY(30px); opacity: 0; }
  100% { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

/* #42: Voidstone warp ring */
@keyframes voidWarp {
  0%   { transform: scale(1)    rotate(0deg);   opacity: 0.7; }
  50%  { transform: scale(1.06) rotate(180deg); opacity: 0.4; }
  100% { transform: scale(1)    rotate(360deg); opacity: 0.7; }
}

/* #2: Combo display pulse */
@keyframes comboPulse {
  0%   { transform: scale(1);    }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1);    }
}
#combo-display:not(:empty) {
  animation: comboPulse 0.3s ease-out;
}

/* #28: Crit flash keyframe (already inline, but backup) */
@keyframes critFlash {
  0%   { background: rgba(255,200,71,0.30); }
  100% { background: transparent; }
}

/* Smooth HP bar colour transitions */
[data-hp] {
  transition: width 0.12s ease, background 0.3s ease;
}

/* ============================================================
   PHASE 1 — Rarity-driven gem polish (replaces tier system)
   ============================================================ */


/* Breathing glow halo around the cell — kept subtle (smaller radius, no spread) */
@keyframes gemPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
  50%      { box-shadow: 0 0 10px 0 var(--rarity-glow, rgba(255,255,255,.25)); }
}

/* Subtle vertical bob */
@keyframes gemBreath {
  0%, 100% { transform: translateY(0)    scale(1);    }
  50%      { transform: translateY(-2px) scale(1.03); }
}

/* Per-rarity tint for the cell pulse halo. Toned down so it complements the
   SVG radial glow instead of doubling up on it. */
[data-rarity="uncommon"]     { --rarity-glow: rgba(94,233,211,.22);  }
[data-rarity="rare"]         { --rarity-glow: rgba(111,166,255,.30); }
[data-rarity="epic"]         { --rarity-glow: rgba(194,128,255,.36); }
[data-rarity="legendary"]    { --rarity-glow: rgba(255,215,120,.42); }
[data-rarity="mythic"]       { --rarity-glow: rgba(176,107,255,.48); }
[data-rarity="cosmic"]       { --rarity-glow: rgba(208,64,255,.60);  }
[data-rarity="ethereal"]     { --rarity-glow: rgba(128,200,255,.66); }
[data-rarity="astral"]       { --rarity-glow: rgba(192,96,255,.72);  }
[data-rarity="transcendent"] { --rarity-glow: rgba(255,224,128,.80); }
[data-rarity="primordial"]   { --rarity-glow: rgba(255,112,48,.86);  }
[data-rarity="eternal"]      { --rarity-glow: rgba(255,255,255,.92); }

/* Gentle vertical bob — common stays static, others breathe at a slow pace. */
[data-rarity="rare"]         .rock-svg,
[data-rarity="epic"]         .rock-svg,
[data-rarity="legendary"]    .rock-svg,
[data-rarity="mythic"]       .rock-svg,
[data-rarity="cosmic"]       .rock-svg,
[data-rarity="ethereal"]     .rock-svg,
[data-rarity="astral"]       .rock-svg,
[data-rarity="transcendent"] .rock-svg,
[data-rarity="primordial"]   .rock-svg,
[data-rarity="eternal"]      .rock-svg { animation: gemBreath 3.2s ease-in-out infinite; }

/* Cell halo — only rare+ pulses; common/uncommon stay clean. */
[data-rarity="rare"],
[data-rarity="epic"],
[data-rarity="legendary"],
[data-rarity="mythic"],
[data-rarity="cosmic"],
[data-rarity="ethereal"],
[data-rarity="astral"],
[data-rarity="transcendent"],
[data-rarity="primordial"],
[data-rarity="eternal"]      { animation: gemPulse 3.6s ease-in-out infinite; }


/* Rarity badge — tiny chip that replaces the old "T1" tier badge.
   Scales off the grid's --cell variable so the ore name (Stone / Copper / …)
   reads at every grid size (3×3 → 5×4), matching the HP label scaling rule
   in game.js (renderCellContent). Falls back to the original clamp range when
   the chip is rendered outside the mining grid (--cell unset). */
.rarity-chip {
  position: absolute;
  top: calc(var(--cell, 100px) * 0.025);
  left: calc(var(--cell, 100px) * 0.045);
  font-family: var(--font-display);
  font-size: clamp(8px, calc(var(--cell, 100px) * 0.095), 13px);
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: calc(var(--cell, 100px) * 0.015) calc(var(--cell, 100px) * 0.055);
  border-radius: 6px;
  text-shadow: 0 0 4px rgba(0,0,0,.85);
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.15);
  pointer-events: none;
  line-height: 1;
  white-space: nowrap;
}
.rarity-chip[data-r="common"]    { color: #c0c4cc; }
.rarity-chip[data-r="uncommon"]  { color: var(--accent-teal); border-color: var(--accent-teal); }
.rarity-chip[data-r="rare"]      { color: var(--accent-blue); border-color: var(--accent-blue); }
.rarity-chip[data-r="epic"]      { color: var(--accent-purple); border-color: var(--accent-purple); }
.rarity-chip[data-r="legendary"] { color: var(--accent-gold); border-color: var(--accent-gold); }
.rarity-chip[data-r="mythic"]    { color: #d8a2ff; border-color: #b061ff; box-shadow: 0 0 6px rgba(176,97,255,.5); }

/* ============================================================
   PHASE 2 — Daily sheet sections, quests
   ============================================================ */

.daily-section {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.daily-section-title {
  font-family: var(--font-display);
  font-size: clamp(10px, 2.4vw, 11px);
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
}

/* CLAIM button used in daily sections / quests */
.daily-claim-btn,
.quest-claim-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-orange), var(--accent-gold));
  color: #fff;
  font-weight: 800;
  font-size: clamp(10px, 2.4vw, 11px);
  font-family: var(--font-display);
  letter-spacing: 1px;
  box-shadow: 0 2px 0 #b84a1a;
  transition: transform .08s;
  white-space: nowrap;
}
.daily-claim-btn:active,
.quest-claim-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #b84a1a; }
.daily-claim-btn.disabled,
.quest-claim-btn.disabled {
  background: var(--bg-card);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
  opacity: .6;
}

/* Quest card */
.quest-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.quest-card.ready {
  border-color: var(--accent-gold);
  box-shadow: 0 0 14px var(--accent-gold-glow);
}
.quest-card.claimed { opacity: .55; }
.quest-card .quest-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.quest-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(10px, 2.4vw, 11px);
  color: var(--text-primary);
  margin-bottom: 2px;
}
.quest-meta {
  font-size: clamp(10px, 2.4vw, 11px);
  color: var(--text-muted);
}
.quest-bar-track {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}
.quest-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-teal), var(--accent-gold));
  transition: width .25s ease;
  box-shadow: 0 0 6px var(--accent-teal-glow);
}

/* ============================================================
   PHASE 3 — Skin themes grid + Rebirth panel
   ============================================================ */

.skin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.skin-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  cursor: pointer;
  text-align: center;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  position: relative;
}
.skin-tile:active { transform: scale(.97); }
.skin-tile:hover { border-color: var(--border-light); }
.skin-tile.equipped {
  border-color: var(--accent-gold);
  box-shadow: 0 0 16px var(--accent-gold-glow);
  background: rgba(255,201,71,.05);
}
.skin-tile.locked { opacity: .55; cursor: not-allowed; }
.skin-tile.locked .skin-tile-art { filter: grayscale(.6); }
.skin-tile-art {
  width: 56px; height: 56px;
  margin: 0 auto 4px;
}
.skin-tile-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(10px, 2.4vw, 11px);
  letter-spacing: 1px;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.skin-tile-status {
  font-size: clamp(10px, 2.4vw, 11px);
  color: var(--text-muted);
  letter-spacing: .5px;
}
.skin-tile.equipped .skin-tile-status {
  color: var(--accent-gold);
  font-weight: 700;
}

/* Rebirth panel — purple-pink gradient identity (legacy pre-built, not currently used) */
.rebirth-hero {
  background: linear-gradient(135deg, rgba(176,97,255,.12), rgba(236,72,153,.08));
  border: 1px solid rgba(176,97,255,.3);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  text-align: center;
}
.rebirth-points {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: #d8a2ff;
  text-shadow: 0 0 14px rgba(176,97,255,.5);
}
.rebirth-pts-label {
  font-family: var(--font-display);
  font-size: clamp(10px, 2.4vw, 11px);
  letter-spacing: 2px;
  color: var(--text-muted);
}
.rebirth-do-btn {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 1.5px;
  box-shadow: 0 3px 0 #6a2eb5;
  transition: transform .08s;
}
.rebirth-do-btn:active { transform: translateY(1px); box-shadow: 0 2px 0 #6a2eb5; }
.rebirth-do-btn:disabled {
  background: var(--bg-card);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
  letter-spacing: 1px;
}

/* ============================================================
   PHASE 6 — Mineshaft re-skin: panels, tabs, buttons
   These rules layer on TOP of the inline styles set by el(),
   using `background-image` and `border` overrides so the
   inline `background:` colour-only declarations stay intact
   underneath as a fallback.
   ============================================================ */

/* Wood-plank header strip (the top-bar at the very top of the app) */
.top-bar {
  background:
    repeating-linear-gradient(180deg,
      rgba(0,0,0,.0)    0  10px,
      rgba(0,0,0,.18) 10px 11px,
      rgba(0,0,0,.0)  11px 22px
    ),
    linear-gradient(180deg, var(--wood-light) 0%, var(--wood-mid) 50%, var(--wood-dark) 100%) !important;
  border-bottom: 2px solid #1a0e05 !important;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.15),
    inset 0 -2px 4px rgba(0,0,0,.6),
    0 4px 10px rgba(0,0,0,.55) !important;
  position: relative;
}
/* Iron rivets removed — were rendering as a stray brown ball next to the title */

/* === Wanted-poster panel cards === */
.panel-card {
  background:
    /* radial darkening towards corners (aged paper) */
    radial-gradient(ellipse at 50% 50%, rgba(255,225,170,.06) 0%, rgba(0,0,0,.0) 60%),
    /* paper grain via fine repeating noise */
    repeating-linear-gradient(45deg,  rgba(0,0,0,.05) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.04) 0 1px, transparent 1px 3px),
    /* base parchment-on-wood */
    linear-gradient(180deg, #4a3624 0%, #3a2a1c 55%, #2c1f12 100%) !important;
  border: 1px solid #6b4226 !important;
  box-shadow:
    inset 0 0 24px rgba(0,0,0,.55),
    inset 0 1px 0 rgba(255,210,150,.10),
    0 4px 10px rgba(0,0,0,.55) !important;
}
/* Four nailheads in the corners */
.panel-card::before,
.panel-card::after,
.panel-card > .panel-card-header::before,
.panel-card > .panel-card-header::after {
  content: "";
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--rivet);
  box-shadow: 0 1px 2px rgba(0,0,0,.7);
  pointer-events: none;
}
/* Four corner rivets per card. The bottom pair are pseudo-elements of the
   header (each element only gets one ::before / ::after), but they're
   positioned against .panel-card (the nearest positioned ancestor) so they
   land inside the card's bottom corners — mirroring the top pair instead of
   floating 10 px below the card on the empty backdrop. */
.panel-card::before { top: 6px;    left: 6px; }
.panel-card::after  { top: 6px;    right: 6px; }
.panel-card > .panel-card-header::before {
  content: ""; position: absolute;
  bottom: 6px; left: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rivet);
  box-shadow: 0 1px 2px rgba(0,0,0,.7);
  pointer-events: none;
}
.panel-card > .panel-card-header::after  {
  content: ""; position: absolute;
  bottom: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rivet);
  box-shadow: 0 1px 2px rgba(0,0,0,.7);
  pointer-events: none;
}
/* Heading underline mimics ink stamp */
.panel-card-title {
  text-shadow: 0 1px 0 rgba(0,0,0,.55), 0 0 8px rgba(255,170,80,.18);
}

/* === Wooden tabs === */
#main-row [data-tab],
#main-row [data-tab]:focus {
  background:
    repeating-linear-gradient(180deg,
      rgba(0,0,0,.0)   0  4px,
      rgba(0,0,0,.18) 4px 5px,
      rgba(0,0,0,.0)  5px 9px
    ),
    linear-gradient(180deg, var(--wood-light) 0%, var(--wood-mid) 100%) !important;
  border: 1px solid #1a0e05 !important;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.15),
    inset 0 -1px 2px rgba(0,0,0,.4) !important;
  color: var(--text-secondary) !important;
  font-family: var(--font-display) !important;
  letter-spacing: .5px !important;
}
/* Active tab — lit by lantern.
   v23 — also key off the robust data-active="1" / aria-selected="true" attrs the
   JS already sets (buildTabs ~4793), not just the brittle inline-style substring. */
#main-row [data-tab][style*="bg-card"],
#main-row [data-tab][data-active="1"],
#main-row [data-tab][aria-selected="true"] {
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255,180,80,.18), transparent 70%),
    linear-gradient(180deg, var(--wood-light) 0%, #5a3520 100%) !important;
  color: var(--accent-gold) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.25),
    0 0 12px rgba(255,170,80,.25) !important;
  border-color: var(--accent-orange) !important;
}

/* The tab strip parent itself becomes a plank */
#main-row > div > div:first-child {
  /* match the existing tabs-row gap; non-destructive */
}

/* === Iron-bound primary buttons (claim, ascend, rebirth, etc.) === */
.daily-claim-btn,
.quest-claim-btn,
.rebirth-do-btn {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(255,210,150,.15), transparent 65%),
    linear-gradient(180deg, #6a4a30 0%, #3a2515 100%) !important;
  color: #fff5d8 !important;
  border: 1px solid #1a0e05 !important;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,.25),
    inset 0 -2px 0 rgba(0,0,0,.55),
    0 3px 0 #1a0e05 !important;
  text-shadow: 0 1px 0 rgba(0,0,0,.6), 0 0 6px rgba(255,180,80,.4);
}
.daily-claim-btn::before,
.quest-claim-btn::before,
.rebirth-do-btn::before {
  content: ""; position: absolute; top: 3px; left: 4px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--rivet); pointer-events: none;
}
.daily-claim-btn::after,
.quest-claim-btn::after,
.rebirth-do-btn::after {
  content: ""; position: absolute; top: 3px; right: 4px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--rivet); pointer-events: none;
}
/* Disabled iron buttons look rusted */
.daily-claim-btn.disabled, .daily-claim-btn[disabled],
.quest-claim-btn.disabled, .quest-claim-btn[disabled],
.rebirth-do-btn[disabled] {
  background: linear-gradient(180deg, #2a1d12 0%, #1a1208 100%) !important;
  color: var(--text-muted) !important;
  text-shadow: none;
  box-shadow: inset 0 1px 0 rgba(0,0,0,.4) !important;
}

/* === Mining grid as a stone wall === */
#mining-grid {
  background:
    /* darker mortar lines between cells already provided by gap; layer some texture */
    radial-gradient(ellipse at 30% 20%, rgba(255,180,80,.08), transparent 55%),
    repeating-linear-gradient(  0deg, rgba(0,0,0,.10) 0 30px, rgba(0,0,0,.0) 30px 32px),
    repeating-linear-gradient( 90deg, rgba(0,0,0,.10) 0 30px, rgba(0,0,0,.0) 30px 32px),
    linear-gradient(180deg, #2a1d12 0%, #1a120a 100%) !important;
  border: 2px solid var(--wood-mid) !important;
  box-shadow:
    inset 0 0 18px rgba(0,0,0,.6),
    0 4px 14px rgba(0,0,0,.55) !important;
}
#mining-grid > div {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255,180,80,.06), transparent 70%),
    linear-gradient(180deg, #2c1f12 0%, #1a1208 100%) !important;
  border-color: rgba(0,0,0,.55) !important;
  box-shadow: inset 0 1px 0 rgba(255,210,150,.05), inset 0 -2px 4px rgba(0,0,0,.5);
}

/* (Old iron+wood tap-card panel rule removed — the SPAWN button now owns
   its own chunky cel-shaded surface; see the #tap-card rules near the top.) */

/* Subtle "claim ready" pulse on the header gift button when its notif-dot is present. */
@keyframes giftClaimPulse {
  0%, 100% { transform: scale(1);   filter: drop-shadow(0 0 0   rgba(255,201,71,.0)); }
  50%      { transform: scale(1.08); filter: drop-shadow(0 0 8px rgba(255,201,71,.7)); }
}
#hud-daily:has(.notif-dot) > div { animation: giftClaimPulse 1.6s ease-in-out infinite; }

/* === Ascend action button (vertical layout in reward row) === */
.ascend-do-btn {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(200,160,255,.22), transparent 65%),
    linear-gradient(180deg, #9060e0 0%, #4c1d95 100%) !important;
  color: #f0e0ff !important;
  border: 1px solid rgba(168,107,255,.55) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,220,255,.25),
    inset 0 -2px 0 rgba(0,0,0,.55),
    0 3px 0 #2e1165,
    0 0 18px rgba(168,107,255,.3) !important;
  text-shadow: 0 1px 0 rgba(0,0,0,.5), 0 0 8px rgba(200,150,255,.5);
  font-family: var(--font-display) !important;
  letter-spacing: 1.5px !important;
  transition: box-shadow .15s, opacity .15s;
}
.ascend-do-btn[disabled] {
  background: linear-gradient(180deg, #2a1d12 0%, #1a1208 100%) !important;
  color: var(--text-muted) !important;
  text-shadow: none;
  box-shadow: inset 0 1px 0 rgba(0,0,0,.4) !important;
  border-color: var(--border) !important;
}

/* === Buy-Max toggle (panel-header pill, Gear-Factory style) === */
.buy-max-toggle {
  flex: 0 0 auto;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(10px, 2.4vw, 11px);
  letter-spacing: 1px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
  min-width: 38px;
}
.buy-max-toggle:hover { color: var(--accent-orange); border-color: var(--accent-orange); }
.buy-max-toggle.on {
  background: linear-gradient(135deg, var(--accent-orange), #e85d1e);
  color: #fff;
  border-color: var(--accent-orange);
  box-shadow: 0 0 8px rgba(255,170,80,.35), inset 0 1px 0 rgba(255,210,150,.25);
}

/* ==============================================================
   v12 — Cold-Open Onboarding (Phase 1 of Deep Core redesign)
   Ghost finger, banner pop-ins, cargo-urgent pulse, sell-tab reveal,
   rare-strike golden sparks.
   ============================================================== */
@keyframes ghostFingerTap {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  45%      { transform: translate(-50%, -38%) scale(1.04); }
  55%      { transform: translate(-50%, -55%) scale(.92); }
}
@keyframes onboardBannerIn {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.6); filter: blur(8px); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.08); filter: blur(0); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes onboardBannerOut {
  to { opacity: 0; transform: translate(-50%, -120%) scale(.9); }
}
@keyframes goldenSpark {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(.4); }
}
@keyframes cargoUrgentPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(239,68,68,.55); }
  50%      { box-shadow: 0 0 26px rgba(239,68,68,.95), 0 0 44px rgba(239,68,68,.4); }
}
/* Combo-display stage-up pulse — replaces the old top-center HOT/INFERNO
   banners. Briefly scales the inline combo label so the player notices the
   stage threshold crossing without breaking their focus on the grid. */
@keyframes comboStagePulse {
  0%   { transform: scale(1)    rotate(-1deg); }
  20%  { transform: scale(1.45) rotate(3deg); }
  45%  { transform: scale(1.1)  rotate(-2deg); }
  70%  { transform: scale(1.22) rotate(1deg); }
  100% { transform: scale(1)    rotate(0deg); }
}
.combo-stage-pulse {
  animation: comboStagePulse .7s cubic-bezier(.2,1.6,.4,1);
  transform-origin: center;
}
@media (prefers-reduced-motion: reduce) {
  .combo-stage-pulse { animation: none !important; }
}

/* SELL ALL cartoon pop — bubble springs up out of the button, peaks above it,
   then drifts up and fades. Replaces the generic "+N CR" center toast so the
   payout visually originates from the action that produced it. */
@keyframes buttonPop {
  0%   { opacity: 0; transform: translate(-50%, -40%) scale(.4)  rotate(-4deg); }
  25%  { opacity: 1; transform: translate(-50%, -140%) scale(1.18) rotate(2deg);  }
  55%  { opacity: 1; transform: translate(-50%, -180%) scale(1)    rotate(-1deg); }
  100% { opacity: 0; transform: translate(-50%, -240%) scale(.92)  rotate(0deg);  }
}
.button-pop {
  animation: buttonPop 1.25s cubic-bezier(.2,1.3,.4,1) forwards;
  will-change: transform, opacity;
}
@media (prefers-reduced-motion: reduce) {
  .button-pop { animation: none !important; opacity: 1 !important; transform: translate(-50%, -120%) !important; }
}
#mine-cargo-bar.cargo-urgent,
#mine-cargo-badge.cargo-urgent {
  animation: cargoUrgentPulse 1.0s ease-in-out infinite;
  border-color: rgba(239,68,68,.75) !important;
}
@keyframes tabReveal {
  0%   { opacity: 0; transform: translateX(40px) scale(.9); }
  60%  { opacity: 1; transform: translateX(-4px) scale(1.06); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes tabRevealRing {
  0%, 100% { box-shadow: 0 0 0 0 rgba(94,233,211,0); }
  50%      { box-shadow: 0 0 0 6px rgba(94,233,211,.35); }
}
[data-tab].tab-reveal {
  animation: tabReveal .55s cubic-bezier(.2,1.4,.4,1) both,
             tabRevealRing 1.4s ease-in-out 2 .55s;
}
@media (prefers-reduced-motion: reduce) {
  .ghost-finger { animation: none !important; opacity: .85; }
  .onboard-banner { animation: none !important; }
  #mine-cargo-bar.cargo-urgent,
  #mine-cargo-badge.cargo-urgent { animation: none !important; box-shadow: 0 0 14px rgba(239,68,68,.7); }
  [data-tab].tab-reveal { animation: none !important; }
}

/* ==============================================================
   v13 — DISCOVERY modal (Phase 2 of Deep Core redesign).
   First-time ore-mine spectacle: portrait spins, halo pulses.
   ============================================================== */
@keyframes discoveryPop {
  0%   { opacity: 0; transform: scale(.55) rotate(-6deg); filter: blur(6px); }
  55%  { opacity: 1; transform: scale(1.06) rotate(2deg); filter: blur(0); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes discoveryFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
@media (prefers-reduced-motion: reduce) {
  .discovery-overlay { animation: none !important; }
  .discovery-overlay [style*="discoveryFloat"] { animation: none !important; }
}

/* ==============================================================
   v13 — CRIT ECONOMY (Phase 3 of Deep Core redesign).
   Stage-up banners, body-level tint per combo stage, Heavy Rock
   golden veins, Geode rainbow shimmer.
   ============================================================== */
@keyframes comboStageIn {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(.6); }
  60%  { opacity: 1; transform: translateX(-50%) translateY(0)     scale(1.12); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0)     scale(1); }
}
@keyframes comboStageOut {
  to { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(.9); }
}

/* Body-wide tint while in a combo stage. The grid soaks up a faint colour
   wash so the player can feel the stage in their peripheral vision. */
body[data-combo-stage="1"] #mining-grid { box-shadow: 0 0 24px rgba(255,138,58,.20); }
body[data-combo-stage="2"] #mining-grid { box-shadow: 0 0 32px rgba(255,200,71,.30); }
body[data-combo-stage="3"] #mining-grid {
  box-shadow: 0 0 44px rgba(236,72,153,.40);
  animation: comboPulseInferno 1.2s ease-in-out infinite;
}
body[data-combo-stage="4"] #mining-grid {
  box-shadow: 0 0 60px rgba(176,97,255,.60), inset 0 0 40px rgba(176,97,255,.18);
  animation: comboPulseSupernova .8s ease-in-out infinite;
}
@keyframes comboPulseInferno {
  0%, 100% { box-shadow: 0 0 32px rgba(236,72,153,.30); }
  50%      { box-shadow: 0 0 56px rgba(236,72,153,.55); }
}
@keyframes comboPulseSupernova {
  0%, 100% { box-shadow: 0 0 50px rgba(176,97,255,.50), inset 0 0 32px rgba(176,97,255,.12); }
  50%      { box-shadow: 0 0 84px rgba(176,97,255,.85), inset 0 0 60px rgba(176,97,255,.28); }
}

/* Heavy Rock golden veins — slow shimmer along the gradient. */
.rock-heavy-veins {
  animation: heavyVeinShine 2.4s ease-in-out infinite;
}
@keyframes heavyVeinShine {
  0%, 100% { opacity: .65; }
  50%      { opacity: 1; filter: drop-shadow(0 0 6px #ffd86b); }
}
[data-special="heavy"] { outline: 2px solid #ffd86b66; outline-offset: -1px; border-radius: 6px; }

/* Geode shimmer — animated conic-gradient overlay. */
.rock-geode-shimmer {
  background: conic-gradient(from 0deg,
    rgba(255,77,107,.35), rgba(255,200,71,.35), rgba(94,233,211,.35),
    rgba(77,142,255,.35), rgba(176,97,255,.35), rgba(255,77,107,.35));
  mix-blend-mode: screen;
  border-radius: 50%;
  animation: geodeSpin 4s linear infinite, geodeBreath 1.6s ease-in-out infinite;
  opacity: .85;
}
@keyframes geodeSpin { to { transform: rotate(360deg); } }
@keyframes geodeBreath {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: .65; }
  50%      { transform: scale(1.08) rotate(180deg); opacity: 1; }
}
[data-special="geode"] {
  outline: 2px solid #ff60d0aa; outline-offset: -1px; border-radius: 6px;
  box-shadow: 0 0 22px rgba(255,96,208,.5);
}

@media (prefers-reduced-motion: reduce) {
  .combo-stage-banner { animation: none !important; }
  body[data-combo-stage] #mining-grid { animation: none !important; }
  .rock-heavy-veins, .rock-geode-shimmer { animation: none !important; }
}

/* ==============================================================
   v15 — CRATES (Phase 5 of Deep Core redesign).
   Header pill pulse, slot-machine reel animation.
   ============================================================== */
@keyframes cratePulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255,200,71,.45); transform: scale(1); }
  50%      { box-shadow: 0 0 18px rgba(255,200,71,.85), 0 0 32px rgba(255,200,71,.4); transform: scale(1.05); }
}
/* Floating crate badge over the mining grid — bounces while crates are
   unopened so the player can tap-to-open without leaving the grid view. */
@keyframes crateBadgeBounce {
  0%, 100% { transform: translateY(0)   scale(1);    box-shadow: 0 4px 0 #6b4112, 0 0 16px rgba(255,200,71,.55); }
  45%      { transform: translateY(-6px) scale(1.06); box-shadow: 0 8px 12px rgba(0,0,0,.35), 0 0 24px rgba(255,200,71,.85); }
}
#crate-tap-badge:active { transform: translateY(2px) scale(.97); }
@media (prefers-reduced-motion: reduce) {
  #crate-tap-badge { animation: none !important; }
}
@keyframes crateReel {
  0%   { transform: translateY(0); }
  100% { transform: translateY(calc(-120px * 7)); }
}
@media (prefers-reduced-motion: reduce) {
  #hud-crates { animation: none !important; }
  .crate-overlay [style*="crateReel"] { animation: none !important; transform: translateY(calc(-120px * 7)); }
}

/* ==============================================================
   v16 — LIVING WORLD (Phase 6 of Deep Core redesign).
   Biome-event banner pop-in, Gravity Flip board rotate, Boss outline.
   ============================================================== */
@keyframes biomeEventIn {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(.6); filter: blur(8px); }
  60%  { opacity: 1; transform: translateX(-50%) translateY(0)     scale(1.10); filter: blur(0); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0)     scale(1); }
}
@keyframes biomeEventOut {
  to { opacity: 0; transform: translateX(-50%) translateY(-16px) scale(.92); }
}
/* Gravity Flip — visual rotation removed; biome event still fires but no
   longer spins the grid (it read as messy / disorienting). The event banner
   and yield mods continue to apply via `body.biome-flip` data attributes. */
/* Boss rock outline + ambient pulse */
[data-special="boss"] {
  outline: 3px solid #ff4d6b; outline-offset: -2px; border-radius: 6px;
  box-shadow: 0 0 26px rgba(255,77,107,.55);
  animation: bossPulse 1.4s ease-in-out infinite;
}
@keyframes bossPulse {
  0%, 100% { box-shadow: 0 0 22px rgba(255,77,107,.45); }
  50%      { box-shadow: 0 0 40px rgba(255,77,107,.85), 0 0 60px rgba(255,77,107,.4); }
}
.rock-boss-crown { z-index: 10; filter: drop-shadow(0 2px 6px rgba(0,0,0,.5)); }

@media (prefers-reduced-motion: reduce) {
  .biome-event-banner, .boss-defeat-banner { animation: none !important; }
  [data-special="boss"] { animation: none !important; }
}

/* ==============================================================
   v17 — RESET CINEMATICS (Phase 7 of Deep Core redesign).
   Full-screen 2-second spectacle per reset tier.
   ============================================================== */
@keyframes cinematicFadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes cinematicFadeOut { to   { opacity: 0; } }

/* Ascend — tectonic crack stroke-dash unveil */
@keyframes cinematicCrack {
  0%   { stroke-dashoffset: 1000; }
  100% { stroke-dashoffset: 0; }
}

/* Rebirth — supernova bloom (ring + bright core) */
@keyframes cinematicBloom {
  0%   { width: 40px;   height: 40px;   opacity: 1; }
  100% { width: 1400px; height: 1400px; opacity: 0; }
}
@keyframes cinematicBloomCore {
  0%   { width: 80px;   height: 80px;   opacity: 0; filter: blur(0); }
  30%  { width: 240px;  height: 240px;  opacity: 1; filter: blur(0); }
  100% { width: 1600px; height: 1600px; opacity: 0; filter: blur(60px); }
}

/* Prestige — particles pull to center, then the singularity disk collapses */
@keyframes cinematicPull {
  0%   { transform: translate(var(--tx), var(--ty)) scale(1); opacity: 1; }
  100% { transform: translate(0, 0) scale(0.2); opacity: 0; }
}
@keyframes cinematicSingularity {
  0%   { width: 160px;  height: 160px;  opacity: 0; }
  40%  { width: 280px;  height: 280px;  opacity: 1; }
  80%  { width: 40px;   height: 40px;   opacity: 1; }
  100% { width: 4px;    height: 4px;    opacity: 0; }
}

/* Shared title-card */
@keyframes cinematicTitle {
  0%   { opacity: 0; transform: scale(.6); letter-spacing: 24px; filter: blur(20px); }
  40%  { opacity: 1; transform: scale(1.05); letter-spacing: 6px; filter: blur(0); }
  100% { opacity: 1; transform: scale(1); letter-spacing: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .reset-cinematic, .reset-cinematic * { animation: none !important; }
}

/* ==============================================================
   v17 — STREAK BUFF pill pulse (Phase 8 of Deep Core redesign).
   ============================================================== */
@keyframes streakBuffPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255,138,58,.4); transform: scale(1); }
  50%      { box-shadow: 0 0 18px rgba(255,138,58,.8), 0 0 32px rgba(255,138,58,.35); transform: scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  #hud-streakbuff { animation: none !important; }
}

/* ==============================================================
   v18 — MAP TAB miner bob (Phase 9 of Deep Core redesign).
   ============================================================== */
@keyframes mapMinerBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
.map-strip[data-current="1"] {
  animation: mapStripPulse 1.6s ease-in-out infinite;
}
@keyframes mapStripPulse {
  0%, 100% { box-shadow: inset 0 0 12px rgba(255,138,58,.2); }
  50%      { box-shadow: inset 0 0 28px rgba(255,138,58,.45); }
}
@media (prefers-reduced-motion: reduce) {
  .map-miner, .map-strip[data-current="1"] { animation: none !important; }
}

/* ==============================================================
   v18 — THEMES (Phase 10 of Deep Core redesign).
   Each theme swaps the CSS custom properties; all inline-style usage of
   var(--accent-*) etc. picks up the override automatically.
   ============================================================== */

/* SYNTHWAVE — neon retro, magenta + cyan on inky purple */
body[data-theme="synthwave"] {
  --bg-primary:    #0a0420;
  --bg-secondary:  #150930;
  --bg-tertiary:   #200d44;
  --bg-card:       #2a1456;
  --bg-card-hover: #382070;
  --bg-surface:    #0d0628;
  --text-primary:  #f6e6ff;
  --text-secondary:#bd9ce8;
  --text-muted:    #7e64a3;
  --accent-orange: #ff3eb5;
  --accent-orange-glow: rgba(255,62,181,.45);
  --accent-gold:   #ffe247;
  --accent-gold-glow: rgba(255,226,71,.4);
  --accent-blue:   #4ad4ff;
  --accent-blue-glow: rgba(74,212,255,.4);
  --accent-purple: #c47bff;
  --accent-purple-glow: rgba(196,123,255,.4);
  --accent-teal:   #5ce6c9;
  --accent-teal-glow: rgba(92,230,201,.4);
  --accent-red:    #ff4a78;
  --accent-pink:   #ff6acc;
  --border:        rgba(196,123,255,.18);
  --border-light:  rgba(196,123,255,.30);
  --border-accent: rgba(255,62,181,.45);
}
/* Add a faint horizontal-grid backdrop for synthwave flavour */
body[data-theme="synthwave"]::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(transparent 96%, rgba(255,62,181,.07) 96%),
    linear-gradient(90deg, transparent 96%, rgba(74,212,255,.07) 96%);
  background-size: 40px 40px;
  opacity: .6;
}

/* GOLDRUSH — saloon-era opulence, deep mahogany + gold leaf */
body[data-theme="goldrush"] {
  --bg-primary:    #1a0e04;
  --bg-secondary:  #2a1808;
  --bg-tertiary:   #3a2210;
  --bg-card:       #4a2e16;
  --bg-card-hover: #5a3a1c;
  --bg-surface:    #20120a;
  --text-primary:  #ffe6b3;
  --text-secondary:#e0b878;
  --text-muted:    #9a7a4a;
  --accent-orange: #ffa830;
  --accent-orange-glow: rgba(255,168,48,.5);
  --accent-gold:   #ffd86b;
  --accent-gold-glow: rgba(255,216,107,.5);
  --accent-blue:   #c8a560;
  --accent-blue-glow: rgba(200,165,96,.35);
  --accent-purple: #d09848;
  --accent-purple-glow: rgba(208,152,72,.35);
  --accent-teal:   #ffcb6c;
  --accent-teal-glow: rgba(255,203,108,.35);
  --accent-red:    #d8542c;
  --border:        rgba(255,216,107,.20);
  --border-light:  rgba(255,216,107,.32);
  --border-accent: rgba(255,168,48,.50);
}

/* VOIDCORE — after the singularity. Inky violet, electric cyan, dark gold */
body[data-theme="voidcore"] {
  --bg-primary:    #06050d;
  --bg-secondary:  #0c0a18;
  --bg-tertiary:   #131028;
  --bg-card:       #1a1638;
  --bg-card-hover: #241a4a;
  --bg-surface:    #050410;
  --text-primary:  #d6e0ff;
  --text-secondary:#8a9ad8;
  --text-muted:    #4e598c;
  --accent-orange: #ff2e6b;
  --accent-orange-glow: rgba(255,46,107,.55);
  --accent-gold:   #b4e6ff;
  --accent-gold-glow: rgba(180,230,255,.45);
  --accent-blue:   #5060ff;
  --accent-blue-glow: rgba(80,96,255,.5);
  --accent-purple: #9038ff;
  --accent-purple-glow: rgba(144,56,255,.55);
  --accent-teal:   #2ee9c8;
  --accent-teal-glow: rgba(46,233,200,.45);
  --accent-red:    #ff2e6b;
  --border:        rgba(144,56,255,.22);
  --border-light:  rgba(144,56,255,.36);
  --border-accent: rgba(255,46,107,.50);
}

/* ==============================================================
   v18 — Universal button squish on press (Phase 10).
   Applies to anything that's clickable inside the game UI without
   needing every button to opt in. Skips modals / disabled buttons.
   ============================================================== */
button:not([disabled]):active,
[onclick]:not([disabled]):active,
.daily-claim-btn:not(.disabled):active,
.quest-claim-btn:not(.disabled):active,
.map-strip:active {
  transform: scale(0.96);
  transition: transform .06s ease-out;
}
button, [onclick] { transition: transform .15s cubic-bezier(.2,1.6,.4,1); }

/* ============================================================
   v18 — Universal grid + right-panel sizing.

   Goals (per user spec):
     - Grid is always as big as possible while fully on-screen, filling
       the available space.
     - Right tabs panel always leans against the right edge of the
       viewport, and it can expand sideways up to a non-stretched cap
       so the gap between grid and panel stays minimal.

   Implementation:
     - Cell size is whichever is smallest of three budgets:
         · (viewport width − reserved panel/padding) / cols
         · (viewport height − reserved chrome) / rows
         · an aesthetic max so cells don't grow unboundedly on 4K
       …clamped to a floor so the grid stays usable on tiny phones.
     - Right panel: flex 1, hugged to the right via #main-row's
       justify-content: space-between, max-width via clamp() so it
       grows with viewport up to a content-appropriate ceiling.

   Replaces all the per-breakpoint cell-size overrides above; later
   source order + !important means this rule wins everywhere.
   ============================================================ */
/* The banner sits IN the top bar (game.js #cg-banner, between title and coins),
   so it adds ~50px to the header height. -300px reserves header (incl. banner) +
   tabs bar + status bar + paddings; cells grow to fill the rest, and #main-row's
   overflow:auto absorbs any residual. */
#mining-grid[data-cols="3"] {
  --cell: max(46px, min(
    calc((100vw - 330px) / 3),
    calc((100dvh - 272px) / 3),
    300px
  )) !important;
  grid-template-columns: repeat(3, var(--cell)) !important;
  grid-template-rows:    repeat(3, var(--cell)) !important;
}
#mining-grid[data-cols="4"] {
  --cell: max(40px, min(
    calc((100vw - 330px) / 4),
    calc((100dvh - 272px) / 3),
    232px
  )) !important;
  grid-template-columns: repeat(4, var(--cell)) !important;
  grid-template-rows:    repeat(3, var(--cell)) !important;
}
#mining-grid[data-cols="5"] {
  --cell: max(36px, min(
    calc((100vw - 330px) / 5),
    calc((100dvh - 272px) / 4),
    184px
  )) !important;
  grid-template-columns: repeat(5, var(--cell)) !important;
  grid-template-rows:    repeat(4, var(--cell)) !important;
}
/* Same specificity (#mining-grid[data-cols="N"] ...) as the legacy breakpoint
   rules so source-order + !important reliably wins. With a generic
   `#mining-grid > [data-cell]` selector the older `[data-cols="3"]` rules
   would beat us on specificity and the cells would stay frozen at the old
   hardcoded px while the grid template stretched to `var(--cell)`. */
#mining-grid[data-cols="3"] > [data-cell],
#mining-grid[data-cols="4"] > [data-cell],
#mining-grid[data-cols="5"] > [data-cell] {
  width:  var(--cell) !important;
  height: var(--cell) !important;
}
#mining-grid[data-cols="3"] .rock-svg,
#mining-grid[data-cols="4"] .rock-svg,
#mining-grid[data-cols="5"] .rock-svg {
  width:  calc(var(--cell) * 0.82) !important;
  height: calc(var(--cell) * 0.82) !important;
}

/* Grid + tabs panel are CENTERED as a group (previously space-between shoved the
   grid to the far-left edge with a big empty gap — the "not centered, tiny grid"
   the desktop screenshot showed). The panel no longer flex-grows; it sits at its
   content width up to a cap, so the pair stays balanced in the middle. */
#main-row {
  justify-content: center !important;
  /* Extra gap so the crate-tap badge that overhangs the grid's top-right corner
     (~14px) clears the upgrade panel instead of overlapping it. */
  gap: 34px !important;
}
#main-row > div:last-child {
  flex: 0 1 auto !important;
  min-width: 280px !important;
  max-width: clamp(300px, 36vw, 560px) !important;
}

/* v23 — PORTRAIT / NARROW STACK FIX.
   #main-row was flex-direction:row at ALL widths and the right panel had
   min-width:280px, so on a ~360px portrait phone the row (grid + 280px panel)
   overflowed → horizontal scroll, the classic CrazyGames portrait failure.
   Below 640px we stack the panel UNDER the grid (column) and drop its
   min-width so the row can never exceed the viewport. The inline
   flex-direction:row set in JS is beaten by !important here. The per-cols
   --cell formulas reserve 360px for a side panel, which no longer applies once
   the panel is below, so we recompute --cell off (almost) the full viewport. */
@media (max-width: 640px) {
  /* Single source of truth for the narrow STACK: flex-direction + align-items
     live here (no competing declaration in the portrait block above), so the
     stacked layout no longer depends on source order. align-items:stretch lets
     the full-width tabs panel span edge-to-edge in the single-scroll layout. */
  #main-row {
    flex-direction: column !important;
    align-items: stretch !important;
    flex-wrap: nowrap !important;
    overflow-x: hidden !important;
  }
  #main-row > div:first-child,
  #main-row > div:last-child {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  #mining-grid[data-cols="3"] {
    --cell: max(56px, min(calc((100vw - 36px) / 3), calc((100dvh - 430px) / 3), 150px)) !important;
  }
  #mining-grid[data-cols="4"] {
    --cell: max(46px, min(calc((100vw - 36px) / 4), calc((100dvh - 430px) / 3), 130px)) !important;
  }
  #mining-grid[data-cols="5"] {
    --cell: max(40px, min(calc((100vw - 36px) / 5), calc((100dvh - 430px) / 4), 110px)) !important;
  }
}
