@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap");

:root {
  --bg-deep: #0d1119;
  --bg-mid: #151c2b;
  --accent-hot: #ffb347;
  --accent-cold: #53d6ff;
  --text-main: #f5f0d9;
  --panel-bg: rgba(10, 14, 26, 0.88);
  --panel-border: rgba(245, 240, 217, 0.35);
  --pixel-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 20% 20%, #26314c 0%, var(--bg-deep) 65%);
  color: var(--text-main);
  font-family: "VT323", monospace;
  font-size: 22px;
  overflow: hidden;
  touch-action: none;
}

#game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02) 0px,
    rgba(255, 255, 255, 0.02) 2px,
    rgba(0, 0, 0, 0) 4px,
    rgba(0, 0, 0, 0) 6px
  );
  z-index: 15;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#hud {
  position: absolute;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  padding: 12px 12px 0;
  pointer-events: none;
}

.row.top {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.chip {
  padding: 5px 10px;
  border: 2px solid var(--panel-border);
  background: rgba(6, 10, 20, 0.66);
  border-radius: 6px;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 0.3px;
  box-shadow: var(--pixel-shadow);
}

.bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.bar-label {
  width: 30px;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  line-height: 1.2;
}

.bar {
  position: relative;
  flex: 1;
  height: 12px;
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  box-shadow: var(--pixel-shadow);
}

.bar > div {
  width: 50%;
  height: 100%;
  transition: width 120ms linear;
}

.bar.hp > div {
  background: linear-gradient(90deg, #ff9550, var(--accent-hot));
}

.bar.xp > div {
  background: linear-gradient(90deg, #58d6ff, var(--accent-cold));
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.62);
  z-index: 20;
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(560px, 100%);
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 6px;
  padding: 18px;
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.3);
}

.panel h1,
.panel h2 {
  margin: 0 0 8px;
  line-height: 1.2;
  font-family: "Press Start 2P", monospace;
  font-size: 19px;
}

.panel p {
  margin: 6px 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 24px;
  line-height: 1.1;
}

.panel p a {
  color: #8ec9ff;
}

.btn {
  width: 100%;
  margin-top: 14px;
  padding: 12px 14px 10px;
  border: 2px solid #f8e6b4;
  border-radius: 5px;
  background: linear-gradient(180deg, #f38b45, #c6521e);
  color: white;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  line-height: 1.3;
  box-shadow: var(--pixel-shadow);
}

.upgrade-list {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.upgrade-btn {
  border: 2px solid var(--panel-border);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  text-align: left;
  padding: 8px;
  font-size: 18px;
  line-height: 1.05;
  box-shadow: var(--pixel-shadow);
  min-height: 170px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.upgrade-btn strong {
  display: block;
  margin-bottom: 6px;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  line-height: 1.3;
}

.upgrade-meta {
  display: block;
  font-size: 16px;
  color: rgba(255, 245, 218, 0.9);
  line-height: 1.1;
}

.upgrade-art {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 2px solid rgba(255, 245, 218, 0.45);
  border-radius: 4px;
  margin-bottom: 8px;
  object-fit: contain;
  image-rendering: pixelated;
  background: radial-gradient(circle at 50% 45%, rgba(31, 45, 74, 0.9), rgba(10, 15, 28, 0.95));
  padding: 8px;
}
