/* Crypt Tactics — pixel UI. Art: Minifantasy by Krishna Palacio */
:root {
  --tile: 64px;            /* 8px native x 8 */
  --scale: 8;
  --ink: #e8e0d0;
  --dim: #968ea0;
  --gold: #e8c860;
  --blood: #c83c3c;
  --bone: #d8d0b8;
  --panel: #1a1626;
  --panel2: #241e34;
  --edge: #4a4060;
  --blue: #5878d8;
  --green: #58b868;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #0a0810; color: var(--ink);
  font-family: "Courier New", Courier, monospace; }
img, .sprite, #board-bg, .title-bg, .prop, .fx, .unit, .uface
  { image-rendering: pixelated; }
button { font-family: inherit; }

.hidden { display: none !important; }
.screen { position: fixed; inset: 0; overflow: auto; display: flex;
  align-items: center; justify-content: center; }

/* ---------------- title ---------------- */
.title-bg { position: absolute; inset: 0;
  background: url("../assets/maps/title.png") center / cover no-repeat;
  filter: brightness(.45) saturate(.8); }
.title-inner { position: relative; text-align: center; padding: 40px; }
.game-title { font-size: 64px; letter-spacing: 6px; color: var(--bone);
  text-shadow: 0 4px 0 #000, 0 0 24px #38b06860; }
.game-title span { color: var(--gold); }
.tagline { color: var(--dim); margin: 8px 0 32px; letter-spacing: 2px; }
.menu { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.foot { margin-top: 40px; color: var(--dim); font-size: 12px; }

.mbtn { background: var(--panel2); color: var(--ink);
  border: 2px solid var(--edge); padding: 12px 36px; font-size: 18px;
  cursor: pointer; letter-spacing: 1px; box-shadow: 0 3px 0 #000; }
.mbtn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
.mbtn:disabled { opacity: .4; cursor: default; }
.mbtn.small { font-size: 14px; padding: 8px 20px; }
.mbtn.danger { border-color: #6a3040; }
.mbtn.danger:hover { border-color: var(--blood); color: var(--blood); }
.hard-toggle { color: var(--dim); font-size: 14px; cursor: pointer; }
.hard-toggle input { accent-color: var(--blood); margin-right: 6px; }

/* ---------------- generic panels ---------------- */
.panel { background: var(--panel); border: 2px solid var(--edge);
  box-shadow: 0 6px 0 #000, 0 0 60px #000a; padding: 28px 36px;
  max-width: 720px; text-align: center; }
.panel.wide { max-width: 980px; width: 94vw; }
.panel h2 { color: var(--gold); letter-spacing: 3px; margin-bottom: 12px; }
.panel h3 { color: var(--bone); margin-bottom: 8px; font-size: 15px;
  letter-spacing: 1px; }
.hint { color: var(--dim); margin-bottom: 16px; }
.row { display: flex; gap: 16px; justify-content: center; margin-top: 20px; }
.back-btn { margin-top: 20px; }
.big-credit { font-size: 20px; margin: 14px 0; color: var(--bone); }
#credits-body p { margin-bottom: 14px; line-height: 1.6; color: var(--dim); }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  text-align: left; font-size: 14px; }
.help-cols ul { margin: 0 0 14px 18px; }
.help-cols li { margin-bottom: 6px; line-height: 1.45; color: var(--ink); }
.help-cols h3 { margin-top: 8px; }
.hz { color: #68d878; }

/* ---------------- squad select ---------------- */
.cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px;
  margin: 10px 0; }
.card { background: var(--panel2); border: 2px solid var(--edge);
  padding: 10px 6px; cursor: pointer; position: relative; }
.card:hover { border-color: var(--dim); }
.card.picked { border-color: var(--gold); background: #2e2640;
  box-shadow: 0 0 14px #e8c86030 inset; }
.card .uface { width: 96px; height: 96px; margin: 0 auto; }
.card h4 { color: var(--bone); margin: 6px 0 2px; font-size: 15px; }
.card .crole { color: var(--gold); font-size: 11px; display: block;
  margin-bottom: 6px; }
.card .cstats { font-size: 11px; color: var(--dim); line-height: 1.5; }
.card .cab { font-size: 11px; color: #8fd0ff; margin-top: 6px;
  line-height: 1.35; min-height: 42px; }
.uface { background-repeat: no-repeat; }

/* ---------------- camp ---------------- */
.camp-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 24px;
  text-align: left; }
#camp-heroes .chero { display: grid;
  grid-template-columns: 72px 1fr auto; gap: 10px; align-items: center;
  background: var(--panel2); border: 1px solid var(--edge); padding: 8px;
  margin-bottom: 8px; }
.chero .uface { width: 72px; height: 72px; }
.chero .cinfo b { color: var(--bone); }
.chero .cinfo { font-size: 13px; line-height: 1.5; }
.chero .cinfo .hpline { color: var(--dim); }
.chero.dead-hero { opacity: .55; }
.lvl-btns { display: flex; flex-direction: column; gap: 4px; }
.lvl-btns button { background: #203028; color: var(--green);
  border: 1px solid #3a5848; padding: 4px 10px; cursor: pointer;
  font-size: 12px; }
.lvl-btns button:hover { border-color: var(--green); }
.lvl-done { color: var(--green); font-size: 12px; }
.shop-item { display: flex; justify-content: space-between; gap: 8px;
  align-items: center; background: var(--panel2);
  border: 1px solid var(--edge); padding: 8px 10px; margin-bottom: 8px;
  font-size: 13px; }
.shop-item small { color: var(--dim); display: block; }
.shop-item button { background: #302818; color: var(--gold);
  border: 1px solid #585030; padding: 4px 12px; cursor: pointer; }
.shop-item button:hover:not(:disabled) { border-color: var(--gold); }
.shop-item button:disabled { opacity: .35; cursor: default; }
.gold { color: var(--gold); }
.bag { font-size: 13px; color: var(--ink); line-height: 1.7; }

/* ---------------- mission layout ---------------- */
#screen-mission { align-items: flex-start; padding: 10px; }
#mission-layout { display: flex; gap: 12px; margin: auto; }
#stage-wrap { position: relative; }
#stage { position: relative; width: calc(var(--tile) * 12);
  height: calc(var(--tile) * 10); background: #0a0810;
  border: 2px solid var(--edge); box-shadow: 0 8px 0 #000; overflow: hidden; }
#board-bg { position: absolute; inset: 0;
  background-size: 100% 100%; background-repeat: no-repeat; }
#grid-layer, #prop-layer, #unit-layer, #fx-layer
  { position: absolute; left: var(--tile); top: var(--tile);
    width: calc(var(--tile) * 10); height: calc(var(--tile) * 8); }
#fx-layer { pointer-events: none; }
#prop-layer { pointer-events: none; }
#unit-layer { pointer-events: none; }

/* tiles */
.tile { position: absolute; width: var(--tile); height: var(--tile);
  cursor: pointer; }
.tile.t-move { background: #4878ff3d; outline: 1px solid #6890ff88;
  outline-offset: -2px; }
.tile.t-atk { background: #ff404038; outline: 1px solid #ff585888;
  outline-offset: -2px; }
.tile.t-heal { background: #40ff8038; outline: 1px solid #58ff9888;
  outline-offset: -2px; }
.tile.t-aoe { background: #ff8c2050; outline: 1px solid #ffa040aa;
  outline-offset: -2px; }
.tile.t-threat { background: #ff204018;
  box-shadow: inset 0 0 0 1px #ff3c5040; }
.tile.t-sel { outline: 2px solid var(--gold); outline-offset: -2px; }
.tile.t-exit { background: #38e8a02c; outline: 2px dashed #38e8a0aa;
  outline-offset: -3px; }
.tile.t-haz { box-shadow: inset 0 0 0 1px #58e87830; }

/* units */
.unit { position: absolute; width: calc(32px * var(--scale));
  height: calc(32px * var(--scale)); background-repeat: no-repeat;
  pointer-events: none; transition: left .12s linear, top .12s linear; }
.unit.acted { filter: grayscale(.85) brightness(.75); }
.unit.boss-shield { filter: drop-shadow(0 0 6px #b048e8)
  drop-shadow(0 0 2px #b048e8); }
.ubar { position: absolute; height: 7px; background: #100c18;
  border: 1px solid #000; }
.ubar i { display: block; height: 100%; background: var(--green);
  transition: width .2s; }
.ubar.enemy i { background: var(--blood); }
.ubadge { position: absolute; font-size: 11px; font-weight: bold;
  color: #fff; text-shadow: 0 1px 0 #000; }
.emote { position: absolute; width: 48px; height: 48px;
  background-repeat: no-repeat; pointer-events: none; z-index: 950; }

/* fx */
.fx { position: absolute; background-repeat: no-repeat;
  pointer-events: none; }
.float-num { position: absolute; font-size: 22px; font-weight: bold;
  color: #ff6868; text-shadow: 2px 2px 0 #000; z-index: 980;
  animation: floatnum 1s ease-out forwards; pointer-events: none; }
.float-num.heal-num { color: #68e888; }
.float-num.block-num { color: #a8a8c0; font-size: 16px; }
@keyframes floatnum {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-44px); opacity: 0; } }
.tracer { position: absolute; width: 14px; height: 4px;
  background: #ffe8a0; box-shadow: 0 0 8px #ffd058; z-index: 940;
  pointer-events: none; }

/* phase banner */
#phase-banner { position: absolute; left: 0; right: 0; top: 42%;
  text-align: center; font-size: 38px; letter-spacing: 8px; color: var(--bone);
  background: #000c; padding: 18px 0; z-index: 990;
  text-shadow: 0 3px 0 #000; }
#phase-banner.enemy { color: #ff7878; }

/* side panel */
#side-panel { width: 320px; display: flex; flex-direction: column; gap: 10px; }
#mission-head { background: var(--panel); border: 2px solid var(--edge);
  padding: 10px 12px; }
#mission-name { color: var(--gold); letter-spacing: 1px; font-size: 16px; }
#turn-ind { color: var(--dim); font-size: 13px; margin-top: 4px; }
#turn-ind b { color: var(--bone); }
#objective-box { background: var(--panel); border: 2px solid var(--edge);
  padding: 10px 12px; font-size: 13px; line-height: 1.5; }
#objective-box .obj-t { color: #8fd0ff; letter-spacing: 1px; }
#objective-box .obj-p { color: var(--ink); }
#objective-box .obj-warn { color: #ff9858; }

#unit-card { background: var(--panel); border: 2px solid var(--edge);
  padding: 10px 12px; font-size: 13px; }
#unit-card .uc-head { display: flex; gap: 10px; align-items: center; }
#unit-card .uface { width: 64px; height: 64px; flex: none; }
#unit-card .uc-name { color: var(--bone); font-size: 15px; }
#unit-card .uc-class { color: var(--gold); font-size: 11px; }
#unit-card .uc-hp { margin: 2px 0; }
#unit-card .uc-stats { color: var(--dim); line-height: 1.5; margin-top: 6px; }
#unit-card .uc-stats b { color: var(--ink); }
#unit-card .uc-note { color: #8fd0ff; margin-top: 4px; font-size: 12px;
  line-height: 1.4; }

#action-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.abtn { flex: 1 1 44%; background: var(--panel2); color: var(--ink);
  border: 2px solid var(--edge); padding: 8px 6px; cursor: pointer;
  font-size: 13px; }
.abtn:hover:not(:disabled) { border-color: var(--gold); }
.abtn:disabled { opacity: .4; cursor: default; }
.abtn.armed { border-color: var(--blood); color: #ff9898;
  background: #38202a; }
.abtn .cd { color: #ff9858; }
.abtn small { display: block; color: var(--dim); font-size: 10px; }

#log-box { background: var(--panel); border: 2px solid var(--edge);
  padding: 8px 10px; font-size: 12px; flex: 1; min-height: 90px;
  max-height: 200px; overflow-y: auto; color: var(--dim); line-height: 1.5; }
#log-box .l-p { color: #9fc0ff; }
#log-box .l-e { color: #ff9898; }
#log-box .l-s { color: #78e898; }
.side-foot { display: flex; gap: 8px; }
.side-foot .mbtn { flex: 1; }

/* tooltip */
#tooltip { position: fixed; background: #100c18f0;
  border: 1px solid var(--edge); padding: 8px 10px; font-size: 12px;
  pointer-events: none; z-index: 1000; max-width: 240px; line-height: 1.5; }
#tooltip b { color: var(--bone); }
#tooltip .tt-class { color: var(--gold); }
#tooltip .tt-warn { color: #ff9858; }

/* overlays */
.overlay { position: fixed; inset: 0; background: #000a; z-index: 1100;
  display: flex; align-items: center; justify-content: center; }
.overlay .panel { max-width: 560px; }
.overlay p { line-height: 1.6; margin-bottom: 10px; }
.overlay .obj { color: #8fd0ff; }
#end-title.victory { color: var(--gold); }
#end-title.defeat { color: var(--blood); }

/* props */
.prop { position: absolute; background-repeat: no-repeat;
  pointer-events: none; }

@media (max-width: 1180px) {
  :root { --tile: 48px; --scale: 6; }
}
