:root {
  --bg: #050a10;
  --bg-deep: #071017;
  --panel: #0c1721;
  --panel-2: #101f2b;
  --panel-3: #142938;
  --line: #254354;
  --line-soft: rgba(92, 174, 202, .18);
  --text: #edf7f8;
  --muted: #8fa8b4;
  --faint: #557180;
  --cyan: #38d9ff;
  --cyan-dim: #0c718b;
  --green: #55ef9b;
  --green-deep: #103b2a;
  --gold: #ffc65a;
  --gold-deep: #5d4314;
  --red: #ff7788;
  --slot: #081218;
  --shadow: rgba(0, 0, 0, .54);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --dock: 72px;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 80% -10%, rgba(21, 103, 131, .2), transparent 34rem),
    radial-gradient(circle at 10% 100%, rgba(12, 102, 77, .14), transparent 28rem),
    var(--bg);
  font-family: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

img {
  display: block;
  max-width: 100%;
  image-rendering: auto;
  user-select: none;
  -webkit-user-drag: none;
}

#app {
  min-height: 100dvh;
  padding-top: var(--safe-t);
  padding-bottom: calc(var(--dock) + var(--safe-b) + 14px);
}

/* Header */
.topbar {
  display: grid;
  grid-template-columns: minmax(190px, .9fr) auto minmax(500px, 2.1fr);
  align-items: center;
  gap: 20px;
  min-height: 84px;
  padding: 12px clamp(16px, 3vw, 42px);
  border-bottom: 1px solid rgba(101, 178, 201, .16);
  background: linear-gradient(180deg, rgba(8, 18, 26, .97), rgba(7, 15, 22, .88));
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  letter-spacing: .08em;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 198, 90, .42);
  border-radius: 12px;
  background: linear-gradient(145deg, #182128, #0a0f14);
  box-shadow: inset 0 0 14px rgba(255, 198, 90, .13), 0 0 18px rgba(255, 198, 90, .08);
}

.brand-mark img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand b {
  display: block;
  color: #f6fcff;
  font-family: "Press Start 2P", "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}

.brand small {
  display: block;
  margin-top: 5px;
  color: var(--faint);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 600;
  white-space: nowrap;
}

.network-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(85, 239, 155, .25);
  border-radius: 999px;
  color: #94d6b0;
  background: rgba(16, 59, 42, .35);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  white-space: nowrap;
}

.network-status i,
.legend-dot.live {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(85, 239, 155, .11), 0 0 10px var(--green);
  animation: pulse 1.8s ease-in-out infinite;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid rgba(91, 168, 193, .16);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(18, 36, 48, .72), rgba(8, 19, 27, .72));
}

.metric span,
.metric small {
  display: block;
  overflow: hidden;
  color: var(--faint);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric b {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: #eaf7fb;
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(12px, 1.1vw, 15px);
  font-weight: 600;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-money b { color: var(--gold); }
.metric-btc b,
.metric-income b { color: var(--green); }
.metric-power b { color: var(--cyan); }
.metric-power small { margin-top: 2px; color: #7194a2; }

/* Main layout */
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
  gap: 16px;
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 18px clamp(16px, 3vw, 42px) 0;
}

.play-area,
.inventory-panel {
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px 12px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--cyan);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.section-heading h1,
.panel-head h2 {
  margin: 0;
  color: #f2fbff;
  font-size: clamp(19px, 2vw, 25px);
  line-height: 1.1;
}

.section-copy {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section-copy b {
  color: var(--cyan);
  font-weight: 700;
}

.heading-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.tool-btn,
.round-btn,
.icon-btn {
  color: var(--text);
  border: 1px solid rgba(118, 192, 214, .25);
  background: linear-gradient(145deg, #152938, #0c1721);
  box-shadow: inset 0 1px rgba(255, 255, 255, .03), 0 4px 12px rgba(0, 0, 0, .15);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 37px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.tool-btn span {
  color: var(--cyan);
  font-family: "IBM Plex Mono", monospace;
  font-size: 18px;
  line-height: 1;
}

.tool-btn em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.tool-btn:hover,
.round-btn:hover,
.icon-btn:hover {
  border-color: rgba(56, 217, 255, .65);
  color: #fff;
}

/* Room */
.room-viewport {
  position: relative;
  min-height: 500px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(84, 168, 196, .3);
  border-radius: var(--radius);
  /* Фон привязан к видимому окну, а не к высоте всех рядов ригов:
     добавление корпусов больше не увеличивает и не размывает картинку. */
  background: #02070b url("../assets/room-bg.png") center / cover no-repeat;
  box-shadow: 0 16px 38px rgba(0, 0, 0, .25), inset 0 0 0 1px rgba(0, 0, 0, .8);
  scrollbar-color: #2a6073 #081117;
  scrollbar-width: thin;
}

.room-viewport::-webkit-scrollbar,
.sheet-body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.room-viewport::-webkit-scrollbar-thumb,
.sheet-body::-webkit-scrollbar-thumb {
  border: 2px solid #071017;
  border-radius: 10px;
  background: #2a6073;
}

.room-floor {
  position: relative;
  min-width: 100%;
  min-height: 500px;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(180deg, rgba(4, 12, 19, .14), rgba(4, 12, 19, .32));
}

.room-floor::before,
.room-floor::after {
  position: absolute;
  z-index: 1;
  content: "";
  pointer-events: none;
}

.room-floor::before {
  inset: 0;
  background:
    linear-gradient(90deg, rgba(1, 7, 11, .44), transparent 19%, transparent 78%, rgba(1, 7, 11, .4)),
    linear-gradient(180deg, rgba(3, 9, 14, .28), transparent 40%, rgba(2, 8, 12, .5));
}

.room-floor::after {
  right: 0;
  bottom: 0;
  left: 0;
  height: 42%;
  background: linear-gradient(0deg, rgba(2, 8, 12, .26), transparent);
}

.floor-grid {
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  opacity: .26;
  background-image:
    linear-gradient(rgba(72, 175, 198, .11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(72, 175, 198, .11) 1px, transparent 1px);
  background-position: center bottom;
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, transparent, #000 38%, #000);
}

.floor-light {
  position: absolute;
  z-index: 2;
  width: 180px;
  height: 70px;
  border-radius: 50%;
  filter: blur(20px);
  pointer-events: none;
}

.light-one {
  top: 17%;
  left: 16%;
  background: rgba(36, 205, 255, .17);
}

.light-two {
  right: 8%;
  bottom: 11%;
  background: rgba(87, 239, 155, .12);
}

.world {
  position: absolute;
  z-index: 5;
  inset: 0;
}

.floor-caption {
  position: absolute;
  z-index: 4;
  right: 16px;
  bottom: 11px;
  margin: 0;
  color: rgba(184, 221, 231, .45);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .08em;
  pointer-events: none;
}

/* Movable room objects */
.world-object {
  position: absolute;
  z-index: 6;
  max-width: calc(100% - 12px);
  user-select: none;
  -webkit-user-select: none;
  transition: filter .16s ease, transform .16s ease;
}

.object-drag-handle {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(111, 193, 217, .35);
  border-radius: 8px;
  color: #a8c7d2;
  background: rgba(7, 19, 27, .91);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .3);
  font-family: "IBM Plex Mono", monospace;
  font-size: 16px;
  line-height: 1;
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.object-drag-handle:active {
  cursor: grabbing;
}

.endpoint-object {
  width: clamp(132px, 16vw, 174px);
}

.endpoint-object .object-drag-handle {
  position: absolute;
  z-index: 5;
  top: -2px;
  right: -2px;
}

.endpoint-action {
  position: relative;
  display: block;
  width: 100%;
  padding: 4px 3px 1px;
  border-radius: 14px;
  color: var(--text);
  background: radial-gradient(ellipse at 50% 82%, rgba(18, 91, 116, .3), transparent 55%);
  text-align: center;
  transition: transform .15s ease, filter .15s ease;
}

.endpoint-action:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.endpoint-action img {
  width: 100%;
  height: 94px;
  object-fit: contain;
  filter: drop-shadow(0 10px 8px rgba(0, 0, 0, .65));
  pointer-events: none;
}

.shop-object .endpoint-action img {
  height: 106px;
}

.endpoint-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-height: 22px;
  margin-top: -2px;
  padding: 4px 7px;
  border: 1px solid rgba(90, 187, 213, .27);
  border-radius: 7px;
  background: rgba(6, 17, 24, .86);
  box-shadow: 0 4px 8px rgba(0, 0, 0, .35);
  color: #cdebf5;
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.endpoint-label i {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 7px var(--green);
}

.shop-object .endpoint-label {
  border-color: rgba(255, 198, 90, .35);
  color: #ffe1a0;
}

.shop-object .endpoint-label i {
  background: var(--gold);
  box-shadow: 0 0 7px var(--gold);
}

.rig-object {
  width: min(310px, calc(100vw - 38px));
  border: 1px solid rgba(98, 195, 219, .43);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(14, 35, 47, .97), rgba(6, 16, 23, .97));
  box-shadow: 0 13px 23px rgba(0, 0, 0, .48), inset 0 1px rgba(255, 255, 255, .06), inset 0 0 0 1px rgba(0, 0, 0, .54);
  overflow: hidden;
}

.rig-top {
  display: grid;
  grid-template-columns: 27px 1fr auto;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 6px 7px;
  border-bottom: 1px solid rgba(95, 185, 209, .19);
  background: linear-gradient(90deg, rgba(25, 62, 78, .82), rgba(10, 24, 33, .84));
}

.rig-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #d9f6ff;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rig-name [data-rig-count] {
  color: #7fa3ae;
  font-size: 10px;
}

.rig-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #94d8b1;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 600;
  white-space: nowrap;
}

.rig-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #49616b;
}

.rig-status.online i {
  background: var(--green);
  box-shadow: 0 0 7px var(--green);
}

.rig-body {
  position: relative;
  min-height: 142px;
  padding: 10px 9px 8px;
  overflow: hidden;
}

.rig-body::before {
  position: absolute;
  z-index: 0;
  top: 7px;
  right: 7px;
  bottom: 7px;
  width: 64px;
  border-left: 1px solid rgba(87, 205, 231, .09);
  background: linear-gradient(90deg, transparent, rgba(4, 13, 20, .35));
  content: "";
}

.rig-art {
  position: absolute;
  z-index: 0;
  right: -17px;
  bottom: -19px;
  width: 105px;
  opacity: .28;
  filter: drop-shadow(0 8px 6px rgba(0, 0, 0, .65));
  pointer-events: none;
}

.rig-slots {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  width: calc(100% - 43px);
}

.gpu-slot {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 74px;
  padding: 4px 2px 3px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #2c5261;
  border-radius: 7px;
  background:
    linear-gradient(135deg, rgba(34, 74, 88, .35), rgba(6, 17, 23, .9)),
    #08141b;
  color: var(--text);
  transition: border-color .14s ease, background .14s ease, box-shadow .14s ease, transform .14s ease;
  touch-action: none;
}

.gpu-slot:hover {
  border-color: rgba(66, 218, 255, .7);
}

.gpu-slot.empty {
  border-style: dashed;
  border-color: rgba(88, 144, 159, .55);
  color: #63818e;
}

.gpu-slot.empty:hover {
  border-color: var(--cyan);
  background: rgba(14, 72, 89, .65);
}

.gpu-slot.filled {
  border-color: rgba(85, 239, 155, .48);
  box-shadow: inset 0 0 12px rgba(85, 239, 155, .08);
}

.gpu-slot.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 198, 90, .18), inset 0 0 12px rgba(255, 198, 90, .13);
}

.gpu-slot.drag-source,
.inventory-card.drag-source {
  opacity: .42;
  filter: saturate(.55);
}

.gpu-slot.drop-target {
  transform: translateY(-2px) scale(1.04);
  border-color: var(--cyan);
  background: rgba(15, 92, 111, .83);
  box-shadow: 0 0 0 2px rgba(56, 217, 255, .21), 0 0 17px rgba(56, 217, 255, .22);
}

.gpu-slot img {
  width: 100%;
  height: 39px;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .6));
  pointer-events: none;
}

.slot-number {
  position: absolute;
  z-index: 2;
  top: 3px;
  left: 4px;
  color: rgba(173, 217, 229, .6);
  font-family: "IBM Plex Mono", monospace;
  font-size: 7px;
  line-height: 1;
}

.slot-plus {
  color: var(--cyan);
  font-family: "IBM Plex Mono", monospace;
  font-size: 23px;
  line-height: .9;
}

.slot-empty-text {
  position: absolute;
  right: 0;
  bottom: 4px;
  left: 0;
  color: #6f8e9a;
  font-family: "IBM Plex Mono", monospace;
  font-size: 6px;
  font-weight: 600;
  letter-spacing: .04em;
}

.rig-bottom {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 7px;
  width: calc(100% - 42px);
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid rgba(78, 151, 171, .16);
  color: #73939e;
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
}

.rig-bottom b {
  color: var(--green);
  font-weight: 600;
  text-align: right;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.rig-bottom b.damaged {
  color: #ffc890;
}

.workshop-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 3px 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
}

.workshop-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border: 1px dashed #71929d;
  border-radius: 50%;
}

.legend-drag {
  margin-left: auto;
  color: #9bcbd8;
}

/* Inventory */
.inventory-panel {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  min-height: 400px;
  padding: 14px;
  border: 1px solid rgba(94, 180, 207, .25);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(16, 35, 47, .95), rgba(7, 16, 23, .96)),
    var(--panel);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .21), inset 0 1px rgba(255, 255, 255, .035);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 11px;
  border-bottom: 1px solid rgba(85, 161, 186, .18);
}

.panel-head h2 {
  font-size: 16px;
}

.panel-head h2 #inventory-count {
  display: inline-grid;
  min-width: 21px;
  height: 21px;
  place-items: center;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: #1a4d5c;
  color: var(--cyan);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  vertical-align: 2px;
}

.round-btn {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-size: 23px;
  line-height: 1;
}

.inventory-copy {
  margin: 10px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.42;
}

.inventory-actions {
  margin-bottom: 9px;
}

.inventory-actions-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: stretch;
}

.inventory-actions-row .btn {
  min-height: 38px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  text-align: center;
}

.inventory-actions-row .auto-install-btn {
  grid-column: 1 / -1;
  width: 100%;
}

.inventory-actions-row .btn.ghost {
  color: #dff2f7;
}

.inventory-actions-row .btn.danger {
  color: #2b070d;
}

.inventory-list {
  display: flex;
  min-height: 98px;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 7px;
  overflow: visible;
  padding: 1px 2px 4px;
}

.inventory-empty {
  display: grid;
  min-height: 112px;
  place-items: center;
  padding: 16px;
  border: 1px dashed rgba(104, 164, 181, .36);
  border-radius: 12px;
  background: rgba(4, 13, 19, .32);
  color: #718f9a;
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}

.inventory-empty b {
  display: block;
  margin-bottom: 3px;
  color: #b0d8e3;
  font-size: 12px;
}

.inventory-card {
  position: relative;
  display: grid;
  min-height: 75px;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 7px;
  padding: 6px;
  overflow: hidden;
  border: 1px solid rgba(90, 162, 185, .3);
  border-radius: 10px;
  background: linear-gradient(135deg, #112937, #0a1821);
  color: var(--text);
  text-align: left;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
  touch-action: none;
}

.inventory-card:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 217, 255, .74);
}

.inventory-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 198, 90, .13), inset 0 0 15px rgba(255, 198, 90, .08);
}

.inventory-card img {
  width: 76px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .55));
  pointer-events: none;
}

.inventory-card strong,
.inventory-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-card strong {
  margin-top: 5px;
  color: #dff6fb;
  font-size: 11px;
  line-height: 1.15;
}

.inventory-card span {
  margin-top: 4px;
  color: var(--green);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
}

.inventory-card .inventory-tag {
  position: absolute;
  top: 5px;
  right: 6px;
  margin: 0;
  color: #75939e;
  font-size: 7px;
  letter-spacing: .07em;
}

.inventory-hint {
  min-height: 35px;
  margin-top: 8px;
  padding: 8px 9px;
  border: 1px dashed rgba(89, 159, 181, .27);
  border-radius: 9px;
  color: #7798a5;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  line-height: 1.35;
  text-align: center;
  transition: .16s ease;
}

.inventory-hint.drop-target,
.inventory-panel.drop-target .inventory-hint {
  border-color: var(--cyan);
  background: rgba(17, 98, 119, .42);
  color: #ccf7ff;
  box-shadow: 0 0 16px rgba(56, 217, 255, .16);
}

/* Fixed navigation */
.dock {
  position: fixed;
  z-index: 40;
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: calc(9px + var(--safe-b));
  left: max(10px, env(safe-area-inset-left, 0px));
  display: grid;
  width: min(490px, calc(100% - 20px));
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin: 0 auto;
  padding: 5px;
  border: 1px solid rgba(104, 187, 211, .28);
  border-radius: 15px;
  background: rgba(8, 19, 27, .93);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .42), inset 0 1px rgba(255, 255, 255, .05);
  backdrop-filter: blur(14px);
}

.dock button {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 11px;
  background: transparent;
  color: #819ba6;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .025em;
  white-space: nowrap;
}

.dock button span {
  color: #7196a5;
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
}

.dock button.active {
  background: linear-gradient(145deg, #2ac6df, #3ce08c);
  box-shadow: 0 4px 12px rgba(31, 208, 178, .24);
  color: #052019;
}

.dock button.active span {
  color: #052019;
}

/* Sheets and controls */
.sheet-bg {
  position: fixed;
  z-index: 50;
  inset: 0;
  opacity: 0;
  background: rgba(1, 6, 9, .69);
  backdrop-filter: blur(3px);
  pointer-events: none;
  transition: opacity .2s ease;
}

.sheet-bg.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  z-index: 60;
  visibility: hidden;
  pointer-events: none;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: min(640px, 100%);
  max-height: min(83dvh, 760px);
  flex-direction: column;
  margin: 0 auto;
  padding-bottom: calc(12px + var(--safe-b));
  transform: translateY(110%);
  border: 1px solid rgba(105, 193, 217, .34);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background: linear-gradient(145deg, #10212d, #09141c 70%);
  box-shadow: 0 -20px 55px rgba(0, 0, 0, .5), inset 0 1px rgba(255, 255, 255, .06);
  transition: transform .24s cubic-bezier(.2, .85, .25, 1);
}

.sheet.open {
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  flex: 0 0 auto;
  margin: 8px auto 0;
  border-radius: 4px;
  background: #416374;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 11px;
  border-bottom: 1px solid rgba(101, 185, 209, .18);
}

.sheet-head .eyebrow {
  margin-bottom: 3px;
  font-size: 8px;
}

.sheet-head h2 {
  margin: 0;
  color: #f1fcff;
  font-size: 20px;
}

.icon-btn {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
}

.sheet-body {
  overflow-y: auto;
  padding: 14px 16px 20px;
  overscroll-behavior: contain;
}

.sheet-summary {
  margin: 0 0 12px;
  padding: 9px 11px;
  border: 1px solid rgba(89, 168, 192, .19);
  border-radius: 10px;
  background: rgba(4, 14, 20, .41);
  color: #91b3be;
  font-size: 12px;
  line-height: 1.42;
}

.sheet-summary b {
  color: var(--gold);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.tabs button {
  min-height: 38px;
  padding: 7px 4px;
  border: 1px solid rgba(101, 181, 204, .2);
  border-radius: 9px;
  background: #10212c;
  color: #88a5b0;
  font-size: 11px;
  font-weight: 600;
}

.tabs button.on {
  border-color: rgba(255, 198, 90, .75);
  background: linear-gradient(145deg, #efaf3e, #ffd66f);
  color: #281a05;
}

.shop-card,
.up-card,
.profile-card,
.gpu-detail {
  border: 1px solid rgba(91, 168, 191, .22);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(19, 43, 57, .92), rgba(9, 23, 31, .92));
  box-shadow: inset 0 1px rgba(255, 255, 255, .035);
}

.shop-card {
  display: grid;
  grid-template-columns: 114px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  padding: 9px;
}

.shop-card.locked {
  opacity: .48;
  filter: saturate(.55);
}

.shop-card > img,
.shop-card-art {
  width: 114px;
  height: 67px;
  object-fit: contain;
  filter: drop-shadow(0 6px 5px rgba(0, 0, 0, .5));
}

.shop-card h4,
.up-card h4 {
  margin: 0 0 3px;
  color: #e6f9fd;
  font-size: 13px;
}

.shop-card p,
.up-card p {
  margin: 0;
  color: #8ca8b2;
  font-size: 11px;
  line-height: 1.38;
}

.shop-card .price {
  margin-top: 5px;
  color: var(--green);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
}

.row-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.btn {
  min-height: 35px;
  padding: 8px 11px;
  border: 1px solid rgba(187, 224, 235, .16);
  border-radius: 9px;
  box-shadow: inset 0 1px rgba(255, 255, 255, .16), 0 3px 8px rgba(0, 0, 0, .16);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  transition: transform .12s ease, filter .12s ease, border-color .12s ease;
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn.primary {
  border-color: rgba(85, 239, 155, .6);
  background: linear-gradient(145deg, #3bdc8b, #6bf0ac);
  color: #062719;
}

.btn.gold {
  border-color: rgba(255, 214, 111, .65);
  background: linear-gradient(145deg, #eaaa3e, #ffd46b);
  color: #2d1b03;
}

.btn.ghost {
  border-color: rgba(102, 180, 205, .27);
  background: #102330;
  color: #c7e2e9;
}

.btn.danger {
  border-color: rgba(255, 119, 136, .62);
  background: linear-gradient(145deg, #dc5067, #ff8392);
  color: #310810;
}

.btn.wide {
  width: 100%;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .42;
  box-shadow: none;
}

.case-shop-art {
  height: 95px !important;
}

.up-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding: 11px;
}

.up-card > div {
  min-width: 0;
}

.up-card .btn {
  flex: 0 0 auto;
}

.pips {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}

.pip {
  width: 15px;
  height: 6px;
  border: 1px solid #2f5767;
  border-radius: 3px;
  background: #132732;
}

.pip.on {
  border-color: #45d88d;
  background: var(--green);
  box-shadow: 0 0 6px rgba(85, 239, 155, .5);
}

.profile-hero {
  position: relative;
  margin-bottom: 10px;
  padding: 12px 14px 12px 108px;
  overflow: hidden;
  border: 1px solid rgba(92, 185, 210, .28);
  border-radius: 13px;
  background: linear-gradient(120deg, rgba(22, 63, 79, .85), rgba(9, 24, 32, .93));
  min-height: 92px;
}

/* Декоративная картинка профиля гостя — строго внутри рамки карточки. */
.profile-hero img {
  position: absolute;
  bottom: 9px;
  left: 12px;
  width: 86px;
  height: 74px;
  max-width: calc(100% - 120px);
  max-height: calc(100% - 14px);
  object-fit: contain;
  filter: drop-shadow(0 6px 7px rgba(0, 0, 0, .55));
}

/* Аватарка игрока из Telegram в профиле: аккуратный круг, вертикально по
   центру карточки и никогда не выходит за её границы. */
.profile-hero img.profile-avatar,
.profile-avatar-fallback {
  position: absolute;
  top: 50%;
  bottom: auto;
  left: 14px;
  width: 72px;
  height: 72px;
  max-width: calc(100% - 28px);
  max-height: calc(100% - 16px);
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(92, 185, 210, .55);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .5);
  filter: none;
  background: #0a1c26;
  transform: translateY(-50%);
}

/* Замена аватарки, если фото из Telegram не загрузилось: круг с инициалом. */
.profile-avatar-fallback {
  display: grid;
  place-items: center;
  color: #bfe9f5;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: .02em;
  background: linear-gradient(145deg, #1d4a5c, #0d2431);
}

.profile-hero h3 {
  margin: 3px 0 4px;
  font-size: 19px;
}

.profile-hero p {
  margin: 0;
  color: #94b8c4;
  font-size: 12px;
  line-height: 1.35;
}

.profile-card {
  margin-bottom: 9px;
  padding: 11px;
}

.profile-card h4 {
  margin: 0 0 8px;
  color: #e9faff;
  font-size: 14px;
}

.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(100, 172, 194, .14);
  font-size: 12px;
}

.kv:last-child {
  border-bottom: 0;
}

.kv span {
  flex: 0 1 auto;
  min-width: 0;
  color: #8ba7b2;
}

/* ============ Топ-10 майнеров (живой рейтинг сервера) ============ */
.top-tabs {
  margin-bottom: 9px;
}

.top-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.top-row {
  display: grid;
  grid-template-columns: 38px 42px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid rgba(91, 168, 191, .22);
  border-radius: 11px;
  background: linear-gradient(145deg, #122839, #0a1a24);
}

.top-row.me {
  border-color: rgba(255, 198, 90, .65);
  background: linear-gradient(145deg, #1d3040, #0c202b);
  box-shadow: 0 0 0 1px rgba(255, 198, 90, .22), 0 8px 18px rgba(0, 0, 0, .3);
}

.top-place {
  color: #9fc2cd;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.top-place.p1,
.top-place.p2,
.top-place.p3 {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .5));
}

.top-avatar {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(92, 185, 210, .5);
  border-radius: 50%;
  background: linear-gradient(145deg, #1d4a5c, #0d2431);
}

.top-avatar i {
  color: #bfe9f5;
  font-size: 16px;
  font-style: normal;
  font-weight: 700;
}

.top-avatar img {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.top-avatar img.broken {
  display: none;
}

.top-name {
  display: block;
  overflow: hidden;
  min-width: 0;
  color: #e3f8fd;
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-name small {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: #7fa3ae;
  font-size: 9.5px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-value {
  color: var(--green);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.top-row.me .top-value {
  color: var(--gold);
}

.top-loading {
  padding: 22px 14px;
  color: #7fa3ae;
  font-size: 12px;
  text-align: center;
}

.top-me {
  margin-top: 10px;
  color: #9fc2cd;
  font-size: 11.5px;
  text-align: center;
}

.top-me b {
  color: var(--gold);
}

@media (max-width: 430px) {
  .top-row {
    grid-template-columns: 30px 36px minmax(0, 1fr) auto;
    gap: 7px;
    padding: 6px 8px;
  }

  .top-avatar {
    width: 36px;
    height: 36px;
  }

  .top-value {
    font-size: 10px;
  }
}

.kv b {
  max-width: 64%;
  color: #dff4f8;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  line-height: 1.4;
  text-align: right;
  overflow-wrap: anywhere;
}

.exchange {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin-top: 8px;
}

.exchange input,
.name-row input {
  min-width: 0;
  border: 1px solid rgba(99, 180, 205, .31);
  border-radius: 9px;
  outline: none;
  background: #07141c;
  color: #e6f8fc;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

.exchange input {
  min-height: 35px;
  padding: 8px 9px;
}

.gpu-detail {
  display: grid;
  grid-template-columns: minmax(130px, .9fr) 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 11px;
  padding: 13px;
}

.gpu-detail img {
  width: 100%;
  max-height: 95px;
  object-fit: contain;
  filter: drop-shadow(0 8px 7px rgba(0, 0, 0, .55));
}

.gpu-detail h3 {
  margin: 0 0 5px;
  color: #e9faff;
  font-size: 15px;
}

.gpu-detail p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.36;
}

.gpu-detail .hash {
  color: var(--green);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.detail-copy {
  margin: 0 0 10px;
  color: #92b0ba;
  font-size: 12px;
  line-height: 1.45;
}

.name-row {
  display: flex;
  gap: 8px;
}

.name-row input {
  width: 100%;
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 9px 10px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
}

.settings-row span {
  color: #dff4f8;
  font-size: 13px;
  font-weight: 600;
}

.settings-row .btn {
  flex: 0 0 auto;
}

/* Toast and intro */
.toast {
  position: fixed;
  z-index: 100;
  bottom: calc(var(--dock) + var(--safe-b) + 19px);
  left: 50%;
  max-width: min(90vw, 460px);
  padding: 10px 14px;
  transform: translate(-50%, 22px);
  border: 1px solid rgba(85, 239, 155, .47);
  border-radius: 10px;
  background: rgba(8, 32, 23, .96);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .35);
  color: #a8f6c9;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.tutorial {
  position: fixed;
  z-index: 110;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(1, 7, 11, .78);
  backdrop-filter: blur(5px);
}

.tutorial.open {
  display: flex;
}

.tutorial-card {
  width: min(510px, 100%);
  padding: clamp(18px, 4vw, 27px);
  border: 1px solid rgba(83, 213, 244, .44);
  border-radius: 18px;
  background:
    radial-gradient(circle at 100% 0, rgba(36, 172, 199, .18), transparent 44%),
    linear-gradient(145deg, #122935, #09151d);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .6), inset 0 1px rgba(255, 255, 255, .08);
}

.tutorial-card h2 {
  margin: 0 0 9px;
  color: #edfcff;
  font-size: clamp(22px, 5vw, 28px);
  line-height: 1.08;
}

.tutorial-card > p:not(.eyebrow) {
  margin: 0;
  color: #a0bbc5;
  font-size: 14px;
  line-height: 1.48;
}

.tutorial-steps {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
}

.tutorial-steps li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 9px;
  align-items: center;
  color: #b6d0d7;
  font-size: 12px;
  line-height: 1.38;
}

.tutorial-steps b {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid rgba(56, 217, 255, .45);
  border-radius: 7px;
  color: var(--cyan);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.tutorial-steps strong {
  color: var(--cyan);
}

.drag-ghost {
  position: fixed;
  z-index: 120;
  display: grid;
  width: 145px;
  grid-template-columns: 65px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  padding: 6px;
  transform: translate(-50%, -50%) rotate(2deg);
  border: 1px solid rgba(84, 239, 183, .9);
  border-radius: 10px;
  background: rgba(8, 29, 26, .96);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .45), 0 0 18px rgba(85, 239, 155, .24);
  color: #dffbf0;
  pointer-events: none;
}

.drag-ghost img {
  width: 65px;
  height: 43px;
  object-fit: contain;
}

.drag-ghost b,
.drag-ghost span {
  display: block;
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drag-ghost span {
  margin-top: 3px;
  color: var(--green);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .52; }
}

@media (min-width: 801px) {
  html,
  body {
    height: auto;
    overflow: visible;
  }

  #app {
    display: flex;
    height: auto;
    flex-direction: column;
  }

  .game-layout {
    min-height: 0;
    flex: 1;
    padding-bottom: 12px;
  }

  .play-area,
  .inventory-panel {
    min-height: 0;
  }

  .play-area {
    display: flex;
    flex-direction: column;
  }

  .room-viewport {
    min-height: 0;
    flex: 1;
  }

  .inventory-panel {
    max-height: 100%;
  }
}

@media (max-width: 1060px) {
  .topbar {
    grid-template-columns: minmax(180px, 1fr) auto;
  }

  .metrics {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr) 270px;
  }
}

@media (max-width: 800px) {
  #app {
    padding-bottom: calc(var(--dock) + var(--safe-b) + 18px);
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 0;
    padding: 11px 14px 9px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .brand-mark img {
    width: 26px;
    height: 26px;
  }

  .brand b {
    font-size: 10px;
  }

  .brand small {
    margin-top: 3px;
    font-size: 7px;
  }

  .network-status {
    padding: 6px 8px;
    font-size: 8px;
  }

  .metrics {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .metric {
    padding: 7px 8px;
    border-radius: 9px;
  }

  .metric b {
    font-size: 12px;
  }

  .metric span,
  .metric small {
    font-size: 7px;
  }

  .game-layout {
    display: block;
    padding: 14px 12px 0;
  }

  .section-heading {
    padding-bottom: 9px;
  }

  .section-heading h1 {
    font-size: 19px;
  }

  .section-copy {
    max-width: 270px;
    font-size: 11px;
    line-height: 1.34;
  }

  .heading-actions {
    gap: 4px;
  }

  .tool-btn {
    width: 34px;
    min-height: 34px;
    justify-content: center;
    padding: 6px;
  }

  .tool-btn em {
    display: none;
  }

  .room-viewport {
    min-height: 440px;
    height: min(58dvh, 540px);
    border-radius: 13px;
  }

  .room-floor {
    min-height: 440px;
  }

  .floor-caption {
    right: 9px;
    bottom: 8px;
    max-width: 200px;
    font-size: 7px;
    text-align: right;
  }

  .endpoint-object {
    width: 133px;
  }

  .endpoint-action img {
    height: 79px;
  }

  .shop-object .endpoint-action img {
    height: 85px;
  }

  .endpoint-label {
    max-width: 126px;
    padding: 4px 5px;
    font-size: 7px;
  }

  .rig-object {
    width: min(300px, calc(100vw - 44px));
  }

  .workshop-legend {
    gap: 8px;
    padding-top: 8px;
    font-size: 8px;
  }

  .legend-drag {
    width: 100%;
    margin-left: 0;
  }

  .inventory-panel {
    min-height: auto;
    margin-top: 13px;
    padding: 12px;
    border-radius: 13px;
  }

  .inventory-copy {
    margin: 7px 0 9px;
  }

  .inventory-list {
    max-height: none;
  }

  .inventory-empty {
    min-height: 70px;
    grid-column: 1 / -1;
    padding: 11px;
  }

  .inventory-card {
    min-height: 68px;
    grid-template-columns: 65px minmax(0, 1fr);
  }

  .inventory-card img {
    width: 65px;
    height: 52px;
  }

  .dock {
    width: min(490px, calc(100% - 16px));
  }

  .dock button {
    min-height: 48px;
    font-size: 9px;
  }

  .sheet {
    max-height: min(86dvh, 760px);
  }
}

@media (max-width: 430px) {
  .network-status {
    font-size: 0;
  }

  .network-status i {
    width: 8px;
    height: 8px;
  }

  .gpu-slot {
    min-height: 69px;
  }

  .gpu-slot img {
    height: 35px;
  }

  .shop-card {
    grid-template-columns: 94px minmax(0, 1fr);
  }

  .shop-card > img,
  .shop-card-art {
    width: 94px;
    height: 60px;
  }

  .up-card {
    padding: 9px;
  }

  .up-card h4 {
    font-size: 12px;
  }

  .gpu-detail {
    grid-template-columns: 1fr;
  }

  .gpu-detail img {
    max-height: 76px;
  }

  .profile-hero {
    padding-left: 92px;
  }

  .profile-hero img {
    width: 70px;
    height: 60px;
  }

  .profile-hero img.profile-avatar,
  .profile-avatar-fallback {
    width: 60px;
    height: 60px;
    left: 12px;
  }

  .profile-avatar-fallback {
    font-size: 22px;
  }

  .dock button {
    gap: 4px;
    font-size: 8px;
  }
}

@media (max-width: 360px) {
  .network-status {
    display: none;
  }

  .brand b {
    font-size: 9px;
  }

  .brand small {
    font-size: 6px;
  }

  .gpu-slot {
    min-height: 74px;
  }

  .rig-object {
    width: calc(100vw - 28px);
  }

  .inventory-actions-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .inventory-actions-row .auto-install-btn {
    grid-column: 1 / -1;
  }
}

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

/* ============ АНТИ-ВЫДЕЛЕНИЕ: это игра, а не документ ============ */
html, body, #app, #app *:not(input):not(textarea) {
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
}
input, textarea {
  -webkit-touch-callout: default;
}

/* ============ Баннер отключения ============ */
#blackout-banner {
  display: none;
  width: min(1540px, calc(100% - 32px));
  margin: 12px auto 0;
  padding: 12px 16px;
  border: 1px solid rgba(255, 90, 100, .7);
  border-radius: 12px;
  background: linear-gradient(145deg, #4a0f16, #7c1620);
  box-shadow: 0 0 22px rgba(255, 60, 70, .35);
  color: #ffd7db;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
  text-align: center;
  animation: banner-blink 1.4s ease-in-out infinite;
}
#blackout-banner.show { display: block; }
@keyframes banner-blink {
  0%, 100% { box-shadow: 0 0 22px rgba(255, 60, 70, .35); }
  50% { box-shadow: 0 0 34px rgba(255, 60, 70, .6); }
}

/* ============ Стенд огнетушителя ============ */
.ext-holster {
  position: sticky;
  top: 10px;
  z-index: 30;
  height: 0;
  margin-right: 10px;
  pointer-events: none;
}
.ext-can {
  position: absolute;
  top: 0;
  right: 0;
  width: 62px;
  padding: 6px 6px 4px;
  border: 1px solid rgba(255, 120, 110, .4);
  border-radius: 12px;
  background: rgba(20, 8, 8, .78);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .5);
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  animation: ext-sway 3.2s ease-in-out infinite;
}
.ext-can:active { cursor: grabbing; }
.ext-can img {
  width: 100%;
  height: 82px;
  object-fit: contain;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .6));
  pointer-events: none;
}
.ext-label {
  position: absolute;
  top: 100px;
  right: 0;
  width: 62px;
  padding: 3px 0;
  border: 1px solid rgba(255, 120, 110, .4);
  border-radius: 7px;
  background: rgba(20, 8, 8, .85);
  color: #ffb3a8;
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}
.ext-holster.in-hands .ext-can { opacity: .25; animation: none; }
.ext-holster.alarm .ext-can {
  border-color: #ff5148;
  box-shadow: 0 0 18px rgba(255, 60, 40, .8);
  animation: ext-alarm .5s ease-in-out infinite;
}
.ext-holster.alarm .ext-label {
  border-color: #ff5148;
  color: #fff;
  background: rgba(160, 20, 15, .9);
}
@keyframes ext-sway {
  0%, 100% { transform: rotate(-1.5deg); }
  50% { transform: rotate(1.5deg); }
}
@keyframes ext-alarm {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  50% { transform: rotate(6deg) scale(1.08); }
}
.ext-ghost {
  position: fixed;
  z-index: 130;
  width: 88px;
  transform: translate(-50%, -62%) rotate(-18deg);
  filter: drop-shadow(0 14px 12px rgba(0, 0, 0, .55));
  pointer-events: none;
}
.ext-ghost img { width: 100%; }
.ext-ghost.spraying { animation: ext-spray-shake .12s linear infinite; }
@keyframes ext-spray-shake {
  0%, 100% { transform: translate(-50%, -62%) rotate(-19deg); }
  50% { transform: translate(calc(-50% + 2px), -62%) rotate(-17deg); }
}

/* ============ Канвас эффектов ============ */
#fx {
  position: absolute;
  z-index: 15;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ============ Состояния рига: ватты, перегрев, пожар ============ */
.rig-status em { font-style: normal; }
.rig-status.idle { color: #71909b; }
.rig-status.online { color: #94d8b1; }
.rig-status.online i { background: var(--green); box-shadow: 0 0 7px var(--green); }
.rig-status.overheat { color: #ffb35a; animation: status-blink 1s steps(2) infinite; }
.rig-status.overheat i { background: #ff9a2e; box-shadow: 0 0 8px #ff9a2e; }
.rig-status.burning { color: #ff6a5a; animation: status-blink .45s steps(2) infinite; }
.rig-status.burning i { background: #ff3b2e; box-shadow: 0 0 9px #ff3b2e; }
.rig-status.offline { color: #8a8f96; }
.rig-status.offline i { background: #4a4f55; }
.rig-status.blackout { color: #c9a2ff; }
.rig-status.blackout i { background: #9a63ff; box-shadow: 0 0 8px #9a63ff; }
@keyframes status-blink { 50% { opacity: .45; } }

.rig-object.is-overheat {
  border-color: rgba(255, 154, 46, .8);
  animation: overheat-pulse 1s ease-in-out infinite;
}
.rig-object.is-burning {
  border-color: rgba(255, 59, 46, .95);
  animation: burn-glow .5s ease-in-out infinite;
}
.rig-object.is-offline { filter: saturate(.35) brightness(.8); }
@keyframes overheat-pulse {
  0%, 100% { box-shadow: 0 13px 23px rgba(0, 0, 0, .48), 0 0 12px rgba(255, 154, 46, .25); }
  50% { box-shadow: 0 13px 23px rgba(0, 0, 0, .48), 0 0 26px rgba(255, 154, 46, .55); }
}
@keyframes burn-glow {
  0%, 100% { box-shadow: 0 13px 23px rgba(0, 0, 0, .48), 0 0 18px rgba(255, 59, 46, .5); }
  50% { box-shadow: 0 13px 23px rgba(0, 0, 0, .48), 0 0 38px rgba(255, 90, 30, .85); }
}

.rig-power {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  width: calc(100% - 42px);
  margin-top: 7px;
}
.rig-loadbar {
  height: 8px;
  flex: 1;
  overflow: hidden;
  border: 1px solid #2c5261;
  border-radius: 5px;
  background: #060f15;
}
.rig-loadbar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #2ac6df, #3ce08c);
  transition: width .3s ease;
}
.rig-loadbar i.high { background: linear-gradient(90deg, #eaaa3e, #ffd46b); }
.rig-loadbar i.over { background: linear-gradient(90deg, #dc5067, #ff6a3b); }
.rig-watts {
  color: #9fc2cd;
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 600;
  white-space: nowrap;
}

/* Температура корпуса: 1…100°, на 100° — пожар. */
.rig-temp {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  width: calc(100% - 42px);
  margin-top: 4px;
}
.rig-temp-icon {
  font-size: 9px;
  line-height: 1;
  opacity: .85;
}
.rig-tempbar {
  height: 6px;
  flex: 1;
  overflow: hidden;
  border: 1px solid #2c5261;
  border-radius: 4px;
  background: #060f15;
}
.rig-tempbar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #2ac6df, #3ce08c);
  transition: width .3s ease, background .3s ease;
}
.rig-tempbar i.warn { background: linear-gradient(90deg, #eaaa3e, #ffd46b); }
.rig-tempbar i.crit { background: linear-gradient(90deg, #dc5067, #ff6a3b); }
.rig-temp-value {
  min-width: 26px;
  color: #9fc2cd;
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.rig-temp.warn .rig-temp-value { color: #ffd46b; }
.rig-temp.crit .rig-temp-value { color: #ff8f6a; }
.rig-temp.crit .rig-temp-icon { animation: pulse 1s ease-in-out infinite; }
.rig-object.is-hot {
  border-color: rgba(255, 122, 46, .85);
  box-shadow: 0 13px 23px rgba(0, 0, 0, .48), 0 0 22px rgba(255, 122, 46, .45);
}

/* Перенос рига тем же жестом, что и карта. */
.rig-object.drag-source,
.stock-rig.drag-source {
  opacity: .45;
  filter: saturate(.5);
}
#room-floor.drop-target {
  outline: 2px dashed rgba(56, 217, 255, .55);
  outline-offset: -6px;
  background-color: rgba(56, 217, 255, .05);
}
.drag-ghost.rig-ghost {
  border-color: rgba(255, 198, 90, .9);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .45), 0 0 18px rgba(255, 198, 90, .28);
}

/* Живое перемещение рига: корпус едет за указателем сам,
   поэтому призрак-прицел не показываем — риг и есть прицел. */
.drag-ghost.rig-live-hidden {
  display: none;
}
.rig-object.rig-dragging {
  z-index: 60;
  opacity: .97;
  box-shadow: 0 18px 34px rgba(0, 0, 0, .55), 0 0 22px rgba(56, 217, 255, .25);
  cursor: grabbing;
}
/* Красный контур — сюда встать нельзя: там другой риг. */
.rig-object.rig-blocked {
  outline: 2px dashed rgba(255, 81, 72, .9);
  outline-offset: 3px;
}

/* Анимированный огонь */
.fire-fx {
  position: absolute;
  z-index: 3;
  right: 6px;
  bottom: 30px;
  left: 6px;
  height: 128px;
  opacity: var(--f, 0);
  pointer-events: none;
  transition: opacity .2s linear;
}
.fire-fx .fl {
  position: absolute;
  bottom: 0;
  background: radial-gradient(ellipse at 50% 82%, #fff9d8 0%, #ffd76b 22%, #ff8a1e 52%, #e52b1e 78%, rgba(180, 10, 10, 0) 100%);
  border-radius: 50% 50% 46% 46% / 64% 64% 36% 36%;
  transform-origin: 50% 100%;
}
.fire-fx .f1 { left: 6%; width: 42%; height: 92%; animation: flame-a .42s ease-in-out infinite; }
.fire-fx .f2 { left: 33%; width: 36%; height: 74%; animation: flame-b .31s ease-in-out infinite; }
.fire-fx .f3 { left: 58%; width: 30%; height: 58%; animation: flame-a .27s ease-in-out infinite reverse; }
.fire-fx .fglow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 92%, rgba(255, 96, 20, .5), transparent 70%);
  animation: glow-pulse .5s ease-in-out infinite;
}
@keyframes flame-a {
  0%, 100% { transform: scaleY(1) skewX(0deg); }
  30% { transform: scaleY(1.14) skewX(-4deg); }
  60% { transform: scaleY(.9) skewX(5deg); }
}
@keyframes flame-b {
  0%, 100% { transform: scaleY(1.08) skewX(3deg); }
  50% { transform: scaleY(.88) skewX(-5deg); }
}
@keyframes glow-pulse {
  0%, 100% { opacity: .7; }
  50% { opacity: 1; }
}

/* Говорящие облачка ригов */
.bubbles {
  position: absolute;
  z-index: 25;
  inset: 0;
  pointer-events: none;
}
.rig-bubble {
  position: absolute;
  max-width: min(250px, 62vw);
  padding: 7px 11px 8px;
  transform: translate(-50%, -100%);
  border-radius: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  animation: bubble-talk .8s ease-in-out infinite;
}
.rig-bubble::after {
  position: absolute;
  top: 100%;
  left: 50%;
  border: 7px solid transparent;
  content: "";
  transform: translateX(-50%);
}
.rig-bubble.warn {
  border: 1px solid rgba(255, 180, 90, .8);
  background: rgba(74, 38, 6, .95);
  color: #ffd9a8;
}
.rig-bubble.warn::after { border-top-color: rgba(74, 38, 6, .95); }
.rig-bubble.fire {
  border: 1px solid #ff6a5a;
  background: linear-gradient(145deg, #7c1010, #b32314);
  box-shadow: 0 0 20px rgba(255, 60, 30, .55);
  color: #fff;
  animation-duration: .45s;
}
.rig-bubble.fire::after { border-top-color: #b32314; }
.rig-bubble.off {
  border: 1px solid rgba(150, 158, 165, .6);
  background: rgba(24, 28, 32, .95);
  color: #c3c9cf;
  animation: none;
}
.rig-bubble.off::after { border-top-color: rgba(24, 28, 32, .95); }
@keyframes bubble-talk {
  0%, 100% { transform: translate(-50%, -100%) rotate(-1.2deg); }
  50% { transform: translate(-50%, calc(-100% - 5px)) rotate(1.2deg); }
}

/* ============ Энергия в шите ============ */
.danger-text {
  border-color: rgba(255, 90, 100, .55) !important;
  background: rgba(74, 12, 18, .5) !important;
  color: #ffc9ce !important;
}
.debt-bar {
  height: 11px;
  margin: 9px 0 11px;
  overflow: hidden;
  border: 1px solid #2c5261;
  border-radius: 7px;
  background: #060f15;
}
.debt-bar i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #2ac6df, #3ce08c);
  transition: width .3s ease;
}
.debt-bar i.high { background: linear-gradient(90deg, #eaaa3e, #ffd46b); }
.debt-bar i.over {
  background: linear-gradient(90deg, #dc5067, #ff6a3b);
  animation: status-blink .6s steps(2) infinite;
}
.mini-bar {
  height: 6px;
  margin: 1px 0 9px;
  overflow: hidden;
  border-radius: 4px;
  background: #060f15;
}
.mini-bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #2ac6df, #3ce08c);
}
.mini-bar i.over { background: linear-gradient(90deg, #dc5067, #ff6a3b); }
.kv.rigload { padding-bottom: 2px; border-bottom: 0; }

/* ============ HUD: счёт и тревога ============ */
.metric-power small { display: block; }
.metric-power.warn { border-color: rgba(255, 198, 90, .6); }
.metric-power.warn #hud-debt { color: var(--gold); }
.metric-power.danger {
  border-color: rgba(255, 90, 100, .8);
  background: linear-gradient(145deg, rgba(90, 18, 25, .8), rgba(40, 8, 12, .8));
}
.metric-power.danger #hud-debt { color: #ff8f9a; }
.legend-dot.fire {
  border: 0;
  background: #ff4b3a;
  box-shadow: 0 0 7px #ff4b3a;
  animation: pulse 1s ease-in-out infinite;
}

/* ============ Док на 4 кнопки ============ */
.dock {
  width: min(560px, calc(100% - 20px));
  grid-template-columns: repeat(4, 1fr);
}
.dock button { position: relative; }
.dock button.alert::after {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff5148;
  box-shadow: 0 0 8px #ff5148;
  content: "";
  animation: pulse 1s ease-in-out infinite;
}

@media (max-width: 800px) {
  #blackout-banner {
    width: calc(100% - 24px);
    font-size: 10px;
  }
  .ext-can { width: 52px; }
  .ext-can img { height: 68px; }
  .ext-label { top: 84px; width: 52px; font-size: 7px; }
  .dock { width: min(560px, calc(100% - 16px)); }
  .dock button { font-size: 9px; }
  .rig-bubble { font-size: 9px; }
}

/* ============ v4: риги-модели, оптимизация, склад ============ */
/* Четыре кнопки дока: Магазин · Энергия · Топ · Профиль. */
.dock { grid-template-columns: repeat(4, 1fr); }
.metric-power { cursor: pointer; text-align: left; font-family: inherit; }
.metric-power:active { transform: scale(.98); }

/* Оффскрин-риги не рендерятся — главный выигрыш на телефоне. */
.rig-object { content-visibility: auto; contain-intrinsic-size: 320px 300px; }
.rig-object.rows-2 .rig-body { min-height: 218px; }
.rig-model { display: block; margin-top: 1px; color: #7fa3ae; font-size: 8px; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Огонь не крутит анимации, пока риг не горит. */
.fire-fx { display: none; }
.rig-object.is-burning .fire-fx { display: block; }

/* Браузер выбирает touch-action в начале жеста, не после удержания.
   Быстрый свайп по карте прокручивается обработчиком; остальная страница — нативно. */
.inventory-card, .gpu-slot.filled { touch-action: none; }
.gpu-slot.empty { touch-action: manipulation; }
/* Риг и корпус со склада тоже тянутся пальцем: без этого браузер
   начинает прокрутку страницы и обрывает жест. */
.rig-object, .stock-rig { touch-action: none; }
.inv-count {
  position: absolute; right: 36px; bottom: 7px; margin: 0; padding: 2px 6px;
  border-radius: 999px; background: #1a4d5c; color: var(--cyan);
  font-family: "IBM Plex Mono", monospace; font-size: 9px; font-weight: 600;
}

/* Баллон выше пальца, чтобы было видно цель. */
.ext-ghost { transform: translate(-50%, -118%) rotate(-18deg); }
.ext-ghost.spraying { animation: ext-spray-shake .12s linear infinite; }
@keyframes ext-spray-shake {
  0%, 100% { transform: translate(-50%, -118%) rotate(-19deg); }
  50% { transform: translate(calc(-50% + 2px), -118%) rotate(-17deg); }
}
.ext-holster.armed .ext-can {
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(56, 217, 255, .7);
  animation: ext-alarm .5s ease-in-out infinite;
}

/* Рожица в облачке подпрыгивает — риг «говорит». */
.bubble-face { display: inline-block; animation: face-bounce .5s ease-in-out infinite; }
@keyframes face-bounce { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-3px) scale(1.15); } }

@media (max-width: 800px) {
  .floor-light { display: none; }
  .room-floor {
    background:
      radial-gradient(circle at 80% 0%, rgba(21, 103, 131, .25), transparent 60%),
      radial-gradient(circle at 10% 100%, rgba(12, 102, 77, .18), transparent 55%),
      linear-gradient(180deg, #0a1822, #050c12);
  }
  .ext-can { min-width: 60px; }
}

/* ============ v5: этажи, износ, урон, переноска, тиры ============ */

/* --- Панель этажей --- */
.floor-bar {
  display: flex;
  gap: 7px;
  align-items: stretch;
  margin-bottom: 10px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  scrollbar-width: none;
}
.floor-bar::-webkit-scrollbar { display: none; }
.floor-tab {
  display: flex;
  flex: 1 0 auto;
  min-width: 108px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid rgba(101, 181, 204, .25);
  border-radius: 11px;
  background: linear-gradient(145deg, #13242f, #0a161e);
  color: #9fc0cb;
  font-family: "IBM Plex Mono", monospace;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.floor-tab b { font-size: 11px; letter-spacing: .06em; }
.floor-tab span { font-size: 10px; color: #6d8b96; }
.floor-tab i { font-style: normal; font-size: 12px; line-height: 1; }
.floor-tab.on {
  border-color: rgba(255, 198, 90, .75);
  background: linear-gradient(145deg, #3a2c10, #1d1608);
  color: #ffd98a;
  box-shadow: 0 0 14px rgba(255, 198, 90, .18);
}
.floor-tab.on span { color: #c9a25a; }
.floor-tab.has-warn { border-color: rgba(255, 198, 90, .55); }
.floor-tab.has-crit { border-color: rgba(255, 154, 46, .85); color: #ffc890; }
.floor-tab.has-fire {
  border-color: #ff5148;
  color: #fff;
  background: linear-gradient(145deg, #5a1210, #2a0806);
  animation: floor-fire 1s ease-in-out infinite;
}
@keyframes floor-fire {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 60, 40, .35); }
  50% { box-shadow: 0 0 22px rgba(255, 60, 40, .75); }
}
.floor-tab.drop-hover {
  transform: translateY(-2px) scale(1.04);
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(56, 217, 255, .45);
  color: #d8f7ff;
}
.floor-buy {
  flex: 1 0 auto;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px dashed rgba(255, 198, 90, .55);
  border-radius: 11px;
  background: rgba(58, 44, 16, .25);
  color: #ffd98a;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.floor-buy:hover { background: rgba(58, 44, 16, .55); }
.floor-max {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  color: #8fa8b4;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  white-space: nowrap;
}

/* --- Шапка рига: меню и бейджи --- */
.rig-top { grid-template-columns: 27px minmax(0, 1fr) auto auto auto; }
.rig-badges {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.rig-badges .badge {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  padding: 0 4px;
  border-radius: 7px;
  background: rgba(4, 12, 18, .8);
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}
.badge.suppress { border: 1px solid rgba(56, 217, 255, .5); }
.badge.damage { border: 1px solid rgba(255, 154, 46, .6); color: #ffc890; font-family: "IBM Plex Mono", monospace; font-weight: 600; }
.rig-menu-btn {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(111, 193, 217, .35);
  border-radius: 8px;
  background: rgba(7, 19, 27, .91);
  color: #a8c7d2;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}
.rig-menu-btn:hover { border-color: var(--gold); color: var(--gold); }

/* --- Таймер выгорания --- */
.burn-timer {
  position: absolute;
  z-index: 4;
  top: 6px;
  right: 8px;
  padding: 4px 8px;
  pointer-events: none;
  border: 1px solid #ff6a5a;
  border-radius: 8px;
  background: rgba(60, 8, 6, .88);
  box-shadow: 0 0 14px rgba(255, 60, 30, .5);
  color: #fff;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
}
.burn-timer.critical { animation: status-blink .4s steps(2) infinite; }

/* --- Урон корпуса: налёт гари --- */
.rig-object.dmg-1 .rig-body::after,
.rig-object.dmg-2 .rig-body::after,
.rig-object.dmg-3 .rig-body::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  content: "";
  pointer-events: none;
}
.rig-object.dmg-1 .rig-body::after { background: linear-gradient(180deg, rgba(10, 8, 6, .12), rgba(10, 8, 6, .28)); }
.rig-object.dmg-2 .rig-body::after { background: linear-gradient(180deg, rgba(12, 8, 5, .25), rgba(8, 5, 3, .5)); }
.rig-object.dmg-3 .rig-body::after { background: linear-gradient(180deg, rgba(14, 8, 4, .38), rgba(5, 3, 2, .66)); }
.rig-object.dmg-2, .rig-object.dmg-3 { border-color: rgba(120, 90, 60, .55); }

/* --- Стадии пожара: пламя злее к выгоранию --- */
.burn-early .fire-fx { transform: scale(.85); transform-origin: 50% 100%; }
.burn-rage .fire-fx { transform: scale(1.08); transform-origin: 50% 100%; }
.burn-crit .fire-fx { transform: scale(1.28); transform-origin: 50% 100%; }
.burn-crit .fire-fx .f1 { animation-duration: .25s; }
.burn-crit .fire-fx .f2 { animation-duration: .19s; }

/* --- Автотушение в работе --- */
.rig-object.is-suppressing {
  border-color: rgba(56, 217, 255, .9);
  animation: suppress-glow .4s ease-in-out infinite;
}
@keyframes suppress-glow {
  0%, 100% { box-shadow: 0 13px 23px rgba(0, 0, 0, .48), 0 0 14px rgba(56, 217, 255, .35); }
  50% { box-shadow: 0 13px 23px rgba(0, 0, 0, .48), 0 0 34px rgba(56, 217, 255, .7); }
}

/* --- Тиры карт: рамка, свечение, LED --- */
.gpu-slot.filled.tier-low { border-color: rgba(125, 143, 150, .6); box-shadow: inset 0 0 12px rgba(125, 143, 150, .1); }
.gpu-slot.filled.tier-mid { border-color: rgba(56, 217, 255, .55); box-shadow: inset 0 0 12px rgba(56, 217, 255, .12); }
.gpu-slot.filled.tier-high { border-color: rgba(154, 99, 255, .65); box-shadow: inset 0 0 12px rgba(154, 99, 255, .16); }
.gpu-slot.filled.tier-titan { border-color: rgba(255, 198, 90, .75); box-shadow: inset 0 0 14px rgba(255, 198, 90, .18), 0 0 10px rgba(255, 198, 90, .15); }
.slot-led {
  position: absolute;
  z-index: 2;
  right: 4px;
  bottom: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7d8f96;
  animation: led-blink 2.2s ease-in-out infinite;
}
.tier-mid .slot-led { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.tier-high .slot-led { background: #9a63ff; box-shadow: 0 0 6px #9a63ff; animation-duration: 1.6s; }
.tier-titan .slot-led { background: var(--gold); box-shadow: 0 0 8px var(--gold); animation-duration: 1.1s; }
@keyframes led-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* --- Склад: тиры и кнопка ⋮ --- */
.inventory-card.tier-mid { border-left: 3px solid rgba(56, 217, 255, .6); }
.inventory-card.tier-high { border-left: 3px solid rgba(154, 99, 255, .7); }
.inventory-card.tier-titan { border-left: 3px solid rgba(255, 198, 90, .8); }
.inv-menu {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  margin: 0;
  border: 1px solid rgba(111, 193, 217, .4);
  border-radius: 7px;
  background: rgba(6, 16, 23, .9);
  color: #a8c7d2;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.inventory-card:hover .inv-menu { border-color: var(--gold); color: var(--gold); }

/* --- Подсветка только во время удерживаемого перетаскивания --- */
.drag-ghost.touch-drag { transform: translate(-50%, -120%) rotate(2deg); }
body.card-moving, body.card-moving button { cursor: grabbing; }
body.card-moving .gpu-slot.empty {
  border-color: var(--gold);
  background: rgba(58, 44, 16, .5);
  animation: slot-call 1s ease-in-out infinite;
}
@keyframes slot-call {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 198, 90, 0); }
  50% { box-shadow: 0 0 14px rgba(255, 198, 90, .45); }
}
/* --- Меню-действия в шите --- */
.menu-actions {
  display: grid;
  gap: 7px;
  margin: 4px 0 10px;
}
.btn.mini {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 11px;
}
.rig-quick { margin: 2px 0 10px; }
.rig-extra {
  color: #9fc2cd;
  font-style: normal;
  font-size: 10px;
}
.row-btns.floor-pick .btn { flex: 1 1 auto; }
.gpu-detail.tier-mid { border-color: rgba(56, 217, 255, .4); }
.gpu-detail.tier-high { border-color: rgba(154, 99, 255, .5); }
.gpu-detail.tier-titan { border-color: rgba(255, 198, 90, .6); }

/* --- Износ в энерговкладке --- */
.mini-bar.wear { background: rgba(6, 15, 21, .9); }
.mini-bar.wear i { background: linear-gradient(90deg, #7d8f96, #a9b6bd); }
.mini-bar.wear i.warn { background: linear-gradient(90deg, #eaaa3e, #ffd46b); }
.mini-bar.wear i.crit { background: linear-gradient(90deg, #dc5067, #ff6a3b); }

/* --- Новые облачка --- */
.rig-bubble.crit {
  border: 1px solid #ff5148;
  background: linear-gradient(145deg, #5a1210, #8a1a12);
  box-shadow: 0 0 20px rgba(255, 60, 30, .5);
  color: #fff;
  animation-duration: .5s;
}
.rig-bubble.crit::after { border-top-color: #8a1a12; }
.rig-bubble.dust {
  border: 1px solid rgba(210, 180, 120, .65);
  background: rgba(52, 40, 18, .95);
  color: #e8d5a8;
}
.rig-bubble.dust::after { border-top-color: rgba(52, 40, 18, .95); }
.legend-dot.dust { border: 1px solid #d2b478; background: rgba(210, 180, 120, .4); }

/* --- Магазин на 4 вкладки --- */
.tabs { grid-template-columns: repeat(4, 1fr); }

/* --- Оптимизация перетаскивания --- */
body.card-moving .rig-object { transition: none; }
body.card-moving .rig-bubble { animation: none; }

@media (max-width: 800px) {
  .tabs button { font-size: 10px; }
  .floor-tab { min-width: 96px; min-height: 38px; }
  .rig-badges .badge { min-width: 20px; height: 20px; font-size: 9px; }
}

/* ================================================================
   V6: секции Риги/Видеокарты на складе, пыль этажа с кнопкой
   «Обслужить этаж», поэтажные улучшения, сплэш-экран, адаптация
   под ПК и планшет. Склад — ПОД лабораторией (на ПК — справа).
   ================================================================ */

/* --- Лаборатория сверху, склад под ней: страница листается целиком --- */
.game-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inventory-panel {
  min-height: 0;
  align-self: stretch;
  padding: 10px 14px 11px;
}

.inventory-panel .panel-head {
  padding-bottom: 7px;
}

.panel-head h2 {
  font-size: 14px;
}

.inventory-panel.is-collapsed .panel-head {
  border-bottom: 0;
}

.inventory-copy {
  margin: 6px 0 7px;
  font-size: 10.5px;
  line-height: 1.3;
}

.stock-tabs {
  display: inline-flex;
  gap: 5px;
  margin-bottom: 8px;
}

.stock-tabs button {
  min-height: 27px;
  padding: 4px 10px;
  border: 1px solid rgba(101, 181, 204, .22);
  border-radius: 8px;
  background: #0d1e29;
  color: #88a5b0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .05em;
}

.stock-tabs button b {
  color: inherit;
  font-weight: 700;
}

.stock-tabs button.on {
  border-color: rgba(255, 198, 90, .7);
  background: linear-gradient(145deg, #efaf3e, #ffd66f);
  color: #281a05;
}

/* Карты и риги идут сверху вниз. Список растёт со страницей:
   без горизонтальной карусели и без отдельной прокрутки склада. */
.inventory-list {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  min-height: 0;
  max-height: none;
  overflow: visible;
  padding: 2px;
}

.inventory-empty {
  flex: 1 1 auto;
  min-width: min(340px, 100%);
  min-height: 68px;
  padding: 10px 14px;
}

.inventory-card {
  flex: 0 0 auto;
  width: 100%;
  min-height: 64px;
  grid-template-columns: 62px minmax(0, 1fr);
  padding: 5px;
}

.inventory-card img {
  width: 62px;
  height: 50px;
}

.inventory-hint {
  min-height: 0;
  margin-top: 5px;
  padding: 4px 8px;
  font-size: 8.5px;
  line-height: 1.25;
}

/* Корпуса на складе (секция «Риги»). */
.stock-rig {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 4px 10px;
  align-items: center;
  width: 100%;
  min-width: 0;
  padding: 6px 10px 7px 6px;
  border: 1px solid rgba(91, 168, 191, .25);
  border-radius: 11px;
  background: linear-gradient(145deg, #12303f, #0a1a24);
}

.stock-rig > img {
  width: 74px;
  height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 6px 5px rgba(0, 0, 0, .5));
}

.stock-rig-info strong,
.stock-rig-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-rig-info strong {
  color: #e3f8fd;
  font-size: 12px;
}

.stock-rig-info span {
  margin-top: 3px;
  color: #7fa3ae;
  font-size: 10px;
}

.stock-rig-actions {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* --- Сервис этажа: пыль, уборка, улучшения --- */
.floor-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-bottom: 10px;
  padding: 7px 9px;
  border: 1px solid rgba(91, 168, 191, .2);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(15, 32, 43, .92), rgba(7, 16, 23, .92));
}

.floor-tools.warn {
  border-color: rgba(255, 198, 90, .55);
  box-shadow: 0 0 14px rgba(255, 198, 90, .08);
}

.floor-tools.crit {
  border-color: rgba(255, 81, 72, .7);
  box-shadow: 0 0 16px rgba(255, 60, 40, .15);
}

.floor-tools-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.floor-tools-item .tool-btn {
  width: auto;
  min-height: 34px;
}

.floor-tools-item .tool-btn em {
  display: inline;
}

.floor-tools-icon {
  font-size: 17px;
  line-height: 1;
}

.ft-dust-wrap {
  width: clamp(130px, 22vw, 210px);
  min-width: 120px;
}

.ft-label-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.ft-label {
  color: #7fa3ae;
  font-family: "IBM Plex Mono", monospace;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.ft-value {
  color: #cfe6ee;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
}

.floor-tools.warn .ft-value { color: #ffd98a; }
.floor-tools.crit .ft-value {
  color: #ff9a8a;
  animation: status-blink .6s steps(2) infinite;
}

.ft-dust-track {
  height: 7px;
  margin-top: 3px;
  overflow: hidden;
  border: 1px solid #2c5261;
  border-radius: 5px;
  background: #060f15;
}

.ft-dust-track i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #7d8f96, #b9c6cc);
  transition: width .35s ease;
}

.ft-dust-track i.warn { background: linear-gradient(90deg, #eaaa3e, #ffd46b); }
.ft-dust-track i.crit { background: linear-gradient(90deg, #dc5067, #ff6a3b); }

.floor-tools .tool-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.gold-hint {
  border-color: rgba(255, 198, 90, .4) !important;
}

.gold-hint em {
  color: #ffe1a0 !important;
}

.floor-tools-item .tool-btn em {
  color: #cfe2e9;
  font-size: 10.5px;
}

.ft-status {
  margin-left: auto;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ft-chip {
  padding: 3px 7px;
  border: 1px solid rgba(56, 217, 255, .3);
  border-radius: 999px;
  background: rgba(6, 21, 29, .8);
  color: #9fdcec;
  font-family: "IBM Plex Mono", monospace;
  font-size: 8.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* --- Сплэш-экран --- */
.splash {
  position: fixed;
  z-index: 300;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 75% 12%, rgba(25, 120, 148, .28), transparent 30rem),
    radial-gradient(circle at 15% 88%, rgba(14, 110, 84, .2), transparent 26rem),
    linear-gradient(180deg, #07131b, #040a10);
  opacity: 1;
  transition: opacity .55s ease;
}

.splash::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: .5;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 3px);
}

.splash.hide {
  opacity: 0;
  pointer-events: none;
}

.splash-inner {
  position: relative;
  display: flex;
  width: min(560px, 100%);
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.splash-logo {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 2px solid rgba(255, 198, 90, .55);
  border-radius: 24px;
  background: linear-gradient(145deg, #1c2a33, #0a1116);
  box-shadow: 0 0 0 8px rgba(255, 198, 90, .05), 0 0 34px rgba(255, 198, 90, .22), inset 0 0 24px rgba(255, 198, 90, .12);
  animation: splash-logo-pulse 1.6s ease-in-out infinite;
}

.splash-logo img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(255, 198, 90, .5));
}

@keyframes splash-logo-pulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(255, 198, 90, .05), 0 0 24px rgba(255, 198, 90, .18); }
  50% { box-shadow: 0 0 0 12px rgba(255, 198, 90, .09), 0 0 44px rgba(255, 198, 90, .34); }
}

.splash-title {
  margin: 20px 0 4px;
  color: #f4fbff;
  font-family: "Press Start 2P", "IBM Plex Mono", monospace;
  font-size: clamp(19px, 4.6vw, 30px);
  line-height: 1.3;
  letter-spacing: .02em;
}

.splash-title b {
  color: var(--gold);
}

.splash-sub {
  margin: 0 0 18px;
  color: #6f93a3;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .18em;
}

.splash-log {
  width: min(520px, 100%);
  min-height: 88px;
  padding: 9px 12px;
  overflow: hidden;
  border: 1px solid rgba(56, 190, 232, .2);
  border-radius: 11px;
  background: rgba(3, 10, 15, .72);
  color: #7fb4c8;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  line-height: 1.8;
  text-align: left;
}

.splash-log span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
}

.splash-log b {
  color: #eafcff;
  font-weight: 600;
  letter-spacing: 1px;
}

.splash-bar-track {
  position: relative;
  width: min(520px, 100%);
  height: 16px;
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid rgba(105, 193, 217, .4);
  border-radius: 9px;
  background: rgba(3, 10, 15, .85);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .6);
}

#splash-bar-fill {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #25c4e8, #3ce08c, #25c4e8);
  background-size: 200% 100%;
  box-shadow: 0 0 16px rgba(56, 217, 255, .6);
  animation: splash-grad 1.1s linear infinite;
  transition: none;
}

@keyframes splash-grad {
  from { background-position: 0% 0; }
  to { background-position: 200% 0; }
}

.splash-bar-meta {
  display: flex;
  justify-content: space-between;
  width: min(520px, 100%);
  margin-top: 7px;
  color: #9fd6e6;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 600;
}

.splash-bar-meta span:last-child {
  color: #6f93a3;
  font-weight: 500;
}

.splash-error[hidden] {
  display: none;
}

.splash-error {
  display: flex;
  width: min(520px, 100%);
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 105, 91, .5);
  border-radius: 11px;
  background: rgba(65, 17, 20, .72);
  color: #ffd9d5;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

.splash-error b {
  color: #ff9d8f;
  font-size: 12px;
  letter-spacing: .04em;
}

.splash-error .btn {
  min-height: 36px;
  margin-top: 4px;
}

.splash.has-error #splash-bar-fill {
  background: linear-gradient(90deg, #ff665b, #f0bd4b, #ff665b);
  box-shadow: 0 0 16px rgba(255, 102, 91, .55);
}

.splash-skip {
  margin: 18px 0 0;
  color: rgba(143, 168, 180, .55);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  letter-spacing: .08em;
  animation: status-blink 1.6s ease-in-out infinite;
}

/* Три вкладки магазина (глобальные улучшения убраны). */
.tabs {
  grid-template-columns: repeat(3, 1fr);
}

/* --- Desktop / планшет: всё в колонку, склад сверху, поле — на остаток --- */
@media (min-width: 801px) {
  #app {
    overflow: visible;
  }

  .game-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 6px;
  }

  .inventory-panel {
    flex: 0 0 auto;
    max-height: none;
    margin: 0;
  }

  .inventory-panel.is-collapsed {
    max-height: none;
    min-height: 0;
  }

  .play-area {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
  }

  .room-viewport {
    min-height: 0;
    flex: 1 1 auto;
  }

  .inventory-list {
    max-height: none;
  }
}

@media (max-width: 800px) {
  .inventory-panel {
    margin: 0;
    border-radius: 13px;
  }

  .inventory-list {
    max-height: none;
  }

  .room-viewport {
    min-height: 330px;
    height: min(54dvh, 520px);
    /* Свайп по полю докручивает само поле и отдаёт прокрутку странице:
       так до склада (он под лабораторией) можно доехать, даже когда
       вся лаборатория заполнена. Риги по-прежнему двигаются удержанием
       пальца — у них свой touch-action: none и скролл-скрипт. */
    overscroll-behavior: auto;
    touch-action: pan-y;
  }

  .room-floor {
    min-height: 330px;
  }

  .floor-tools-item .tool-btn em {
    font-size: 9.5px;
  }

  .ft-status {
    width: 100%;
    margin-left: 0;
  }
}

@media (min-width: 1101px) and (max-height: 800px) {
  .inventory-copy {
    display: none;
  }

  .inventory-panel .panel-head {
    padding-bottom: 6px;
  }
}

/* ПК: склад справа (в DOM он после лаборатории — порядок прямой);
   длинный список прокручивается вместе со страницей, лаборатория
   остаётся рядом, а не сжимается до нулевой высоты. */
@media (min-width: 801px) {
  .game-layout {
    flex-direction: row;
    align-items: flex-start;
  }

  .inventory-panel {
    flex: 0 0 350px;
    width: 350px;
    height: auto;
    min-height: 0;
    max-height: none;
    align-self: flex-start;
    margin: 0;
    background: #111317;
  }

  .play-area {
    position: sticky;
    top: 12px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .room-viewport {
    background-image: url("../assets/room-bg-hd.webp");
    flex: 0 0 auto;
    height: clamp(420px, calc(100dvh - 300px), 900px);
    overflow: auto;
  }
}

.stock-tabs button {
  cursor: pointer;
}
.stock-tabs button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}
.stock-tabs button.on {
  background: rgba(255, 198, 90, 0.2);
  border-color: #ffc65a;
  color: #ffc65a;
}

/* Меню модели: крупные контролы количества для мыши и пальца. */
.inventory-card .inventory-info {
  min-width: 0;
  padding-right: 66px;
}
.card-quantity {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(4, 13, 19, .32);
}
.card-quantity label {
  display: block;
  margin-bottom: 9px;
  font-size: 13px;
  font-weight: 600;
}
.quantity-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.quantity-controls .btn {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
}
.quantity-controls input {
  width: 64px;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--bg-deep);
  text-align: center;
  font-family: "IBM Plex Mono", monospace;
  appearance: textfield;
  -moz-appearance: textfield;
}
.quantity-controls input::-webkit-inner-spin-button,
.quantity-controls input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.quantity-controls input[aria-invalid="true"] { border-color: var(--red); }
.card-quantity p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
}
