/* =============================================================================
 * Tiny Miner — web game stylesheet (v4 web layout).
 * One file: app shell (fullscreen column), scene (native-res sprites), menu.
 * Plugin-era overlay layout retired 2026-07-02; original lives in versions/v3.2.
 * Sprites render at native resolution (miner frames 96px, ores 72x60) and are
 * scaled once via --tm-scene-scale — never double-resampled.
 * =========================================================================== */

@font-face {
  font-family: "Jersey 10";
  src: url("../assets/fonts/jersey10.ttf") format("truetype");
  font-weight: 400;
  /* block (not swap): the title h1 is huge, so a fallback-font first paint
     reads as the page loading twice at two different sizes */
  font-display: block;
}

#tmc-root {
  --tmc-panel: #14191d;
  --tmc-panel-2: #1d252a;
  --tmc-line: #3b454c;
  --tmc-gold: #f2bf3a;
  --tmc-green: #54c55d;
  --tmc-blue: #7ad1ff;
  --tmc-text: #f5f0d8;
  --tmc-muted: #9fb0b9;
  --tm-scene-scale: 1.35;
  --miner-idle: url("../assets/miner-v13/miner_idle_4.png");
  --miner-travel: url("../assets/miner-v13/miner_travel_4.png");
  --miner-mine: url("../assets/miner-v13/miner_mine_4.png");
  --miner-mine-cycle: url("../assets/miner-v13/miner_mine_cycle_4.png");
  --miner-hard-swing: url("../assets/miner-v13/miner_hard_swing_4.png");
  --miner-tired-enter: url("../assets/miner-v13/miner_tired_enter_4.png");
  --miner-tired-hold: url("../assets/miner-v13/miner_tired_hold_2.png");
  --ore-stone: url("../assets/theme-v12/ores/stone_intact.png");
  --ore-tin: url("../assets/theme-v12/ores/tin_intact.png");
  --ore-copper: url("../assets/theme-v12/ores/copper_intact.png");
  --ore-iron: url("../assets/theme-v12/ores/iron_intact.png");
  --ore-mithril: url("../assets/theme-v12/ores/mithril_intact.png");
  --ore-adamite: url("../assets/theme-v12/ores/adamite_intact.png");
  --ore-gold: url("../assets/theme-v12/ores/gold_intact.png");
  --ore-amethyst: url("../assets/theme-v12/ores/amethyst_intact.png");
  --ore-runite: url("../assets/theme-v12/ores/runite_intact.png");
  --ore-diamond: url("../assets/theme-v12/ores/diamond_intact.png");
  --ore-netherite: url("../assets/theme-v12/ores/netherite_intact.png");
  --ore-prismatic: url("../assets/theme-v12/ores/prismatic_intact.png");
  --ui-coin: url("../assets/sprites/ui/coin.png");
  --tm-ground: url("../assets/ground/path.png");
  position: fixed;
  inset: 0;
  /* extend past the layout viewport so standalone-mode safe areas and any
     viewport-height quirks never expose a white strip at the screen edges */
  bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
  min-height: 100dvh;
  z-index: 100;
  background: #11151a;
  /* Data/UI text uses a clean humanist face (pixel fonts blur below ~16px);
     the pixel font is applied selectively to large display text only. */
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  color: var(--tmc-text);
}

/* Pixel font ONLY where it renders big enough to stay crisp. */
.tmc-panel-top,
.tmc-tabs button,
.tmc-status,
.tmc-descend,
.tmc-sell-hint span {
  font-family: "Jersey 10", "Trebuchet MS", Arial, sans-serif;
  letter-spacing: 0.02em;
}

#tmc-root * {
  box-sizing: border-box;
}

/* Bigger scene on bigger screens (single integer-ish scale of native art). */
@media (min-width: 600px)  { #tmc-root { --tm-scene-scale: 1.6; } }
@media (min-width: 1000px) { #tmc-root { --tm-scene-scale: 2; } }
@media (max-width: 360px)  { #tmc-root { --tm-scene-scale: 1.2; } }

/* ---------------------------------------------------------------------------
 * App shell: scene centered in the free space, menu docked at the bottom.
 * ------------------------------------------------------------------------- */

.tmc-frame {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* Zone backdrop: tiled pixel cave wall + vignette so the scene stays the hero. */
.tmc-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  image-rendering: pixelated;
  background:
    radial-gradient(ellipse 90% 70% at 50% 36%, transparent 0 28%, rgb(11 14 18 / 45%) 70%, rgb(11 14 18 / 78%) 100%),
    linear-gradient(180deg, rgb(11 14 18 / 40%), transparent 26% 62%, rgb(11 14 18 / 55%)),
    var(--tm-backdrop) left top / 240px 240px repeat;
}

.tmc-companion,
.tmc-panel {
  position: relative;
  z-index: 1;
}

/* Environment layers (screen-space, behind the scene; JS drives their
   parallax scroll off the same treadmill offset as the ground). */
.tmc-midrocks,
.tmc-soil,
.tmc-ceiling {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  image-rendering: pixelated;
}

.tmc-ceiling {
  top: 0;
  height: 76px;
  background: var(--tm-ceiling) left top repeat-x;
}

.tmc-midrocks {
  background: var(--tm-midrocks) left bottom / auto 100% repeat-x;
  opacity: 0.8;
}

.tmc-soil {
  bottom: 0;
  /* Subtle sediment strata (dark seam + faint accent-tinted band) break up the
     flat dirt between the path and the panel. Decorative only. */
  background:
    linear-gradient(180deg, rgb(4 6 10 / 60%) 0, rgb(4 6 10 / 12%) 3px, transparent 6px),
    linear-gradient(180deg, transparent 0, rgb(4 6 10 / 55%) 78%, rgb(4 6 10 / 75%) 100%),
    linear-gradient(180deg,
      transparent 0 44px,
      rgb(0 0 0 / 20%) 44px 48px,
      color-mix(in srgb, var(--tmc-accent, #c9b27f) 13%, transparent) 48px 54px,
      transparent 54px 110px,
      rgb(0 0 0 / 24%) 110px 115px,
      color-mix(in srgb, var(--tmc-accent, #c9b27f) 9%, transparent) 115px 122px,
      transparent 122px 180px,
      rgb(0 0 0 / 26%) 180px 186px,
      color-mix(in srgb, var(--tmc-accent, #c9b27f) 6%, transparent) 186px 194px,
      transparent 194px),
    var(--tm-soil) left top / auto 96px repeat;
}

/* Depth darkness: deeper zones dim the environment (never the sprites). */
.tmc-darkness {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: #04060a;
  opacity: var(--tm-depth-dark, 0);
  transition: opacity 600ms ease;
}

/* Helmet-lamp glow: warm pool of light around the miner, above the darkness,
   below the sprites. Positioned over the miner by JS. */
.tmc-lamp {
  position: absolute;
  pointer-events: none;
  mix-blend-mode: screen;
  background: radial-gradient(circle,
    rgb(255 214 130 / 30%) 0%,
    rgb(255 195 95 / 15%) 34%,
    rgb(255 170 60 / 6%) 58%,
    transparent 72%);
  animation: tmcLampFlicker 4600ms ease-in-out infinite;
}

.tmc-lamp i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: #ffe9b0;
  opacity: 0;
  animation: tmcMote 7s linear infinite;
}

.tmc-lamp i:nth-child(1) { left: 32%; top: 58%; animation-delay: 0s; }
.tmc-lamp i:nth-child(2) { left: 55%; top: 42%; animation-delay: 1.6s; animation-duration: 8.5s; }
.tmc-lamp i:nth-child(3) { left: 44%; top: 66%; animation-delay: 3.1s; animation-duration: 6.2s; }
.tmc-lamp i:nth-child(4) { left: 63%; top: 56%; animation-delay: 4.4s; animation-duration: 9s; }
.tmc-lamp i:nth-child(5) { left: 38%; top: 38%; animation-delay: 5.6s; animation-duration: 7.4s; }

/* ---------------------------------------------------------------------------
 * Title screen: cave mouth, big pixel wordmark, the miner in his own gear.
 * One tap starts the game (and unlocks mobile audio).
 * ------------------------------------------------------------------------- */
.tmc-title {
  position: fixed;
  inset: 0;
  bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
  z-index: 180;
  display: grid;
  place-items: center;
  cursor: pointer;
  image-rendering: pixelated;
  /* opaque base color under the image layers: paints on the very first frame,
     so the game UI never shows through while the backdrop PNGs decode */
  background:
    radial-gradient(ellipse 100% 80% at 50% 30%, transparent 0 30%, rgb(5 7 10 / 55%) 75%, rgb(5 7 10 / 92%) 100%),
    url("../assets/env/ceiling_tutorial.png") top left repeat-x,
    url("../assets/backdrops/tutorial.png") left top / 240px 240px repeat
    #1f1c15;
  opacity: 1;
  transition: opacity 550ms ease;
}

.tmc-title.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.tmc-title-inner {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding-bottom: 5vh;
  user-select: none;
  -webkit-user-select: none;
}

.tmc-title h1 {
  margin: 0;
  font-family: "Jersey 10", "Trebuchet MS", sans-serif;
  font-size: clamp(64px, 16vw, 120px);
  line-height: 0.82;
  letter-spacing: 0.04em;
  text-align: center;
  color: #ffe078;
  text-shadow:
    0 4px 0 #a5721c,
    0 8px 0 #5c4110,
    0 12px 18px rgb(0 0 0 / 55%);
}

.tmc-title h1 span {
  display: block;
  color: #f2bf3a;
}

.tmc-title-sub {
  margin-top: 1vh;
  font-family: "Jersey 10", "Trebuchet MS", sans-serif;
  font-style: normal;
  font-size: clamp(16px, 4vw, 24px);
  letter-spacing: 0.32em;
  text-indent: 0.32em; /* recenter: letter-spacing pads only the right edge */
  text-align: center;
  color: #d8cba4;
  text-shadow: 0 2px 0 #5c4110, 0 4px 8px rgb(0 0 0 / 55%);
}

.tmc-title-stage {
  position: relative;
  width: 220px;
  height: 130px;
  margin-top: 2vh;
}

.tmc-title-glow {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 300px;
  height: 220px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle,
    rgb(255 214 130 / 34%) 0%,
    rgb(255 195 95 / 16%) 40%,
    transparent 70%);
  animation: tmcLampFlicker 4600ms ease-in-out infinite;
  pointer-events: none;
}

.tmc-title-miner {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 96px;
  height: 96px;
  transform: translateX(-50%) scale(1.35);
  transform-origin: 50% 100%;
  background: var(--miner-travel) no-repeat;
  background-size: auto 96px;
  animation: tmcThemeSheet4 560ms steps(4) infinite;
  image-rendering: pixelated;
}

/* The title miner walks in the player's REAL gear (var(--miner-travel) is the
   live recolored sheet) — so prismatic owners get their pulsing bloom on the
   home screen too. `background: inherit` tracks the parent's animated frame. */
.tmc-prism-glow .tmc-title-miner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: inherit;
  background-image: var(--miner-travel-glow);
  image-rendering: pixelated;
  animation: tmcPrismBreathe 1.9s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .tmc-prism-glow .tmc-title-miner::after {
    animation: none;
    opacity: 0.85;
  }
}

.tmc-title-ground {
  position: absolute;
  left: -30px;
  right: -30px;
  bottom: 8px;
  height: 14px;
  background: var(--tm-ground) left bottom repeat-x;
  image-rendering: pixelated;
}

.tmc-title-tag {
  margin: 1vh 0 0;
  max-width: 300px;
  text-align: center;
  color: #d8cba4;
  font-family: "Jersey 10", "Trebuchet MS", sans-serif;
  font-size: 17px;
  font-style: normal;
  letter-spacing: 0.03em;
  line-height: 1.3;
  text-shadow: 0 2px 4px rgb(0 0 0 / 60%);
}

.tmc-title-start {
  margin-top: 3vh;
  padding: 12px 26px;
  border: 2px solid #2f6230;
  border-radius: 8px;
  background: #2b7d34;
  color: #ffed92;
  font-family: "Jersey 10", "Trebuchet MS", sans-serif;
  font-size: 24px;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 0 rgb(0 0 0 / 35%);
  animation: tmcStartPulse 1600ms ease-in-out infinite;
}

@keyframes tmcStartPulse {
  0%, 100% { box-shadow: 0 4px 0 rgb(0 0 0 / 35%), 0 0 0 0 rgb(84 197 93 / 0%); }
  50% { box-shadow: 0 4px 0 rgb(0 0 0 / 35%), 0 0 14px 2px rgb(84 197 93 / 40%); }
}

/* Quiet secondary CTA: install as a home-screen app. Deliberately muted next
   to the big green start button. */
.tmc-title-install {
  margin-top: 16px;
  padding: 7px 14px;
  border: 1px solid #4a4436;
  border-radius: 6px;
  background: rgb(18 15 11 / 70%);
  color: #b3a883;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  font-size: 12.5px;
  cursor: pointer;
}

/* Returning-player summary on the title screen: bag value + auto-sold while
   away, readable before tapping in. */
.tmc-title-summary {
  display: grid;
  gap: 5px;
  margin-top: 1.6vh;
  padding: 8px 14px;
  border: 1px solid #4a4030;
  border-radius: 6px;
  background: rgb(24 32 37 / 78%);
  font-family: "Jersey 10", "Trebuchet MS", sans-serif;
  font-size: 15px;
  letter-spacing: 0.03em;
  color: #d8cba4;
}

.tmc-title-summary span {
  display: flex;
  gap: 7px;
  align-items: center;
}

.tmc-title-summary b {
  margin-left: 3px;
  color: #ffd761;
}

.tmc-ts-icon {
  width: 16px;
  height: 14px;
  background: center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #11181c) drop-shadow(0 1px #11181c);
}

.tmc-ts-bag { background-image: var(--ui-bag); }
.tmc-ts-coin { background-image: var(--ui-coin); }

/* Bag value gets the spotlight: entrance pop, then a breathing golden bloom.
   It's the actionable number — that bag sells at full price. */
.tmc-ts-bagline {
  font-size: 18px;
}

.tmc-ts-bloom {
  position: relative;
  font-size: 21px;
  color: #ffe084;
  animation:
    tmcBloomIn 640ms cubic-bezier(0.2, 1.6, 0.4, 1) 180ms backwards,
    tmcBloomPulse 2.4s ease-in-out 820ms infinite;
}

.tmc-ts-bloom::before {
  content: "";
  position: absolute;
  inset: -10px -16px;
  background: radial-gradient(closest-side, rgb(255 208 84 / 30%), transparent 72%);
  animation: tmcBloomHalo 2.4s ease-in-out 820ms infinite;
  pointer-events: none;
}

@keyframes tmcBloomIn {
  0% { opacity: 0; transform: scale(0.4); }
  62% { transform: scale(1.28); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes tmcBloomPulse {
  0%, 100% { text-shadow: 0 0 2px rgb(255 215 97 / 25%); }
  50% {
    text-shadow:
      0 0 7px rgb(255 215 97 / 85%),
      0 0 18px rgb(255 186 42 / 45%);
  }
}

@keyframes tmcBloomHalo {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  .tmc-ts-bloom,
  .tmc-ts-bloom::before {
    animation: none;
  }
}

/* Short landscape (phone rotated): two-column title so the CTA and install
   button stay above the fold. */
@media (orientation: landscape) and (max-height: 520px) {
  .tmc-title-inner {
    grid-template-columns: auto auto;
    grid-template-areas:
      "logo stage"
      "sub  cta"
      "tag  install";
    align-items: center;
    column-gap: 44px;
    row-gap: 4px;
    padding-bottom: 0;
  }

  .tmc-title h1 {
    grid-area: logo;
    font-size: clamp(44px, 20vh, 84px);
  }

  .tmc-title-sub {
    grid-area: sub;
    margin-top: 0;
    font-size: clamp(13px, 4vh, 18px);
  }

  .tmc-title-stage {
    grid-area: stage;
    margin-top: 0;
    height: 118px;
  }

  .tmc-title-tag {
    grid-area: tag;
    margin: 0;
    max-width: 260px;
  }

  /* Summary takes the tagline's slot in the tight two-column layout —
     a returning player's numbers beat a random tagline. */
  .tmc-title-summary {
    grid-area: tag;
    margin-top: 0;
  }

  .tmc-title-inner:has(.tmc-title-summary:not([hidden])) .tmc-title-tag {
    display: none;
  }

  .tmc-title-start {
    grid-area: cta;
    justify-self: center;
    margin-top: 6px;
    padding: 10px 22px;
    font-size: 21px;
  }

  .tmc-title-install {
    grid-area: install;
    justify-self: center;
    margin-top: 2px;
  }
}

.tmc-title-sheet {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(5 7 10 / 68%);
  cursor: default;
}

.tmc-title-sheet[hidden] {
  display: none;
}

.tmc-title-sheet-card {
  width: 300px;
  max-width: 84vw;
  padding: 18px 20px 16px;
  border: 2px solid #4a4436;
  border-radius: 10px;
  background: #1d1913;
  color: #e8dfc2;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
}

.tmc-title-sheet-card > b {
  display: block;
  margin-bottom: 8px;
  color: #ffe078;
}

.tmc-title-sheet-card li b {
  color: #ffe078;
}

.tmc-title-sheet-card ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.tmc-title-sheet-card li {
  margin-bottom: 4px;
}

.tmc-title-sheet-card p {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: #b3a883;
}

.tmc-title-sheet-close {
  display: inline-block;
  padding: 6px 16px;
  border: 1px solid #4a4436;
  border-radius: 6px;
  background: #2a241b;
  color: #ffe078;
  font-size: 13px;
  cursor: pointer;
}

/* Descend transition: brief blackout with the destination name. */
.tmc-descend {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: #05070a;
  color: #e8d9a8;
  font-size: 20px;
  letter-spacing: 1px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
}

.tmc-descend.is-active {
  opacity: 1;
  pointer-events: auto;
}

.tmc-descend span {
  display: block;
  margin-top: 6px;
  color: #9fb0b9;
  font-size: 12px;
}

.tmc-frame.is-rumbling {
  animation: tmcRumble 420ms steps(8);
}

/* ---------------------------------------------------------------------------
 * Scene: miner + ore + ground. All sprite boxes are native asset pixels;
 * the one and only scale step is the transform below.
 * ------------------------------------------------------------------------- */

.tmc-companion {
  position: relative;
  flex: 0 0 auto;
  width: 240px;
  height: 150px;
  margin: auto;
  transform: scale(var(--tm-scene-scale));
  transform-origin: center center;
  pointer-events: none;
  transition: opacity 140ms ease;
  image-rendering: pixelated;
}

.tmc-companion.is-god-mode {
  filter:
    drop-shadow(0 0 3px rgb(255 236 122 / 90%))
    drop-shadow(0 0 8px rgb(122 209 255 / 85%))
    drop-shadow(0 0 13px rgb(84 197 93 / 70%));
}

.tmc-companion.is-god-mode::before,
.tmc-companion.is-god-mode::after {
  content: "";
  position: absolute;
  inset: -16px 24px 4px 30px;
  pointer-events: none;
  z-index: 10;
  image-rendering: pixelated;
  background:
    radial-gradient(circle, #fff5a3 0 3px, transparent 4px) 12px 15px / 42px 36px,
    radial-gradient(circle, #7ad1ff 0 3px, transparent 4px) 36px 3px / 51px 45px,
    radial-gradient(circle, #54c55d 0 3px, transparent 4px) 6px 33px / 57px 48px,
    radial-gradient(circle, #ffffff 0 2px, transparent 3px) 27px 24px / 33px 33px;
  animation: tmcGodSparkles 720ms steps(4) infinite;
}

.tmc-companion.is-god-mode::after {
  inset: -6px 12px -4px 44px;
  opacity: 0.85;
  animation-duration: 520ms;
  animation-direction: reverse;
}

/* Full-width treadmill ground: tiled pebble strip, scrolled by JS in lock-step
   with the ore's approach so the miner reads as walking toward it. */
.tmc-ground {
  position: absolute;
  left: -2400px;
  right: -2400px;
  bottom: 19px;
  height: 14px;
  background: var(--tm-ground) left bottom repeat-x;
  image-rendering: pixelated;
  z-index: 1;
}

.tmc-miner,
.tmc-ore {
  position: absolute;
  pointer-events: auto;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.tmc-miner {
  left: 36px;
  bottom: 28px;
  width: 96px;
  height: 96px;
  overflow: visible;
  z-index: 6;
}

.tmc-miner-body {
  position: absolute;
  display: block;
  pointer-events: none;
  image-rendering: pixelated;
  left: 0;
  top: 0;
  width: 96px;
  height: 96px;
  background-repeat: no-repeat;
  background-size: auto 96px;
  background-image: var(--miner-travel);
  /* walk cadence is stride-synced to the treadmill speed by JS */
  animation: tmcThemeSheet4 var(--tm-walk-ms, 560ms) steps(4) infinite;
  transform: none;
  transform-origin: 50% 100%;
  z-index: 3;
}

/* subtle body bob while walking (two footfalls per sheet cycle) */
.tmc-companion[data-phase="traveling"] .tmc-miner {
  animation: tmcWalkBob calc(var(--tm-walk-ms, 560ms) / 2) ease-in-out infinite;
}

/* mining swing with real timing: long wind-up, snap strike, quick recover.
   Sheet frames: f0 follow-through, f1 raised, f2 impact, f3 mid-swing. */
.tmc-companion[data-phase="mining"] .tmc-miner-body {
  background-image: var(--miner-mine-cycle);
  /* Intentional scale-up while mining (Chad): the bigger pose at impact
     outweighs the slight pixel-grid mismatch with the ore. */
  transform: translateX(45px) translateY(3px) scale(1.21);
  animation: tmcMineSwing var(--tm-swing-ms, 680ms) linear infinite;
}

.tmc-companion[data-phase="bag_full"] .tmc-miner-body {
  background-image: var(--miner-tired-enter);
  animation: tmcThemeSheet4Hold 760ms steps(3) forwards;
}

/* After the tired-enter animation lands, the 2-frame breathing loop takes over
   (class added by content.js on animationend). */
.tmc-companion[data-phase="bag_full"].is-tired-hold .tmc-miner-body {
  background-image: var(--miner-tired-hold);
  animation: tmcThemeSheet2Loop 900ms steps(2) infinite;
}

/* Sprint feel: the stride never restarts — the body just leans in while the
   world surges (smoothed), plus dust. */
.tmc-companion[data-phase="traveling"] .tmc-miner-body {
  transition: transform 170ms ease;
}

.tmc-companion.phase-snap .tmc-miner-body {
  transition: none;
}

.tmc-companion.is-hustling[data-phase="traveling"] .tmc-miner-body {
  transform: translateX(6px);
}

.tmc-companion.tired-pop .tmc-miner-body {
  background-image: var(--miner-tired-enter);
  animation: tmcThemeSheet4Hold 450ms steps(3) forwards;
}

/* Headlamp flare (owner 2026-07-10): while #tmc-root carries .tmc-lamp-flare
   (lucky ore on screen / gem just spotted), every miner pose swaps to its
   -flare sheet — same art, lamp glass lit yellow. Falls back to the normal
   sheet until gear-skin has generated the flare variants. */
.tmc-lamp-flare .tmc-miner-body {
  background-image: var(--miner-travel-flare, var(--miner-travel));
}
.tmc-lamp-flare .tmc-companion[data-phase="mining"] .tmc-miner-body {
  background-image: var(--miner-mine-cycle-flare, var(--miner-mine-cycle));
}
.tmc-lamp-flare .tmc-companion[data-phase="bag_full"] .tmc-miner-body {
  background-image: var(--miner-tired-enter-flare, var(--miner-tired-enter));
}
.tmc-lamp-flare .tmc-companion[data-phase="bag_full"].is-tired-hold .tmc-miner-body {
  background-image: var(--miner-tired-hold-flare, var(--miner-tired-hold));
}
.tmc-lamp-flare .tmc-companion.tired-pop .tmc-miner-body {
  background-image: var(--miner-tired-enter-flare, var(--miner-tired-enter));
}

/* Prismatic gear bloom: a glow-only copy of the gear sheet breathes behind the
   sprite (owner ask 2026-07-07 — pulse like the gem twinkle). `background:
   inherit` tracks the parent's ANIMATED background-position frame-perfectly,
   so the glow always matches the current cel; only its opacity pulses. The
   glow sheet is pre-erased under the sprite silhouette, so paint order can
   never tint the miner himself. */
.tmc-prism-glow .tmc-miner-body::after {
  content: "";
  position: absolute;
  inset: 0;
  background: inherit;
  background-image: var(--miner-travel-glow);
  image-rendering: pixelated;
  animation: tmcPrismBreathe 1.9s ease-in-out infinite;
}
.tmc-prism-glow .tmc-companion[data-phase="mining"] .tmc-miner-body::after {
  background-image: var(--miner-mine-cycle-glow);
}
.tmc-prism-glow .tmc-companion[data-phase="bag_full"] .tmc-miner-body::after {
  background-image: var(--miner-tired-enter-glow);
}
.tmc-prism-glow .tmc-companion[data-phase="bag_full"].is-tired-hold .tmc-miner-body::after {
  background-image: var(--miner-tired-hold-glow);
}
.tmc-prism-glow .tmc-companion.tired-pop .tmc-miner-body::after {
  background-image: var(--miner-tired-enter-glow);
}

@keyframes tmcPrismBreathe {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .tmc-prism-glow .tmc-miner-body::after {
    animation: none;
    opacity: 0.85;
  }
}

.tmc-ore {
  right: 20px;
  bottom: 27px;
  width: 72px;
  height: 60px;
  background: var(--ore-sprite) center bottom / contain no-repeat;
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc((1 - var(--ore-arrival, 0)) * var(--ore-enter-distance, 150px)));
  /* transform must stay instant (arrival drives it per frame). Hiding is
     instant too — at the break the ore must vanish the same frame, or the
     already-swapped next-ore sprite shows beside the burst. */
  transition: none;
  z-index: 2;
}

.tmc-ore.is-visible {
  opacity: 1;
  pointer-events: auto;
  /* the fade covers only the post-burst REAPPEARANCE so it never pops in */
  transition: opacity 150ms ease;
}

.tmc-ore[data-ore="stone"] { --ore-sprite: var(--ore-stone); }
.tmc-ore[data-ore="tin"] { --ore-sprite: var(--ore-tin); }
.tmc-ore[data-ore="copper"] { --ore-sprite: var(--ore-copper); }
.tmc-ore[data-ore="iron"] { --ore-sprite: var(--ore-iron); }
.tmc-ore[data-ore="mithril"] { --ore-sprite: var(--ore-mithril); }
.tmc-ore[data-ore="adamite"] { --ore-sprite: var(--ore-adamite); }
.tmc-ore[data-ore="gold"] { --ore-sprite: var(--ore-gold); }
.tmc-ore[data-ore="amethyst"] { --ore-sprite: var(--ore-amethyst); }
.tmc-ore[data-ore="runite"] { --ore-sprite: var(--ore-runite); }
.tmc-ore[data-ore="diamond"] { --ore-sprite: var(--ore-diamond); }
.tmc-ore[data-ore="netherite"] { --ore-sprite: var(--ore-netherite); }
.tmc-ore[data-ore="prismatic"] { --ore-sprite: var(--ore-prismatic); }

/* Props strip: beams/lanterns/set pieces riding the treadmill behind the miner. */
.tmc-props {
  position: absolute;
  left: -2400px;
  right: -2400px;
  bottom: 31px;
  height: 124px;
  background: var(--tm-props) left bottom repeat-x;
  image-rendering: pixelated;
  z-index: 1;
}

/* Ore fragments thrown when the rock breaks. */
.tmc-frag {
  position: absolute;
  width: 4px;
  height: 4px;
  pointer-events: none;
  image-rendering: pixelated;
  z-index: 8;
  animation: tmcFrag 560ms ease-in forwards;
}

/* Coins flying from a sale up to the header counter. */
.tmc-flycoin {
  position: fixed;
  width: 14px;
  height: 14px;
  background: var(--ui-coin) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #3c2511) drop-shadow(0 1px #3c2511);
  pointer-events: none;
  z-index: 150;
  transition: transform 560ms cubic-bezier(.5, -0.2, .9, .6), opacity 560ms ease;
}

.tmc-coins.is-pinged {
  animation: tmcCoinPing 260ms ease-out;
}

/* One-shot spark burst shown where the ore was when it breaks. */
/* Path gem: hovers above the trail ahead, scrolls with the ground, collected
   when the miner walks under it. In FRONT of the miner (z 7 > miner 6) so it
   reads clearly as it passes him. */
.tmc-gem {
  position: absolute;
  left: 200px;
  bottom: 36px;   /* hovers above the path (ground line ~27px) */
  /* 2× the sprite's native 12×10 — at full walking speed the native size was
     too easy to miss (owner report 2026-07-07) */
  width: 24px;
  height: 20px;
  background: url("../assets/sprites/ui/gem-rare.png") center bottom / contain no-repeat;
  image-rendering: pixelated;
  opacity: 0;
  pointer-events: none;
  z-index: 7;
  filter: drop-shadow(0 0 3px rgb(120 236 222 / 55%));
}

.tmc-gem.is-ultra {
  width: 28px;
  height: 24px;
  background-image: url("../assets/sprites/ui/gem-ultra.png");
  filter: drop-shadow(0 0 4px rgb(220 130 255 / 60%));
}

.tmc-gem.is-visible {
  opacity: 1;
  animation:
    tmcGemFloat 2.3s ease-in-out infinite,
    tmcGemTwinkle 1.4s ease-in-out infinite;
}

@keyframes tmcGemFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes tmcGemTwinkle {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 3px rgb(160 240 230 / 45%)); }
  50% { filter: brightness(1.45) drop-shadow(0 0 6px rgb(200 250 244 / 75%)); }
}

@media (prefers-reduced-motion: reduce) {
  .tmc-gem.is-visible { animation: none; }
}

/* Gem spawn announce: expanding ring glint where the gem lands on the path
   (sparkle frags spawn alongside in JS). No sound by design — the stinger is
   reserved for the pickup. */
.tmc-gem-ping {
  position: absolute;
  bottom: 32px;
  width: 10px;
  height: 10px;
  margin-left: 7px;
  border: 2px solid rgb(160 240 230 / 85%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 7;
  animation: tmcGemPing 720ms ease-out forwards;
}

.tmc-gem-ping.is-ultra {
  border-color: rgb(220 130 255 / 85%);
}

@keyframes tmcGemPing {
  0% { opacity: 1; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(4.6); }
}

/* Gem pickup celebration: center-scene burst with the coin count-up. Purely
   presentational — the game never pauses under it. */
.tmc-gem-celebrate {
  position: fixed;
  left: 50%;
  top: 34%;
  z-index: 160;
  display: grid;
  justify-items: center;
  gap: 4px;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
}

.tmc-gc-rays {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 132px;
  height: 132px;
  margin: -66px 0 0 -66px;
  background: repeating-conic-gradient(rgb(160 240 230 / 22%) 0 9deg, transparent 9deg 30deg);
  border-radius: 50%;
  mask-image: radial-gradient(circle, #000 18%, transparent 68%);
  -webkit-mask-image: radial-gradient(circle, #000 18%, transparent 68%);
  animation: tmcGemRays 1.4s linear infinite;
}

.tmc-gem-celebrate.is-ultra .tmc-gc-rays {
  width: 156px;
  height: 156px;
  margin: -78px 0 0 -78px;
  background: repeating-conic-gradient(rgb(220 130 255 / 26%) 0 9deg, transparent 9deg 30deg);
}

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

.tmc-gc-gem {
  width: 48px;
  height: 40px;
  background: url("../assets/sprites/ui/gem-rare.png") center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 8px rgb(120 236 222 / 70%));
}

.tmc-gem-celebrate.is-ultra .tmc-gc-gem {
  width: 56px;
  height: 48px;
  background-image: url("../assets/sprites/ui/gem-ultra.png");
  filter: drop-shadow(0 0 10px rgb(220 130 255 / 75%));
}

.tmc-gc-value {
  font-size: 24px;
  font-weight: 900;
  color: #7becde;
  text-shadow: 0 2px 0 #0d2b27, 0 0 12px rgb(120 236 222 / 45%);
}

.tmc-gem-celebrate.is-ultra .tmc-gc-value {
  font-size: 27px;
  color: #e2a6ff;
  text-shadow: 0 2px 0 #2a1233, 0 0 12px rgb(220 130 255 / 50%);
}

.tmc-gem-celebrate.is-live {
  animation: tmcGemCelebrate 1250ms ease-out forwards;
}

.tmc-gem-celebrate.is-ultra.is-live {
  animation-duration: 1650ms;
}

@keyframes tmcGemCelebrate {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  10% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  16% { transform: translate(-50%, -50%) scale(1); }
  78% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -56%) scale(0.92); }
}

/* Gem receipt toast: slides in from the top edge and lingers past the
   celebration, so a player who looked away still gets the story. */
.tmc-gem-toast {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 170;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 2px solid #2e5f58;
  border-radius: 8px;
  background: #10201e;
  color: #d6fff8;
  font-size: 13px;
  transform: translate(-50%, -160%);
  opacity: 0;
  pointer-events: none;
  transition: transform 280ms cubic-bezier(.2, .9, .3, 1.2), opacity 280ms ease;
}

.tmc-gem-toast i {
  width: 20px;
  height: 17px;
  background: url("../assets/sprites/ui/gem-rare.png") center / contain no-repeat;
  image-rendering: pixelated;
}

.tmc-gem-toast.is-ultra {
  border-color: #6b4a86;
  background: #1d1524;
  color: #f0dcff;
}

.tmc-gem-toast.is-ultra i {
  background-image: url("../assets/sprites/ui/gem-ultra.png");
}

.tmc-gem-toast b {
  color: #ffe078;
}

.tmc-gem-toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .tmc-gem-ping { animation: none; opacity: 0; }
  .tmc-gc-rays { animation: none; }
  .tmc-gem-celebrate.is-live { animation: tmcGemCelebrateStill 1250ms ease-out forwards; }
  .tmc-gem-toast { transition: opacity 280ms ease; }
}

@keyframes tmcGemCelebrateStill {
  0% { opacity: 0; }
  12% { opacity: 1; }
  78% { opacity: 1; }
  100% { opacity: 0; }
}

.tmc-ore-burst {
  position: absolute;
  right: 20px;
  bottom: 27px;
  width: 72px;
  height: 60px;
  background: var(--ore-sprite) center bottom / contain no-repeat;
  image-rendering: pixelated;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

.tmc-ore-burst.is-live {
  animation: tmcOreBurst 360ms steps(3) forwards;
}

/* Lucky ore glints while it's on screen. */
.tmc-ore.is-lucky {
  animation: tmcLuckyShimmer 1500ms ease-in-out infinite;
}

/* Tappable nudge while the bag is full. */
.tmc-sell-hint {
  position: absolute;
  left: 44px;
  bottom: 134px;
  display: none;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  z-index: 15;
  transition: bottom 160ms ease;
}

/* Stacking rule: while the speech bubble is up, the sell pill anchors ABOVE it
   and reward toasts drop BELOW it, so the three never overlap. */
.tmc-companion.has-speech .tmc-sell-hint {
  bottom: 188px;
}

.tmc-companion.has-speech .tmc-rewards {
  bottom: 60px;
}

.tmc-sell-hint span {
  display: block;
  padding: 5px 8px;
  border: 2px solid #2f6230;
  border-radius: 6px;
  background: #2b7d34;
  color: #ffed92;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 3px 0 rgb(0 0 0 / 25%);
  animation: tmcSellHintBob 1100ms ease-in-out infinite;
}

.tmc-sell-hint.is-visible {
  display: block;
}

/* The lamp settles while he rests on a full bag. */
.tmc-lamp {
  transition: opacity 700ms ease;
}

.tmc-frame.is-resting .tmc-lamp {
  animation: none;
  opacity: 0.72;
}

.tmc-tabs button.is-tip-glow {
  border-color: #8b6621;
  color: #ffe078;
  animation: tmcTabGlow 1200ms ease-in-out infinite;
}

.tmc-lucky-alert {
  position: absolute;
  right: 48px;
  bottom: 92px;
  width: 16px;
  height: 16px;
  display: none;
  opacity: 1;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 9;
  /* rides in with the ore it's marking */
  transform: translateX(calc((1 - var(--ore-arrival, 1)) * var(--ore-enter-distance, 150px)));
}

.tmc-lucky-alert span {
  display: block;
  width: 16px;
  height: 16px;
  border: 2px solid #3a2410;
  border-radius: 999px;
  background: #ffe45f;
  color: #2a1a0c;
  font-size: 15px;
  line-height: 12px;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 1px #fff7ad;
  box-shadow: 0 2px 0 rgb(0 0 0 / 22%), 0 0 5px rgb(255 228 95 / 55%);
  transform-origin: 50% 70%;
  image-rendering: pixelated;
}

.tmc-lucky-alert.is-visible {
  display: block;
}

.tmc-lucky-alert.is-visible span {
  animation: tmcLuckyPulse 1400ms ease-in-out infinite;
}

/* Discovery beam (reworked 2026-07-10 v2 — owner: soft falloff everywhere,
   and the tip must ride the lamp on EVERY animation frame).
   Construction: a conic wedge (soft angular edges) whose length falloff comes
   from a radial mask, so every edge of the cone fades fully to nothing; a
   small radial hotspot sits at the origin so the tip visually touches the
   glass. The cone's ORIGIN is animated with `translate` in a step-end track
   that runs at the sprite's own cadence (same duration var), so the origin
   jumps with the lamp every cel — walk and mine each have their own anchor
   track from masks/lamps.json positions. The slow search-sway stays on
   `transform` (rotate), which composes with `translate` without conflict. */
.tmc-companion.is-lucky-active .tmc-miner::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -19px;
  width: 96px;
  height: 100px;
  background:
    radial-gradient(circle at 0% 31%,
      rgb(255 242 175 / 75%) 0, rgb(255 232 140 / 45%) 4px, rgb(255 226 125 / 0%) 13px),
    conic-gradient(from 76deg at 0% 31%,
      transparent 0deg,
      rgb(255 226 125 / 18%) 11deg,
      rgb(255 229 132 / 32%) 17deg,
      rgb(255 231 138 / 42%) 21deg,
      rgb(255 231 138 / 42%) 27deg,
      rgb(255 229 132 / 32%) 31deg,
      rgb(255 226 125 / 18%) 37deg,
      transparent 48deg);
  -webkit-mask-image: radial-gradient(100px 100px at 0% 31%,
      #000 34%, rgb(0 0 0 / 55%) 62%, transparent 90%);
  mask-image: radial-gradient(100px 100px at 0% 31%,
      #000 34%, rgb(0 0 0 / 55%) 62%, transparent 90%);
  mix-blend-mode: screen;   /* light adds over the dark cave instead of greying it */
  translate: 77px 11px;     /* frame-0 lamp anchor; the step track below owns this */
  transform: rotate(0deg);
  transform-origin: 0 31%;
  animation:
    tmcBeamAnchorWalk var(--tm-walk-ms, 560ms) step-end infinite,
    tmcHelmetBeam 2600ms ease-in-out infinite;
  pointer-events: none;
  z-index: 7;
}
/* mining: the lamp lives elsewhere per cel (and the body is shifted +45px,
   scale 1.21 — anchors below are pre-mapped through that transform); beam
   aims down at the rock, per-cel rotation baked into the anchor track */
.tmc-companion[data-phase="mining"].is-lucky-active .tmc-miner::before {
  animation:
    tmcBeamAnchorMine var(--tm-swing-ms, 680ms) step-end infinite,
    tmcBeamGlowMine 2600ms ease-in-out infinite;
}
@keyframes tmcBeamAnchorWalk {
  /* lamp front-center per travel cel (masks/lamps.json) */
  0%   { translate: 77px 11px; }
  25%  { translate: 76px 8px; }
  50%  { translate: 78px 11px; }
  75%  { translate: 76px 8px; }
  100% { translate: 77px 11px; }
}
@keyframes tmcBeamAnchorMine {
  /* Anchor AND angle per mine_cycle cel. The percentages MIRROR tmcMineSwing
     exactly (0/20/55/78 — wind-up hold, anticipation, impact, pull-out), so
     the beam changes cel at the same instant as the sprite; both animations
     start on the same phase flip and share var(--tm-swing-ms). Anchors are
     MEASURED lamp centers per cel (masked warm-glass cluster) mapped through
     the mining body transform; angles aim the midline at the ore face. */
  /* angles follow the HELMET (near-level through the swing — owner beam-lab
     review id 6: no steep dives while the helmet doesn't tilt), not the ore */
  0%   { translate: 127px 20px; transform: rotate(38deg); }
  20%  { translate: 124px 21px; transform: rotate(36deg); }
  55%  { translate: 97px 18px; transform: rotate(36deg); }
  78%  { translate: 94px 18px; transform: rotate(34deg); }
  100% { translate: 94px 18px; transform: rotate(34deg); }
}

.tmc-status {
  position: absolute;
  left: 0;
  bottom: 4px;
  width: 100%;
  color: #c9d3d8;
  font-size: 13px;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 2px rgb(0 0 0 / 65%);
  pointer-events: none;
}

.tmc-speech {
  position: absolute;
  left: 8px;
  bottom: 138px;
  width: 170px;
  padding: 5px 6px;
  border: 2px solid #2a1d12;
  border-radius: 6px;
  background: #fff6cf;
  color: #2a1d12;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  opacity: 0;
  transform: translateY(4px) scale(0.94);
  transform-origin: 72px 100%;
  pointer-events: none;
  box-shadow: 0 3px 0 rgb(0 0 0 / 18%);
  z-index: 14;
  transition: opacity 140ms ease, transform 140ms ease;
}

.tmc-speech::after {
  content: "";
  position: absolute;
  left: 68px;
  bottom: -7px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #2a1d12;
  border-bottom: 2px solid #2a1d12;
  background: #fff6cf;
  transform: rotate(45deg);
}

.tmc-speech.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tmc-rewards {
  position: absolute;
  left: 70px;
  bottom: 100px;
  width: 110px;
  pointer-events: none;
  transition: bottom 160ms ease;
  z-index: 13;   /* above the sprites, below the speech bubble (14) */
}

.tmc-reward {
  position: absolute;
  left: 0;
  bottom: 0;
  white-space: nowrap;
  padding: 2px 4px;
  border: 1px solid #1c2328;
  border-radius: 4px;
  background: #fbf4ca;
  color: #1b2227;
  font-size: 10px;
  font-weight: 800;
  animation: tmcFloat 1500ms ease-out forwards;
}

.tmc-reward.coins {
  background: #ffe084;
}

.tmc-reward.coins.sell {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffd761;
  font-size: 14px;
  text-shadow:
    -1px 0 #3c2511,
    1px 0 #3c2511,
    0 -1px #3c2511,
    0 1px #3c2511,
    0 2px 0 rgb(0 0 0 / 22%);
  animation: tmcSellFloat 2100ms cubic-bezier(.2, 1.35, .26, 1) forwards;
}

.tmc-reward.coins.sell-tier-1 {
  font-size: 15px;
}

.tmc-reward.coins.sell-tier-2 {
  font-size: 17px;
  filter: drop-shadow(0 0 3px rgb(255 215 97 / 42%));
}

.tmc-reward.coins.sell-tier-3 {
  font-size: 20px;
  filter: drop-shadow(0 0 5px rgb(255 215 97 / 58%));
  animation-duration: 2300ms;
}

.tmc-reward.coins.sell-tier-4 {
  font-size: 23px;
  filter: drop-shadow(0 0 7px rgb(255 215 97 / 72%));
  animation-duration: 2500ms;
}

.tmc-reward.coins.sell i {
  width: 15px;
  height: 15px;
  background: var(--ui-coin) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #3c2511) drop-shadow(0 1px #3c2511);
}

.tmc-reward.coins.sell::after {
  content: "";
  width: 3px;
  height: 3px;
  background: #fff1a8;
  box-shadow: 7px -5px 0 #ffd761, 13px 1px 0 #fff1a8, 4px 7px 0 #ffb83d;
  image-rendering: pixelated;
  animation: tmcSellSpark 620ms steps(2) 2;
}

/* Scene effect pops -------------------------------------------------------- */

/* Dust anchors to its own layer near the miner's boots (the ground strip now
   spans the whole screen, so it can't anchor the effect anymore). */
.tmc-dust {
  position: absolute;
  left: 30px;
  bottom: 30px;
  width: 60px;
  height: 24px;
  pointer-events: none;
  image-rendering: pixelated;
  z-index: 5;
}

.tmc-companion.dust-pop .tmc-dust::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 4px;
  width: 39px;
  height: 20px;
  background: radial-gradient(#d8bd8c 3px, transparent 4px);
  background-size: 12px 9px;
  opacity: 0.9;
  box-shadow: 12px 4px 0 -3px #b9935c, 26px 2px 0 -3px #d8bd8c, 36px 6px 0 -3px #b9935c;
  animation: tmcDust 420ms ease-out forwards;
}

.tmc-companion.dust-pop .tmc-dust::before {
  content: "";
  position: absolute;
  left: 30px;
  top: 8px;
  width: 30px;
  height: 12px;
  background: radial-gradient(#c9a46b 3px, transparent 4px);
  background-size: 10px 7px;
  opacity: 0.75;
  box-shadow: 15px 3px 0 -3px #d8bd8c, 27px 0 0 -3px #b9935c;
  animation: tmcDustFollow 420ms ease-out forwards;
}

/* Helping-tap impact: the ore flashes and shakes, sparks fly — the miner's
   own swing loop is never interrupted. */
.tmc-companion.hit-pop .tmc-ore {
  animation: tmcOreShake 210ms steps(2), tmcOreHitFlash 300ms ease-out;
}

.tmc-companion.hit-pop .tmc-miner::after {
  content: "";
  position: absolute;
  left: 118px;
  top: 56px;
  width: 4px;
  height: 4px;
  background: #ffd45a;
  opacity: 0;
  z-index: 12;
  pointer-events: none;
  box-shadow: 8px -5px 0 #ffd45a, 14px 0 0 #fff1a8, 3px -12px 0 #ff8d3a, 17px -11px 0 #ffd45a, 6px 8px 0 #fff1a8;
  animation: tmcAxeSparks 620ms linear forwards;
}

/* ---------------------------------------------------------------------------
 * Menu: always-open bottom sheet. Full-width on phones, centered card on
 * larger screens.
 * ------------------------------------------------------------------------- */

.tmc-panel {
  flex: 0 0 auto;
  width: 100%;
  max-width: 560px;
  border: 2px solid #0f1316;
  border-top-color: color-mix(in srgb, var(--tmc-accent, #f2bf3a) 40%, #0f1316);
  border-bottom-width: 0;
  background: #11171b;
  filter: drop-shadow(0 -6px 16px rgb(0 0 0 / 40%));
  clip-path: polygon(
    0 8px, 4px 8px, 4px 4px, 8px 4px, 8px 0,
    calc(100% - 8px) 0, calc(100% - 8px) 4px, calc(100% - 4px) 4px, calc(100% - 4px) 8px, 100% 8px,
    100% 100%, 0 100%
  );
  image-rendering: pixelated;
  pointer-events: auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Bigger screens sit farther from the eye: scale the whole menu up. */
@media (min-width: 700px) and (min-height: 600px) {
  .tmc-panel { zoom: 1.15; }
}

@media (min-width: 1100px) and (min-height: 600px) {
  .tmc-panel { zoom: 1.3; }
}

@media (min-width: 600px) {
  .tmc-panel {
    margin-bottom: 18px;
    border-bottom-width: 2px;
    clip-path: polygon(
      0 8px, 4px 8px, 4px 4px, 8px 4px, 8px 0,
      calc(100% - 8px) 0, calc(100% - 8px) 4px, calc(100% - 4px) 4px, calc(100% - 4px) 8px, 100% 8px,
      100% calc(100% - 8px), calc(100% - 4px) calc(100% - 8px), calc(100% - 4px) calc(100% - 4px),
      calc(100% - 8px) calc(100% - 4px), calc(100% - 8px) 100%,
      8px 100%, 8px calc(100% - 4px), 4px calc(100% - 4px), 4px calc(100% - 8px), 0 calc(100% - 8px)
    );
  }
}

/* Short landscape screens (phones rotated): scene left, menu right. */
@media (orientation: landscape) and (max-height: 520px) {
  #tmc-root { --tm-scene-scale: 1.2; }

  .tmc-frame {
    flex-direction: row;
  }

  .tmc-panel {
    display: flex;
    flex-direction: column;
    width: 46%;
    max-width: 430px;
    height: 100%;
    margin: 0;
    border-radius: 0;
    border-width: 0 0 0 2px;
    padding-bottom: 0;
    padding-right: env(safe-area-inset-right, 0px);
  }

  .tmc-panel-top {
    border-radius: 0;
  }

  /* .tmc-panel prefix beats the later base .tmc-panel-body { max-height: 42vh }
     rule (equal specificity + source order previously re-capped the panel). */
  .tmc-panel .tmc-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }
}

.tmc-panel button {
  font-family: inherit;
}

.tmc-panel-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px 6px;
  border-bottom: 1px solid var(--tmc-line);
  background: #0b0f12;
  font-size: 16px;
  line-height: 1;
}

.tmc-zone {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.tmc-bag-text {
  justify-self: end;
  padding-left: 8px;
  border-left: 1px solid #2d373e;
}

.tmc-coins {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 4px;
  color: #ffd761;
}

/* Coin sprite instead of a "$": one currency mark everywhere. */
.tmc-coins::before {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--ui-coin) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #3c2511) drop-shadow(0 1px #3c2511);
}

.tmc-zone {
  color: color-mix(in srgb, var(--tmc-accent, #f3d19a) 70%, #f3d19a);
}

.tmc-bag-text {
  color: #f3d19a;
}

.tmc-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 5px;
  border-bottom: 1px solid var(--tmc-line);
}

/* Tabs: icon stacked over an always-on label. Stays inside its cell at every
   viewport (320-844+); the label shrinks, never clips. */
.tmc-tabs button {
  position: relative;
  display: grid;
  grid-auto-flow: row;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 3px 1px 2px;
  overflow: hidden;
  border: 1px solid #39434b;
  border-radius: 6px;
  background: var(--tmc-panel-2);
  color: var(--tmc-muted);
  cursor: pointer;
  font-size: 12px;
}

.tmc-tabs button.is-active {
  border-color: color-mix(in srgb, var(--tmc-accent, #f2bf3a) 60%, #39434b);
  color: #ffe078;
  background: color-mix(in srgb, var(--tmc-accent, #f2bf3a) 14%, #14191d);
}

@media (max-width: 360px) {
  .tmc-tabs button { font-size: 11px; letter-spacing: 0; }
}

@media (min-width: 600px) {
  .tmc-tabs button { font-size: 14px; }
}

/* Persistent nudge: Go Deeper is affordable (pattern shared with the bag-full
   and goals-claimable tab states). */
.tmc-tabs button.is-descend-ready::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #ffe078;
  box-shadow: 0 0 0 2px #11181c, 0 0 6px rgb(255 224 120 / 60%);
}

.tmc-tabs button.is-bag-full {
  border-color: #a8842a;
  color: #ffe078;
  animation: tmcTabGlow 1200ms ease-in-out infinite;
}

.tmc-tabs button.is-claimable {
  border-color: #2f6230;
  animation: tmcTabGlowGreen 1200ms ease-in-out infinite;
}

.tmc-tab-dot,
.tmc-tab-bag,
.tmc-tab-gear,
.tmc-tab-star,
.tmc-mini-pick {
  display: inline-block;
  position: relative;
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}

.tmc-mini-pick {
  background: var(--ui-pick) center / contain no-repeat;
  filter: drop-shadow(1px 0 #171b1f) drop-shadow(0 1px #171b1f);
}

/* Inline pickaxe sprite — replaces the ⛏ emoji anywhere it appeared (game-feel
   consistency: sprites, not emoji). Sizes with the surrounding text. */
.tmc-ui-pick {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  vertical-align: -0.12em;
  background: var(--ui-pick) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #171b1f) drop-shadow(0 1px #171b1f);
}

/* Overview icon: the original helmet sprite (owner preference, 2026-07-05 —
   reverted from today's redesign attempts). */
.tmc-tab-dot::before {
  content: "";
  position: absolute;
  inset: -4px;
  background: var(--ui-helmet) center / contain no-repeat;
  filter: drop-shadow(1px 0 #11181c) drop-shadow(0 1px #11181c);
}

.tmc-tab-bag::before {
  content: "";
  position: absolute;
  inset: -4px;
  background: var(--ui-bag) center / contain no-repeat;
  filter: drop-shadow(1px 0 #11181c) drop-shadow(0 1px #11181c);
}

.tmc-tab-star::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 1px;
  width: 14px;
  height: 14px;
  background: linear-gradient(135deg, #ffe078 0 40%, #e0b341 41% 100%);
  clip-path: polygon(
    50% 0,
    63% 33%,
    98% 37%,
    72% 60%,
    80% 96%,
    50% 76%,
    20% 96%,
    28% 60%,
    2% 37%,
    37% 33%
  );
  filter:
    drop-shadow(1px 0 #11181c)
    drop-shadow(-1px 0 #11181c)
    drop-shadow(0 1px #11181c)
    drop-shadow(0 -1px #11181c);
}

.tmc-tab-gear::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 1px;
  width: 14px;
  height: 14px;
  background:
    linear-gradient(135deg, #dce5ea 0 18%, #aeb8bd 19% 58%, #7f8b93 59% 100%);
  clip-path: polygon(
    42% 0,
    58% 0,
    64% 18%,
    76% 8%,
    92% 24%,
    82% 36%,
    100% 42%,
    100% 58%,
    82% 64%,
    92% 76%,
    76% 92%,
    64% 82%,
    58% 100%,
    42% 100%,
    36% 82%,
    24% 92%,
    8% 76%,
    18% 64%,
    0 58%,
    0 42%,
    18% 36%,
    8% 24%,
    24% 8%,
    36% 18%
  );
  filter:
    drop-shadow(1px 0 #11181c)
    drop-shadow(-1px 0 #11181c)
    drop-shadow(0 1px #11181c)
    drop-shadow(0 -1px #11181c);
}

.tmc-tab-gear::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #202a30;
  box-shadow:
    0 0 0 1px #11181c,
    0 0 0 2px #9aa6ad,
    inset 1px 1px #11181c;
}

.tmc-panel-body {
  padding: 4px 5px 6px;
  max-height: 42vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Upgrades tab ------------------------------------------------------------- */

.tmc-upgrade {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 76px;
  gap: 4px;
  align-items: center;
  padding: 2px;
  border-bottom: 1px solid #29343a;
}

.tmc-row-main {
  display: grid;
  grid-template-columns: 30px 1fr 108px;
  gap: 5px;
  align-items: center;
  min-width: 0;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--tmc-text);
  text-align: left;
  cursor: pointer;
}

.tmc-row-icon {
  position: relative;
  width: 28px;
  height: 28px;
  font-size: 0;
  background: var(--icon) center / 28px 28px no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #11181c) drop-shadow(0 1px #11181c);
}

.tmc-row-name {
  display: grid;
  gap: 2px;
  font-size: 12px;
  line-height: 1;
}

.tmc-row-name em {
  color: var(--tmc-muted);
  font-style: normal;
  font-size: 12px;
}

.tmc-row-stat {
  display: grid;
  gap: 2px;
  justify-self: end;
  text-align: right;
  line-height: 1;
  position: relative;
  cursor: help;
}

.tmc-row-stat b {
  color: var(--tmc-blue);
  font-size: 12px;
  font-weight: 800;
}

.tmc-row-stat em {
  color: #54c55d;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.tmc-buy {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 2px solid #2f6230;
  border-radius: 4px;
  background: #2b7d34;
  color: #ffed92;
  font-weight: 800;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}

/* Invisible hit-area extender: 34px visual stays pixel-tidy, taps get >=44px. */
.tmc-buy::before {
  content: "";
  position: absolute;
  inset: -6px -3px;
}

.tmc-buy span {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}

.tmc-buy i {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: var(--ui-coin) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #3c2511) drop-shadow(0 1px #3c2511);
}

.tmc-upgrade.is-research-locked .tmc-buy {
  border-color: #3c4246;
  background: #283038;
  /* #a8b8c0 on #283038 = 6.55:1 (WCAG AA); the old #7d8a91 was 3.77:1.
     Still clearly dimmer than the affordable green/gold states. */
  color: #a8b8c0;
  cursor: pointer;
}

.tmc-upgrade.is-coin-needed .tmc-buy {
  border-color: #7b632b;
  background: #2d2a22;
  color: #ffd761;
  cursor: pointer;
}

.tmc-upgrade.is-coin-needed {
  background: linear-gradient(90deg, rgb(242 191 58 / 8%), transparent 65%);
}

.tmc-upgrade.is-max .tmc-buy {
  border-color: #4a4534;
  background: #302d23;
  color: #d6bd81;
  cursor: pointer;
}

.tmc-upgrade.is-affordable {
  background: linear-gradient(90deg, rgb(84 197 93 / 10%), transparent 65%);
}

.tmc-upgrade.is-affordable .tmc-buy {
  box-shadow: 0 0 0 1px rgb(255 237 146 / 18%), inset 0 2px rgb(255 255 255 / 14%);
}

.tmc-fun-tier-controls {
  position: absolute;
  right: 82px;
  top: 9px;
  z-index: 2;
  display: grid;
  grid-template-columns: 14px 16px 14px;
  align-items: center;
  gap: 1px;
  width: 48px;
  height: 19px;
  padding: 0;
  border: 1px solid #355245;
  border-radius: 999px;
  background: rgb(18 30 26 / 92%);
  box-shadow: 0 1px 2px rgb(0 0 0 / 28%);
}

.tmc-fun-tier-controls button {
  display: grid;
  place-items: center;
  width: 14px;
  height: 17px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #8ef08e;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.tmc-fun-tier-controls b {
  color: #c7ffb4;
  font-size: 9px;
  line-height: 1;
  text-align: center;
}

.tmc-req {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 3px 6px;
  padding: 0 2px 4px 34px;
  color: #d6bd81;
  font-size: 11px;
  line-height: 1.15;
}

.tmc-req span {
  color: var(--tmc-muted);
}

.tmc-req b {
  color: #f4d994;
  font-weight: 700;
}

.tmc-req i,
.tmc-meter-row i {
  grid-column: 1 / -1;
  display: block;
  height: 4px;
  border-radius: 99px;
  background: #0c1114;
  box-shadow: inset 0 0 0 1px #2c363c;
  overflow: hidden;
}

.tmc-req em,
.tmc-meter-row em {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #53b95a, #f2bf3a);
}

/* Depth meter picks up the zone accent. */
.tmc-meter-row em {
  background: linear-gradient(90deg, #53b95a, color-mix(in srgb, var(--tmc-accent, #f2bf3a) 75%, #f2bf3a));
}

/* Tooltips ------------------------------------------------------------------ */

.tmc-row-stat.tmc-tip,
.tmc-ore-chip.tmc-tip,
.tmc-ore-value i.tmc-tip,
.tmc-ore-info-toggle.tmc-tip,
.tmc-buy.tmc-tip,
.tmc-autosell-card.tmc-tip,
.tmc-reset-cancel.tmc-tip,
.tmc-reset-confirm.tmc-tip {
  position: relative;
}

.tmc-tip::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 5px);
  width: max-content;
  max-width: 160px;
  padding: 4px 6px;
  border: 1px solid #3d4850;
  border-radius: 4px;
  background: #10161a;
  color: #f4d994;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
  text-align: left;
  opacity: 0;
  transform: translateY(2px);
  pointer-events: none;
  box-shadow: 0 3px 8px rgb(0 0 0 / 28%);
  z-index: 50;
  transition: opacity 90ms ease, transform 90ms ease;
}

.tmc-tip[data-tooltip=""]::after {
  display: none;
}

/* Hover/focus reveal only on devices that actually hover — on touch screens a
   tap would otherwise leave a stuck :hover tooltip (tap-to-info handles touch). */
@media (hover: hover) {
  .tmc-tip:hover::after,
  .tmc-tip:focus-visible::after,
  .tmc-tip:focus-within::after {
    opacity: 1;
    transform: translateY(0);
  }
}

.tmc-tip.is-tip-open::after {
  opacity: 1;
  transform: translateY(0);
}

.tmc-ore-chip.tmc-tip::after {
  left: 0;
  right: auto;
  bottom: calc(100% + 4px);
}

/* Scene tooltips point down from the sprites (they sit mid-screen). */
.tmc-miner.tmc-tip::after,
.tmc-ore.tmc-tip::after {
  right: auto;
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  font-size: 8px;
}

.tmc-miner.tmc-tip:hover::after,
.tmc-ore.tmc-tip:hover::after {
  transform: translateX(-50%) translateY(0);
}

/* Overview tab -------------------------------------------------------------- */

.tmc-overview {
  display: grid;
  gap: 4px;
}

.tmc-zone-card,
.tmc-next-card,
.tmc-mini-stats,
.tmc-meter-row,
.tmc-settings {
  display: grid;
  gap: 8px;
  padding: 6px;
  border: 1px solid #29343a;
  border-radius: 5px;
  background: #182025;
  font-size: 12px;
}

.tmc-overview span {
  color: var(--tmc-muted);
  font-size: 12px;
}

.tmc-finished-card {
  border-color: var(--tmc-accent, #ffe078);
}

.tmc-finished-card > b {
  color: #ffe078;
}

.tmc-finished-stats {
  padding-top: 3px;
  border-top: 1px solid #29343a;
  font-size: 11px;
}

.tmc-backup-row {
  display: grid;
  gap: 4px;
}

.tmc-backup-row span {
  color: var(--tmc-muted);
  font-size: 11px;
}

.tmc-backup-row textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 4px;
  border: 1px solid #29343a;
  border-radius: 4px;
  background: #11181c;
  color: var(--tmc-muted);
  font-family: monospace;
  font-size: 10px;
  resize: none;
}

/* Native-app store card (Round G). Buttons inherit .tmc-settings button; the
   card itself matches the backup-row framing. */
.tmc-support-card {
  display: grid;
  gap: 4px;
  padding-top: 4px;
  border-top: 1px solid #29343a;
  margin-top: 8px;
}

.tmc-support-card > b {
  color: #ffe078;
}

.tmc-support-card > span {
  color: var(--tmc-muted);
  font-size: 11px;
}

.tmc-support-owned {
  color: var(--tmc-muted);
  font-style: normal;
  font-size: 11px;
}

.tmc-iap-autosell {
  margin-top: 4px;
}

.tmc-about {
  display: grid;
  gap: 2px;
  padding-top: 6px;
  border-top: 1px solid #29343a;
  text-align: center;
}

.tmc-about span {
  color: var(--tmc-muted);
  font-size: 11px;
}

.tmc-meter-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.tmc-meter-row b {
  color: #ffe078;
}

.tmc-meter-hint {
  grid-column: 1 / -1;
  color: var(--tmc-muted);
  font-size: 11px;
  font-style: normal;
  text-decoration: none;
}

.tmc-buy .tmc-ore-mini {
  display: inline-block;
  width: 14px;
  height: 12px;
  background: var(--ore-img) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #11181c) drop-shadow(0 1px #11181c);
}

.tmc-mini-stats {
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.tmc-gem-mini {
  display: inline-block;
  width: 13px;
  height: 11px;
  margin-right: 4px;
  background: url("../assets/sprites/ui/gem-rare.png") center / contain no-repeat;
  image-rendering: pixelated;
  vertical-align: -1px;
}

.tmc-mini-stats div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tmc-mini-stats b {
  color: #ffe078;
  font-size: 12px;
}

.tmc-mini-stats span {
  font-size: 11px;
}

.tmc-go,
.tmc-settings .tmc-on {
  color: #7ede96;
  font-style: normal;
}

.tmc-toggle-row {
  display: flex;
  gap: 8px;
}
.tmc-toggle-row button {
  flex: 1 1 0;
  min-width: 0;
  height: auto;
  min-height: 44px;
  padding: 8px 6px;
  font-size: 12px;
  line-height: 1.3;
  white-space: normal;
}

.tmc-settings button {
  height: 44px;
  border: 1px solid #39434b;
  border-radius: 4px;
  background: #202a30;
  color: var(--tmc-text);
  cursor: pointer;
}

.tmc-go.is-ready {
  border-color: #80631c;
  background: #5c4618;
  color: #ffe078;
}

.tmc-go.is-locked {
  color: #9fb0b9;
  background: #202a30;
}

/* Bag tab -------------------------------------------------------------------- */

.tmc-bag-page {
  display: grid;
  gap: 5px;
}

.tmc-sell-panel {
  display: grid;
  grid-template-columns: 54px 1fr 40px 88px;
  gap: 6px;
  align-items: center;
  padding: 6px;
  border: 1px solid #29343a;
  border-radius: 5px;
  background: #182025;
  font-size: 11px;
}

.tmc-sell-panel b {
  color: #ffe078;
}

.tmc-sell-panel span {
  color: var(--tmc-muted);
  font-size: 12px;
}

.tmc-total-value {
  display: inline-grid;
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: 2px;
  color: #ffd761 !important;
}

.tmc-total-value i {
  width: 11px;
  height: 11px;
  background: var(--ui-coin) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #3c2511) drop-shadow(0 1px #3c2511);
}

.tmc-sell-panel button {
  height: 44px;
  border: 1px solid #2f6230;
  border-radius: 4px;
  background: #2b7d34;
  color: #ffed92;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.tmc-sell-panel .tmc-ore-info-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  justify-self: center;
  padding: 0;
  border: 1px solid #45636f;
  border-radius: 999px;
  background: #1a2a31;
  color: #a9dff2;
  font-size: 11px;
  font-weight: 900;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  cursor: pointer;
  box-shadow: inset 0 1px rgb(255 255 255 / 8%);
}

.tmc-sell-panel .tmc-ore-info-toggle::before {
  content: "";
  position: absolute;
  inset: -4px;
}

.tmc-sell-panel .tmc-ore-info-toggle.is-open {
  border-color: #79bfd8;
  background: #203a44;
  color: #d9f6ff;
}

.tmc-sell-panel button:disabled {
  border-color: #3c4246;
  background: #283038;
  /* #a8b8c0 on #283038 = 6.55:1 (WCAG AA); the old #7d8a91 was 3.77:1.
     Still clearly dimmer than the affordable green/gold states. */
  color: #a8b8c0;
  cursor: default;
}

.tmc-ore-info {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 5px;
  border: 1px solid #29343a;
  border-radius: 5px;
  background: #10171b;
}

.tmc-ore-info.is-open {
  display: grid;
}

.tmc-ore-value {
  display: grid;
  grid-template-columns: 22px minmax(42px, 1fr) 11px;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 3px 4px;
  border: 1px solid #263037;
  border-radius: 3px;
  background: #151d22;
}

.tmc-ore-value.is-fun-add {
  border-color: #317844;
  background: #14241b;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgb(88 221 104 / 12%);
}

.tmc-ore-value.is-fun-add:hover {
  filter: brightness(1.08);
}

.tmc-ore-value i {
  width: 22px;
  height: 18px;
  background: var(--ore-img) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #111) drop-shadow(0 1px #111);
}

.tmc-ore-value b {
  min-width: 0;
  color: #ffd761;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.tmc-ore-value em {
  width: 11px;
  height: 11px;
  background: var(--ui-coin) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #3c2511) drop-shadow(0 1px #3c2511);
}

.tmc-ore-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.tmc-ore-chip,
.tmc-empty {
  min-height: 38px;
  border: 1px solid #29343a;
  border-radius: 5px;
  background: #182025;
}

.tmc-ore-chip {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 1px 4px;
  align-items: center;
  padding: 4px;
  color: var(--tmc-text);
}

.tmc-ore-chip i {
  grid-row: 1 / 3;
  width: 22px;
  height: 19px;
  background: var(--ore-img) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #111) drop-shadow(0 1px #111);
}

.tmc-ore-chip b {
  font-size: 11px;
  line-height: 1;
}

.tmc-ore-chip span {
  display: inline-grid;
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: 2px;
  color: #ffd761;
  font-size: 11px;
  line-height: 1;
}

.tmc-ore-chip span em {
  width: 10px;
  height: 10px;
  background: var(--ui-coin) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #3c2511) drop-shadow(0 1px #3c2511);
}

.tmc-empty {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  color: var(--tmc-muted);
  font-size: 12px;
}

/* Goals tab -------------------------------------------------------------------- */

.tmc-goals {
  display: grid;
  gap: 4px;
}

.tmc-goals-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid #29343a;
  border-radius: 5px;
  background: #182025;
}

.tmc-goals-summary b {
  color: #ffe078;
  font-size: 14px;
}

.tmc-goals-summary span {
  color: var(--tmc-muted);
  font-size: 11px;
}

.tmc-goals-summary i {
  grid-column: 1 / -1;
  display: block;
  height: 4px;
  border-radius: 99px;
  background: #0c1114;
  box-shadow: inset 0 0 0 1px #2c363c;
  overflow: hidden;
}

.tmc-goals-summary em {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #53b95a, #f2bf3a);
}

.tmc-goal-tier {
  color: var(--tmc-muted);
  font-size: 10px;
  font-weight: 400;
  text-decoration: none;
}

.tmc-goal {
  display: grid;
  grid-template-columns: 30px 1fr 92px;
  gap: 6px;
  align-items: center;
  padding: 5px 6px;
  border: 1px solid #29343a;
  border-radius: 5px;
  background: #182025;
}

.tmc-goal.is-claimable {
  border-color: #2f6230;
  background: linear-gradient(90deg, rgb(84 197 93 / 10%), #182025 65%);
}

.tmc-goal.is-done {
  opacity: 0.75;
}

.tmc-goal > i {
  width: 28px;
  height: 24px;
  background: var(--ore-img) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #111) drop-shadow(0 1px #111);
}

.tmc-goal-info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.tmc-goal-info b {
  font-size: 12px;
  line-height: 1;
}

.tmc-goal-info span {
  color: var(--tmc-muted);
  font-size: 12px;
  line-height: 1;
}

.tmc-goal-info em {
  display: block;
  height: 4px;
  border-radius: 99px;
  background: #0c1114;
  box-shadow: inset 0 0 0 1px #2c363c;
  overflow: hidden;
}

.tmc-goal-info em u {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #53b95a, #f2bf3a);
}

.tmc-goal-claim {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  border: 2px solid #2f6230;
  border-radius: 4px;
  background: #2b7d34;
  color: #ffed92;
  font-weight: 800;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.tmc-goal.is-claimable .tmc-goal-claim {
  box-shadow: 0 0 10px 0 color-mix(in srgb, var(--tmc-accent, #f2bf3a) 45%, transparent);
}

.tmc-goal-claim:disabled {
  border-color: #3c4246;
  background: #283038;
  /* #a8b8c0 on #283038 = 6.55:1 (WCAG AA); the old #7d8a91 was 3.77:1.
     Still clearly dimmer than the affordable green/gold states. */
  color: #a8b8c0;
  cursor: default;
}

.tmc-goal-claim i {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: var(--ui-coin) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 0 #3c2511) drop-shadow(0 1px #3c2511);
}

.tmc-goal-done {
  justify-self: center;
  color: #54c55d;
  font-size: 14px;
  font-weight: 900;
}

/* Goals: sealed state (ore left behind by the one-way descent) ------------------ */

.tmc-goal.is-sealed {
  opacity: 0.55;
}

.tmc-goal.is-sealed i {
  filter: grayscale(0.8);
}

.tmc-goal.is-sealed em u {
  background: #4a545b;
}

.tmc-goal-sealed {
  justify-self: center;
  padding: 2px 7px;
  border: 1px solid #39434a;
  border-radius: 4px;
  color: var(--tmc-muted);
  font-size: 10px;
}

.tmc-goals-sealed-note {
  grid-column: 1 / -1;
  color: var(--tmc-muted);
  font-size: 10px;
  text-decoration: none;
}

/* Overview: departing-ore note above Go Deeper ----------------------------------- */

.tmc-depart-note {
  padding: 5px 8px;
  border: 1px solid #4a3d24;
  border-radius: 5px;
  background: #201b12;
  color: #d8bd7d;
  font-size: 10.5px;
  line-height: 1.45;
}

.tmc-depart-note b {
  color: #ffe078;
}

/* Descend confirm: hazard-sign board shown only when the drop would seal
   unfinished goals. Wood-and-warning-stripe framing, cave palette; the safe
   choice (stay) is the big green default. */
.tmc-dconfirm {
  position: fixed;
  inset: 0;
  z-index: 190;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(5 7 10 / 72%);
}

.tmc-dconfirm[hidden] {
  display: none;
}

.tmc-dconfirm-card {
  width: 340px;
  max-width: 92vw;
  overflow: hidden;
  border: 2px solid #4a4436;
  border-radius: 10px;
  background: #1d1913;
  color: #e8dfc2;
  box-shadow: 0 10px 30px rgb(0 0 0 / 55%);
}

.tmc-dconfirm-stripe {
  height: 10px;
  background: repeating-linear-gradient(-45deg, #ffd761 0 12px, #241f14 12px 24px);
  border-bottom: 2px solid #4a4436;
}

.tmc-dconfirm-card > .tmc-dconfirm-stripe:last-child {
  border-bottom: 0;
  border-top: 2px solid #4a4436;
}

.tmc-dconfirm-title {
  display: block;
  padding: 12px 16px 0;
  color: #ffe078;
  font-size: 15px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.tmc-dconfirm-sub {
  margin: 6px 0 0;
  padding: 0 16px;
  color: #b3a883;
  font-size: 12px;
  line-height: 1.5;
}

.tmc-dconfirm-list {
  display: grid;
  gap: 6px;
  padding: 10px 16px 0;
}

.tmc-dconfirm-ore {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid #4a3d24;
  border-radius: 6px;
  background: #201b12;
}

.tmc-dconfirm-ore i {
  grid-row: 1 / span 2;
  width: 28px;
  height: 28px;
  background: var(--ore-img) center / contain no-repeat;
  image-rendering: pixelated;
}

.tmc-dconfirm-ore b {
  color: #ffe078;
  font-size: 13px;
}

.tmc-dconfirm-ore span {
  color: #d8bd7d;
  font-size: 11px;
}

.tmc-dconfirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 16px 14px;
}

.tmc-dconfirm-actions button {
  height: 44px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.tmc-dconfirm-stay {
  border: 2px solid #2f6230;
  background: #2b7d34;
  color: #ffed92;
}

.tmc-dconfirm-go {
  border: 2px solid #6b3a2a;
  background: #3a241c;
  color: #ffc2b8;
}

/* Overview: auto-sell card ------------------------------------------------------ */

.tmc-autosell-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  min-height: 30px;
  padding: 3px 6px;
  border: 1px solid #29343a;
  border-radius: 5px;
  background: #182025;
  font-size: 12px;
}

.tmc-autosell-buy {
  position: relative;
  height: 32px;
  padding: 0 10px;
  border: 2px solid #2f6230;
  border-radius: 4px;
  background: #2b7d34;
  color: #ffed92;
  font-weight: 800;
  font-size: 11px;
  cursor: pointer;
}

.tmc-autosell-buy::before {
  content: "";
  position: absolute;
  inset: -6px 0;
}

.tmc-autosell-buy:disabled {
  border-color: #7b632b;
  background: #2d2a22;
  color: #ffd761;
  cursor: default;
}

.tmc-autosell-owned {
  color: #54c55d;
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
}

.tmc-autosell-desc {
  grid-column: 1 / -1;
  font-size: 10px;
  line-height: 1.45;
  color: #9db1ba;
}

.tmc-autosell-notice {
  padding: 6px 8px;
  border: 1px solid #7b632b;
  border-radius: 5px;
  background: #241f14;
  color: #ffd761;
  font-size: 11px;
  line-height: 1.5;
}

.tmc-autosell-notice-ok {
  display: block;
  margin-top: 6px;
  min-height: 30px;
  padding: 0 12px;
  border: 2px solid #7b632b;
  border-radius: 4px;
  background: #3a3120;
  color: #ffed92;
  font-weight: 800;
  font-size: 11px;
  cursor: pointer;
}

/* Settings tab ---------------------------------------------------------------- */

.tmc-settings {
  grid-template-columns: 1fr;
}

/* Reset confirm: full-width labeled buttons, destructive action in red and
   clearly separated from cancel (both >=44px tall). */
.tmc-confirm-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  align-items: center;
  padding: 8px;
  border: 1px solid #4a3330;
  border-radius: 4px;
  background: #1c1512;
  color: #ffc2b8;
  font-size: 12px;
  line-height: 1.25;
}

.tmc-confirm-row > span {
  grid-column: 1 / -1;
}

.tmc-confirm-row button {
  height: 44px;
  min-width: 0;
  padding: 0;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.tmc-reset-cancel {
  border-color: #3c4246 !important;
  background: #283038 !important;
  color: #dbe3e7 !important;
}

.tmc-reset-confirm {
  border-color: #7c2f28 !important;
  background: #8a3129 !important;
  color: #ffd9d2 !important;
}

.tmc-reset {
  color: #ffc2b8 !important;
}

/* ---------------------------------------------------------------------------
 * Touch feedback: every enabled control presses down 1px and darkens; the
 * miner/ore sprites keep their own richer tap effects (dust, hit-pop).
 * Disabled buttons get a brief deny shake from content.js (.tmc-deny).
 * ------------------------------------------------------------------------- */
.tmc-tabs button:active,
.tmc-buy:active:not(:disabled),
.tmc-sell-panel button:active:not(:disabled),
.tmc-goal-claim:active:not(:disabled),
.tmc-go:active,
.tmc-settings button:active,
.tmc-autosell-buy:active:not(:disabled),
.tmc-row-main:active,
.tmc-fun-tier-controls button:active,
.tmc-title-install:active,
.tmc-title-sheet-close:active,
.tmc-sell-hint:active {
  transform: translateY(1px);
  filter: brightness(0.86);
}

/* The title screen is itself the start button: pressing anywhere presses the CTA. */
.tmc-title:active .tmc-title-start {
  transform: translateY(1px);
  filter: brightness(0.9);
}

.tmc-deny {
  animation: tmcDenyShake 240ms linear;
}

@media (prefers-reduced-motion: reduce) {
  .tmc-deny {
    animation: tmcDenyDim 240ms ease;
  }
}

@keyframes tmcDenyShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  50% { transform: translateX(2px); }
  75% { transform: translateX(-1px); }
}

@keyframes tmcDenyDim {
  0%, 100% { filter: none; }
  40% { filter: brightness(0.55); }
}

/* ---------------------------------------------------------------------------
 * Keyframes (only the ones in use).
 * Sheet distances are native: 4 frames x 96px = 384px; hold sheet 2 x 96 = 192.
 * ------------------------------------------------------------------------- */

@keyframes tmcThemeSheet4 {
  0% { background-position: 0 0; }
  100% { background-position: -384px 0; }
}

/* Non-uniform swing timing. step-end per segment: each cel HOLDS until the
   next keyframe with zero interpolation (interpolating background-position
   would briefly show two half-frames stitched together). */
/* Composed one-direction cycle sheet: f0 wind-up, f1 overhead, f2 impact, f3 pull-out. */
@keyframes tmcMineSwing {
  0%   { background-position: 0 0; animation-timing-function: step-end; }       /* wind-up */
  20%  { background-position: -96px 0; animation-timing-function: step-end; }   /* overhead: anticipation */
  55%  { background-position: -192px 0; animation-timing-function: step-end; }  /* IMPACT */
  78%  { background-position: -288px 0; animation-timing-function: step-end; }  /* pull-out */
  100% { background-position: -288px 0; }
}

@keyframes tmcOreHitFlash {
  0% { filter: brightness(1.55) saturate(1.2); }
  100% { filter: none; }
}

@keyframes tmcLuckyShimmer {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.28) drop-shadow(0 0 4px rgb(255 228 95 / 45%)); }
}

@keyframes tmcSellHintBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes tmcWalkBob {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-1.5px); }
  60% { transform: translateY(0.5px); }
}

@keyframes tmcThemeSheet4Hold {
  0% { background-position: 0 0; }
  100% { background-position: -288px 0; }
}

@keyframes tmcThemeSheet2Loop {
  0% { background-position: 0 0; }
  100% { background-position: -192px 0; }
}

@keyframes tmcAxeSparks {
  0%, 70% { opacity: 0; transform: scale(0.7); }
  71%, 88% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.25); }
}

@keyframes tmcOreShake {
  /* `translate`, not `transform`: the shake must COMPOSE with the arrival
     transform, never override it (that pinned the next ore at the break spot) */
  0% { translate: 0; }
  100% { translate: 1px 0; }
}

@keyframes tmcDust {
  0% { opacity: 0.95; transform: translateX(0) translateY(0) scale(0.85); }
  55% { opacity: 0.72; }
  100% { opacity: 0; transform: translateX(-32px) translateY(-7px) scale(1.25); }
}

@keyframes tmcDustFollow {
  0% { opacity: 0.75; transform: translateX(0) translateY(0) scale(0.75); }
  100% { opacity: 0; transform: translateX(-22px) translateY(-4px) scale(1.1); }
}

@keyframes tmcTabGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgb(242 191 58 / 0%); }
  50% { box-shadow: 0 0 8px 1px rgb(242 191 58 / 45%); }
}

@keyframes tmcTabGlowGreen {
  0%, 100% { box-shadow: 0 0 0 0 rgb(84 197 93 / 0%); }
  50% { box-shadow: 0 0 8px 1px rgb(84 197 93 / 45%); }
}

@keyframes tmcOreBurst {
  0% { opacity: 1; transform: scale(1); }
  60% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 0; transform: scale(1.12); }
}

@keyframes tmcLuckyPulse {
  0% { transform: scale(0.96); }
  50% { transform: scale(1.08); }
  100% { transform: scale(0.96); }
}

@keyframes tmcHelmetBeam {
  /* turn on quick, then a slow search sweep with a soft breath — the cone
     never stretches, only aims (rotation only; translate = anchor track) */
  0% { opacity: 0; transform: rotate(7deg); }
  6% { opacity: 0.95; transform: rotate(7deg); }
  30% { opacity: 0.85; transform: rotate(4.5deg); }
  52% { opacity: 0.93; transform: rotate(8.5deg); }
  74% { opacity: 0.82; transform: rotate(6deg); }
  100% { opacity: 0.95; transform: rotate(7deg); }
}
@keyframes tmcBeamGlowMine {
  /* opacity breathe only — rotation lives in the per-cel anchor track */
  0% { opacity: 0.9; }
  50% { opacity: 0.8; }
  100% { opacity: 0.9; }
}

@keyframes tmcFloat {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-36px) scale(0.92); }
}

@keyframes tmcSellFloat {
  0% { opacity: 0; transform: translateY(2px) scale(0.74) rotate(-3deg); }
  10% { opacity: 1; transform: translateY(-4px) scale(1.18) rotate(2deg); }
  26% { opacity: 1; transform: translateY(-10px) scale(1.04) rotate(-1deg); }
  76% { opacity: 1; transform: translateY(-34px) scale(1) rotate(0); }
  100% { opacity: 0; transform: translateY(-50px) scale(0.94) rotate(2deg); }
}

@keyframes tmcSellSpark {
  0% { opacity: 0; transform: translateY(3px) scale(0.5); }
  30% { opacity: 1; transform: translateY(-2px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-9px) scale(0.8); }
}

@keyframes tmcLampFlicker {
  0%, 100% { opacity: 1; }
  38% { opacity: 0.92; }
  41% { opacity: 0.99; }
  67% { opacity: 0.9; }
  71% { opacity: 1; }
}

@keyframes tmcMote {
  0% { opacity: 0; transform: translate(0, 6px); }
  18% { opacity: 0.35; }
  60% { opacity: 0.22; }
  100% { opacity: 0; transform: translate(9px, -16px); }
}

@keyframes tmcRumble {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2px, 1px); }
  40% { transform: translate(2px, -1px); }
  60% { transform: translate(-2px, -1px); }
  80% { transform: translate(2px, 1px); }
}

@keyframes tmcFrag {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  45% { opacity: 1; transform: translate(calc(var(--fx) * 0.62), var(--fy)) rotate(80deg); }
  100% { opacity: 0; transform: translate(var(--fx), 16px) rotate(160deg); }
}

@keyframes tmcCoinPing {
  35% { transform: scale(1.22); filter: brightness(1.35); }
  100% { transform: scale(1); }
}

@keyframes tmcGodSparkles {
  0% { opacity: 0.65; transform: translate(0, 0) scale(0.92); }
  25% { opacity: 1; transform: translate(2px, -1px) scale(1.1); }
  50% { opacity: 0.78; transform: translate(-1px, 1px) scale(0.96); }
  75% { opacity: 1; transform: translate(1px, -2px) scale(1.18); }
  100% { opacity: 0.72; transform: translate(0, 0) scale(0.92); }
}

/* ---------------------------------------------------------------------------
 * Multi-tab takeover card: shown when another tab has taken the world lock.
 * This tab is frozen (no simulation, no saves); tapping re-takes the lock
 * and reloads fresh from storage.
 * ------------------------------------------------------------------------- */
.tmc-takeover {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(8 11 14 / 92%);
  cursor: pointer;
}

.tmc-takeover-card {
  display: grid;
  gap: 8px;
  max-width: 300px;
  padding: 18px 20px;
  border: 1px solid #3a444b;
  border-radius: 12px;
  background: #171d22;
  color: #f5f0d8;
  font-family: "Trebuchet MS", Arial, sans-serif;
  text-align: center;
}

.tmc-takeover-card b { font-size: 15px; }
.tmc-takeover-card span { font-size: 12.5px; color: #aeb9bf; }

/* ---------------------------------------------------------------------------
 * Reduced motion: shakes, flashes and ambient drift sit out; core gameplay
 * sprites (walking, mining) keep animating. The JS-driven parallax layers
 * are gated the same way via matchMedia in content.js.
 * ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .tmc-frame.is-rumbling { animation: none; }   /* descend flash/shake */
  .tmc-lamp { animation: none; }                /* lamp flicker */
  .tmc-lamp i { animation: none; opacity: 0; }  /* floating motes */
}
