@font-face {
  font-family: "Press Start 2P";
  src: url("assets/PressStart2P.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "VT323";
  src: url("assets/VT323.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #140e0a;
  --wood: #3a2416;
  --wood-2: #5a3820;
  --wood-3: #7a4e2a;
  --gold: #e6c35c;
  --gold-2: #f8e7a0;
  --cream: #f4e6c1;
  --moss: #6db36a;
  --danger: #d45a4a;
  --hud-h: 52px;
  --dock-h: 74px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(ellipse at 50% 20%, #2a1c14 0%, #0a0706 70%);
  color: var(--cream);
  font-family: "VT323", monospace;
  font-size: 20px;
  line-height: 1.25;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow: hidden;
}
img { image-rendering: pixelated; image-rendering: crisp-edges; }
button { font: inherit; color: inherit; cursor: pointer; }

#app {
  width: min(430px, 100%);
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--ink);
  box-shadow: 0 0 0 3px #1c120c, 0 0 0 6px #c9a227, 0 20px 80px rgba(0,0,0,.7);
}
@media (min-width: 500px) {
  body { display: grid; place-items: center; }
  #app {
    height: min(100dvh, 920px);
    border-radius: 12px;
  }
}

.screen { position: absolute; inset: 0; }
.hidden { display: none !important; }

/* Title */
.title-bg {
  position: absolute; inset: 0;
  background: url("assets/bg.png") center / cover no-repeat;
  image-rendering: pixelated;
  filter: saturate(1.05);
}
.title-veil {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,6,4,.15) 10%, rgba(10,6,4,.72) 60%, rgba(10,6,4,.92) 100%);
}
.title-card {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 24px 22px calc(28px + env(safe-area-inset-bottom));
  text-align: center;
}
.kicker {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 14px;
  text-shadow: 0 2px 0 #000;
}
.title-card h1 {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(18px, 6.4vw, 26px);
  line-height: 1.45;
  color: #fff6d8;
  text-shadow: 0 3px 0 #3a2416, 0 6px 0 #120a06, 0 0 18px rgba(230,195,92,.4);
  margin-bottom: 12px;
}
.subtitle { color: #d7c7a4; margin-bottom: 22px; font-size: 22px; }
.proto-note { margin-top: 14px; color: #9a8868; font-size: 16px; }

.btn-gold {
  display: inline-block;
  background: linear-gradient(#f0d27a, #c4922a);
  color: #2a1a0a;
  border: 3px solid #3a2416;
  box-shadow: 0 0 0 2px #e6c35c, 0 4px 0 #2a1a0a;
  padding: 12px 18px;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  letter-spacing: .5px;
}
.btn-gold:active { transform: translateY(2px); box-shadow: 0 0 0 2px #e6c35c, 0 2px 0 #2a1a0a; }
.btn-gold:disabled { opacity: .45; pointer-events: none; }

.btn-wood {
  background: linear-gradient(#6b4428, #3e2616);
  border: 2px solid #e6c35c;
  color: var(--cream);
  padding: 8px 12px;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
}
.btn-wood:disabled { opacity: .4; pointer-events: none; }

/* HUD */
.hud {
  height: var(--hud-h);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 4px;
  align-items: center;
  padding: 6px 8px 6px 8px;
  background:
    linear-gradient(#5a3820, #3a2416);
  border-bottom: 3px solid #e6c35c;
  box-shadow: 0 3px 0 #1a1008;
  z-index: 2;
  position: relative;
}
.res {
  display: flex; align-items: center; gap: 4px;
  min-width: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: #ffe9a0;
  text-shadow: 0 2px 0 #000;
}
.res img { width: 16px; height: 16px; flex: 0 0 16px; }
.res span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wave {
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  color: #fff;
  background: #1a1008;
  border: 2px solid #c9a227;
  padding: 5px 7px;
  white-space: nowrap;
}

/* Stage */
#stage {
  position: absolute;
  top: var(--hud-h);
  bottom: var(--dock-h);
  left: 0; right: 0;
  background: url("assets/bg.png") center 30% / cover no-repeat;
  image-rendering: pixelated;
  overflow: hidden;
}
.side {
  position: absolute;
  bottom: 14%;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  z-index: 2;
}
.side.left { left: 4%; flex-direction: row; }
.side.right { right: 4%; flex-direction: row-reverse; }

.actor {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: idle 1.1s ease-in-out infinite;
}
.actor:nth-child(2) { animation-delay: .15s; }
.actor:nth-child(3) { animation-delay: .3s; }
.actor:nth-child(4) { animation-delay: .45s; }
.actor img.sprite {
  height: var(--h, 72px);
  width: auto;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.45));
}
.actor.hero { --h: 78px; }
.actor.hero.kael { --h: 70px; }
.actor.enemy { --h: 62px; }
.actor.boss { --h: 118px; }
.actor.hit img.sprite { filter: brightness(2) drop-shadow(0 0 6px #fff); }
.actor.lunge img.sprite { transform: translateX(10px); }
.side.right .actor.lunge img.sprite { transform: translateX(-10px); }
.actor.dead { opacity: 0; transform: translateY(8px); transition: .3s; }

.hpbar {
  width: 44px; height: 5px;
  background: #1a1008;
  border: 1px solid #3a2416;
  margin-bottom: 3px;
  overflow: hidden;
}
.actor.boss .hpbar { width: 86px; height: 7px; border: 1px solid #e6c35c; }
.hpbar > i {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(#9ee07a, #3d8f3a);
  transform-origin: left;
}
.actor.boss .hpbar > i { background: linear-gradient(#ff8a6a, #b33322); }

@keyframes idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

#fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.floater {
  position: absolute;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  color: #ffe566;
  text-shadow: 0 2px 0 #000;
  animation: rise 800ms ease-out forwards;
  white-space: nowrap;
}
.floater.dmg { color: #fff; }
.floater.herb { color: #9ee07a; }
.floater.crystal { color: #8ec8ff; }
@keyframes rise {
  0% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -36px); }
}

#stage-banner {
  position: absolute; left: 8%; right: 8%; top: 10%;
  text-align: center;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  line-height: 1.5;
  color: #fff0c8;
  background: rgba(20,10,6,.72);
  border: 2px solid #e6c35c;
  padding: 8px 10px;
  text-shadow: 0 2px 0 #000;
  z-index: 4;
}

#log {
  position: absolute;
  left: 8px; right: 8px;
  bottom: calc(var(--dock-h) + 8px);
  font-size: 16px;
  color: #fff6d8;
  text-shadow: 0 1px 2px #000, 0 0 6px #000;
  pointer-events: none;
  z-index: 3;
  min-height: 1.2em;
}

/* Dock */
.dock {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--dock-h);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(#5a3820, #2c1a10);
  border-top: 3px solid #e6c35c;
  z-index: 2;
}
.dock button {
  background: linear-gradient(#6b4428, #3e2616);
  border: 2px solid #c9a227;
  color: #fff6d8;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-family: "Press Start 2P", monospace;
  font-size: 6px;
  letter-spacing: 0;
  padding: 4px 2px;
  text-shadow: 0 1px 0 #000;
}
.dock button .ico { font-size: 14px; font-family: sans-serif; line-height: 1; }
.dock button:active, .dock button.active {
  background: linear-gradient(#8a5a30, #5a3820);
  color: #ffe9a0;
}

/* Panel */
.panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  top: 18%;
  background: #1c120c;
  border-top: 3px solid #e6c35c;
  z-index: 6;
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 24px rgba(0,0,0,.5);
}
.panel > header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(#5a3820, #3a2416);
  border-bottom: 2px solid #c9a227;
}
.panel > header h2 {
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  color: #fff6d8;
}
#panel-close {
  background: #2a1a0a; border: 2px solid #c9a227;
  color: #fff; width: 32px; height: 32px; font-size: 22px; line-height: 1;
}
#panel-body {
  overflow: auto;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.hero-card, .row-card, .rank-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 8px;
  align-items: center;
  background: #2a1c14;
  border: 2px solid #5a3820;
  padding: 8px;
  margin-bottom: 8px;
}
.hero-card img { height: 52px; width: auto; justify-self: center; }
.hero-card h3, .row-card h3 {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: #fff6d8;
  margin-bottom: 3px;
}
.muted { color: #b9a88a; font-size: 17px; }
.tag {
  display: inline-block;
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  padding: 2px 5px;
  border: 1px solid currentColor;
  margin-right: 4px;
}
.stars { color: #e6c35c; letter-spacing: 1px; font-size: 14px; }
.actions { display: flex; flex-direction: column; gap: 6px; }
.hint { color: #b9a88a; margin: 0 0 10px; }
.odds { font-size: 16px; color: #d7c7a4; margin: 8px 0 14px; }
.odds b { font-weight: 400; }

/* Modal */
.modal {
  position: absolute; inset: 0;
  background: rgba(8,5,3,.78);
  z-index: 8;
  display: grid; place-items: center;
  padding: 20px;
}
.modal .card {
  width: 100%;
  background: #1c120c;
  border: 3px solid #e6c35c;
  padding: 18px 16px;
  text-align: center;
}
.modal .card h2 {
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #fff6d8;
  margin-bottom: 10px;
}
.modal .card img { height: 96px; margin: 8px auto; display: block; }
.modal .rarity {
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  margin: 6px 0 12px;
}

.summon-flash {
  animation: flash 600ms ease;
}
@keyframes flash {
  0% { filter: brightness(3); }
  100% { filter: none; }
}

.wb-bar {
  height: 14px; background: #1a1008; border: 2px solid #e6c35c;
  margin: 8px 0 12px; overflow: hidden;
}
.wb-bar > i { display: block; height: 100%; background: linear-gradient(#c06bff, #6b2aa8); width: 100%; transform-origin: left; }

.map-node {
  border: 2px solid #5a3820;
  background: #2a1c14;
  padding: 10px;
  margin-bottom: 8px;
}
.map-node.current { border-color: #e6c35c; }
.map-node.locked { opacity: .45; }
.map-node strong {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  display: block;
  margin-bottom: 4px;
}
