:root {
  --bg-0: #0d1418;
  --bg-1: #182127;
  --ink: #f3efe3;
  --muted: #9aa6ad;
  --hp: #ff5c6c;
  --hp-bg: #4a1c22;
  --xp: #6ddcff;
  --xp-bg: #143746;
  --gold: #ffce5c;
  --accent: #b3f06d;
  --raccoon: #c9c5b8;
  --shadow: rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, #1f2c33 0%, #0a0f12 80%);
}

canvas#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hidden { display: none !important; }

/* HUD */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.topbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  align-items: center;
  background: rgba(10, 16, 20, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 8px 18px;
  backdrop-filter: blur(6px);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.topbar .time { font-size: 22px; color: var(--gold); }
.topbar .killcount { color: #ffb3b8; }
.topbar .killcount .ico { margin-right: 4px; opacity: 0.8; }
.topbar .level { color: var(--xp); }
.topbar .level .lbl { opacity: 0.6; margin-right: 4px; font-size: 13px; }

.bars {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(620px, 80%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar {
  position: relative;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.bar.hp { background: var(--hp-bg); height: 18px; }
.bar.hp .fill {
  height: 100%;
  background: linear-gradient(180deg, #ff8590, var(--hp));
  width: 100%;
  transition: width 0.18s ease;
}
.bar.hp #hpText {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.bar.xp { background: var(--xp-bg); }
.bar.xp .fill {
  height: 100%;
  background: linear-gradient(180deg, #b1ecff, var(--xp));
  width: 0%;
  transition: width 0.15s ease;
}

.weapons {
  position: absolute;
  top: 70px;
  left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.weapon-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(10, 16, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 5px 10px 5px 6px;
  font-size: 12px;
  font-weight: 600;
  color: #e9ecef;
}
.weapon-pill .icon {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.weapon-pill .lvl {
  font-size: 10px;
  color: var(--gold);
  background: rgba(255, 206, 92, 0.12);
  border-radius: 4px;
  padding: 1px 5px;
}

.hint {
  position: absolute;
  top: 70px;
  right: 18px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(10, 16, 20, 0.5);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 9, 12, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel {
  background: linear-gradient(180deg, #1c262d 0%, #131a1f 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 36px 44px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  max-width: min(90vw, 720px);
}

.panel h1 {
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
  color: var(--ink);
}
.panel h1 .sub {
  font-size: 22px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.panel h2 {
  font-size: 30px;
  margin-bottom: 12px;
}

.panel .flavor {
  color: var(--muted);
  margin-bottom: 22px;
  line-height: 1.6;
  font-size: 15px;
}

.ctrls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  margin: 0 auto 24px;
  max-width: 380px;
  font-size: 13px;
  color: #cfd5da;
  text-align: left;
}
.ctrls kbd {
  background: #0d1418;
  border: 1px solid #2c3940;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 7px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  margin-right: 4px;
}

.big-btn {
  background: linear-gradient(180deg, #b3f06d, #7ec641);
  color: #0c1207;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.6px;
  padding: 13px 30px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 0 #4d7d28, 0 12px 22px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  text-transform: uppercase;
}
.big-btn:hover { transform: translateY(-1px); }
.big-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #4d7d28, 0 6px 14px rgba(0, 0, 0, 0.4); }

.ghost-btn {
  display: block;
  margin: 12px auto 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.ghost-btn:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.3); }

/* Level up choices */
.lvtitle {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--gold);
  text-shadow: 0 0 22px rgba(255, 206, 92, 0.45);
  margin-bottom: 4px;
}
.lvsub {
  color: var(--muted);
  margin-bottom: 22px;
  font-size: 14px;
}

.choices {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.choice {
  position: relative;
  width: 200px;
  background: linear-gradient(180deg, #243038, #19232a);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 16px 14px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.choice:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--accent);
}
.choice .icon {
  width: 56px; height: 56px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin-bottom: 10px;
}
.choice .name {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 2px;
}
.choice .lvltag {
  font-size: 10px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.choice .desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.choice .key {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  padding: 2px 6px;
  color: #cfd5da;
  font-family: ui-monospace, monospace;
}

/* Game over */
.over-panel { min-width: 360px; }
.over-panel h2 { color: #ff8590; }
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 22px 0 24px;
}
.stats > div {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 12px 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.stats b {
  font-size: 18px;
  color: var(--gold);
}

/* Banner messages */
.banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: var(--accent);
  border: 1px solid rgba(179, 240, 109, 0.4);
  padding: 10px 22px;
  border-radius: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: 17px;
  pointer-events: none;
  text-shadow: 0 2px 12px rgba(179, 240, 109, 0.3);
  animation: bannerIn 0.4s cubic-bezier(.2,.7,.2,1.2);
}
@keyframes bannerIn {
  from { opacity: 0; transform: translate(-50%, -10px) scale(0.9); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
