/* ==========================================================================
   Inline SVG art & micro-interactions
   ========================================================================== */

.machine-art,
.rig-art {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

img.rig-art {
  object-fit: contain;
  object-position: center;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

img.machine-art {
  object-fit: contain;
  object-position: center;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

.material-art {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

img.material-art {
  object-fit: contain;
  object-position: center;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

.material-art.mini {
  width: 13px;
  height: 11px;
  display: inline-block;
  vertical-align: -2px;
}

.tool-art {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

img.tool-art {
  object-fit: contain;
  object-position: center;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

.fire-glow {
  transform-origin: center;
  animation: fire-breathe 1.8s ease-in-out infinite;
}

@keyframes fire-breathe {
  0%, 100% { opacity: 0.55; transform: scaleY(0.94); }
  50% { opacity: 0.95; transform: scaleY(1.06); }
}

.art-pulse-light {
  animation: art-pulse-light 2.2s ease-in-out infinite;
}

@keyframes art-pulse-light {
  0%, 100% { opacity: 0.5; }
  12% { opacity: 1; }
  23% { opacity: 0.6; }
  50% { opacity: 0.95; }
  72% { opacity: 0.4; }
}

.art-blink {
  animation: art-blink 2.7s steps(1) infinite;
}

@keyframes art-blink {
  0%, 8%, 10%, 100% { opacity: 0.35; }
  4%, 9% { opacity: 1; }
}

.art-spin-slow {
  transform-box: fill-box;
  transform-origin: center;
  animation: art-spin-slow 7s linear infinite;
  animation-play-state: paused;
}

.is-working .art-spin-slow,
.is-running .art-spin-slow {
  animation-play-state: running;
}

@keyframes art-spin-slow {
  to { transform: rotate(360deg); }
}

.art-smoke {
  animation: art-smoke 4.2s ease-in-out infinite;
}

@keyframes art-smoke {
  0%, 100% { opacity: 0.14; transform: translateY(2px); }
  50% { opacity: 0.4; transform: translateY(-2px); }
}

.art-spark {
  animation: art-spark 3.1s steps(1) infinite;
}

@keyframes art-spark {
  0%, 6%, 8%, 100% { opacity: 0.15; }
  4%, 7% { opacity: 0.65; }
  44% { opacity: 0.1; }
  48% { opacity: 0.7; }
  50% { opacity: 0.2; }
}

.art-belt-lines {
  animation: art-belt-lines 1s linear infinite;
}

@keyframes art-belt-lines {
  to { stroke-dashoffset: -16; }
}

.machine-slot .machine-art {
  filter: brightness(1.16) saturate(1.08) drop-shadow(0 3px 3px rgba(0, 0, 0, 0.4));
  transition: filter 0.25s ease, transform 0.25s ease;
}

.factory-cell.is-machine.is-running .machine-art {
  transform: translateY(-1px);
}

.factory-cell.is-machine {
  background:
    linear-gradient(180deg, rgba(91, 129, 129, 0.07), transparent 50%),
    #111a1e;
}

.factory-cell.is-machine:hover {
  border-color: rgba(242, 182, 68, 0.3);
}

.factory-output-float.is-store {
  background: var(--cyan);
  color: #06201c;
}

.output-mode-mark {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 3px;
  transform: translateX(-50%);
  padding: 1px 4px;
  border: 1px solid rgba(242, 182, 68, 0.24);
  border-radius: 2px;
  background: rgba(8, 12, 12, 0.72);
  color: var(--gold);
  font-family: var(--mono);
  font-size: 5px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.output-mode-mark.is-store {
  border-color: rgba(102, 212, 197, 0.24);
  color: var(--cyan);
}

.factory-board-wrap.is-building {
  cursor: crosshair;
}

.factory-board,
.build-tray {
  -webkit-user-select: none;
  user-select: none;
}

.factory-cell.is-machine-pop .machine-slot {
  animation: machine-pop 0.42s cubic-bezier(.2,.8,.3,1);
}

@keyframes machine-pop {
  0% { transform: scale(0.94); filter: brightness(1.35); }
  55% { transform: scale(1.04); filter: brightness(1.2); }
  100% { transform: scale(1); filter: brightness(1); }
}

.factory-cell.is-selected {
  z-index: 4;
  box-shadow:
    inset 0 0 0 1px rgba(242, 182, 68, 0.8),
    0 0 15px rgba(242, 182, 68, 0.18);
  border-color: rgba(242, 182, 68, 0.65) !important;
}

.factory-board-wrap.is-demolishing {
  border-color: rgba(236, 105, 105, 0.32);
  cursor: crosshair;
}

.factory-board-wrap.is-demolishing .factory-cell {
  border-color: rgba(236, 105, 105, 0.06);
}

.factory-board-wrap.is-demolishing .factory-cell:hover {
  border-color: rgba(236, 105, 105, 0.65);
  background: rgba(236, 105, 105, 0.08);
}

.factory-cell[data-kind="source"],
.factory-cell[data-kind="output"] {
  cursor: default;
}

.factory-board-wrap.is-building .factory-cell[data-kind="source"],
.factory-board-wrap.is-building .factory-cell[data-kind="output"] {
  opacity: 0.55;
}

.factory-cell.is-machine {
  cursor: pointer;
}

.factory-items-layer .factory-item {
  transform-origin: center;
}

.source-art.is-pulsing {
  animation: source-art-pulse 0.5s ease;
}

@keyframes source-art-pulse {
  50% { filter: brightness(1.6) drop-shadow(0 0 9px rgba(102, 212, 197, 0.5)); }
}

.mine-tile.is-hit .tile-glint {
  animation: none;
  opacity: 0;
}

.mine-stage.is-gold-moment .mine-topbar {
  background: linear-gradient(180deg, #171b18, #0d1316);
}

.hud-pill.power-pill.is-limited {
  border-color: rgba(236, 105, 105, 0.24);
}

.hud-pill.power-pill.is-limited .hud-icon,
.hud-pill.power-pill.is-limited .hud-pill-copy strong {
  color: #e9a267;
}

.mobile-account-btn {
  display: none;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(242, 182, 68, 0.24);
  border-radius: 6px;
  background: rgba(242, 182, 68, 0.09);
  color: var(--gold);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.rig-level-pips .level-pip {
  display: inline-block;
}

.auth-card .btn-auth.is-loading {
  opacity: 0.68;
  pointer-events: none;
}

.auth-card .btn-auth.is-loading span {
  animation: text-fade 1s ease-in-out infinite alternate;
}

@keyframes text-fade {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

/* Buttons living inside copy blocks */
.factory-tips .btn {
  min-height: 21px;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 7.5px;
}

.build-art {
  width: 76px;
  height: 64px;
  overflow: hidden;
}

.build-card strong {
  font-size: 10px;
}

.build-meta {
  font-size: 7.5px;
}

.build-card {
  padding: 10px 6px 8px;
}

.machine-name-mini {
  display: inline-flex;
  align-items: center;
  padding: 1px 3px;
  border-radius: 2px;
  background: rgba(6, 9, 10, 0.72);
  color: #93a6a1;
  font-family: var(--sans);
  font-size: 5.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.factory-cell[data-type="refiner"] {
  background:
    radial-gradient(ellipse at 50% 65%, rgba(235, 155, 66, 0.13), transparent 66%),
    #12191d;
}

.factory-cell[data-type="purifier"] {
  background:
    radial-gradient(ellipse at 50% 65%, rgba(102, 212, 197, 0.13), transparent 66%),
    #111a1e;
}

.factory-cell[data-type="compressor"] {
  background:
    radial-gradient(ellipse at 50% 65%, rgba(193, 122, 78, 0.12), transparent 66%),
    #131a1d;
}

.factory-cell[data-type="dieselGen"] {
  background:
    radial-gradient(ellipse at 50% 65%, rgba(242, 182, 68, 0.11), transparent 66%),
    #12191d;
}

.factory-cell[data-type="coalGen"] {
  background:
    radial-gradient(ellipse at 50% 65%, rgba(224, 110, 58, 0.13), transparent 66%),
    #14191b;
}

.machine-led {
  background: #51615f;
  box-shadow: none;
  animation: none;
}

.factory-cell.is-running .machine-led {
  background: var(--cyan);
  box-shadow: 0 0 5px var(--cyan);
  animation: led-pulse 0.9s ease-in-out infinite;
}

.inspector-art {
  width: 78px;
  height: 64px;
}

.inspector-art svg {
  width: 73px;
  height: 61px;
}

.inspector-head {
  align-items: flex-start;
}

.rig-chip {
  cursor: default;
  font: inherit;
}

button.rig-chip {
  cursor: pointer;
  color: var(--ink-faint);
  border-style: dashed;
  border-color: rgba(242, 182, 68, 0.18);
  background: rgba(242, 182, 68, 0.025);
}

button.rig-chip:hover {
  color: var(--gold);
  border-color: rgba(242, 182, 68, 0.4);
  background: rgba(242, 182, 68, 0.07);
}

.quest-toggle {
  width: 100%;
  margin-top: 9px;
  border-style: dashed;
}

.build-tray {
  align-items: stretch;
}

.build-card:focus-visible,
.mine-tile:focus-visible,
.factory-cell:focus-visible,
button:focus-visible,
.toggle:focus-visible {
  outline: 2px solid rgba(242, 182, 68, 0.65);
  outline-offset: 2px;
}

.mine-tile:focus-visible {
  outline-offset: -2px;
}

.wh-equipment-row .material-art {
  width: 22px;
  height: 19px;
}

.inspector-stats + .inspector-actions {
  margin-top: 10px;
}

.factory-cell .machine-art {
  overflow: visible;
}

.wh-equipment-row > span:first-child {
  display: grid !important;
  place-items: center;
}

.wh-equipment-row > span:first-child svg {
  width: 23px;
  height: 19px;
}

.market-art .material-art {
  width: 34px;
  height: 30px;
}

.shop-art .material-art {
  width: 63px;
  height: 52px;
}

.shift-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.018);
  color: var(--ink-faint);
  font-size: 8.5px;
  line-height: 1.7;
}

.quest-check svg {
  width: 9px;
  height: 9px;
  stroke-width: 2.4;
}

.shop-owned-tag svg {
  width: 12px;
  height: 12px;
  stroke-width: 2;
}

.factory-help-card strong svg {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 3px;
  vertical-align: -2px;
  color: var(--gold);
}

.factory-tips svg {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  color: var(--gold-deep);
}

.market-note > svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  color: var(--gold);
  stroke-width: 1.7;
}

.inline-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.inline-note-icon {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
}

.inline-note-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.factory-tip-banner svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.fuel-card-head .pill svg,
.settings-row-copy svg {
  width: 12px;
  height: 12px;
}

@media (max-width: 760px) {
  .build-art {
    width: 48px;
    height: 40px;
  }

  .build-card {
    padding: 8px 3px 7px;
  }

  .build-card strong {
    font-size: 8.5px;
  }

  .build-meta {
    font-size: 6.6px;
  }

  .inspector-art {
    width: 69px;
    height: 57px;
  }

  .inspector-art svg {
    width: 64px;
    height: 54px;
  }
}

@media (max-width: 1020px) {
  .hud-actions {
    display: flex;
    border-left: 0;
    padding-left: 0;
  }

  .hud-actions .icon-btn {
    width: 28px;
    height: 28px;
  }

  .hud-actions #sound-toggle,
  .hud-actions #help-toggle {
    display: none;
  }

  .mobile-account-btn {
    display: grid;
    place-items: center;
  }

  .hud-actions #account-toggle {
    display: none;
  }
}

@media (max-width: 520px) {
  .hud-actions {
    display: none;
  }

  .mobile-account-btn {
    display: grid;
    place-items: center;
    width: 27px;
    height: 27px;
    font-size: 10px;
  }
}

/* ==========================================================================
   Bitmap FX — black-background sprite strips composited with screen blending
   ========================================================================== */

.fx-strip {
  position: absolute;
  pointer-events: none;
  background-repeat: no-repeat;
  background-size: 1600% 100%;
  background-position: 0% 0;
  mix-blend-mode: screen;
}

@keyframes fxStrip {
  from { background-position-x: 0%; }
  to { background-position-x: 100%; }
}

@keyframes fxStripLoop {
  from { background-position-x: 0%; }
  to { background-position-x: 100%; }
}

@keyframes fxPickupRise {
  0% { transform: translateY(4px) scale(0.82); opacity: 0; }
  18% { opacity: 1; }
  100% { transform: translateY(-54px) scale(1.06); opacity: 0; }
}

.fx-dig {
  mix-blend-mode: normal;
  width: 130px;
  height: 130px;
  margin: -65px 0 0 -65px;
  background-image: url("https://renderfarm-1389434004.cos.ap-shanghai.myqcloud.com/deep-vein/assets/6de3458b7ea7d1a4ecd9bab5f3de129e6b57948a0475435026d7b9a547d8e551/fx/dig-impact.webp");
  animation: fxStrip 0.72s steps(15, end) forwards;
}

.fx-pickup {
  mix-blend-mode: normal;
  width: 92px;
  height: 92px;
  margin: -46px 0 0 -46px;
  background-image: url("https://renderfarm-1389434004.cos.ap-shanghai.myqcloud.com/deep-vein/assets/8bdf71717da33ee41f9f781e093800d84755cbf3e775642ce90bd59cfb1d3f1f/fx/ore-pickup.webp");
  animation: fxStrip 0.9s steps(15, end) forwards, fxPickupRise 0.9s ease-out forwards;
}

.fx-ring {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 300px;
  height: 300px;
  margin: -150px 0 0 -150px;
  pointer-events: none;
  background: url("https://renderfarm-1389434004.cos.ap-shanghai.myqcloud.com/deep-vein/assets/851417927d9bfa9bc6808334ca59a99ecdaa6a36e0ebb616127cbc4bf643a6d5/fx/resonance-ring.webp") no-repeat;
  background-size: 1600% 100%;
  background-position: 0% 0;
  mix-blend-mode: screen;
  animation: fxStrip 1.1s steps(15, end) forwards;
}

/* --- state badges (cut from assets/PNG/zhuangtai) -------------------------- */
.state-badge {
  display: inline-block;
  width: 15px;
  height: 15px;
  object-fit: contain;
  vertical-align: -2px;
  -webkit-user-drag: none;
  user-select: none;
}

.machine-badge-row .state-badge {
  width: 16px;
  height: 16px;
  margin-left: 1px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

.inspector-state {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  margin-left: auto;
  padding-left: 6px;
}

.inspector-state .state-badge {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* --- UI glyphs (cut from assets/PNG/UI): alpha stencils used as masks ------ */
.ui-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-color: currentColor;
  -webkit-mask: var(--ui-mask) center / contain no-repeat;
  mask: var(--ui-mask) center / contain no-repeat;
  vertical-align: -0.14em;
}

.daily-icon .ui-icon {
  width: 15px;
  height: 15px;
}

.research-card-icon .ui-icon {
  width: 19px;
  height: 19px;
}

/* --- artwork must never swallow a click: the cell/card handles it ---------- */
img.machine-art,
img.rig-art,
img.tool-art,
img.material-art,
img.logistics-art,
img.state-badge,
.ui-icon {
  pointer-events: none;
}

/* warehouse rows size the image itself: the wrapper is a grid container whose
   auto track would otherwise grow to the image's intrinsic 240px */
.wh-equipment-row > span:first-child img {
  width: 23px;
  height: 19px;
}

/* --- grid art wrappers -----------------------------------------------------
   These boxes are `display:grid` with `place-items:center`. Their single auto
   track sizes itself to the child's intrinsic width, so a 240px-wide bitmap
   makes the track 240px and `width:100%` then resolves against the track - the
   art blows up (or, if clipped, shows only a corner). Pinning the track to the
   box size keeps every bitmap art inside its frame. */
.build-art,
.inspector-art,
.shop-art,
.market-art,
.wh-item-art,
.rail-tool-art,
.tool-banner-art,
.daily-icon,
.research-card-icon,
.logistics-cell-art,
.rig-chip {
  grid-template-columns: 100%;
  grid-template-rows: 100%;
}

/* the logistics bitmap had no base box: every context sized the old SVG via a
   `svg` rule, so the <img> fell back to its intrinsic 240x200 */
img.logistics-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  -webkit-user-drag: none;
  user-select: none;
}

/* loot float on the mine: show the material icon instead of a colour dot */
.loot-float .material-art {
  width: 14px;
  height: 12px;
  flex: 0 0 auto;
  margin-right: 1px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
}
