:root {
  color-scheme: dark;
  --pickaxe-cursor: url("imagen/pickaxe-cursor.svg") 6 4, auto;
  --bg: #0d1014;
  --bg-2: #12171d;
  --panel: #1a232d;
  --panel-2: #111820;
  --text: #ecf4ff;
  --muted: #8ca0b8;
  --accent: #58de6f;
  --accent-2: #40bf58;
  --border: #2f3d4d;
}

* { box-sizing: border-box; }

button,
input,
select,
textarea,
[role="button"],
.icon-btn {
  cursor: var(--pickaxe-cursor);
}

.hidden { display: none !important; }

.auth-fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.auth-fx-layer.hidden {
  display: none;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  min-height: 100vh;
  position: relative;
  cursor: var(--pickaxe-cursor);
  background: #000;
}

.app {
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px;
}

h1, h2 { margin: 0; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1rem; margin-bottom: 8px; }

.panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(26, 35, 45, 0.95), rgba(17, 24, 32, 0.95));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  padding: 12px;
}

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

.top-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 4px 16px;
  font-size: 0.95rem;
}

.icon-actions {
  display: flex;
  gap: 8px;
}

.layout {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 12px;
}

.auth-panel {
  margin-bottom: 12px;
}

.auth-gate {
  width: min(680px, 94vw);
  margin: 0;
  border-radius: 0;
  border: 2px solid #52f1ab;
  background: linear-gradient(180deg, rgba(8, 22, 24, 0.95), rgba(5, 14, 18, 0.95));
  box-shadow:
    0 0 0 2px rgba(5, 16, 20, 1),
    0 0 24px rgba(82, 241, 171, 0.22),
    inset 0 0 0 1px rgba(185, 255, 227, 0.2);
  font-family: "Lucida Console", "Courier New", monospace;
  letter-spacing: 0.02em;
  z-index: 3;
}

#authGate:not(.hidden) {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.auth-gate::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.045) 0,
    rgba(255, 255, 255, 0.045) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.2;
}

.auth-fx-pickaxe {
  position: absolute;
  left: 0;
  top: 0;
  font-size: clamp(1rem, 1.9vw, 1.5rem);
  color: rgba(185, 255, 227, 0.9);
  text-shadow: 0 0 10px rgba(82, 241, 171, 0.55);
  transform: translate(-50%, -50%);
  animation: auth-fx-float var(--dur, 9s) linear forwards;
}

.auth-fx-chip {
  position: absolute;
  left: 0;
  top: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(146, 240, 255, 0.9);
  box-shadow: 0 0 10px rgba(146, 240, 255, 0.8);
  transform: translate(-50%, -50%);
  animation: auth-fx-chip var(--dur, 1.4s) ease-out forwards;
}

@keyframes auth-fx-float {
  0% {
    transform: translate(-50%, -50%) scale(0.72) rotate(0deg);
    opacity: 0;
  }
  12% {
    opacity: 0.95;
  }
  86% {
    opacity: 0.9;
  }
  100% {
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(1.08) rotate(var(--rot, 360deg));
    opacity: 0;
  }
}

@keyframes auth-fx-chip {
  0% {
    transform: translate(-50%, -50%) scale(0.65);
    opacity: 0.95;
  }
  100% {
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(0.1);
    opacity: 0;
  }
}

.auth-gate h1 {
  font-family: "Lucida Console", "Courier New", monospace;
  font-size: 2rem;
  margin-bottom: 8px;
  color: #b9ffe3;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(82, 241, 171, 0.35);
  text-align: center;
}

.auth-subtitle {
  margin: 0 0 8px;
  color: #8fe7c2;
  font-size: 0.88rem;
  text-align: center;
}

.admin-bootstrap-box {
  margin-top: 8px;
  border: 1px dashed #445971;
  border-radius: 8px;
  padding: 8px;
  background: rgba(10, 18, 27, 0.4);
}

.admin-bootstrap-box summary {
  cursor: pointer;
  font-weight: 700;
  color: #cfe0f4;
}

.auth-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
  width: min(560px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.auth-grid input {
  background: #041116;
  color: #e8fff7;
  border: 1px solid #2fa275;
  border-radius: 0;
  padding: 11px 12px;
  font-family: "Lucida Console", "Courier New", monospace;
  font-size: 0.96rem;
}

.auth-grid input:focus {
  outline: 2px solid #52f1ab;
  border-color: #52f1ab;
  box-shadow: 0 0 0 2px rgba(10, 30, 24, 1), 0 0 16px rgba(82, 241, 171, 0.32);
}

.auth-gate .worker-actions {
  margin-top: 2px;
  width: min(560px, 100%);
  margin-left: auto;
  margin-right: auto;
  justify-content: center;
  flex-wrap: wrap;
}

.auth-gate button {
  border-radius: 0;
  border-width: 2px;
  font-family: "Lucida Console", "Courier New", monospace;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}

#authModeHint,
#authStatus {
  text-align: center;
}

.auth-gate .primary {
  background: #52f1ab;
  border-color: #52f1ab;
  color: #02150f;
}

.forge-panel {
  grid-column: 1 / -1;
}

.mine-panel,
.inv-panel { min-height: 300px; }

.mine-panel {
  padding: 10px;
}

.muted,
.feed { color: var(--muted); font-size: 0.9rem; }

.mine-block {
  position: relative;
  width: 230px;
  height: 230px;
  border: 4px solid #2b3745;
  margin: 14px auto;
  cursor: inherit;
  image-rendering: pixelated;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.mine-block::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.12));
  mix-blend-mode: soft-light;
}

.mine-area {
  position: relative;
  width: 100%;
  min-height: 560px;
  margin: 8px auto;
  display: grid;
  place-items: center;
}

.mine-bg {
  background-image: url("imagen/mine.png"), url("image/mine.png");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  border-radius: 12px;
}

.mine-workers-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.ring-worker {
  position: absolute;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  transform: translate(-50%, -50%);
  text-shadow: 0 0 8px rgba(110, 181, 255, 0.45);
}

.ring-worker.working {
  animation: pulse-work 1s infinite ease-in-out;
}

@keyframes pulse-work {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.08); }
}

.block-pixels {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(16, 1fr);
  gap: 0;
  padding: 0;
  z-index: 1;
}

.block-worker-fx {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.block-worker-pick {
  position: absolute;
  font-size: 1.35rem;
  color: #ffe39a;
  animation: block-pick 0.8s infinite ease-in-out;
  text-shadow: 0 0 12px rgba(255, 232, 166, 0.75);
}

@keyframes block-pick {
  0%, 100% { transform: rotate(-16deg) translateY(0); }
  50% { transform: rotate(10deg) translateY(-4px); }
}

.pixel-cell {
  background: rgba(84, 92, 101, 0.95);
  transition: opacity 0.1s linear;
}

.pixel-cell.removed {
  opacity: 0;
}

.mine-block.breaking {
  animation: shake-block 0.14s linear;
}

@keyframes shake-block {
  0% { transform: translateX(-2px); }
  25% { transform: translateX(2px); }
  50% { transform: translateY(-2px); }
  75% { transform: translateY(2px); }
  100% { transform: translateX(0); }
}

.mine-block span {
  display: none;
}

.mine-hud {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(8, 13, 20, 0.68);
  border: 1px solid rgba(111, 136, 164, 0.45);
  font-size: 0.9rem;
  max-width: 56%;
  z-index: 3;
}

.mine-hud .feed {
  color: #c5d4e8;
}

.rock-stone {
  background: linear-gradient(135deg, #7f8690, #686f78 60%, #5b626b);
}

.rock-coal {
  background: linear-gradient(135deg, #555f69, #2b333c 55%, #1f252d);
}

.rock-copper {
  background: linear-gradient(135deg, #8d7367, #b36d4b 55%, #cb7a54);
}

.rock-iron {
  background: linear-gradient(135deg, #7f858d, #ad9c88 55%, #d7c4ad);
}

.rock-gold {
  background: linear-gradient(135deg, #7d838b, #b59532 55%, #e6c44f);
}

.rock-diamond {
  background: linear-gradient(135deg, #7a8189, #47bcc8 55%, #8ff5ff);
}

.rock-emerald {
  background: linear-gradient(135deg, #757d85, #2ea957 55%, #67ed8b);
}

.block-cracks {
  display: none;
}

.ore-cell-coal { background: #212830; }
.ore-cell-copper { background: #ad6b48; }
.ore-cell-iron { background: #ccbaa5; }
.ore-cell-gold { background: #e5be47; }
.ore-cell-diamond { background: #74ecfa; }
.ore-cell-emerald { background: #50da78; }
.ore-cell-copper-ingot { background: #d4865e; }
.ore-cell-iron-ingot { background: #e4d3bf; }
.ore-cell-gold-ingot { background: #ffda66; }

.mine-block:active {
  transform: scale(0.985);
}

.block-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

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

.slot {
  min-height: 72px;
  border: 2px solid #3c4d61;
  background: linear-gradient(180deg, #283746, #202a34);
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.slot-draggable {
  cursor: grab;
  border-color: #5f82a8;
}

.slot-draggable:active {
  cursor: grabbing;
}

.slot .pixel {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 0, 0, 0.35);
}

.slot .name { font-size: 0.78rem; }
.slot .count { font-size: 0.8rem; color: #d9e8ff; text-align: right; }

.pixel-coal { background: #2f3640; }
.pixel-copper { background: #bf7751; }
.pixel-iron { background: #c7b7a2; }
.pixel-gold { background: #f0c94f; }
.pixel-diamond { background: #64e8f5; }
.pixel-emerald { background: #4bdd70; }
.pixel-copper-ingot { background: #d7946f; }
.pixel-iron-ingot { background: #e7d8c5; }
.pixel-gold-ingot { background: #ffd86a; }

.full-width-workers {
  margin-top: 12px;
}

.workers-yard {
  min-height: 300px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  background: rgba(0, 0, 0, 0.18);
  overflow: auto;
}

.workers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.workers-table th,
.workers-table td {
  border-bottom: 1px solid #35475d;
  padding: 10px 8px;
  text-align: left;
}

.workers-table th {
  font-size: 0.75rem;
  color: #9db2cb;
  position: sticky;
  top: 0;
  background: #1a2430;
}

.status-good { color: #73df92; }
.status-warn { color: #f2c45e; }
.status-bad { color: #f07878; }

.worker-mini-actions {
  display: flex;
  gap: 6px;
}

.worker-mini-actions button {
  padding: 5px 8px;
  font-size: 0.74rem;
}

.worker-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.buyer-list,
.store-list,
.cave-list {
  display: grid;
  gap: 8px;
}

.market-filters,
.market-sell-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.market-filters input,
.market-filters select,
.market-sell-grid input,
.market-sell-grid select {
  background: #121c27;
  color: var(--text);
  border: 1px solid #445971;
  border-radius: 7px;
  padding: 8px 10px;
}

.market-sell-box {
  margin-bottom: 12px;
}

.market-sell-box h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.modal-card.market-modal-card {
  width: min(1520px, 99vw);
}

.market-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 12px;
}

.market-sidebar {
  border: 1px solid #2e3b4a;
  border-radius: 8px;
  padding: 10px;
  background: #121b24;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.market-tab-btn {
  text-align: left;
  font-weight: 700;
}

.market-tab-btn.active {
  border-color: #7fb1e8;
  background: #243344;
}

.market-sidebar-block {
  display: grid;
  gap: 5px;
  margin-top: 6px;
}

.market-sidebar label {
  font-size: 0.78rem;
  color: #a7bdd6;
}

.market-sidebar input,
.market-sidebar select {
  background: #0f1720;
  color: var(--text);
  border: 1px solid #445971;
  border-radius: 7px;
  padding: 8px 10px;
}

.market-main {
  min-height: 60vh;
}

.market-panel h3 {
  margin: 6px 0 8px;
}

.market-separator {
  height: 1px;
  background: linear-gradient(90deg, transparent, #39506b, transparent);
  margin: 12px 0;
}

.market-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.market-stat {
  border: 1px solid #39506b;
  border-radius: 7px;
  padding: 6px;
  background: #182433;
  font-size: 0.8rem;
}

.row {
  border: 1px solid #3a4b60;
  background: #1a2430;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.row small { display: block; color: var(--muted); }

button {
  background: #2c3b4d;
  color: var(--text);
  border: 1px solid #445971;
  border-radius: 7px;
  padding: 8px 10px;
  cursor: pointer;
}

button:hover:not(:disabled) { border-color: #6b86a5; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.primary {
  background: var(--accent);
  color: #08210e;
  border-color: #3eb955;
  font-weight: 700;
}

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  font-size: 1.15rem;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  padding: 5px 8px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: #d7fff2;
  border: 1px solid #2fa275;
  background: #031017;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 15;
}

.icon-btn[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.danger-btn {
  background: linear-gradient(180deg, #b32727, #8e1818);
  color: #ffe4e4;
  border-color: #db4d4d;
  font-weight: 700;
}

.danger-btn:hover:not(:disabled) {
  border-color: #ff7f7f;
}

.reset-mine-card {
  width: min(520px, 100%);
  border: 1px solid #7a2d2d;
  box-shadow: 0 0 22px rgba(186, 50, 50, 0.22);
}

.warning-copy {
  margin-top: 4px;
  margin-bottom: 10px;
  color: #ffc3c3;
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(720px, 100%);
  max-height: 80vh;
  overflow: auto;
}

.furnace-card {
  position: absolute;
  width: min(520px, 92vw);
  max-height: 78vh;
}

.drag-handle {
  cursor: move;
}

.furnace-drop {
  border: 2px dashed #5f7a98;
  border-radius: 9px;
  padding: 16px;
  text-align: center;
  background: rgba(17, 26, 36, 0.75);
  margin-bottom: 10px;
}

.furnace-drop.active {
  border-color: #7fd8ff;
  background: rgba(27, 47, 63, 0.8);
}

.furnace-source-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.furnace-source-item {
  border: 1px solid #44607f;
  border-radius: 7px;
  padding: 6px;
  font-size: 0.8rem;
  background: #1a2736;
  cursor: grab;
}

.furnace-source-item:active {
  cursor: grabbing;
}

.forge-containers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.forge-container {
  border: 1px solid #3a516c;
  border-radius: 8px;
  background: #1a2533;
  padding: 8px;
  display: grid;
  gap: 8px;
}

.forge-container.active {
  border-color: #7fd8ff;
  box-shadow: inset 0 0 0 1px rgba(127, 216, 255, 0.55);
}

.forge-title {
  font-size: 0.86rem;
  font-weight: 700;
}

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

.forge-slot {
  border: 2px dashed #5f7a98;
  border-radius: 8px;
  min-height: 74px;
  padding: 8px;
  background: rgba(17, 26, 36, 0.72);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.forge-slot small {
  color: var(--muted);
  font-size: 0.76rem;
}

.forge-slot.active {
  border-color: #7fd8ff;
  background: rgba(27, 47, 63, 0.8);
}

.forge-status {
  font-size: 0.82rem;
}

.forge-status small {
  color: var(--muted);
}

.forge-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.forge-item .pixel {
  width: 18px;
  height: 18px;
}

.forge-job-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.emoji-chip {
  display: inline-block;
  min-width: 28px;
}

.furnace-queue {
  display: grid;
  gap: 8px;
}

.smelt-row {
  border: 1px solid #3a516c;
  border-radius: 8px;
  padding: 7px;
  background: #1a2533;
}

.smelt-bar {
  height: 8px;
  border-radius: 999px;
  background: #101922;
  overflow: hidden;
  margin-top: 5px;
}

.smelt-fill {
  height: 100%;
  background: linear-gradient(90deg, #f28d47, #ffcf69);
}

.application-card {
  border: 1px solid #3a5169;
  border-radius: 8px;
  padding: 10px;
  background: #17222f;
  margin-bottom: 10px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

#accountModal .modal-card {
  width: min(760px, 100%);
}

#accountModal #accountInfo {
  display: grid;
  gap: 4px;
  background: #162434;
  border-color: #3d5d80;
}

#accountModal .auth-grid {
  width: min(640px, 100%);
  margin: 0 auto 10px;
}

#accountModal .worker-actions {
  justify-content: flex-end;
}

.sync-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 140;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #59c48e;
  background: rgba(12, 32, 22, 0.95);
  color: #d7ffe9;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.sync-toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1020px) {
  .layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  #authGate:not(.hidden) {
    position: static;
    transform: none;
    margin: 18px auto;
  }

  .auth-gate h1 {
    font-size: 1.5rem;
  }

  .layout,
  .top-stats,
  .auth-grid { grid-template-columns: 1fr; }
  .market-filters,
  .market-sell-grid { grid-template-columns: 1fr; }
  .market-shell { grid-template-columns: 1fr; }
  .mine-block { width: 190px; height: 190px; }
  .mine-area { min-height: 360px; }
  .mine-hud { max-width: 80%; font-size: 0.82rem; }
}
