* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #111821;
  color: #f7efe1;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.game-shell {
  position: relative;
  width: min(100vw, 960px);
  height: min(100vh, 560px);
  min-height: 520px;
  overflow: hidden;
  background: #18212b;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #172322;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  padding: 18px;
}

.hidden {
  display: none !important;
}

.lobby {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  background:
    linear-gradient(180deg, rgba(13, 19, 28, 0.84), rgba(18, 25, 34, 0.94)),
    radial-gradient(circle at 30% 10%, rgba(141, 213, 198, 0.24), transparent 32%);
}

.topbar,
.panel,
.result-card,
.hud-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(24, 34, 43, 0.88);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 8px;
}

.kicker,
.panel-title span,
.hud-card span {
  display: block;
  color: #8fd5c6;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

.currency {
  text-align: right;
}

.currency span {
  display: block;
  color: #d9cfb6;
  font-size: 12px;
  font-weight: 700;
}

.currency strong {
  font-size: 28px;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.8fr 1.25fr;
  gap: 14px;
  min-height: 0;
}

.panel {
  min-height: 0;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-title strong {
  text-align: right;
  font-size: 16px;
}

.choice-grid,
.shop-list,
.map-loot-panel {
  overflow-y: auto;
  scrollbar-color: #8fd5c6 rgba(255, 255, 255, 0.08);
}

.choice-grid {
  display: grid;
  gap: 8px;
  align-content: start;
  padding-right: 3px;
}

.map-panel .choice-grid {
  flex: 1;
}

.mode-panel .choice-grid {
  max-height: 188px;
}

.choice,
.gear-card,
.map-loot-button,
.play-button,
.result-card button {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px;
  text-align: left;
}

.choice.active,
.gear-card.active {
  border-color: #8fd5c6;
  background: rgba(143, 213, 198, 0.18);
}

.choice.locked {
  opacity: 0.5;
}

.choice strong,
.gear-card strong {
  display: block;
  font-size: 14px;
}

.choice small,
.gear-card small,
.map-loot-panel small {
  display: block;
  color: #d9cfb6;
  font-size: 12px;
  margin-top: 3px;
}

.map-loot-button {
  color: #16201d;
  background: #8fd5c6;
  text-align: center;
  font-weight: 900;
}

.map-loot-panel {
  max-height: 150px;
  border-radius: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.equipment-categories {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.equipment-categories button {
  min-width: 0;
  padding: 8px 4px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.equipment-categories button.active {
  background: #ffd36a;
  color: #1f1a10;
}

.shop-list {
  flex: 1;
  display: grid;
  gap: 8px;
  align-content: start;
  padding-right: 3px;
}

.gear-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.rarity-Common {
  color: #e2d4b8;
}

.rarity-Rare {
  color: #7ce6ff;
}

.rarity-Epic {
  color: #c9a8ff;
}

.rarity-Legendary {
  color: #ffd36a;
}

.rarity-Mythic {
  color: #ff7df3;
}

.rarity-Divine {
  color: #ffffff;
  text-shadow: 0 0 12px #fff1a8;
}

.play-button {
  justify-self: center;
  min-width: 220px;
  text-align: center;
  color: #172322;
  background: #ffd36a;
  font-size: 22px;
  font-weight: 950;
  box-shadow: 0 10px 30px rgba(255, 211, 106, 0.28);
}

.hud {
  position: absolute;
  inset: 12px 14px auto 14px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.hud-card {
  width: 230px;
  padding: 9px 10px;
  border-radius: 8px;
}

.hud-card strong {
  display: block;
  margin: 2px 0 6px;
}

.hud-track {
  height: 12px;
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
}

.health-fill,
.damage-fill,
.room-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: inherit;
}

.damage-fill {
  background: #ff6d5f;
  opacity: 0.45;
  transition: width 0.22s ease;
}

.health-fill {
  background: #8fd5c6;
  z-index: 2;
}

.room-fill {
  background: #ffd36a;
}

.message {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 6;
  transform: translateX(-50%);
  max-width: min(90%, 520px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.64);
  color: #fff8e8;
  text-align: center;
  font-weight: 800;
}

.result {
  display: grid;
  place-items: center;
  background: rgba(8, 12, 16, 0.74);
}

.result-card {
  width: min(480px, 92vw);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.result-card h2 {
  font-size: 34px;
  margin: 4px 0 8px;
}

.crate-reward {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.reward-item {
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.08);
}

.reward-item span,
.reward-item strong {
  display: block;
}

.result-card button {
  margin-top: 16px;
  color: #172322;
  background: #8fd5c6;
  font-weight: 900;
  text-align: center;
}

@media (max-width: 820px) {
  .game-shell {
    height: 100vh;
  }

  .lobby-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .panel {
    min-height: 220px;
  }

  .hud {
    gap: 8px;
  }

  .hud-card {
    width: min(46vw, 220px);
  }
}
