:root {
  --gold: #f0c86a;
  --ink: #f8edd4;
  --muted: #c9b386;
  --bg: #05080a;
  --panel: rgba(8, 12, 15, 0.82);
  --line: rgba(240, 200, 106, 0.28);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 60px;
  padding: 10px clamp(14px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 8, 10, 0.86);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.topbar nav {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar nav a:hover {
  color: var(--gold);
}

.game-shell {
  position: fixed;
  inset: 0;
}

#renderCanvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

.hud {
  position: fixed;
  top: 78px;
  left: 18px;
  right: 18px;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.vitals,
.rpg-panel,
.quest-card,
.shop-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.42);
}

.vitals {
  display: grid;
  gap: 10px;
  width: min(390px, 45vw);
  padding: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.bar-row strong {
  color: var(--ink);
}

.bar {
  grid-column: 1 / -1;
  height: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
}

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

.bar.enemy i {
  background: linear-gradient(90deg, #7c1f22, #ff5c4e);
}

.rpg-panel {
  display: grid;
  gap: 8px;
  min-width: 220px;
  padding: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.rpg-panel strong {
  color: var(--gold);
}

.quest-card {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  width: min(360px, calc(100vw - 36px));
  padding: 16px;
}

.quest-card h1 {
  margin: 0 0 8px;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
}

.quest-card p {
  color: var(--muted);
  line-height: 1.45;
}

.quick-buttons,
.shop-panel {
  display: grid;
  gap: 8px;
}

button {
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

button:hover {
  border-color: var(--gold);
  background: rgba(240, 200, 106, 0.16);
}

.shop-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 30;
  width: min(360px, calc(100vw - 32px));
  padding: 18px;
  transform: translate(-50%, -50%);
}

.shop-panel h2 {
  margin: 0 0 4px;
  color: var(--gold);
}

.shop-panel p {
  margin-top: 0;
  color: var(--muted);
}

.message-screen,
.start-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
}

.message-screen > div,
.start-screen > div {
  width: min(520px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  background: rgba(8, 12, 15, 0.94);
}

.message-screen h2,
.start-screen h2 {
  margin: 0 0 10px;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.3rem, 6vw, 4.6rem);
}

.message-screen p,
.start-screen p {
  color: var(--muted);
}

#damageLayer {
  position: fixed;
  inset: 0;
  z-index: 18;
  pointer-events: none;
}

.damage-text {
  position: absolute;
  color: #ffef96;
  font-weight: 900;
  text-shadow: 0 2px 8px #000;
  animation: floatDamage 900ms ease-out forwards;
}

@keyframes floatDamage {
  from {
    opacity: 1;
    transform: translate(-50%, -10px) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -70px) scale(1.24);
  }
}

.interaction-hint {
  position: fixed;
  left: 50%;
  bottom: 120px;
  z-index: 22;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(8, 12, 15, 0.86);
  transform: translateX(-50%);
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .topbar nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .brand span {
    display: none;
  }

  .hud {
    top: 104px;
    flex-direction: column;
  }

  .vitals,
  .rpg-panel {
    width: min(100%, 420px);
  }

  .quest-card {
    display: none;
  }
}
