/* ASHFALL — style.css
 * Ink, parchment, vermillion. Hades-style committed palette:
 * charcoal ground, bone parchment cards, vermillion accents, gold hints. */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #131017;
  --panel: #1d1922;
  --panel-2: #262130;
  --parchment: #ece1c8;
  --parchment-dim: #cfc2a4;
  --verm: #e0452c;
  --gold: #d9a441;
  --text: #cfc6b8;
  --text-dim: #8b8275;
  --danger: #e0664f;
  --ok: #7fb069;
}

body {
  background: radial-gradient(1200px 600px at 50% -10%, #241d2b 0%, var(--ink) 60%);
  color: var(--text);
  font-family: Georgia, 'Times New Roman', serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app { width: 720px; padding: 14px 0 30px; }

/* ---------------- hud ---------------- */
#hud {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 10px 14px; margin-bottom: 10px;
  background: var(--panel); border: 1px solid #322a3e; border-radius: 10px;
}
.hud-left { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 46px; height: 46px; display: grid; place-items: center;
  font-size: 26px; color: var(--ink); background: var(--verm);
  border-radius: 8px; font-weight: bold;
}
.game-title { letter-spacing: 4px; font-size: 15px; color: var(--parchment); }
.enc { font-size: 12px; color: var(--text-dim); font-style: italic; }
.hud-mid { flex: 1; max-width: 240px; text-align: center; }
.hpbar {
  height: 12px; background: #0d0b10; border: 1px solid #3a3145;
  border-radius: 6px; overflow: hidden;
}
.hpbar .fill {
  height: 100%; background: linear-gradient(90deg, #a83322, var(--verm));
  transition: width .3s ease;
}
.hptext { font-size: 11px; margin-top: 3px; color: var(--text-dim); }
.hud-right { display: flex; gap: 12px; font-size: 13px; color: var(--text-dim); }
.hud-right .energy { color: var(--gold); letter-spacing: 2px; }

/* ---------------- board ---------------- */
#stage { display: flex; justify-content: center; }
#board {
  position: relative;
  width: calc(7 * 88px); height: calc(3 * 88px);
  background: #151119;
  border: 1px solid #3a3145; border-radius: 10px;
  overflow: hidden;
}
#diorama { position: absolute; inset: 0; pointer-events: none; }
#diorama svg { width: 100%; height: 100%; display: block; }
.embers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.embers i {
  position: absolute; bottom: -8px; width: 3px; height: 3px; border-radius: 50%;
  background: #e0452c; box-shadow: 0 0 6px 1px rgba(224,69,44,.8);
  opacity: 0; animation: emberup linear infinite;
}
.embers i:nth-child(1) { left: 7%;  animation-duration: 11s; animation-delay: 0s; }
.embers i:nth-child(2) { left: 19%; animation-duration: 8s;  animation-delay: 3s; }
.embers i:nth-child(3) { left: 31%; animation-duration: 13s; animation-delay: 6s; }
.embers i:nth-child(4) { left: 43%; animation-duration: 9s;  animation-delay: 1.5s; }
.embers i:nth-child(5) { left: 55%; animation-duration: 12s; animation-delay: 4.5s; }
.embers i:nth-child(6) { left: 67%; animation-duration: 7.5s; animation-delay: 2s; }
.embers i:nth-child(7) { left: 79%; animation-duration: 10s; animation-delay: 5s; }
.embers i:nth-child(8) { left: 91%; animation-duration: 12.5s; animation-delay: 7s; }
@keyframes emberup {
  0% { transform: translate(0, 0); opacity: 0; }
  12% { opacity: .85; }
  100% { transform: translate(16px, -240px); opacity: 0; }
}
#board.shake { animation: shake .4s; }
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-6px,3px); } 40% { transform: translate(5px,-3px); }
  60% { transform: translate(-4px,-2px); } 80% { transform: translate(3px,2px); }
}

#cells, #chips, #fx { position: absolute; inset: 0; }
#chips, #fx { pointer-events: none; }
.cell { pointer-events: auto; }
.cell {
  position: absolute; width: 88px; height: 88px;
  border: 1px solid rgba(255,255,255,.045);
  transition: background .15s, border-color .15s;
}
.cell.alt { background: rgba(255,255,255,.015); }
.cell.deploy-hint {
  border-color: var(--gold); background: rgba(217,164,65,.10); cursor: pointer;
}
.cell.move-hint { border-color: #4fa3d1; background: rgba(79,163,209,.10); cursor: pointer; }

/* ---------------- chips (units) ---------------- */
.chip {
  pointer-events: auto;
  position: absolute; width: 80px; height: 80px;
  background: var(--panel-2);
  border: 2px solid var(--sc, #666);
  border-radius: 10px;
  overflow: hidden;
  transition: left .22s ease, top .22s ease, opacity .3s, filter .2s;
  cursor: pointer;
}
.chip .c-art { position: absolute; inset: 0; }
.chip .c-art svg { width: 100%; height: 100%; display: block; animation: idlebob 3.2s ease-in-out infinite alternate; }
.chip.spawn .c-art svg { animation: spawnpop .5s cubic-bezier(.34,1.56,.64,1), idlebob 3.2s ease-in-out .5s infinite alternate; }
@keyframes idlebob { from { transform: translateY(0); } to { transform: translateY(2.5px); } }
@keyframes spawnpop { from { transform: scale(.25); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.chip.hurt { border-color: #ff6b4f; }
.chip.hurt .c-art svg { filter: brightness(2.1) saturate(1.5) drop-shadow(0 0 7px rgba(224,69,44,.9)); }
.ghost {
  position: absolute; width: 80px; height: 80px; border-radius: 10px; overflow: hidden;
  pointer-events: none;
  animation: ghostout .7s ease-out forwards;
}
.ghost svg { width: 100%; height: 100%; display: block; }
@keyframes ghostout {
  to { opacity: 0; transform: translateY(-14px) scale(.8); filter: grayscale(1) brightness(1.4); }
}
.chip .kanji { font-size: 34px; color: var(--parchment); line-height: 1; }
.chip.enemy .c-art svg { filter: saturate(.85) hue-rotate(-12deg); }
.chip .hp, .chip .atk {
  position: absolute; bottom: 3px; font-size: 13px; font-weight: bold;
  font-family: 'Segoe UI', sans-serif;
  background: rgba(13, 11, 16, .78); border-radius: 6px; padding: 0 4px;
  text-shadow: 0 1px 2px #000;
}
.chip .hp { left: 8px; color: var(--ok); }
.chip .atk { right: 8px; color: var(--danger); }
.chip.fatigued { filter: grayscale(.7) brightness(.6); }
.chip.fatigued::after {
  content: 'zzz'; position: absolute; top: 4px; right: 6px;
  font-size: 9px; color: var(--text-dim); font-family: 'Segoe UI', sans-serif;
}
.chip.selected { outline: 2px solid var(--parchment); box-shadow: 0 0 14px rgba(236,225,200,.25); }
.chip.attack-hint { outline: 2px solid var(--verm); box-shadow: 0 0 14px rgba(224,69,44,.45); }
.chip.target-hint { outline: 2px dashed var(--gold); box-shadow: 0 0 12px rgba(217,164,65,.4); }
.chip.lunge { transform: translate(var(--lx, 0), var(--ly, 0)); transition: transform .1s; }

.intent {
  position: absolute; top: -24px; left: 50%; transform: translateX(-50%);
  background: #0d0b10; border: 1px solid #4a3f55; color: var(--text);
  font-size: 11px; padding: 1px 7px; border-radius: 8px; white-space: nowrap;
  font-family: 'Segoe UI', sans-serif; pointer-events: none;
}
.intent.i-attack, .intent.i-hitleader { color: var(--danger); border-color: #6b3027; }
.intent.i-nova { color: var(--gold); border-color: #6b5527; }
.intent.i-summon { color: #a06ee0; border-color: #4c3670; }

/* ---------------- fx ---------------- */
.popup {
  position: absolute; transform: translateX(-50%);
  font-weight: bold; font-size: 18px; font-family: 'Segoe UI', sans-serif;
  text-shadow: 0 2px 3px #000; pointer-events: none;
  animation: rise .95s ease-out forwards; z-index: 5;
}
.popup.center { left: 50% !important; top: 46% !important; font-size: 24px; }
.popup.e-hurt { color: var(--verm); }
.popup.p-hurt { color: var(--danger); }
.popup.heal { color: var(--ok); }
.popup.dead { color: var(--text-dim); }
.popup.spawn { color: var(--gold); font-size: 14px; }
.popup.cast { color: var(--parchment); font-style: italic; }
@keyframes rise {
  0% { opacity: 0; margin-top: 6px; }
  15% { opacity: 1; }
  100% { opacity: 0; margin-top: -34px; }
}

/* ---------------- controls ---------------- */
#controls {
  display: flex; align-items: center; gap: 12px;
  margin: 10px 0; padding: 8px 12px;
  background: var(--panel); border: 1px solid #322a3e; border-radius: 10px;
}
#relics { display: flex; gap: 4px; }
.relic {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; cursor: help;
  background: var(--panel); border: 1px solid var(--gold);
  color: var(--gold); font-size: 13px;
}
.card .wep { font-size: 10px; text-align: center; color: #8a6d2f; }
#log {
  flex: 1; text-align: center; font-size: 13px; font-style: italic;
  color: var(--text-dim); min-height: 18px;
}
button {
  font-family: Georgia, serif; font-size: 14px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid #3a3145; border-radius: 8px;
  padding: 8px 16px; cursor: pointer; transition: all .15s;
}
button:hover:not(:disabled) { border-color: var(--gold); color: var(--parchment); }
button:disabled { opacity: .4; cursor: default; }
#btn-auto.on { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: bold; }
#btn-end { background: var(--verm); border-color: var(--verm); color: var(--parchment); min-width: 110px; }
#btn-end:hover:not(:disabled) { filter: brightness(1.15); }

/* ---------------- hand ---------------- */
#hand {
  display: flex; justify-content: center; gap: 10px; min-height: 250px;
  align-items: flex-end; padding: 14px 6px 8px;
}
#hand .gcard { width: 150px; flex: 0 0 150px; }
.card {
  position: relative; width: 136px; min-height: 232px;
  background: linear-gradient(180deg, var(--parchment) 82%, #d9cba8 100%);
  color: #2b2118; border-radius: 10px; padding: 0;
  border-top: 4px solid var(--sc, var(--gold));
  box-shadow: 0 4px 10px rgba(0,0,0,.5);
  cursor: pointer; transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column;
}
.card .portrait { margin: 4px 4px 0; border-radius: 7px; overflow: hidden; background: #211d28; height: 118px; }
.card .portrait svg { display: block; width: 100%; height: 100%; }
.card .portrait img.portrait-art { width: 100%; height: 100%; object-fit: cover; object-position: 50% 8%; display: block; }
.chip .c-art img.chip-art-img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; display: block; }
.real-art.hero-art { width: 100%; height: auto; aspect-ratio: 200 / 260; object-fit: cover; display: block; }
.card .body { padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.card .cost {
  position: absolute; top: -10px; left: -6px; z-index: 3;
  width: 26px; height: 26px; display: grid; place-items: center;
  background: var(--ink); color: var(--gold); border: 1px solid var(--gold);
  border-radius: 50%; font-weight: bold; font-size: 14px;
  font-family: 'Segoe UI', sans-serif;
}
.card.playable:hover { transform: translateY(-12px); box-shadow: 0 10px 22px rgba(0,0,0,.65); z-index: 3; }
.card.dim { filter: grayscale(.65) brightness(.75); cursor: default; }
.card.playing { transform: translateY(-12px); outline: 2px solid var(--gold); }
.card .sigil {
  position: absolute; top: 4px; right: 8px; font-size: 26px; opacity: .35;
}
.card .name { font-size: 13px; font-weight: bold; text-align: center; line-height: 1.15; }
.card .type { font-size: 10px; text-align: center; color: #6d5c44; font-family: 'Segoe UI', sans-serif; }
.card .stat { font-size: 11px; text-align: center; font-family: 'Segoe UI', sans-serif; color: #4a3a28; }
.card .text { font-size: 10.5px; font-style: italic; text-align: center; color: #57452e; line-height: 1.25; }
.card .kws { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; margin-top: 2px; }
.card .kws span {
  font-size: 9px; background: #2b2118; color: var(--parchment-dim);
  padding: 1px 5px; border-radius: 6px; font-family: 'Segoe UI', sans-serif;
}
.card .fork {
  margin-top: auto; font-size: 10px; text-align: center;
  color: var(--gold); background: #2b2118; border-radius: 6px; padding: 2px 4px;
}

/* ---------------- overlay ---------------- */
#overlay {
  position: fixed; inset: 0; display: none;
  background: rgba(9, 7, 12, .82); backdrop-filter: blur(3px);
  place-items: center; z-index: 50;
}
#overlay.show { display: grid; }
.panel {
  width: min(680px, 92vw); max-height: 92vh; overflow: auto;
  background: var(--panel); border: 1px solid #3a3145; border-radius: 14px;
  padding: 28px 30px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
}
.panel h1 { letter-spacing: 5px; color: var(--parchment); font-size: 26px; }
.subtitle { color: var(--gold); margin: 6px 0 2px; font-size: 14px; }
.big-kanji { font-size: 56px; color: var(--verm); line-height: 1.1; }
.flavor { color: var(--text-dim); font-style: italic; font-size: 13.5px; margin: 12px auto; max-width: 480px; line-height: 1.5; }
.howto {
  list-style: none; margin: 10px auto 18px; max-width: 460px; text-align: left;
  font-size: 12.5px; color: var(--text); line-height: 1.5;
}
.howto li::before { content: '· '; color: var(--verm); }
button.primary {
  background: var(--verm); border-color: var(--verm); color: var(--parchment);
  font-size: 16px; padding: 12px 28px;
}
button.ghost { margin-top: 14px; font-size: 12px; color: var(--text-dim); }

.offers { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 14px 0 4px; }
.offer {
  flex: 1; min-width: 180px; max-width: 210px;
  background: var(--panel-2); border: 1px solid #3a3145; border-radius: 10px; padding: 12px;
}
.offer-head { font-size: 14px; color: var(--parchment); margin-bottom: 10px; line-height: 1.3; }
.sigil-s { color: var(--verm); font-size: 20px; margin-right: 4px; }
.offer-forks { display: flex; flex-direction: column; gap: 8px; }
.offer-forks button {
  display: flex; flex-direction: column; gap: 3px; padding: 8px 10px;
  text-align: left; font-size: 12px; line-height: 1.35;
}
.offer-forks button b { color: var(--parchment); }
.offer-forks button span { color: var(--text-dim); font-size: 11px; font-style: italic; }
.offer-forks button:hover { border-color: var(--gold); }

.stats { display: flex; gap: 26px; justify-content: center; margin: 16px 0 20px; }
.stats div { display: flex; flex-direction: column; gap: 2px; }
.stats b { font-size: 24px; color: var(--gold); font-family: 'Segoe UI', sans-serif; }
.stats span { font-size: 11px; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; }
