:root {
  --bg: #1a1c2c;
  --panel: #2a2c44;
  --panel-light: #3b3d5c;
  --text: #f4f4e8;
  --dim: #9a9ab8;
  --hp: #e0455a;
  --mp: #45a7e0;
  --gold: #f5c542;
  --green: #6fdc7f;
  --boss: #ff8c42;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Courier New", monospace;
  min-height: 100vh;
}

#app { max-width: 640px; margin: 0 auto; padding: 12px; }

header {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0 12px;
}
header h1 { font-size: 1.4em; letter-spacing: 3px; color: var(--gold); }
#best-wave { color: var(--dim); font-size: 0.85em; }

.screen.hidden { display: none; }

.panel {
  background: var(--panel);
  border: 3px solid var(--panel-light);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
}
.intro p { margin-bottom: 12px; }
.dim { color: var(--dim); font-size: 0.9em; }
.boss { color: var(--boss); font-weight: bold; }

.big-btn {
  font-family: inherit; font-size: 1.1em;
  background: var(--gold); color: #222;
  border: none; border-radius: 6px;
  padding: 12px 32px; margin-top: 12px; cursor: pointer;
}
.big-btn:hover { filter: brightness(1.1); }

/* Arena */
#arena {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--panel);
  border: 3px solid var(--panel-light);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 10px;
}
.fighter { flex: 1; text-align: center; min-width: 0; }
.vs { align-self: center; color: var(--dim); font-weight: bold; }

.sprite {
  font-size: 3em; line-height: 1.2;
  transition: transform 0.1s;
}
.sprite.hit { animation: shake 0.3s; }
.sprite.dead { filter: grayscale(1); opacity: 0.4; transform: rotate(90deg); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.hpbar, .mpbar {
  position: relative;
  height: 14px; margin: 4px 0;
  background: #111;
  border-radius: 3px;
  overflow: hidden;
}
.hpbar .fill { height: 100%; background: var(--hp); transition: width 0.3s; }
.mpbar .fill { height: 100%; background: var(--mp); transition: width 0.3s; }
.hpbar span, .mpbar span {
  position: absolute; inset: 0;
  font-size: 10px; line-height: 14px;
  color: #fff; text-shadow: 1px 1px 0 #000;
}
.enemy-hp { background: var(--green); }

.statline { font-size: 0.8em; color: var(--dim); margin-top: 4px; }

#wave-banner {
  text-align: center;
  font-weight: bold; letter-spacing: 4px;
  color: var(--gold);
  padding: 4px 0;
}
#wave-banner.boss { color: var(--boss); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

#log {
  height: 120px; overflow-y: auto;
  background: #111;
  border: 2px solid var(--panel-light);
  border-radius: 6px;
  padding: 8px;
  font-size: 0.8em;
  line-height: 1.5;
  margin-bottom: 10px;
}
#log .latest { color: var(--gold); }

#actions button {
  font-family: inherit; font-size: 1em;
  background: var(--panel-light); color: var(--text);
  border: 2px solid var(--dim);
  border-radius: 6px;
  padding: 10px 8px;
  cursor: pointer;
  width: 100%;
}
#actions button:hover:not(:disabled) { background: var(--dim); }
#actions button:disabled { opacity: 0.35; cursor: default; }
#actions small { color: var(--dim); }
.action-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
#choice-actions { grid-template-columns: 1fr 1fr; margin-top: 6px; }
#choice-actions.hidden { display: none; }
.battle-actions-hidden { display: none !important; }

/* Shop */
#shop-gold { color: var(--gold); margin-bottom: 12px; }
.shop-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-light);
  border-radius: 6px;
  padding: 10px; margin-bottom: 8px;
  text-align: left;
}
.shop-item .info { flex: 1; }
.shop-item .name { font-weight: bold; }
.shop-item .desc { font-size: 0.8em; color: var(--dim); }
.shop-item button {
  font-family: inherit;
  background: var(--gold); color: #222;
  border: none; border-radius: 4px;
  padding: 8px 12px; cursor: pointer;
  white-space: nowrap;
}
.shop-item button:disabled { background: #555; color: #999; cursor: default; }

#screen-shop .panel { text-align: left; }
#screen-shop h2 { text-align: center; margin-bottom: 10px; }
#btn-leave-shop {
  font-family: inherit; font-size: 1em;
  background: var(--green); color: #123;
  border: none; border-radius: 6px;
  padding: 12px; width: 100%; margin-top: 8px; cursor: pointer;
}

footer { text-align: right; padding-top: 10px; }
#btn-mute { background: none; border: none; font-size: 1.2em; cursor: pointer; }

#gameover-summary { margin: 16px 0; line-height: 1.8; }
