* {
  box-sizing: border-box;
}

html,
body,
#root {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Inter, Arial, sans-serif;
  background: #111816;
  color: #f7fbf4;
  touch-action: none;
}

button {
  border: 0;
  font: inherit;
}

.shell {
  width: 100%;
  height: 100%;
  background: #111816;
}

.game-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
}

.viewport,
.viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.viewport.hidden {
  display: none;
}

.basement-canvas {
  display: none;
  width: 100%;
  height: 100%;
  background: #121716;
  touch-action: none;
}

.basement-canvas.active {
  display: block;
}

.topbar {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  top: max(16px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.brand,
.mission,
.meter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  background: rgba(12, 21, 16, 0.76);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.brand {
  padding: 0 14px;
  border-radius: 8px;
  color: #bff5cc;
  font-weight: 800;
  text-transform: uppercase;
}

.mission {
  max-width: min(560px, 56vw);
  padding: 0 14px;
  border-radius: 8px;
  color: #fff6cf;
  font-weight: 700;
}

.dashboard {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(22px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
}

.meter {
  min-width: 112px;
  padding: 9px 12px;
  border-radius: 8px;
}

.meter strong {
  min-width: 34px;
  text-align: right;
  font-size: 1.35rem;
}

.meter span {
  color: #c7d3c9;
  font-size: 0.8rem;
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7px;
  background: rgba(255, 255, 255, 0.18);
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #25a842, #f4db57, #ff5b3f);
  transition: width 0.2s ease;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: linear-gradient(180deg, rgba(5, 11, 7, 0.18), rgba(5, 11, 7, 0.7));
}

.overlay.hidden {
  display: none;
}

.panel {
  display: grid;
  grid-template-columns: minmax(160px, 320px) minmax(220px, 420px);
  gap: 18px;
  align-items: center;
  max-width: 780px;
  padding: 18px;
  border-radius: 8px;
  background: rgba(12, 20, 15, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.4);
}

.panel img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
}

.panel h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
}

.panel p {
  margin: 0 0 18px;
  color: #d5dfd4;
  line-height: 1.45;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  background: #1d8b35;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

#basementButton,
#electricButton,
#switchboardButton {
  background: #3b413c;
}

#electricButton {
  background: #1d6f8b;
}

#switchboardButton {
  background: #6c4f12;
}

.controls {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  touch-action: none;
}

.controls button {
  display: grid;
  place-items: center;
  min-width: 70px;
  height: 42px;
  border-radius: 8px;
  background: rgba(12, 21, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.17);
  color: #dce7de;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#jumpButton {
  min-width: 62px;
  background: rgba(112, 88, 20, 0.84);
  font-size: 1.35rem;
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .mission {
    max-width: none;
  }

  .dashboard {
    right: max(18px, env(safe-area-inset-right));
    justify-content: space-between;
  }

  .meter {
    min-width: 0;
    flex: 1;
  }

  .meter span {
    display: none;
  }

  .panel {
    grid-template-columns: 1fr;
    max-width: 460px;
  }

  .panel img {
    max-height: 210px;
  }

  .controls {
    display: flex;
    bottom: max(76px, calc(env(safe-area-inset-bottom) + 76px));
  }
}
