/* Drakon: The Bestiary of Tartarus — obsidian & gold mythic theme */
:root {
  --bg: #0b0a12;
  --bg2: #14121f;
  --panel: #1a1726;
  --panel2: #221e33;
  --line: rgba(224, 189, 124, 0.18);
  --gold: #e0bd7c;
  --gold-hi: #ffe9b0;
  --gold-dim: #8a6a2f;
  --ink: #f2ecdd;
  --ink-dim: rgba(242, 236, 221, 0.55);
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, "Segoe UI", system-ui, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#app { position: fixed; inset: 0; }

.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.on { display: flex; animation: screenIn .5s ease both; }
#screenBattle {
  background:
    radial-gradient(70% 46% at 50% 6%, rgba(224,106,74,.10), transparent 70%),
    radial-gradient(80% 60% at 50% 104%, rgba(122,58,16,.22), transparent 72%),
    linear-gradient(180deg, #12101c, #0b0a12);
}
@keyframes screenIn { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

/* ------------------------------- menu ------------------------------ */
.menu-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.menu-glow {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 42% at 50% 12%, rgba(224,189,124,.13), transparent 70%),
    radial-gradient(90% 60% at 50% 108%, rgba(122,37,16,.28), transparent 72%);
  pointer-events: none;
}
.menu-wrap {
  position: relative; margin: auto; text-align: center;
  max-width: 560px; padding: 28px 20px; z-index: 2;
}
.crest { width: 76px; margin: 0 auto 12px; animation: crestFloat 5s ease-in-out infinite; }
@keyframes crestFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.eyebrow { font-size: 10.5px; letter-spacing: .42em; text-transform: uppercase; color: var(--gold); opacity: .8; }
h1.title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(44px, 10vw, 74px); letter-spacing: .18em;
  margin: 8px 0 0; color: var(--ink);
  text-shadow: 0 0 26px rgba(224,189,124,.28);
  animation: titleGlow 4s ease-in-out infinite;
}
@keyframes titleGlow { 0%,100% { text-shadow: 0 0 22px rgba(224,189,124,.22); } 50% { text-shadow: 0 0 38px rgba(224,189,124,.4); } }
.title-sub { font-family: var(--serif); font-style: italic; font-size: clamp(15px, 3.4vw, 19px); color: var(--ink-dim); letter-spacing: .08em; }
.rule { margin: 14px 0; color: var(--gold); font-size: 12px; letter-spacing: .6em; }
.tagline { font-size: 13.5px; line-height: 1.65; color: var(--ink-dim); max-width: 440px; margin: 0 auto; }

.menu-actions { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.menu-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.btn {
  font-family: var(--sans); font-size: 13px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink); background: rgba(255,255,255,.04);
  border: 1px solid var(--line); border-radius: 3px;
  padding: 11px 22px; cursor: pointer; min-width: 120px;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.btn:hover { border-color: rgba(224,189,124,.5); background: rgba(224,189,124,.07); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn .lbl { display: flex; flex-direction: column; gap: 2px; }
.btn .lbl small { font-size: 10px; letter-spacing: .2em; color: var(--ink-dim); text-transform: none; }
.btn.gold {
  background: linear-gradient(160deg, #f0d494, #caa257 55%, #9a742c);
  border-color: #f4e2b0; color: #241a08; font-weight: 600;
  box-shadow: 0 6px 24px rgba(224,189,124,.24);
  animation: goldPulse 3.2s ease-in-out infinite;
}
@keyframes goldPulse { 0%,100% { box-shadow: 0 6px 24px rgba(224,189,124,.2); } 50% { box-shadow: 0 8px 34px rgba(224,189,124,.4); } }
.btn.gold:hover { filter: brightness(1.06); }
.btn.ghost { border-style: dashed; }
.menu-progress { margin-top: 20px; font-size: 11px; letter-spacing: .18em; color: var(--ink-dim); }
.menu-foot {
  position: relative; z-index: 2; display: flex; justify-content: space-between;
  padding: 14px 18px; font-size: 10.5px; letter-spacing: .14em; color: rgba(242,236,221,.4);
  text-transform: uppercase;
}
.hidden { display: none !important; }

/* ------------------------------- map / den ------------------------- */
.map-wrap { margin: auto; width: min(760px, 94vw); max-height: 88vh; overflow-y: auto; padding: 18px; }
.map-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; gap: 12px; }
.map-head h2 { font-family: var(--serif); font-weight: 400; font-size: 24px; letter-spacing: .06em; }
.map-head p { font-size: 12px; color: var(--ink-dim); margin-top: 3px; }
.map-back { background: none; border: 1px solid var(--line); color: var(--ink); padding: 8px 14px; border-radius: 3px; cursor: pointer; font-size: 12px; letter-spacing: .1em; }
.map-back:hover { border-color: var(--gold); }
#mapGrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.map-node {
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  padding: 10px 8px; text-align: left; cursor: pointer; color: var(--ink);
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
  position: relative;
}
.map-node:hover:not(.locked) { transform: translateY(-2px); border-color: rgba(224,189,124,.55); box-shadow: 0 8px 22px rgba(0,0,0,.4); }
.map-node b { font-family: var(--serif); font-size: 17px; color: var(--gold); }
.map-node span { font-size: 10.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-node em { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); font-style: normal; }
.map-node .stars { display: flex; gap: 3px; }
.map-node .stars i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.12); }
.map-node .stars i.lit { background: var(--gold); box-shadow: 0 0 6px rgba(224,189,124,.7); }
.map-node.locked { opacity: .38; cursor: default; filter: grayscale(.6); }
.map-node.locked b::after { content: " 🔒"; font-size: 9px; }
.map-node.boss { border-color: rgba(200,80,60,.5); }
.map-node.boss b { color: #e08a6a; }
.den-row {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  flex-wrap: wrap;
}
.den-name b { font-family: var(--serif); font-size: 16px; display: block; }
.den-name em, .den-el, .den-stats { font-size: 11.5px; color: var(--ink-dim); font-style: normal; }
.den-lead { margin-left: auto; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }

/* ------------------------------- battle ---------------------------- */
.field-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.arena {
  position: relative; z-index: 2; margin: auto; width: min(880px, 96vw);
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 84px;
}
.hud-top {
  position: absolute; top: 10px; left: 14px; right: 14px; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
}
.hud-kicker { font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: rgba(232,195,124,.85); }
.hud-items { display: flex; gap: 10px; }
.hud-items b { font-size: 12px; color: var(--ink-dim); font-weight: 500; }

.battle-card {
  display: flex; gap: 16px; align-items: center;
  background: linear-gradient(170deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px;
  position: relative; overflow: visible; min-height: 108px;
  box-shadow: 0 10px 34px rgba(0,0,0,.45);
  transition: transform .25s ease;
}
.battle-card.foe { align-self: flex-start; width: min(560px, 100%); }
.battle-card.me { align-self: flex-end; width: min(560px, 100%); flex-direction: row-reverse; text-align: right; }
.battle-card.me .card-body { display: flex; flex-direction: column; align-items: flex-end; }
.battle-card.boss { border-color: rgba(224,106,74,.55); box-shadow: 0 10px 40px rgba(160,40,20,.3); }
.card-sigil { flex: 0 0 auto; filter: drop-shadow(0 6px 12px rgba(0,0,0,.5)); }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.card-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-name b { font-family: var(--serif); font-size: 18px; letter-spacing: .04em; }
.card-name em { font-size: 11px; color: var(--ink-dim); font-style: normal; }
.el-tag { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; display: inline-flex; align-items: center; gap: 5px; }
.el-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; box-shadow: 0 0 8px currentColor; }
.boss-tag { font-size: 9px; letter-spacing: .2em; color: #ff8a6a; border: 1px solid rgba(224,106,74,.5); border-radius: 2px; padding: 2px 6px; font-style: normal; animation: bossPulse 2s ease-in-out infinite; }
@keyframes bossPulse { 0%,100% { opacity: .75; } 50% { opacity: 1; } }
.hpbar {
  position: relative; height: 14px; border-radius: 3px; overflow: hidden;
  background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.08); width: 100%; max-width: 340px;
}
.hpbar i {
  position: absolute; inset: 0; right: auto;
  transition: width .45s cubic-bezier(.22,1,.36,1);
  box-shadow: 0 0 12px rgba(255,255,255,.18) inset;
}
.hpbar span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; letter-spacing: .08em; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; min-height: 18px; }
.chip { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; border-radius: 2px; padding: 2px 7px; font-style: normal; animation: chipIn .3s ease both; }
@keyframes chipIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.chip-burn { background: rgba(224,102,58,.2); color: #ff9d6e; border: 1px solid rgba(224,102,58,.5); }
.chip-poison { background: rgba(120,180,80,.16); color: #a8d98a; border: 1px solid rgba(120,180,80,.45); }
.chip-stun { background: rgba(230,230,140,.14); color: #f0e68a; border: 1px solid rgba(230,230,140,.4); }
.chip-guard { background: rgba(140,190,230,.14); color: #a8ccf0; border: 1px solid rgba(140,190,230,.4); }
.chip-rage { background: rgba(220,60,60,.16); color: #ff8a8a; border: 1px solid rgba(220,60,60,.5); }

.vs-rune { text-align: center; color: var(--gold-dim); font-size: 15px; letter-spacing: .4em; }

/* battle animations */
.battle-card.lunge { animation: lungeP .26s ease; }
.battle-card.lunge-up { animation: lungeF .26s ease; }
@keyframes lungeP { 40% { transform: translateY(-14px); } }
@keyframes lungeF { 40% { transform: translateY(14px); } }
.battle-card.hurt { animation: hurtShake .3s ease; }
@keyframes hurtShake {
  20% { transform: translateX(-7px); filter: brightness(1.4) saturate(1.6); }
  50% { transform: translateX(6px); }
  80% { transform: translateX(-3px); }
}
.battle-card.faint { opacity: .25; filter: grayscale(1); transition: all .4s ease; }
.battle-card.captured { animation: capturedFlash 1s ease; }
@keyframes capturedFlash { 30% { filter: brightness(2.2) sepia(.6); } 60% { filter: brightness(1.6); } }
.pop {
  position: absolute; top: 8%; font-family: var(--serif); font-size: 22px; font-weight: 700;
  pointer-events: none; z-index: 6;
  animation: popUp .85s ease both;
  text-shadow: 0 2px 10px rgba(0,0,0,.7);
}
.pop.crit { color: #ffb347; font-size: 28px; }
.pop.super { color: #ffd76e; }
.pop.weak { color: #9a9a9a; }
.pop.heal { color: #9be8a0; }
.pop.tick { color: #d0a0e0; font-size: 17px; }
@keyframes popUp { 0% { opacity: 0; transform: translateY(6px) scale(.7); } 25% { opacity: 1; transform: translateY(-10px) scale(1.1); } 100% { opacity: 0; transform: translateY(-34px) scale(1); } }

.battle-log {
  position: relative; z-index: 2; text-align: center; font-size: 13px; font-style: italic;
  color: var(--ink-dim); min-height: 20px; padding: 4px 14px;
  transition: opacity .2s ease;
}
.battle-actions { position: relative; z-index: 2; width: min(880px, 96vw); margin: 0 auto 16px; display: flex; flex-direction: column; gap: 8px; }
.ab-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ab-btn {
  --ab: #e0bd7c;
  background: linear-gradient(170deg, var(--panel), var(--panel2));
  border: 1px solid rgba(255,255,255,.08); border-left: 3px solid var(--ab);
  border-radius: 4px; color: var(--ink); padding: 10px 10px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.ab-btn:hover { transform: translateY(-2px); border-color: var(--ab); box-shadow: 0 6px 18px rgba(0,0,0,.4), 0 0 14px color-mix(in srgb, var(--ab) 30%, transparent); }
.ab-btn:active { transform: scale(.97); }
.ab-btn b { font-size: 12.5px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-btn em { font-size: 10px; color: var(--ink-dim); font-style: normal; }
.ab-key {
  position: absolute; font-size: 9px; color: rgba(255,255,255,.3); margin-top: -2px;
}
.ab-btn { position: relative; }
.ab-key { top: 4px; right: 6px; margin: 0; }
.item-row { display: flex; gap: 8px; align-items: center; }
.item-btn {
  flex: 1; background: rgba(255,255,255,.03); border: 1px dashed var(--line);
  color: var(--ink); border-radius: 4px; padding: 9px 10px; font-size: 12px; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.item-btn em { color: var(--gold); font-style: normal; margin-left: 4px; }
.item-btn:hover:not(:disabled) { border-color: var(--gold); background: rgba(224,189,124,.06); }
.item-btn:disabled { opacity: .35; cursor: default; }
.icon-btn {
  background: none; border: 1px solid var(--line); color: var(--ink-dim); border-radius: 4px;
  width: 38px; height: 38px; font-size: 14px; cursor: pointer; flex: 0 0 auto;
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ------------------------------ overlays --------------------------- */
.overlay {
  position: absolute; inset: 0; z-index: 20; display: none;
  align-items: center; justify-content: center;
  background: rgba(5,4,10,.78); backdrop-filter: blur(6px);
}
.overlay.on { display: flex; animation: ovIn .3s ease both; }
@keyframes ovIn { from { opacity: 0; } to { opacity: 1; } }
.panel {
  width: min(520px, 92vw); max-height: 90vh; overflow-y: auto;
  background: linear-gradient(175deg, #1c1930, #14121f);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 28px 26px; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.03) inset;
  animation: panelIn .35s cubic-bezier(.22,1,.36,1) both;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
.panel.wide { width: min(680px, 94vw); }
.kicker { font-size: 10px; letter-spacing: .34em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; }
.panel h2 { font-family: var(--serif); font-weight: 400; font-size: 26px; letter-spacing: .04em; margin-bottom: 10px; }
.panel .line { font-size: 13.5px; line-height: 1.7; color: var(--ink-dim); }
.panel .tip { font-size: 12px; line-height: 1.6; color: rgba(232,195,124,.85); margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.stars { margin: 14px 0 4px; font-size: 22px; letter-spacing: .3em; }
.star { color: rgba(255,255,255,.14); transition: color .3s ease, text-shadow .3s ease; }
.star.lit { color: var(--gold); text-shadow: 0 0 14px rgba(224,189,124,.8); animation: starPop .5s cubic-bezier(.22,1.4,.36,1) both; }
.star.lit:nth-child(2) { animation-delay: .12s; }
.star.lit:nth-child(3) { animation-delay: .24s; }
@keyframes starPop { from { transform: scale(0); } to { transform: scale(1); } }
.actions { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-top: 20px; }
.pause-stats { font-size: 12.5px; color: var(--ink-dim); }
.result-stats { margin-top: 12px; display: flex; flex-direction: column; gap: 5px; }
.result-stats p { font-size: 13px; color: var(--ink-dim); }
.result-stats b { color: var(--gold-hi); }
.panel.how { text-align: left; }
.panel.how ol { padding-left: 18px; display: flex; flex-direction: column; gap: 9px; }
.panel.how li { font-size: 12.5px; line-height: 1.6; color: var(--ink-dim); }
.panel.how li b { color: var(--ink); }
.keys { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; justify-content: center; }
.kbd { font: 11px/1 var(--sans); background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 3px; padding: 4px 8px; color: var(--ink-dim); }

.starter-row, .foe-row, .switch-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0 4px; }
.starter-card {
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 6px;
  padding: 14px 12px; width: 150px; cursor: pointer; color: var(--ink); text-align: center;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.starter-card:hover { transform: translateY(-4px); box-shadow: 0 14px 34px rgba(0,0,0,.5); }
.starter-card b { font-family: var(--serif); font-size: 15px; }
.starter-card .el-tag { font-size: 9.5px; letter-spacing: .2em; }
.starter-card p { font-size: 10.5px; line-height: 1.5; color: var(--ink-dim); }
.foe-chip {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px;
}
.foe-chip b { font-size: 12.5px; font-family: var(--serif); }
.foe-chip em { font-size: 10.5px; color: var(--ink-dim); font-style: normal; }
.foe-chip.boss { border-color: rgba(224,106,74,.5); }
.foe-chip.boss b { color: #e08a6a; }
.sw-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 14px; cursor: pointer; color: var(--ink); min-width: 110px;
  transition: transform .15s ease, border-color .15s ease;
}
.sw-card:hover { transform: translateY(-3px); border-color: var(--gold); }
.sw-card b { font-family: var(--serif); font-size: 14px; }
.sw-card em, .sw-card span { font-size: 10.5px; color: var(--ink-dim); font-style: normal; }

/* ------------------------------ responsive -------------------------- */
@media (max-width: 640px) {
  .ab-grid { grid-template-columns: repeat(2, 1fr); }
  .battle-card { padding: 10px 12px; min-height: 0; gap: 10px; }
  .card-sigil svg { width: 72px; height: 72px; }
  .card-name b { font-size: 15px; }
  .battle-card.foe, .battle-card.me { width: 100%; }
  #mapGrid { grid-template-columns: repeat(3, 1fr); }
  .hud-top { flex-direction: column; gap: 4px; align-items: flex-start; }
}
@media (max-width: 400px) {
  #mapGrid { grid-template-columns: repeat(2, 1fr); }
  .item-row { flex-wrap: wrap; }
  .item-btn { flex: 1 1 40%; }
}
@media (orientation: landscape) and (max-height: 480px) {
  .arena { flex-direction: row; align-items: stretch; }
  .battle-card { flex: 1; min-height: 0; }
  .vs-rune { align-self: center; }
  .battle-card.foe, .battle-card.me { width: 100%; }
}
