* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #11151c;
  color: #f4f1e8;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  touch-action: none;
  user-select: none;
}

button {
  border: 0;
  border-radius: 6px;
  background: #f0c95a;
  color: #18140d;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 44px;
  padding: 10px 18px;
}

button:hover {
  filter: brightness(1.08);
}

#shell,
#game-wrap,
#game {
  width: 100vw;
  height: 100vh;
}

#game-wrap {
  position: relative;
  background:
    radial-gradient(circle at 50% 45%, rgba(102, 153, 158, 0.16), transparent 34%),
    linear-gradient(145deg, #161d26 0%, #101318 54%, #221a20 100%);
}

#game canvas {
  display: block;
}

#hud {
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 14px;
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 24px));
  z-index: 2;
}

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

.stat {
  align-items: center;
  background: rgba(16, 19, 24, 0.72);
  border: 1px solid rgba(244, 241, 232, 0.18);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  min-height: 38px;
  padding: 8px 10px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}

.stat span {
  color: #b6bec0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.stat strong {
  font-size: 18px;
}

.bar {
  background: rgba(0, 0, 0, 0.46);
  border: 1px solid rgba(244, 241, 232, 0.14);
  border-radius: 999px;
  height: 12px;
  margin-top: 8px;
  overflow: hidden;
}

.bar i {
  background: linear-gradient(90deg, #b8324a, #f0655b);
  display: block;
  height: 100%;
  transition: width 120ms ease;
  width: 100%;
}

.bar.xp i {
  background: linear-gradient(90deg, #48c6d8, #f0c95a);
  width: 0%;
}

.panel {
  align-items: center;
  background: rgba(15, 18, 23, 0.88);
  border: 1px solid rgba(244, 241, 232, 0.2);
  border-radius: 8px;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.44);
  display: none;
  flex-direction: column;
  gap: 14px;
  left: 50%;
  max-width: min(520px, calc(100vw - 28px));
  padding: 28px;
  position: absolute;
  text-align: center;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  z-index: 5;
}

.panel.active {
  display: flex;
}

.panel h1,
.panel h2,
.panel p {
  margin: 0;
}

.panel h1 {
  font-size: clamp(34px, 6vw, 58px);
  line-height: 0.95;
}

.panel h2 {
  font-size: 28px;
}

.panel p,
.panel small {
  color: #c8cdcc;
}

#upgrade-list {
  display: grid;
  gap: 10px;
  width: 100%;
}

.upgrade {
  align-items: flex-start;
  background: rgba(244, 241, 232, 0.08);
  border: 1px solid rgba(244, 241, 232, 0.16);
  color: #f4f1e8;
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: 14px;
  text-align: left;
}

.upgrade span {
  color: #b6bec0;
  font-size: 13px;
  font-weight: 500;
}

@media (max-width: 560px) {
  #hud {
    top: 8px;
  }

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

  .stat {
    min-height: 34px;
    padding: 6px 8px;
  }

  .panel {
    padding: 22px;
  }
}
