:root {
  --bg: rgba(10, 12, 16, 0.72);
  --fg: #e8e6df;
  --muted: #9a9890;
  --accent: #f2c14e;
  --power: #5ec8ff;
  --pick: #e0b07a;
  --good: #7ed37a;
  --bad: #ff6b6b;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0d10; color: var(--fg); }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; overscroll-behavior: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 6; } /* above #mobile (z 5) so the tappable prompt sits over the look zone */
.hud-top-left { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 6px; }
.hud-top-right { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
/* auto-dig indicator: always shown; ON = everything white, OFF = only the F1 key stays white, the rest goes grey */
.stat.auto, .stat.auto .ai { color: #fff; border-color: rgba(255,255,255,0.35); } /* beats .stat.small's grey */
.stat.auto { border: 1px solid rgba(255,255,255,0.35); gap: 8px; }
.stat.auto kbd { color: #fff; font-size: 12px; font-weight: 700; }
.stat.auto.off { border-color: rgba(255,255,255,0.12); }
.stat.auto.off .ai { color: var(--muted); }
.hud-row { display: flex; gap: 6px; } /* depth + fps under the auto-dig indicator */
#db-stat { color: #fff; }
#loc-db { background: none; backdrop-filter: none; padding: 2px 6px; color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px rgba(0,0,0,0.6); } /* plain text, no plaque */
.stat { background: var(--bg); padding: 6px 12px; border-radius: var(--radius); font-weight: 600; font-size: 16px; display: inline-flex; align-items: center; gap: 6px; backdrop-filter: blur(6px); }
.stat.small { font-size: 12px; color: var(--muted); }
.ico { font-size: 15px; }

#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: rgba(255,255,255,0.85); box-shadow: 0 0 0 2px rgba(0,0,0,0.5); }
#target-info { position: absolute; left: 50%; top: calc(50% + 22px); transform: translateX(-50%); font-size: 13px; color: rgba(255,255,255,0.75); text-shadow: 0 1px 2px #000; white-space: nowrap; }

#toasts { position: absolute; left: 50%; top: calc(92px + env(safe-area-inset-top)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
/* a toast fades out AND collapses its height at the end, so the ones below slide up smoothly instead of jumping */
.toast { background: var(--bg); padding: 7px 16px; border-radius: 22px; font-weight: 700; font-size: 18px; animation: toast 1.6s ease-out forwards; white-space: nowrap; max-height: 48px; overflow: hidden; }
.toast.gem { color: var(--accent); }
.toast.bad { color: var(--bad); }
.toast.good { color: var(--good); }
@keyframes toast { 0% { opacity: 0; transform: translateY(12px) scale(0.9);} 12% { opacity: 1; transform: translateY(0) scale(1.05);} 25% { transform: scale(1);} 72% { opacity: 1; max-height: 48px; padding-top: 7px; padding-bottom: 7px; margin-bottom: 0; } 100% { opacity: 0; transform: translateY(-8px); max-height: 0; padding-top: 0; padding-bottom: 0; margin-bottom: -4px; } }

.hud-bottom-left { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; width: min(300px, 45vw); }
.bar-row { display: flex; align-items: center; gap: 8px; background: var(--bg); padding: 6px 10px; border-radius: var(--radius); }
.bar { position: relative; flex: 1; height: 16px; background: rgba(255,255,255,0.08); border-radius: 8px; overflow: hidden; }
.fill { height: 100%; width: 100%; transition: width 0.15s; border-radius: 8px; }
.fill.power { background: linear-gradient(90deg, #2d8fd6, var(--power)); }
.fill.pick { background: linear-gradient(90deg, #a07040, var(--pick)); }
.bar-text { position: absolute; inset: 0; font-size: 11px; line-height: 16px; text-align: center; font-weight: 700; text-shadow: 0 1px 2px #000; }
/* broken pickaxe: the durability row turns red and pulses */
.bar-row.broken { border: 1px solid var(--bad); animation: brokenPulse 1s ease-in-out infinite alternate; }
.bar-row.broken .ico { filter: grayscale(1) brightness(0.7); }
.bar-row.broken .bar { background: rgba(255,107,107,0.18); }
.bar-row.broken .bar-text { color: var(--bad); letter-spacing: 1px; }
@keyframes brokenPulse { from { box-shadow: 0 0 0 0 rgba(255,107,107,0); } to { box-shadow: 0 0 0 3px rgba(255,107,107,0.35); } }
/* landscape phones: shorter energy / durability bars, and the interaction prompt sits a bit higher (less screen height) */
@media (pointer: coarse) and (orientation: landscape) {
  .hud-bottom-left { width: min(200px, 28vw); }
  .touch #prompt { top: calc(50% + 50px); }
  /* backpack moves out from under the depth/fps row: bottom row [🎒][Jump][⛏], top row [⬆][Auto] */
  .touch .mbtns { grid-template-columns: auto auto auto; }
  .mbtns #btn-inv { grid-column: 1; grid-row: 2; } /* .mbtns prefix: outranks the portrait #btn-inv rule declared later */
  .mbtns #btn-lift { grid-column: 2; grid-row: 1; }
  .mbtns #btn-auto { grid-column: 3; grid-row: 1; }
  .mbtns #btn-jump { grid-column: 2; grid-row: 2; }
  .mbtns #btn-dig { grid-column: 3; grid-row: 2; }
}


/* Reward card (Magic Rock): bounces in at the centre, holds, fades out */
#rewards { position: absolute; left: 50%; top: 36%; width: 0; pointer-events: none; }
.rslot { position: absolute; left: 0; transform: translateX(-50%); }
.reward { --rc: #5aa8ff; display: flex; align-items: center; gap: 16px; padding: 10px 20px 10px 12px; background: rgba(10,12,16,0.82); border: 1px solid rgba(255,255,255,0.14); border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,0.5); opacity: 0; }
.reward.in { animation: rewardIn 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) forwards; }
.reward.out { animation: rewardOut 0.55s ease-in forwards; }
.reward.in .rays { animation: spin 2.6s linear infinite, raysIn 0.6s ease-out both; }
@keyframes raysIn { from { opacity: 0; } to { opacity: 0.55; } }
.reward.counting .rtxt { font-variant-numeric: tabular-nums; min-width: 9ch; }
.reward.landed .rtxt { animation: landed 0.45s ease-out; }
@keyframes landed { 0% { transform: scale(1); } 40% { transform: scale(1.22); filter: brightness(1.6); } 100% { transform: scale(1); } }
.reward .ric { position: relative; width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; }
.reward .rays { position: absolute; inset: -22px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, var(--rc) 0 8deg, transparent 8deg 24deg); opacity: 0.55; -webkit-mask: radial-gradient(circle, #000 18%, transparent 68%); mask: radial-gradient(circle, #000 18%, transparent 68%); animation: spin 2.6s linear infinite; }
.reward .ric img { position: relative; width: 46px; height: 46px; image-rendering: pixelated; filter: drop-shadow(0 0 8px var(--rc)); }
.reward .rtxt { font-size: 24px; font-weight: 900; color: var(--rc); text-shadow: 0 2px 4px #000, 0 0 12px var(--rc); white-space: nowrap; }
@keyframes rewardIn { from { opacity: 0; transform: scale(0.35); } to { opacity: 1; transform: scale(1); } }
@keyframes rewardOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-16px); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* HP bar above a vein (DiggerBit deposit) */
#vein-hud { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 5px; background: rgba(10,12,16,0.72); border: 1px solid rgba(255,90,120,0.45); border-radius: 8px; pointer-events: none; white-space: nowrap; will-change: transform; }
#vein-hud[hidden] { display: none; }
#vein-hud img { width: 20px; height: 20px; image-rendering: pixelated; }
#vein-hud .vbar { width: 96px; height: 7px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; }
#vein-hud .vbar > div { height: 100%; background: linear-gradient(90deg, #c8163e, #ff5a78); border-radius: 4px; }
#vein-hud span { font-size: 12px; font-weight: 800; color: #ffb0c0; text-shadow: 0 1px 2px #000; }

/* floating "+N" popups anchored to world positions */
#popups { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.popup { position: absolute; left: 0; top: 0; font-weight: 900; font-size: 22px; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.8), 0 0 8px rgba(0,0,0,0.5); will-change: transform, opacity; white-space: nowrap; }
.popup.vein { color: #ff5a78; text-shadow: 0 2px 4px rgba(0,0,0,0.85), 0 0 10px rgba(255,60,90,0.7); }
.popup.loot { font-size: 18px; }
.popup.gem { font-size: 20px; text-shadow: 0 2px 4px rgba(0,0,0,0.85), 0 0 12px currentColor; }
.sw { width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25); flex: none; }

/* interaction prompt under the crosshair: white keycap + bold outlined label ("[E] Магазин") */
#prompt { position: absolute; left: 50%; top: calc(50% + 72px); transform: translateX(-50%); display: none; align-items: center; gap: 12px; white-space: nowrap; animation: promptIn 0.18s ease-out; }
#prompt.show { display: flex; }
.touch #prompt { pointer-events: auto; cursor: pointer; } /* phones: tapping the prompt opens the kiosk */
/* phones: no auto-dig badge (the Auto button shows the state); energy + durability bars live in the top-right stack */
.touch #auto-ind { display: none; }
.touch .hud-bottom-left { position: static; width: 200px; }
/* portrait phones: the two top columns must share ~360px — narrower bars, "на локации" keeps only icon + number */
@media (pointer: coarse) and (orientation: portrait) { .touch .hud-bottom-left { width: 140px; } }
/* portrait phones: "на локации:" on one line, the number under it */
@media (pointer: coarse) and (orientation: portrait) {
  /* line 1: "на локации:", line 2: gem icon + number, everything flush left */
  #loc-db { display: flex; flex-wrap: wrap; align-items: center; gap: 1px 4px; line-height: 1.25; }
  #loc-db .lbl { order: 1; width: 100%; }
  #loc-db-ico { order: 2; }
  #loc-db-val { order: 3; font-size: 13px; }
}
.touch #prompt:active .key { transform: translateY(3px); box-shadow: 0 1px 0 #b3b6c4, 0 3px 6px rgba(0,0,0,0.5); }
#prompt .key { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 9px; border-radius: 10px; background: linear-gradient(#ffffff, #e4e5ec); color: #1d2130; font-weight: 900; font-size: 22px; line-height: 1; box-shadow: 0 4px 0 #b3b6c4, 0 7px 12px rgba(0,0,0,0.5); }
#prompt .txt { font-size: 24px; font-weight: 800; color: #fff; letter-spacing: 0.3px; text-shadow: -1.5px -1.5px 0 #1a1a1f, 1.5px -1.5px 0 #1a1a1f, -1.5px 1.5px 0 #1a1a1f, 1.5px 1.5px 0 #1a1a1f, 0 3px 6px rgba(0,0,0,0.6); }
#prompt.plain .txt { font-size: 16px; font-weight: 700; }
@keyframes promptIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
/* tutor hint above the crosshair: what to press when stuck (backpack full, no energy, pick broken) */
#tutor { position: absolute; left: 50%; top: calc(50% - 128px); transform: translateX(-50%); display: none; align-items: center; gap: 12px; white-space: nowrap; animation: promptIn 0.25s ease-out; }
#tutor.show { display: flex; }
#tutor .key { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 9px; border-radius: 10px; background: linear-gradient(#ffffff, #e4e5ec); color: #1d2130; font-weight: 900; font-size: 22px; line-height: 1; box-shadow: 0 4px 0 #b3b6c4, 0 7px 12px rgba(0,0,0,0.5); animation: keyPulse 1.1s ease-in-out infinite; }
#tutor .tt b { display: block; font-size: 20px; font-weight: 800; color: #fff; text-shadow: -1.5px -1.5px 0 #1a1a1f, 1.5px -1.5px 0 #1a1a1f, -1.5px 1.5px 0 #1a1a1f, 1.5px 1.5px 0 #1a1a1f, 0 3px 6px rgba(0,0,0,0.6); }
#tutor .tt small { display: block; font-size: 13px; font-weight: 700; color: var(--accent); text-shadow: -1px -1px 0 #1a1a1f, 1px -1px 0 #1a1a1f, -1px 1px 0 #1a1a1f, 1px 1px 0 #1a1a1f, 0 2px 4px rgba(0,0,0,0.6); }
@keyframes keyPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.mbtn.hint { border-color: var(--accent); background: rgba(242,193,78,0.28); animation: hintPulse 0.9s ease-in-out infinite; } /* phones: the button to press pulses */
@keyframes hintPulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 3px rgba(242,193,78,0.35), 0 0 10px rgba(242,193,78,0.5); } 50% { transform: scale(1.16); box-shadow: 0 0 0 6px rgba(242,193,78,0.75), 0 0 26px rgba(242,193,78,0.95); } }
.touch #tutor { pointer-events: auto; cursor: pointer; } /* phones: tapping the hint card does the action too */
.touch #tutor:active .key { transform: translateY(3px); box-shadow: 0 1px 0 #b3b6c4, 0 3px 6px rgba(0,0,0,0.5); }
#hint { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); font-size: 12px; color: rgba(255,255,255,0.55); text-shadow: 0 1px 2px #000; text-align: center; white-space: nowrap; }
kbd { background: rgba(255,255,255,0.12); padding: 1px 5px; border-radius: 4px; font-family: inherit; font-size: 11px; }

/* mobile */
#mobile { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#mobile[hidden] { display: none; }
/* the whole screen turns the view; the fixed joystick and the buttons sit on top of it */
#look-zone { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }
/* joystick: the touch area is an invisible 176px square; the visible 132px ring is drawn centred inside it */
#joy-zone { position: absolute; left: max(6px, env(safe-area-inset-left)); bottom: max(6px, calc(env(safe-area-inset-bottom) + 6px)); width: 176px; height: 176px; pointer-events: auto; touch-action: none; }
#joy-zone::before { content: ''; position: absolute; inset: 22px; border-radius: 50%; background: rgba(20,22,28,0.35); border: 2px solid rgba(255,255,255,0.35); box-shadow: 0 0 0 2px rgba(0,0,0,0.35); }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: linear-gradient(#ffffff, #e4e5ec); border: 2px solid #1a1a1f; box-shadow: 0 3px 0 #b3b6c4, 0 5px 10px rgba(0,0,0,0.5); pointer-events: none; }
/* button cluster in the bottom-right corner: dig is the biggest, the rest scale down
      [🎒]
   [⬆] [Auto]
   [Jump] [⛏] */
/* the grid box itself lets touches through (pointer-events none): only the round buttons catch them,
   so the empty cells (e.g. left of the backpack button) still turn the view */
.mbtns { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(28px, calc(env(safe-area-inset-bottom) + 28px)); display: grid; grid-template-columns: auto auto; gap: 10px 12px; align-items: end; justify-items: end; pointer-events: none; }
#btn-inv { grid-column: 2; }
#btn-lift { margin-right: -28px; } /* pulled right, closer to the Auto button */
/* round translucent buttons; the glyph inside (.g) is forced white with a black outline */
.mbtn { width: 52px; height: 52px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.3); background: rgba(20,22,28,0.55); color: #fff; font-weight: 900; font-size: 24px; line-height: 1; touch-action: none; -webkit-tap-highlight-color: transparent; padding: 0; pointer-events: auto; clip-path: circle(50%); }
.mbtn .g { display: inline-block; filter: brightness(0) invert(1) drop-shadow(0 0 1px #000) drop-shadow(0 0 1px #000) drop-shadow(0 1px 1px #000); }
.mbtn.big { width: 88px; height: 88px; font-size: 40px; }
.mbtn.mid { width: 64px; height: 64px; }
.mbtn.wide { width: 70px; height: 52px; border-radius: 26px; font-size: 28px; clip-path: inset(0 round 26px); }
.mbtn.text { font-size: 17px; letter-spacing: 0.4px; }
.mbtn.mid.text { font-size: 19px; }
.mbtn.small { width: 44px; height: 44px; font-size: 20px; }
.mbtn.on { background: rgba(242,193,78,0.5); border-color: var(--accent); }
.mbtn.ghost { visibility: hidden; }
.mbtn.ghost { visibility: hidden; }

/* panels */
.panel { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, 94vw); height: min(600px, 88vh); background: rgba(14,16,22,0.95); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; display: flex; flex-direction: column; z-index: 20; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.08); gap: 8px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 7px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.tab.active { background: rgba(255,255,255,0.1); color: var(--fg); }
.close { background: transparent; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px 8px; }
.panel-body { flex: 1; min-height: 0; padding: 12px; overflow-y: auto; -webkit-overflow-scrolling: touch; font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.row:last-child { border-bottom: none; }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: block; }
.row .t small { color: var(--muted); }
.row .price { color: var(--accent); font-weight: 700; white-space: nowrap; }
.row .row-ico { width: 40px; height: 40px; flex: none; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; }
.row .row-ico img { width: 30px; height: 30px; image-rendering: pixelated; }
button.buy, button.primary, button.act { background: var(--accent); color: #1a1408; border: none; padding: 8px 14px; border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 14px; white-space: nowrap; }
button.buy:disabled, button.act:disabled { background: rgba(255,255,255,0.12); color: var(--muted); cursor: default; }
button.act.secondary { background: rgba(255,255,255,0.12); color: var(--fg); }
button.buy.energy { background: linear-gradient(90deg, #2d8fd6, var(--power)); color: #06182a; } /* same blue as the energy bar */
button.buy.energy:disabled { background: rgba(255,255,255,0.12); color: var(--muted); } /* greyed out like every other item */
/* energy drink: its own tinted card above the pickaxes, with the same ⚡ as the HUD energy bar, only bigger */
.row.energy-row { background: rgba(94,200,255,0.08); border: 1px solid rgba(94,200,255,0.35); border-radius: 10px; margin: 2px 0 14px; padding: 10px 8px; }
.row.energy-row .row-ico.bolt { width: 48px; height: 48px; font-size: 30px; background: rgba(94,200,255,0.12); border-color: rgba(94,200,255,0.4); }
button.act.danger { background: rgba(255,107,107,0.2); color: var(--bad); }
.total { display: flex; justify-content: space-between; padding: 10px 6px; font-weight: 700; font-size: 16px; }
.muted { color: var(--muted); }
.progress { height: 8px; background: rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.progress > div { height: 100%; background: var(--good); }
/* converter running: lighter diagonal stripes slide along the fill */
.progress.working { height: 10px; }
.progress.working > div { background-color: var(--good); background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.35) 0 8px, transparent 8px 16px); background-size: 22.63px 22.63px; animation: stripes 0.7s linear infinite; }
@keyframes stripes { to { background-position: 22.63px 0; } }
.coal-bad { color: var(--bad); font-weight: 700; }
h3.sec.gap { margin-top: 24px; }
/* premium black "withdraw" button with a periodic light sweep */
button.act.premium { position: relative; overflow: hidden; background: linear-gradient(160deg, #2b2b34, #0c0c10); color: #fff; border: 1px solid rgba(255,255,255,0.4); box-shadow: 0 0 0 1px rgba(0,0,0,0.6), 0 4px 14px rgba(0,0,0,0.5); }
button.act.premium::after { content: ''; position: absolute; top: -40%; bottom: -40%; left: -60%; width: 40%; background: linear-gradient(100deg, transparent, rgba(255,255,255,0.55), transparent); transform: skewX(-20deg); animation: shine 3.2s ease-in-out infinite; pointer-events: none; }
@keyframes shine { 0%, 65% { left: -60%; } 100% { left: 130%; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
/* button feedback inside panels: press = slight squeeze; after an action the button pops green (done) or shakes red (refused) */
.panel button { transition: transform 0.08s ease, filter 0.08s ease; }
.panel button:not(:disabled):active { transform: scale(0.94); filter: brightness(1.15); }
.panel button.ok { animation: btnOk 0.45s ease-out; }
.panel button.fail { animation: btnFail 0.35s ease; }
@keyframes btnOk { 0% { transform: scale(0.94); box-shadow: 0 0 0 0 rgba(126,211,122,0.9); } 40% { transform: scale(1.07); background: var(--good); color: #10200f; } 100% { transform: scale(1); box-shadow: 0 0 0 12px rgba(126,211,122,0); } }
@keyframes btnFail { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } 10%, 90% { box-shadow: 0 0 0 2px var(--bad); } }
.lvl { font-size: 12px; color: var(--muted); }

/* currency icons: Coin (CSS yellow coin), DiggerBit / DiggerBlack (atlas gem icons) */
.coin { display: inline-block; width: 0.95em; height: 0.95em; border-radius: 50%; vertical-align: -0.12em; background: radial-gradient(circle at 35% 32%, #fff2b0 0%, #f6cf5a 38%, #d9a521 70%, #a8771a 100%); box-shadow: inset 0 0 0 1px rgba(120,80,10,0.55), 0 0 0 1px rgba(0,0,0,0.25); }
.ci { width: 1.1em; height: 1.1em; vertical-align: -0.2em; image-rendering: pixelated; }
.price .coin, .price .ci { margin-left: 2px; }
.price.db { color: #ff7a94; }
.price.black { color: #b8bfd0; }

/* marketplace */
.row.mhead { margin-bottom: 8px; padding-bottom: 12px; }
.row.mhead .t small { display: block; margin-bottom: 2px; }
.row.mhead .t b { font-size: 15px; }
.detail .inl { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.mfilters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 4px 6px 8px; }
.mfilters select, .mfilters button.sortbtn { background: rgba(255,255,255,0.08); color: var(--fg); border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.mfilters button.sortbtn.on { background: rgba(242,193,78,0.25); border-color: var(--accent); }
.row .seller { font-size: 11px; color: var(--muted); }
input.qty { width: 84px; background: rgba(255,255,255,0.08); color: var(--fg); border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.row .inl { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.jobbar { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; margin-top: 4px; width: 160px; max-width: 100%; }
/* converter load block: header line + full-width slider that ends at the number field's right edge */
.row.convload { flex-direction: column; align-items: stretch; }
.row.convload .hdr { display: flex; align-items: center; gap: 10px; }
.row.convload .hdr .t { flex: 1; min-width: 0; }
.row.convload .dbg-range { margin-top: 6px; }
/* DiggerBlack tab: fills the panel body so the balance block sits at its bottom edge, with a divider and a gap above it */
.convtab { display: flex; flex-direction: column; min-height: 100%; }
.convtab .balance { margin-top: auto; padding-top: 14px; }
.jobbar > div { height: 100%; background: linear-gradient(90deg, #4a5a78, #b8bfd0); }
.dbg-range { display: block; width: 100%; margin: 8px 0 0; accent-color: var(--accent); cursor: pointer; } /* no side margins: the track ends exactly at the row edge */
/* on/off switch (Debug kiosk) */
.switch { position: relative; display: inline-block; flex: none; width: 46px; height: 26px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 13px; background: rgba(255,255,255,0.14); transition: background 0.15s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--fg); transition: transform 0.15s, background 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); background: #1a1408; }
.stats-grid { display: grid; grid-template-columns: repeat(3, auto); gap: 2px 10px; font-size: 12px; color: var(--muted); }
.panel-title { font-weight: 700; font-size: 15px; padding: 7px 6px; }
h3.sec { margin: 12px 6px 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
h3.sec:first-child { margin-top: 2px; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 4px; }
.slot { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 8px; min-height: 72px; display: flex; flex-direction: column; gap: 3px; }
.slot .sname { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.slot .sitem { font-weight: 700; font-size: 13px; line-height: 1.25; }
.slot .sitem.empty { color: var(--muted); font-weight: 400; }
.slot .sbonus { font-size: 11px; color: var(--good); }
.slot .sact { margin-top: auto; align-self: flex-start; background: rgba(255,255,255,0.12); color: var(--fg); border: none; border-radius: 6px; padding: 3px 8px; font-size: 11px; cursor: pointer; }
.dur { height: 5px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; margin-top: 4px; width: 140px; max-width: 100%; }
.dur > div { height: 100%; background: var(--pick); }
.dur.broken > div { background: var(--bad); }
.tag { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 10px; background: rgba(126,211,122,0.2); color: var(--good); margin-left: 4px; vertical-align: middle; }
.tag.owned { background: rgba(255,255,255,0.1); color: var(--muted); }
.bonus-line { font-size: 12px; color: var(--good); margin: 8px 6px 0; }
.bonus-line.none { color: var(--muted); }
.cells.equip.picks { margin-top: 18px; margin-bottom: 20px; } /* spare pickaxes: a separate row under the hint, clear of the slots and of the backpack */
/* big lime-green "Надеть" with a light sweep */
.detail .acts button.act.wear { position: relative; overflow: hidden; background: linear-gradient(160deg, #c8ff7a, #4fdc63); color: #0f2a10; font-size: 15px; padding: 10px 20px; box-shadow: 0 0 0 1px rgba(120,255,120,0.35), 0 4px 12px rgba(80,220,100,0.35); }
.detail .acts button.act.wear::after { content: ''; position: absolute; top: -40%; bottom: -40%; left: -60%; width: 40%; background: linear-gradient(100deg, transparent, rgba(255,255,255,0.7), transparent); transform: skewX(-20deg); animation: shine 2.6s ease-in-out infinite; pointer-events: none; }
/* section header with a right-aligned note (backpack ↔ DiggerBlack balance) */
h3.sec.split { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
h3.sec .right { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--muted); }
@media (max-width: 420px) { .slots { grid-template-columns: repeat(2, 1fr); } }

/* classic cell grid inventory */
.cells { display: grid; grid-template-columns: repeat(auto-fill, 54px); gap: 6px; margin: 0 4px; }
.cells.equip { grid-template-columns: repeat(auto-fill, 62px); }
.cell { position: relative; width: 54px; height: 54px; background: rgba(255,255,255,0.06); border: 2px solid rgba(255,255,255,0.12); border-radius: 9px; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: inset 0 2px 4px rgba(0,0,0,0.35); -webkit-tap-highlight-color: transparent; }
.cells.equip .cell { width: 62px; height: 62px; }
.cell:hover { border-color: rgba(255,255,255,0.35); }
.cell.empty { cursor: default; opacity: 0.55; }
.cell.empty:hover { border-color: rgba(255,255,255,0.12); }
.cell.equipped { border-color: rgba(126,211,122,0.7); background: rgba(126,211,122,0.08); }
.cell.sel { border-color: var(--accent); box-shadow: inset 0 2px 4px rgba(0,0,0,0.35), 0 0 0 2px rgba(242,193,78,0.35); }
.cell img { width: 38px; height: 38px; image-rendering: pixelated; pointer-events: none; }
.cell .em { font-size: 26px; line-height: 1; pointer-events: none; }
.cell .sicon { font-size: 24px; line-height: 1; opacity: 0.3; pointer-events: none; }
.cell .slabel { position: absolute; left: 0; right: 0; bottom: 3px; font-size: 9px; text-align: center; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; pointer-events: none; }
.cell .cnt { position: absolute; right: 4px; bottom: 2px; font-size: 12px; font-weight: 800; text-shadow: 0 1px 2px #000, 0 0 3px #000; pointer-events: none; }
.cell .dur { position: absolute; left: 6px; right: 6px; bottom: 5px; width: auto; height: 4px; margin: 0; }
.cell .broken-x { position: absolute; right: 3px; top: 1px; color: var(--bad); font-weight: 800; font-size: 13px; pointer-events: none; }
.cell .tier { position: absolute; left: 5px; top: 5px; width: 7px; height: 7px; border-radius: 50%; pointer-events: none; }
.tier.t0 { background: #b87333; } .tier.t1 { background: #d8d8d8; } .tier.t2 { background: #f2c14e; box-shadow: 0 0 4px #f2c14e; }
/* fixed 6×5 slot grid (the cell shrinks on narrow phones so six always fit) */
:root { --cell: 54px; }
@media (max-width: 420px) { :root { --cell: 42px; } }
/* the inventory panel hugs its grid: as wide as six cells + the trash strip, as tall as its content (no scrolling) */
.panel.fit { width: auto; height: auto; max-height: 92vh; max-width: 96vw; }
.panel.fit .panel-body { overflow-y: auto; padding: 10px 12px 12px; }
/* text blocks must not widen the panel beyond the grid: they take the grid's width and wrap inside it */
.panel.fit .detail { width: 0; min-width: calc(100% - 8px); box-sizing: border-box; }
.panel.fit .bonus-line { width: 0; min-width: calc(100% - 12px); }
.panel.fit .panel-body { overflow-x: hidden; }
.bagwrap { display: flex; gap: 8px; align-items: stretch; margin: 0 4px; }
.bagwrap .grid6 { margin: 0; }
/* trash: one cell-sized bin at the bottom right of the backpack; it turns red while an item is being dragged, brighter when over it */
.bagwrap { align-items: flex-end; }
.trash-cell { width: var(--cell); height: var(--cell); flex: none; border: 2px dashed rgba(255,107,107,0.4); border-radius: 9px; display: flex; align-items: center; justify-content: center; color: rgba(255,107,107,0.55); font-size: 20px; transition: background 0.12s, border-color 0.12s, box-shadow 0.12s; }
.trash-cell.armed { background: rgba(255,107,107,0.14); border-color: rgba(255,107,107,0.85); color: var(--bad); }
.trash-cell.over { background: rgba(255,107,107,0.4); border-color: var(--bad); color: #fff; box-shadow: 0 0 14px rgba(255,107,107,0.7); }
/* the backpack header is exactly as wide as the grid, so the capacity count ends at the last cell; extra air above it */
.panel.fit h3.sec.split.w6 { width: calc(6 * var(--cell) + 30px); margin: 20px 4px 4px; }
@media (max-width: 420px) { .bagwrap { gap: 6px; } }
/* monochrome equipment pictograms: dim grey in an empty slot, light grey on an item */
.cell .si { width: 28px; height: 28px; color: #d3d6de; pointer-events: none; }
.cell .si svg { width: 100%; height: 100%; display: block; }
.cell.slot-empty .si { color: #5a5e6a; }
.detail .si { width: 40px; height: 40px; flex: none; color: #d3d6de; }
.detail .si svg { width: 100%; height: 100%; display: block; }
.cell[data-drag] { touch-action: none; }
.grid6 { display: grid; grid-template-columns: repeat(6, var(--cell)); gap: 6px; margin: 0 4px; }
.grid6 .cell { width: var(--cell); height: var(--cell); }
.grid6 .cell img { width: calc(var(--cell) - 12px); height: calc(var(--cell) - 12px); }
.grid6.row1 { margin-bottom: 4px; }
.cell.ghost { visibility: hidden; }
.cell .badge { position: absolute; left: 4px; top: 2px; font-size: 11px; color: var(--accent); pointer-events: none; text-shadow: 0 1px 2px #000; }
.cell.loot { border-color: rgba(120,170,255,0.45); }
.grid6 .cell.loot img { width: calc(var(--cell) - 8px); height: calc(var(--cell) - 8px); }
.cell.drop-ok, .grid6.drop-ok { outline: 2px solid var(--good); outline-offset: 2px; }
.cell[data-drag] { cursor: grab; }
.cell.dragsrc { opacity: 0.35; }
body.dragging, body.dragging .cell { cursor: grabbing; }
#drag-ghost { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 40; transform: translate(-50%, -50%) scale(1.15); filter: drop-shadow(0 8px 12px rgba(0,0,0,0.7)); }
#drag-ghost[hidden] { display: none; }
#drag-ghost img { width: 44px; height: 44px; display: block; }
#drag-ghost .em { font-size: 34px; }
/* trash zone under the backpack */
.trash { margin: 14px 4px 0; padding: 12px; border: 2px dashed rgba(255,107,107,0.5); border-radius: 12px; color: var(--muted); font-size: 13px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: background 0.12s, border-color 0.12s; }
.trash .tb { font-size: 22px; opacity: 0.75; }
.trash.over { background: rgba(255,107,107,0.18); border-color: var(--bad); color: var(--bad); }
h3.sec.split.gap { margin-top: 22px; }
/* what a Magic Rock can drop: popover on hover */
#loot-pop { position: fixed; z-index: 35; min-width: 220px; max-width: 300px; background: rgba(12,14,20,0.97); border: 1px solid rgba(255,255,255,0.14); border-radius: 10px; padding: 8px 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); pointer-events: none; font-size: 12px; }
#loot-pop[hidden] { display: none; }
#loot-pop .lt { font-weight: 700; margin-bottom: 5px; }
#loot-pop .li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
#loot-pop .li .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
#loot-pop .li .n { flex: 1; font-weight: 600; }
#loot-pop .li .pc { color: var(--muted); font-variant-numeric: tabular-nums; }
/* the Magic Rock case window */
.panel.loot { z-index: 22; width: min(640px, 96vw); }
.lhero { display: flex; align-items: center; gap: 18px; padding: 8px 6px 16px; }
.lhero .lic { --rc: #5aa8ff; position: relative; width: 112px; height: 112px; flex: none; display: flex; align-items: center; justify-content: center; }
.lhero .lic .rays { position: absolute; inset: -8px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, var(--rc) 0 8deg, transparent 8deg 24deg); opacity: 0.4; -webkit-mask: radial-gradient(circle, #000 20%, transparent 70%); mask: radial-gradient(circle, #000 20%, transparent 70%); animation: spin 6s linear infinite; }
.lhero .lic img { position: relative; width: 96px; height: 96px; image-rendering: pixelated; filter: drop-shadow(0 0 12px var(--rc)); }
.lhero .lic.shake img { animation: lshake 1.3s ease-in-out; }
@keyframes lshake { 0%, 100% { transform: rotate(0) scale(1); } 15% { transform: rotate(-8deg) scale(1.05); } 30% { transform: rotate(8deg) scale(1.08); } 45% { transform: rotate(-10deg) scale(1.12); } 60% { transform: rotate(10deg) scale(1.16); } 80% { transform: rotate(-4deg) scale(1.2); } }
.lhero .t { flex: 1; min-width: 0; }
.lhero .t b { font-size: 20px; display: block; }
.lhero .t small { display: block; color: var(--muted); margin-top: 3px; }
.lhero .lopen { margin-top: 12px; }
button.act.lopen { font-size: 16px; padding: 11px 22px; box-shadow: 0 4px 16px rgba(242,193,78,0.35); }
.lresult { --rc: #fff; margin: 4px 6px 12px; padding: 14px; border: 1px solid var(--rc); border-radius: 12px; background: linear-gradient(180deg, rgba(255,255,255,0.07), transparent); text-align: center; animation: rewardIn 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
.lresult .lr { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--rc); }
.lresult .ln { font-size: 26px; font-weight: 900; color: var(--rc); text-shadow: 0 0 16px var(--rc); margin: 4px 0; }
.lresult .ln.landed { animation: landed 0.45s ease-out; }
.lcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; margin: 0 4px 6px; }
.lcard { --rc: #fff; position: relative; padding: 9px 9px 14px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; min-height: 72px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.lcard::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: 5px; height: 3px; border-radius: 2px; background: var(--rc); box-shadow: 0 0 8px var(--rc); }
.lcard .ln { font-weight: 700; font-size: 12px; line-height: 1.25; }
.lcard .lp { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.lcard .lp b { color: var(--rc); font-variant-numeric: tabular-nums; }
.lcard .lgot { position: absolute; right: 7px; top: 5px; font-size: 10px; color: var(--good); font-weight: 800; }
.lcard.hit { border-color: var(--rc); box-shadow: 0 0 0 2px var(--rc), 0 0 20px var(--rc); }
.panel-body { touch-action: pan-y; }
.detail { margin: 14px 4px 0; padding: 8px 12px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; display: flex; gap: 12px; align-items: center; min-height: 58px; }
.detail img { width: 44px; height: 44px; image-rendering: pixelated; flex: none; }
.detail .em { font-size: 34px; line-height: 1; flex: none; }
.detail .t { flex: 1; min-width: 0; }
.detail .t b { display: block; }
.detail .t small { color: var(--muted); display: block; }
.detail .t .good { color: var(--good); }
.detail .acts { display: flex; flex-direction: column; gap: 6px; }
.detail .acts button { padding: 6px 12px; font-size: 13px; }

.overlay { position: fixed; inset: 0; background: rgba(6,8,12,0.78); display: flex; align-items: center; justify-content: center; z-index: 30; backdrop-filter: blur(4px); }
.overlay[hidden] { display: none; }
.overlay-card { text-align: center; padding: 28px 32px; max-width: 440px; }
.overlay-card h1 { margin: 0 0 6px; font-size: 42px; letter-spacing: 3px; color: var(--accent); text-shadow: 0 4px 0 #6b4a10; }
.overlay-card .sub { color: var(--fg); margin: 0 0 12px; }
.overlay-card .help { color: var(--muted); font-size: 13px; line-height: 1.7; margin: 0 0 18px; }
.overlay-card .primary { font-size: 20px; padding: 12px 36px; border-radius: 12px; }
.tiny { font-size: 11px; color: var(--muted); margin-top: 12px; }
