/* EVERMARCH — dark chronicle aesthetic */
:root {
  --bg: #14120f;
  --bg2: #1d1a16;
  --panel: #242019;
  --panel2: #2d2820;
  --ink: #e8e0d0;
  --ink-dim: #a89e8c;
  --gold: #d4a946;
  --ember: #d4622e;
  --blood: #b03a30;
  --grass: #7a9c52;
  --steel: #6f8fad;
  --good: #8fb573;
  --bad: #cf6a5a;
  --warn: #d4a946;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 15px; line-height: 1.5;
  background-image: radial-gradient(ellipse at 50% -10%, #2a2117 0%, var(--bg) 60%);
  min-height: 100vh;
}
button { font: inherit; cursor: pointer; }
a { color: var(--gold); }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }
.hidden { display: none !important; }
.muted { color: var(--ink-dim); }
.small { font-size: 13px; }

.panel {
  background: var(--panel); border: 1px solid #3a332a; border-radius: 10px;
  padding: 28px 32px; box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.btn {
  background: var(--panel2); color: var(--ink); border: 1px solid #4a4234;
  padding: 9px 18px; border-radius: 6px; transition: all .15s;
}
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:hover { border-color: #4a4234; color: var(--ink); }
.btn-primary {
  background: linear-gradient(180deg, #8a6a25, #6b5018); color: #fff3d6;
  border-color: #a8843a; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.15); color: #fff; }
.btn.small { padding: 5px 12px; font-size: 13px; }

/* ── Title ── */
#screen-title { display: none; align-items: center; justify-content: center; }
#screen-title.active { display: flex; }
.title-wrap { text-align: center; max-width: 640px; padding: 40px 20px; }
.logo {
  font-family: var(--serif); font-size: 72px; letter-spacing: 14px;
  color: var(--ink); text-shadow: 0 0 40px rgba(212,169,70,.25);
  margin-bottom: 8px;
}
.logo span { color: var(--gold); }
.tagline { color: var(--ink-dim); font-style: italic; font-family: var(--serif); margin-bottom: 36px; }
.title-actions { margin-bottom: 28px; }
.title-actions .btn { font-size: 18px; padding: 14px 34px; }
.campaign-list { display: flex; flex-direction: column; gap: 8px; max-width: 480px; margin: 0 auto 30px; }
.campaign-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); border: 1px solid #3a332a; border-radius: 8px;
  padding: 10px 16px; cursor: pointer; transition: border-color .15s; text-align: left;
}
.campaign-item:hover { border-color: var(--gold); }
.campaign-item .ci-name { font-weight: 600; }
.campaign-item .ci-sub { color: var(--ink-dim); font-size: 13px; }
.title-foot { color: #6b6354; font-size: 13px; }
.quiet-link { color: #8a8070; text-decoration: none; }
.quiet-link:hover { color: var(--gold); }
.dot { margin: 0 8px; }

/* ── Session zero ── */
#screen-setup.active { display: flex; align-items: center; justify-content: center; padding: 30px 16px; }
.setup-wrap { max-width: 640px; width: 100%; }
.setup-wrap h2 { font-family: var(--serif); margin-bottom: 4px; }
.field { display: block; margin-top: 20px; }
.field > span { display: block; font-size: 13px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 7px; }
.field input[type=text] {
  width: 100%; background: var(--bg2); color: var(--ink);
  border: 1px solid #4a4234; border-radius: 6px; padding: 10px 12px; font-size: 15px;
}
.field input[type=text]:focus { outline: none; border-color: var(--gold); }
.archetype-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.archetype {
  background: var(--bg2); border: 1px solid #4a4234; border-radius: 8px;
  padding: 12px; cursor: pointer; transition: all .15s; text-align: left;
}
.archetype:hover { border-color: var(--ink-dim); }
.archetype.selected { border-color: var(--gold); background: #2c2415; box-shadow: 0 0 0 1px var(--gold); }
.archetype h4 { font-family: var(--serif); margin-bottom: 4px; color: var(--gold); }
.archetype p { font-size: 12.5px; color: var(--ink-dim); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--bg2); border: 1px solid #4a4234; color: var(--ink-dim);
  border-radius: 999px; padding: 6px 14px; font-size: 13.5px; transition: all .15s;
}
.chip:hover { border-color: var(--ink-dim); color: var(--ink); }
.chip.selected { border-color: var(--gold); color: var(--gold); background: #2c2415; }
.setup-actions { display: flex; justify-content: space-between; margin-top: 28px; }

/* ── Briefing / Aftermath ── */
#screen-briefing.active, #screen-aftermath.active { display: flex; align-items: center; justify-content: center; padding: 30px 16px; }
.briefing-wrap, .aftermath-wrap { max-width: 720px; width: 100%; }
.briefing-kicker { color: var(--ink-dim); font-size: 13px; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 6px; }
.briefing-wrap h2, .aftermath-wrap h3 { font-family: var(--serif); font-size: 32px; margin-bottom: 14px; }
.aftermath-wrap h3 { font-size: 20px; margin-top: 22px; margin-bottom: 2px; }
.narration {
  font-family: var(--serif); font-size: 17px; line-height: 1.7; color: #ddd3bf;
  white-space: pre-wrap; margin-bottom: 16px; min-height: 54px;
}
.writing { color: var(--ink-dim); font-style: italic; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.commander-quote {
  border-left: 3px solid var(--ember); padding: 8px 16px; margin: 14px 0;
  font-family: var(--serif); font-style: italic; color: #e0b9a4; font-size: 16px;
}
.objective-card { background: var(--bg2); border: 1px solid #4a4234; border-radius: 8px; padding: 14px 18px; margin-top: 14px; }
.objective-label { font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: var(--gold); margin-bottom: 4px; }
.intel { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.intel-line { font-size: 13.5px; color: var(--ink-dim); }
.intel-line b { color: var(--warn); font-weight: 600; }
.briefing-actions, .aftermath-actions { display: flex; justify-content: space-between; margin-top: 26px; }
.am-result { font-family: var(--serif); font-size: 40px; margin-bottom: 12px; letter-spacing: 3px; }
.am-result.victory { color: var(--gold); }
.am-result.defeat { color: var(--bad); }
.consequence-list { list-style: none; margin: 12px 0 6px; display: flex; flex-direction: column; gap: 8px; }
.consequence-list li {
  background: var(--bg2); border-left: 3px solid #555; border-radius: 0 6px 6px 0;
  padding: 9px 14px; font-size: 14px; opacity: 0; transform: translateY(6px);
  animation: rise .4s forwards;
}
@keyframes rise { to { opacity: 1; transform: none; } }
.consequence-list li.good { border-left-color: var(--good); }
.consequence-list li.bad { border-left-color: var(--bad); }
.consequence-list li.warn { border-left-color: var(--warn); }
.consequence-list li.info { border-left-color: var(--steel); }
.hook { margin-top: 18px; font-family: var(--serif); font-style: italic; color: var(--warn); }

/* ── Battle ── */
#screen-battle.active { display: flex; flex-direction: column; height: 100vh; }
#battle-top {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); border-bottom: 1px solid #3a332a; padding: 8px 14px; gap: 10px;
  flex-wrap: wrap;
}
.bt-left, .bt-mid, .bt-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bt-chip {
  background: var(--bg2); border: 1px solid #4a4234; border-radius: 6px;
  padding: 4px 10px; font-size: 13px; color: var(--ink);
}
.bt-obj { color: var(--gold); max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#battle-main { flex: 1; display: flex; min-height: 0; }
#board-wrap { flex: 1; overflow: auto; position: relative; background: #0e0d0b; }
#board { display: block; margin: 0 auto; }
#zoom-toggle {
  position: absolute; top: 10px; right: 10px; z-index: 5;
  width: 32px; height: 32px; border-radius: 6px; font-size: 17px; line-height: 1;
  background: rgba(26,23,19,.85); border: 1px solid #4a4234; color: var(--ink);
  cursor: pointer;
}
#zoom-toggle:hover { border-color: var(--gold); }
#enemy-thinking {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(40,20,16,.92); border: 1px solid var(--ember); color: #e8b09a;
  padding: 8px 22px; border-radius: 999px; font-style: italic; z-index: 5;
}
#battle-side {
  width: 290px; background: var(--panel); border-left: 1px solid #3a332a;
  overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px;
}
.side-card { background: var(--bg2); border: 1px solid #3a332a; border-radius: 8px; padding: 12px; font-size: 13.5px; }
.side-card h4 { font-family: var(--serif); font-size: 16px; margin-bottom: 2px; }
.side-card .sub { color: var(--ink-dim); font-size: 12px; margin-bottom: 8px; }
.statline { display: flex; justify-content: space-between; padding: 2px 0; }
.statline .k { color: var(--ink-dim); }
.hp-bar, .xp-bar { height: 7px; background: #1a1713; border-radius: 4px; overflow: hidden; margin: 4px 0 8px; }
.hp-bar i, .xp-bar i { display: block; height: 100%; border-radius: 4px; }
.hp-bar i { background: linear-gradient(90deg, #5f9e4a, #8fb573); }
.xp-bar i { background: linear-gradient(90deg, #7a6a9e, #a89ad4); }
.atk-row { background: #1a1713; border-radius: 6px; padding: 6px 9px; margin-top: 6px; display: flex; justify-content: space-between; }
.atk-row .an { color: var(--ink); }
.atk-row .ad { color: var(--ink-dim); }
.tag { display: inline-block; background: #1a1713; border: 1px solid #3a332a; border-radius: 4px; padding: 1px 7px; font-size: 11.5px; color: var(--ink-dim); margin: 2px 3px 0 0; }
.tag.scar { border-color: #6e4038; color: #cf8a7a; }
.log-title { font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: var(--ink-dim); margin-bottom: 6px; }
#log-lines { display: flex; flex-direction: column-reverse; gap: 3px; font-size: 12.5px; color: var(--ink-dim); max-height: 30vh; overflow-y: auto; }
#log-lines div { border-bottom: 1px dotted #2c2820; padding-bottom: 3px; }
.forecast-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.forecast-col { background: #1a1713; border-radius: 6px; padding: 8px; }
.forecast-col .fc-head { font-size: 12px; color: var(--ink-dim); margin-bottom: 4px; }
.forecast-col .fc-num { font-size: 17px; }
.fc-them .fc-num { color: var(--bad); } .fc-you .fc-num { color: var(--good); }

/* ── Drawer ── */
.drawer {
  position: fixed; top: 0; right: -560px; width: 540px; max-width: 96vw; height: 100vh;
  background: var(--panel); border-left: 1px solid #4a4234; z-index: 40;
  transition: right .25s ease; overflow-y: auto; padding: 18px 22px;
  box-shadow: -16px 0 50px rgba(0,0,0,.5);
}
.drawer.open { right: 0; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.drawer-head h2 { font-family: var(--serif); font-size: 22px; }
.wd-section { margin-bottom: 20px; }
.wd-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 2px; color: var(--gold); margin-bottom: 8px; }
.region-row { display: grid; grid-template-columns: 1.4fr 0.8fr 1fr 1fr; gap: 8px; align-items: center; padding: 7px 10px; background: var(--bg2); border-radius: 6px; margin-bottom: 5px; font-size: 13px; }
.region-row .rname { font-weight: 600; }
.ctl-player { color: var(--good); } .ctl-adversary { color: var(--bad); } .ctl-neutral { color: var(--ink-dim); }
.meter { height: 6px; background: #1a1713; border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; }
.heat-wrap { background: var(--bg2); border-radius: 8px; padding: 12px; }
.heat-bar { height: 12px; background: #1a1713; border-radius: 6px; overflow: hidden; margin: 8px 0 4px; }
.heat-bar i { display: block; height: 100%; background: linear-gradient(90deg, #d4a946, #d4622e, #b03a30); transition: width .8s ease; }
.nemesis-card { background: #241a1e; border: 1px solid #5e3340; border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.nemesis-card h4 { color: #d489a0; font-family: var(--serif); }
.event-line { font-size: 13px; color: var(--ink-dim); padding: 4px 0; border-bottom: 1px dotted #2c2820; }
.memorial { font-size: 13px; color: #9a8a7a; font-style: italic; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; background: rgba(8,6,4,.7); z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-box { background: var(--panel); border: 1px solid #4a4234; border-radius: 10px; max-width: 700px; width: 94vw; max-height: 86vh; overflow-y: auto; padding: 18px 22px; }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.modal-head h3 { font-family: var(--serif); flex: 1; }
.rm-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.rm-list { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.rm-item { background: var(--bg2); border: 1px solid #3a332a; border-radius: 8px; padding: 10px 12px; cursor: pointer; transition: border-color .12s; }
.rm-item:hover { border-color: var(--ink-dim); }
.rm-item.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.rm-item.disabled { opacity: .45; cursor: default; }
.rm-item h5 { display: flex; justify-content: space-between; }
.rm-item .cost { color: var(--gold); }
.rm-item .sub { font-size: 12px; color: var(--ink-dim); }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--panel2); border: 1px solid var(--gold); color: var(--ink);
  border-radius: 8px; padding: 10px 22px; z-index: 60; transition: transform .25s; pointer-events: none;
  max-width: 80vw;
}
#toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  #battle-side { width: 230px; }
  .logo { font-size: 46px; letter-spacing: 8px; }
  .archetype-row { grid-template-columns: 1fr; }
  .rm-list { grid-template-columns: 1fr; }
}
