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

body {
  background: #0a0c12;
  color: #e8e4d8;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

#wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  width: min(100vw, 177.8vh);
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  background: #161c14;
}

.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(8, 10, 18, 0.92);
  text-align: center;
  z-index: 10;
}
.screen.overlay { background: rgba(8, 10, 18, 0.7); }

h1 {
  font-size: 52px;
  letter-spacing: 6px;
  color: #e8c030;
  text-shadow: 3px 3px 0 #10121c, 0 0 30px rgba(232, 192, 48, 0.3);
  line-height: 1.1;
}
h2 { font-size: 26px; color: #e8c030; text-shadow: 2px 2px 0 #10121c; }
.subtitle { color: #9aa4b8; font-size: 14px; }
.disclaimer { position: absolute; bottom: 12px; font-size: 10px; color: #5a6478; }
.gold-line { color: #ffd860; font-size: 16px; font-weight: bold; }
.best-line { color: #9aa4b8; font-size: 12px; }

/* ---------- buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  color: #e8e4d8;
  background: #232838;
  border: 2px solid #4a5268;
  padding: 10px 34px;
  cursor: pointer;
  transition: all 0.08s;
}
.btn:hover:not(:disabled) { background: #3a4258; border-color: #e8c030; transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.big-btn { font-size: 22px; padding: 14px 60px; border-color: #e8c030; color: #ffd860; }

/* ---------- cards ---------- */
.card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1a1f2e;
  border: 2px solid #3a4258;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.08s;
  text-align: left;
}
.card:hover { border-color: #e8c030; background: #242b40; transform: translateX(3px); }
.card canvas { width: 48px; height: 48px; image-rendering: pixelated; flex-shrink: 0; }

#char-list { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; max-width: 720px; }
.char-card { flex-direction: column; width: 150px; text-align: center; padding: 16px 10px; }
.char-card:hover { transform: translateY(-3px); }
.char-name { font-size: 16px; font-weight: bold; color: #ffd860; }
.char-bonus { font-size: 12px; color: #60e8a0; }
.char-weapon { font-size: 11px; color: #9aa4b8; }

#shop-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 760px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.shop-card { cursor: default; }
.shop-card:hover { transform: none; }
.shop-card.maxed { opacity: 0.6; }
.shop-info { flex: 1; }
.shop-name { font-size: 14px; font-weight: bold; }
.shop-desc { font-size: 11px; color: #9aa4b8; }
.pips { color: #e8c030; font-size: 10px; letter-spacing: 1px; }
.buy { font-family: inherit; font-size: 12px; font-weight: bold; background: #2a3248; color: #ffd860; border: 1px solid #4a5268; padding: 6px 10px; cursor: pointer; }
.buy:hover:not(:disabled) { border-color: #e8c030; }
.buy:disabled { opacity: 0.4; cursor: default; }

/* ---------- panel (levelup / chest / pause) ---------- */
.panel {
  background: #141826;
  border: 3px solid #e8c030;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), inset 0 0 24px rgba(232, 192, 48, 0.06);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  min-width: 420px;
  max-width: 560px;
}
.gold-panel { border-color: #ffd860; }

#lvchoices { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.lv-card { width: 100%; }
.lv-info { flex: 1; }
.lv-name { font-size: 15px; font-weight: bold; color: #e8e4d8; }
.lv-desc { font-size: 12px; color: #9aa4b8; }
.tag { font-size: 10px; background: #2a3248; color: #9aa4b8; padding: 1px 6px; border-radius: 2px; vertical-align: middle; }
.tag.new { background: #e8c030; color: #10121c; }

#chest-content { display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 120px; justify-content: center; }
.chest-spin { width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; font-size: 40px; color: #ffd860; border: 2px dashed #e8c030; animation: pulse 0.4s infinite alternate; }
.chest-spin canvas { width: 56px; height: 56px; image-rendering: pixelated; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
.chest-items { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.chest-item { cursor: default; animation: pop 0.25s ease-out; }
.chest-item:hover { transform: none; }
.chest-item.evo { border-color: #ffd860; box-shadow: 0 0 16px rgba(255, 216, 96, 0.3); }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.evo-banner { font-size: 24px; font-weight: bold; color: #ffd860; letter-spacing: 8px; animation: pulse 0.5s infinite alternate; }
.chest-gold { color: #ffd860; font-size: 18px; font-weight: bold; }

#pause-build { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 420px; }

#over-stats { display: flex; flex-direction: column; gap: 8px; font-size: 17px; color: #c8ccd8; }
#over-stats b { color: #ffd860; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

#xpbar {
  position: absolute; top: 0; left: 0; right: 0; height: 18px;
  background: rgba(10, 12, 20, 0.85);
  border-bottom: 2px solid #10121c;
}
#xpfill { height: 100%; width: 0%; background: linear-gradient(90deg, #3878d8, #60c8ff); transition: width 0.15s; }
#lvltxt {
  position: absolute; right: 8px; top: 1px;
  font-size: 12px; font-weight: bold; color: #fff; text-shadow: 1px 1px 0 #10121c;
}

#timer {
  position: absolute; top: 26px; left: 50%; transform: translateX(-50%);
  font-size: 26px; font-weight: bold; color: #fff;
  text-shadow: 2px 2px 0 #10121c;
}

#runstats {
  position: absolute; top: 28px; right: 12px;
  display: flex; flex-direction: column; gap: 2px; align-items: flex-end;
  font-size: 15px; font-weight: bold; text-shadow: 1px 1px 0 #10121c;
}

#slots { position: absolute; top: 26px; left: 10px; display: flex; flex-direction: column; gap: 4px; }
#wslots, #pslots { display: flex; gap: 3px; flex-wrap: wrap; max-width: 180px; }
.slot {
  position: relative; width: 28px; height: 28px;
  background: rgba(10, 12, 20, 0.7);
  border: 1px solid #3a4258;
}
.slot canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.slot span {
  position: absolute; bottom: -2px; right: 0;
  font-size: 9px; font-weight: bold; color: #ffd860;
  text-shadow: 1px 1px 0 #10121c;
}
.slot.big { width: 44px; height: 44px; pointer-events: auto; }
.slot.big span { font-size: 12px; }

/* ---------- cheat key bar ---------- */
#cheatbar {
  position: absolute; bottom: 10px; left: 10px;
  background: rgba(10, 12, 20, 0.8);
  border: 1px solid #3a4258;
  padding: 8px 12px;
  font-size: 11px;
  color: #9aa4b8;
  line-height: 1.7;
}
.cheat-title { font-weight: bold; color: #60c8ff; font-size: 12px; }
.cheat-hint { color: #5a6478; font-weight: normal; font-size: 10px; }
.cheat-row b {
  display: inline-block;
  background: #2a3248; color: #ffd860;
  border: 1px solid #4a5268;
  padding: 0 5px; margin: 0 2px 0 8px;
  font-size: 10px;
}
.cheat-row b:first-child { margin-left: 0; }
