:root {
  --bg: #1a1028;
  --panel: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.16);
  --gold: #facc15;
  --violet: #a78bfa;
  --rose: #fb7185;
  --mint: #5eead4;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  overflow: hidden;
  font-family: 'Outfit', 'M PLUS Rounded 1c', sans-serif;
  color: #fff;
  background:
    radial-gradient(circle at 18% 12%, rgba(167, 139, 250, 0.24), transparent 32%),
    radial-gradient(circle at 84% 16%, rgba(250, 204, 21, 0.16), transparent 28%),
    linear-gradient(145deg, #13091f, #1a1028 56%, #2e1065);
}

#app {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px;
}

.back-link {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 20;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: #fff;
  background: rgba(19, 9, 31, 0.72);
  text-decoration: none;
  font-weight: 900;
  font-size: 0.78rem;
  backdrop-filter: blur(12px);
}

.game-shell {
  width: min(450px, 100%);
  min-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding-top: 38px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.eyebrow {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

h1 {
  font-size: 2.08rem;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

h1 span {
  color: var(--violet);
}

.wallet {
  min-width: 118px;
  padding: 10px 12px;
  border: 1px solid rgba(167, 139, 250, 0.34);
  border-radius: 8px;
  background: var(--panel);
  text-align: right;
}

.wallet span,
.stats span {
  display: block;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

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

.stats div {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.stats b {
  display: block;
  margin-top: 3px;
  font-size: 1.14rem;
}

.dungeon {
  min-height: 285px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03)),
    rgba(0,0,0,.18);
  box-shadow: 0 24px 42px rgba(0,0,0,.26);
}

.scene {
  min-height: 178px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: center;
}

.hero-cat,
.encounter {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 4.6rem;
  font-weight: 900;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
}

.hero-cat {
  color: var(--gold);
  box-shadow: inset 0 0 34px rgba(250,204,21,.1);
}

.encounter {
  color: var(--mint);
  box-shadow: inset 0 0 34px rgba(94,234,212,.1);
}

#message {
  min-height: 46px;
  color: rgba(255,255,255,.8);
  font-weight: 800;
  line-height: 1.45;
}

.hp-bar {
  height: 10px;
  margin-top: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.12);
}

.hp-bar i {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--rose), var(--gold), var(--mint));
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.actions button {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  padding: 10px;
  color: #13091f;
  background: #fff;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(0,0,0,.24);
}

#explore-btn {
  background: linear-gradient(135deg, var(--violet), var(--mint));
}

#return-btn {
  background: linear-gradient(135deg, var(--gold), #fff7ad);
}

#new-btn {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #fff, #e9d5ff);
}

.actions button:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 rgba(0,0,0,.24);
}

.actions button:disabled {
  opacity: 0.48;
  cursor: default;
}

@media (max-width: 390px) {
  #app {
    padding: 12px;
  }

  h1 {
    font-size: 1.74rem;
  }

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

  .dungeon {
    min-height: 250px;
    padding: 12px;
  }

  .hero-cat,
  .encounter {
    height: 128px;
    font-size: 3.8rem;
  }
}

@media (max-height: 700px) {
  .game-shell {
    justify-content: flex-start;
    gap: 10px;
    padding-top: 42px;
  }

  .dungeon {
    min-height: 236px;
  }

  .scene {
    min-height: 148px;
  }

  .hero-cat,
  .encounter {
    height: 126px;
  }
}
