:root {
  color-scheme: light;
  --ink: #263238;
  --muted: #66737a;
  --paper: #fff7df;
  --panel: #ffffff;
  --line: #d8c8a3;
  --green: #2e9d69;
  --green-dark: #1e764e;
  --gold: #f4bd3f;
  --blue: #48a9e6;
  --red: #e56157;
  --soil-1: #8a5a44;
  --soil-2: #674330;
  --soil-3: #473026;
  --shadow: 0 12px 28px rgba(38, 50, 56, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 130px, rgba(255, 255, 255, 0.7) 0 34px, transparent 35px),
    radial-gradient(circle at 88% 165px, rgba(255, 255, 255, 0.55) 0 42px, transparent 43px),
    linear-gradient(180deg, #8ed8ff 0 210px, #c4ecff 210px 310px, #a9df88 310px 390px, #8a5a44 390px);
}

button {
  min-height: 44px;
  border: 2px solid #263238;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  background: #fff;
  box-shadow: 0 4px 0 #263238;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

button span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 7px;
  border-radius: 999px;
  background: rgba(38, 50, 56, 0.1);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 0 #263238;
}

button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #263238;
}

button:disabled {
  color: #8c969b;
  border-color: #9ea8ad;
  background: #eef1f2;
  box-shadow: 0 3px 0 #9ea8ad;
  cursor: not-allowed;
}

.game-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 34px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) 1.3fr;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 2px solid #263238;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 247, 223, 0.96), rgba(255, 255, 255, 0.95)),
    repeating-linear-gradient(90deg, transparent 0 28px, rgba(46, 157, 105, 0.08) 29px 32px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.eyebrow {
  margin: 0;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
  letter-spacing: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(1.8rem, 2.5rem, 3rem);
}

h2 {
  font-size: 1.1rem;
}

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

.stat,
.panel,
.shaft {
  border: 2px solid #263238;
  border-radius: 8px;
  background: var(--panel);
}

.stat {
  min-width: 0;
  padding: 10px 12px;
}

.stat span,
.line-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.stat strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-size: clamp(1rem, 1.7vw, 1.35rem);
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  position: sticky;
  top: 112px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
  padding: 10px;
  border: 2px solid rgba(38, 50, 56, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
}

.primary-button {
  background: var(--gold);
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  position: sticky;
  top: 186px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.crew-card {
  margin-top: 14px;
  padding: 13px;
  border: 2px solid #263238;
  border-radius: 8px;
  background: linear-gradient(135deg, #dcf7ff, #fff4bf);
}

.crew-card span {
  display: block;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.crew-card strong {
  display: block;
  margin-top: 3px;
  font-size: 1.3rem;
  line-height: 1.1;
}

.line-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e4dbc5;
}

.line-item strong {
  white-space: nowrap;
}

.tip {
  margin-top: 16px;
  padding: 12px;
  border: 2px dashed #8fb95f;
  border-radius: 8px;
  color: #33531f;
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.35;
  background: #f1ffd6;
}

.mine-wrap {
  overflow: hidden;
  border: 3px solid #263238;
  border-radius: 8px;
  background: var(--soil-1);
  box-shadow: var(--shadow);
}

.skyline {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: center;
  height: 148px;
  background:
    linear-gradient(180deg, #7ad2ff 0%, #d7f7ff 70%, #96d76e 70% 100%);
  border-bottom: 3px solid #263238;
}

.office {
  position: absolute;
  left: 28px;
  bottom: 0;
  display: flex;
  gap: 8px;
  align-items: start;
  width: 124px;
  height: 72px;
  padding: 14px 12px;
  border: 3px solid #263238;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #ffdf67;
}

.window {
  width: 24px;
  height: 24px;
  border: 2px solid #263238;
  border-radius: 5px;
  background: #73ccff;
}

.headframe {
  position: relative;
  width: 180px;
  height: 118px;
  border-bottom: 0;
}

.headframe::before,
.headframe::after {
  position: absolute;
  bottom: -4px;
  width: 15px;
  height: 124px;
  border: 3px solid #263238;
  border-radius: 8px 8px 0 0;
  background: #d84d47;
  content: "";
}

.headframe::before {
  left: 44px;
  transform: rotate(15deg);
}

.headframe::after {
  right: 44px;
  transform: rotate(-15deg);
}

.headframe span {
  position: absolute;
  left: 50%;
  bottom: 68px;
  width: 86px;
  height: 86px;
  border: 8px solid #263238;
  border-radius: 999px;
  background: #f7f7f7;
  transform: translateX(-50%);
}

.mine {
  min-height: 980px;
  padding: 18px clamp(12px, 2vw, 24px) 28px;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, 0.12) 0 9px, transparent 10px),
    radial-gradient(circle at 82% 21%, rgba(255, 255, 255, 0.1) 0 7px, transparent 8px),
    linear-gradient(180deg, var(--soil-1), var(--soil-2) 48%, var(--soil-3));
}

.shaft {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(230px, 1fr) 176px;
  gap: 12px;
  align-items: center;
  min-height: 148px;
  margin-bottom: 18px;
  padding: 14px;
  color: #fdf7e4;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.26), transparent 42%),
    repeating-linear-gradient(90deg, transparent 0 42px, rgba(0, 0, 0, 0.16) 43px 48px),
    var(--shaft-color);
}

.shaft::before {
  position: absolute;
  inset: 14px auto 14px 50%;
  width: 74px;
  border: 3px solid rgba(255, 255, 255, 0.34);
  border-top: 0;
  border-bottom: 0;
  transform: translateX(-50%);
  content: "";
}

.shaft.best {
  outline: 4px solid #ffd34f;
  outline-offset: -7px;
}

.shaft h3 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.1;
}

.shaft p {
  margin: 7px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-weight: 700;
}

.best-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-top: 10px;
  padding: 3px 8px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  color: #263238;
  font-size: 0.78rem;
  font-weight: 950;
  background: #ffd34f;
}

.ore-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.ore {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 8px;
  border: 2px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 850;
  background: rgba(0, 0, 0, 0.22);
}

.ore i {
  width: 12px;
  height: 12px;
  border-radius: 50% 45% 55% 40%;
  background: var(--ore-color);
  box-shadow: 0 0 10px var(--ore-color);
}

.work-site {
  position: relative;
  z-index: 1;
  display: grid;
  align-items: end;
  min-height: 104px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0.34)),
    repeating-linear-gradient(0deg, transparent 0 34px, rgba(255, 255, 255, 0.08) 35px 38px);
}

.ore-cluster {
  position: absolute;
  right: 14px;
  bottom: 18px;
  display: flex;
  gap: 5px;
  align-items: end;
}

.ore-rock {
  width: 19px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-radius: 48% 38% 55% 43%;
  background: var(--ore-color);
  box-shadow: 0 0 12px var(--ore-color);
}

.ore-rock:nth-child(2) {
  width: 15px;
  height: 22px;
  transform: translateY(3px);
}

.ore-rock:nth-child(3) {
  width: 22px;
  height: 15px;
  transform: translateY(-2px);
}

.miners {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: end;
  gap: 9px;
  min-height: 86px;
  padding: 0 18px 10px;
}

.miner {
  position: relative;
  width: 34px;
  height: 58px;
  animation: minerBob 850ms ease-in-out infinite;
  animation-delay: var(--delay);
}

.miner::before {
  position: absolute;
  left: 8px;
  top: 0;
  width: 18px;
  height: 18px;
  border: 2px solid #263238;
  border-radius: 50%;
  background: #f2b37f;
  box-shadow: 0 -7px 0 -2px #ffd34f;
  content: "";
}

.miner-body {
  position: absolute;
  left: 6px;
  top: 20px;
  width: 22px;
  height: 26px;
  border: 2px solid #263238;
  border-radius: 7px 7px 5px 5px;
  background: #48a9e6;
}

.miner-body::before,
.miner-body::after {
  position: absolute;
  bottom: -15px;
  width: 8px;
  height: 15px;
  border: 2px solid #263238;
  border-top: 0;
  border-radius: 0 0 5px 5px;
  background: #35546a;
  content: "";
}

.miner-body::before {
  left: 1px;
}

.miner-body::after {
  right: 1px;
}

.pickaxe {
  position: absolute;
  right: -14px;
  top: 19px;
  width: 30px;
  height: 5px;
  border-radius: 999px;
  background: #f0c165;
  transform-origin: 4px center;
  animation: swingPick 850ms ease-in-out infinite;
  animation-delay: var(--delay);
}

.pickaxe::after {
  position: absolute;
  right: -5px;
  top: -7px;
  width: 14px;
  height: 18px;
  border-top: 4px solid #dce7ec;
  border-right: 4px solid #dce7ec;
  border-radius: 3px;
  transform: rotate(35deg);
  content: "";
}

.empty-site {
  position: relative;
  z-index: 2;
  align-self: center;
  justify-self: center;
  padding: 8px 12px;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 900;
  background: rgba(0, 0, 0, 0.16);
}

.shaft-actions {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  justify-items: stretch;
  width: 172px;
}

.worker-meter {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.worker-dot {
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.worker-dot.active {
  background: #ffd34f;
}

.worker-overflow {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
}

.hire-note {
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.25;
  text-align: center;
}

.float-money {
  position: fixed;
  z-index: 20;
  left: 50%;
  top: 52%;
  color: #124b2f;
  font-size: 1.2rem;
  font-weight: 950;
  text-shadow: 0 1px #fff;
  pointer-events: none;
  animation: floatUp 850ms ease-out forwards;
}

@keyframes floatUp {
  to {
    opacity: 0;
    transform: translateY(-44px);
  }
}

@keyframes minerBob {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(4px);
  }
}

@keyframes swingPick {
  0%,
  100% {
    transform: rotate(-32deg);
  }

  50% {
    transform: rotate(22deg);
  }
}

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

  .topbar,
  .controls,
  .panel {
    position: static;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shaft {
    grid-template-columns: 1fr;
  }

  .work-site {
    min-height: 118px;
  }

  .shaft-actions {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .game-shell {
    width: min(100% - 16px, 1180px);
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .office {
    left: 14px;
    width: 96px;
  }
}
