/* Hermes Gold Mine — пиксельная шахта */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: #0a0e14; color: #e6edf3;
  max-width: 480px; margin: 0 auto; padding: 8px;
}
header { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px 10px; }
.title { font-size: 17px; font-weight: 700; }
.clock { font-variant-numeric: tabular-nums; color: #8b949e; font-size: 13px; }

/* ── Шахта ── */
.stage {
  position: relative; height: 320px; overflow: hidden;
  background:
    linear-gradient(#14101a 0%, #0d0a10 60%, #0a080c 100%);
  border: 1px solid #2a2135; border-radius: 14px;
  image-rendering: pixelated;
}
.deco { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }

/* пылинки */
.dust {
  position: absolute; top: 60%; width: 4px; height: 4px;
  background: #e8b83066; z-index: 1;
  animation: floaty 5s linear infinite;
}
@keyframes floaty {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: .8; }
  85% { opacity: .5; }
  100% { transform: translate(-14px, -46px); opacity: 0; }
}

.links { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.links line { stroke: #3a2d52; stroke-width: 2; stroke-dasharray: 6 4; }
.links line.active { stroke: #e8b830; stroke-dasharray: none; filter: drop-shadow(0 0 4px #e8b830aa); }
.links line.hung { stroke: #f85149; }

/* ── Шахтёр (пиксельный спрайт, без рамок) ── */
.miner {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  z-index: 2; cursor: pointer;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.miner:active { transform: scale(.95); }
.miner.hit { animation: hitFlash .4s ease-out; }
@keyframes hitFlash { 0% { filter: drop-shadow(0 0 10px #ffd75e); } 100% { filter: none; } }
.miner svg.pixel { width: 44px; height: 53px; image-rendering: pixelated; overflow: visible; }
.miner .label {
  font-size: 10px; font-weight: 800; margin-top: 1px; color: #ffd75e;
  text-shadow: 0 1px 2px #000, 0 0 6px #000;
  letter-spacing: .4px;
}
.miner .sub { font-size: 9px; color: #b8b0c8; max-width: 130px; text-align: center; line-height: 1.2; margin-top: 1px; text-shadow: 0 1px 2px #000; }

/* иерархия: главный (Hermes) ВЫШЕ, субагенты НИЖЕ */
.miner.center { left: 50%; top: 26%; transform: translate(-50%, -50%); z-index: 3; }
.miner.left  { left: 10%; top: 54%; }
.miner.right { right: 10%; top: 54%; }
.miner.bottom{ left: 50%; bottom: 15%; transform: translateX(-50%); }

/* тень под шахтёром */
.miner::after {
  content: ''; position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  width: 34px; height: 7px; border-radius: 50%;
  background: #000a; filter: blur(2px);
}

/* ── анимации: всегда живы ── */
/* медленное дыхание у всех */
.miner svg.pixel { animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }

/* работа: кирка долбит — вращение вокруг точки крепления руки (0,1) внутри armg */
@keyframes mine { 0%,100% { transform: rotate(-55deg); } 50% { transform: rotate(28deg); } }
.miner.busy .armg { animation: mine .4s ease-in-out infinite; transform-box: view-box; transform-origin: 0px 1px; }

/* искры при работе */
@keyframes spark {
  0% { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(16px,-20px) scale(.4); opacity: 0; }
}
.miner.busy .armg .spark { animation: spark .4s ease-out infinite; }
.miner.busy .armg .spark2 { animation: spark .4s ease-out infinite .2s; }

/* завис: тряска + красная вспышка */
@keyframes shake { 0%,100% { transform: translate(0,0); } 25% { transform: translate(-3px,1px); } 75% { transform: translate(3px,-1px); } }
.miner.hung svg.pixel { animation: shake .3s infinite; }
.miner.hung::before {
  content: ''; position: absolute; inset: -4px; border-radius: 10px;
  border: 2px solid #f85149aa; animation: flash .6s infinite;
}
@keyframes flash { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

/* фонарик мигает всегда */
.lampg { animation: lampGlow 2.4s ease-in-out infinite; }
@keyframes lampGlow { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
/* золотая жила мерцает */
.vg { animation: vshimmer 2.6s ease-in-out infinite; }
@keyframes vshimmer { 0%,100% { opacity: .65; } 50% { opacity: 1; } }

/* моргание */
.eyes { animation: blink 4.5s infinite; }
.eyes.c { opacity: 0; }
@keyframes blink { 0%,90% { opacity: 1; } 95%,100% { opacity: 0; } }

/* губы: иногда короткая «болтовня» (3 быстрых открытия за цикл 14с) */
.mouth-open { opacity: 0; }
@keyframes talk {
  0%, 1.5%, 5.5%, 9.5%, 13.5%, 25%, 100% { opacity: 0; }
  3.5%, 7.5%, 11.5% { opacity: 1; }
}
.mouth { animation: talk 14s infinite; }

/* ── золото ── */
.gold-pile {
  position: absolute; right: 8px; bottom: 10px; z-index: 4;
  font-size: 14px; font-weight: 800; color: #ffd75e;
  text-shadow: 0 0 8px #e8b83088;
  background: #14101acc; border: 1px solid #3a2d52;
  border-radius: 10px; padding: 3px 8px;
  display: flex; align-items: center; gap: 5px;
}
.gold-pile svg.chest { image-rendering: pixelated; display: block; }
svg.chest-mini { image-rendering: pixelated; vertical-align: -1px; }
@keyframes coin-pop { 0% { transform: scale(0) rotate(-30deg); opacity: 0; } 60% { transform: scale(1.4) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
.gold-pile.pop { animation: coin-pop .5s ease-out; }

/* ── панели ── */
.panel { margin-top: 10px; background: #13101c; border: 1px solid #232036; border-radius: 12px; padding: 10px 12px; }
.panel-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: #d8d0e8; }
.meter { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: 12px; }
.meter span { width: 44px; color: #9a92a8; }
.meter .bar { flex: 1; height: 8px; background: #1c1830; border-radius: 4px; overflow: hidden; }
.meter .bar div { height: 100%; width: 0; border-radius: 4px; transition: width .6s; background: linear-gradient(90deg, #e8b830, #f0c040); }
.meter .bar div.warn { background: linear-gradient(90deg, #d29922, #e3b341); }
.meter .bar div.crit { background: linear-gradient(90deg, #f85149, #da3633); }
.meter b { width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.meta { font-size: 11px; color: #9a92a8; margin-top: 6px; }

.bots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bot { background: #1a1730; border-radius: 8px; padding: 7px 9px; font-size: 11.5px; border: 1px solid #232036; }
.bot .n { font-weight: 700; }
.bot .s { color: #9a92a8; font-size: 10.5px; }
.bot .s.win { color: #4ade80; }
.bot .s.wait { color: #fbbf24; }
.bot .pnl { font-weight: 700; font-variant-numeric: tabular-nums; }
.bot .pnl.pos { color: #ffd75e; text-shadow: 0 0 6px #e8b83066; }
.bot .pnl.neg { color: #f85149; }
.bot .mth { font-weight: 700; font-size: 10.5px; font-variant-numeric: tabular-nums; }
.bot .mth.pos { color: #4ade80; }
.bot .mth.neg { color: #f85149; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.dot.on { background: #e8b830; box-shadow: 0 0 5px #e8b83088; }
.dot.off { background: #484f58; }

.events .ev { font-size: 11px; color: #9a92a8; padding: 3px 0; border-bottom: 1px dashed #232036; }
.events .ev b { color: #d8d0e8; }
footer { text-align: center; font-size: 10px; color: #484f58; padding: 8px 0 4px; }

/* ── модалка (инфо по клику) ── */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  background: #000a;
}
.modal.open { display: flex; }
.modal-box {
  background: #16121e; border: 2px solid #3a2d52; border-radius: 14px;
  width: min(320px, 88vw); padding: 14px;
  box-shadow: 0 0 30px #000c, 0 0 40px #e8b83022;
  animation: modalIn .25s ease-out;
}
@keyframes modalIn { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-title { font-size: 15px; font-weight: 800; color: #ffd75e; margin-bottom: 8px; }
.modal-body div { font-size: 12.5px; color: #c8c0d8; padding: 2.5px 0; border-bottom: 1px dashed #232036; }
.m-close {
  width: 100%; margin-top: 10px; padding: 8px;
  background: #2a2342; color: #d8d0e8; border: 1px solid #3a2d52;
  border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.m-close:hover { background: #3a2d52; }

/* ── чат с агентом ── */
.walkie-btn {
  position: absolute; right: 96px; bottom: 10px; z-index: 4;
  background: none; border: 0; padding: 0; cursor: pointer;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 5px #000a);
  animation: breathe 3.2s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
.walkie-btn svg { display: block; }
.walkie-btn:active { transform: scale(.92); }
@keyframes walkieTalk {
  0%, 100% { filter: drop-shadow(0 0 2px #f8514988); }
  50% { filter: drop-shadow(0 0 10px #f85149ee); }
}
.walkie-btn.talk { animation: walkieTalk .7s ease-in-out infinite; }

.chat-window {
  position: fixed; right: 10px; bottom: 62px; z-index: 31;
  width: min(300px, 92vw); height: min(420px, 55vh);
  background: #14101af2; border: 1px solid #3a2d52; border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 6px 24px #000c;
}
.chat-window[hidden], .chat-token[hidden] { display: none; }
.chat-head {
  padding: 8px 12px; font-weight: 800; font-size: 13px; color: #ffd75e;
  border-bottom: 1px solid #2a2040; display: flex; justify-content: space-between;
}
.chat-x { cursor: pointer; color: #8a7fa0; }
.chat-token { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid #2a2040; }
.chat-token-input {
  flex: 1; background: #0d0a14; color: #e8e0f8; border: 1px solid #3a2d52;
  border-radius: 8px; padding: 6px 8px; font-size: 12px; min-width: 0;
}
.chat-btn { background: #3d6b8f; color: #fff; border: 0; border-radius: 8px; padding: 0 12px; font-size: 14px; cursor: pointer; }
.chat-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cm { display: flex; flex-direction: column; max-width: 85%; }
.cm.me { align-self: flex-end; }
.cm.ag { align-self: flex-start; }
.cb {
  padding: 6px 9px; border-radius: 10px; font-size: 12.5px; line-height: 1.35;
  white-space: pre-wrap; word-break: break-word;
}
.cm.me .cb { background: #3d6b8f; color: #f0f6ff; border-bottom-right-radius: 2px; }
.cm.ag .cb { background: #1e1830; color: #e8e0f8; border: 1px solid #2a2040; border-bottom-left-radius: 2px; }
.ct { font-size: 9.5px; color: #8a7fa0; margin-top: 2px; }
.cm.hint { align-self: center; color: #8a7fa0; font-size: 11.5px; text-align: center; padding: 12px; }
.typing { color: #b8b0c8; font-style: italic; }
.chat-input { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #2a2040; }
.chat-text {
  flex: 1; background: #0d0a14; color: #e8e0f8; border: 1px solid #3a2d52;
  border-radius: 8px; padding: 8px; font-size: 12.5px; min-width: 0;
}
.chat-btn:disabled { opacity: .4; cursor: not-allowed; }
.chat-text:disabled { opacity: .45; }

/* ── сон: Z над спящим шахтёром ── */
.zz {
  position: absolute; top: -8px; right: -4px;
  font-weight: 900; color: #a89ed0; line-height: 1;
  text-shadow: 0 1px 2px #000; opacity: 0;
  pointer-events: none;
}
.zz span { display: block; font-size: 13px; animation: zfloat 2.4s ease-in-out infinite; }
.zz span:nth-child(2) { font-size: 8px; animation-delay: .8s; }
.miner.sleeping .zz { opacity: 1; }
@keyframes zfloat {
  0% { transform: translate(0, 4px) scale(.6); opacity: 0; }
  25% { opacity: .95; }
  100% { transform: translate(10px, -16px) scale(1.2); opacity: 0; }
}
