html, body {
  margin: 0; padding: 0;
  background: #0c0d15;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Courier New', monospace;
  color: #f4f4f4;
  image-rendering: pixelated;
  -webkit-text-size-adjust: 100%;
  touch-action: none;
}
/* #stage fills the viewport and centers the (scaled) game */
#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #0c0d15;
}
/* the game is authored at 960x640 and CSS-scaled to fit any screen */
#wrap {
  position: relative;
  width: 960px;
  height: 640px;
  flex: 0 0 auto;
  transform-origin: center center;
}
canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #1a1c2c;
  border: 4px solid #41434f;
  box-sizing: border-box;
  width: 960px; height: 640px;
}

/* ---- overlays ---- */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 18, 30, 0.82);
  z-index: 10;
}
.overlay-bottom {
  position: absolute; left: 24px; right: 24px; bottom: 20px;
  background: #262b44;
  border: 4px solid #f4f4f4;
  box-shadow: 0 0 0 4px #1a1c2c;
  padding: 14px 18px 18px;
  z-index: 20;
  min-height: 84px;
}

/* ---- title ---- */
.title-card { text-align: center; }
/* a slight Bowe Advisory wordmark — understated, navy & gold */
.title-eyebrow {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  color: #cbb27a; font-size: 14px; font-weight: bold; letter-spacing: 5px;
  margin-bottom: 10px; text-transform: uppercase;
}
.title-eyebrow .ba-mark { color: #7e8aa6; font-weight: normal; letter-spacing: 3px; font-size: 12px; }
.title-eyebrow .ba-rule { display: inline-block; width: 46px; height: 2px; background: linear-gradient(90deg, transparent, #cbb27a); }
.title-eyebrow .ba-rule:last-child { background: linear-gradient(90deg, #cbb27a, transparent); }
.title-byline { color: #7e8aa6; margin-top: 18px; font-size: 13px; letter-spacing: 1px; }
.title-byline b { color: #cbb27a; letter-spacing: 3px; }
.title-cross { font-size: 56px; color: #ffd866; text-shadow: 3px 3px 0 #73402c; }
.title-card h1 {
  font-size: 52px; letter-spacing: 6px; margin: 8px 0 4px;
  color: #ffd866; text-shadow: 4px 4px 0 #b13e53, 8px 8px 0 #1a1c2c;
}
.subtitle { color: #94b0c2; margin-bottom: 28px; }
.title-menu button {
  display: block; margin: 10px auto; padding: 10px 38px;
  font-family: inherit; font-size: 20px; font-weight: bold;
  letter-spacing: 3px; cursor: pointer;
  background: #3b5dc9; color: #f4f4f4;
  border: 4px solid #f4f4f4; box-shadow: 4px 4px 0 #1a1c2c;
}
.title-menu button:hover { background: #4f7df0; transform: translate(-1px,-1px); }
.controls-hint { color: #566c86; margin-top: 26px; font-size: 13px; }

/* ---- save slots on the title screen ---- */
.title-menu .slot-row { display: flex; gap: 8px; align-items: stretch; justify-content: center; margin: 8px auto; max-width: 480px; }
.title-menu .slot-btn { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  font-family: inherit; cursor: pointer; padding: 9px 16px; margin: 0; text-align: left;
  background: #3b5dc9; color: #f4f4f4; border: 3px solid #f4f4f4; box-shadow: 3px 3px 0 #1a1c2c; }
.title-menu .slot-btn:hover { background: #4f7df0; transform: translate(-1px,-1px); }
.title-menu .slot-btn b { font-size: 16px; letter-spacing: 2px; }
.slot-meta { font-size: 12px; color: #d2dae4; font-weight: normal; letter-spacing: 1px; }
.title-menu .slot-del { width: 46px; margin: 0; cursor: pointer; font-family: inherit; font-weight: bold; font-size: 16px;
  background: #7a2f34; color: #f4f4f4; border: 3px solid #f4f4f4; box-shadow: 3px 3px 0 #1a1c2c; }
.title-menu .slot-del:hover { background: #b13e53; }

/* ---- character builder ---- */
.builder-card {
  background: #262b44; border: 4px solid #f4f4f4;
  box-shadow: 0 0 0 4px #1a1c2c;
  padding: 18px 24px 22px; width: 700px; max-width: 92%;
  max-height: 92%; overflow-y: auto;
}
.builder-card h2 { margin: 0 0 14px; color: #ffd866; letter-spacing: 3px; text-align: center; }
.builder-body { display: flex; gap: 22px; }
.builder-preview { flex: 0 0 168px; text-align: center; }
#builder-canvas {
  image-rendering: pixelated; width: 128px; height: 128px;
  background: #3f8d4d; border: 3px solid #1a1c2c; box-shadow: 0 0 0 3px #41434f;
}
#builder-fw-name { color: #a7f070; font-weight: bold; margin-top: 12px; font-size: 15px; min-height: 18px; }
#builder-fw-blurb { color: #94b0c2; font-size: 12px; line-height: 1.4; margin-top: 4px; }
#builder-opts { flex: 1 1 auto; }
.bld-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-bottom: 1px solid #3a4466;
}
.bld-row .bld-label { color: #cfd3dc; font-size: 14px; width: 96px; flex: 0 0 auto; }
.bld-row .bld-val { color: #ffd866; font-size: 14px; flex: 1 1 auto; text-align: center; }
.bld-arrow {
  font-family: inherit; font-weight: bold; font-size: 16px;
  background: #3b5dc9; color: #f4f4f4; border: 2px solid #f4f4f4;
  width: 30px; height: 28px; cursor: pointer; flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.bld-arrow:active { transform: translateY(1px); }
.bld-row .bld-name {
  flex: 1 1 auto; min-width: 0; text-align: center;
  font-family: inherit; font-size: 14px; color: #ffd866;
  background: #1a1c2c; border: 2px solid #3b5dc9; outline: none;
  padding: 4px 8px; -webkit-tap-highlight-color: transparent;
}
.bld-row .bld-name:focus { border-color: #ffd866; }
.bld-row .bld-name::placeholder { color: #566c86; }
.bld-sw {
  display: inline-block; width: 18px; height: 18px; border: 2px solid #1a1c2c;
  vertical-align: middle; margin-left: 6px;
}
#btn-begin {
  display: block; margin: 18px auto 0; padding: 10px 34px;
  font-family: inherit; font-size: 18px; font-weight: bold; letter-spacing: 2px;
  background: #3f8d4d; color: #f4f4f4; border: 4px solid #f4f4f4;
  box-shadow: 4px 4px 0 #1a1c2c; cursor: pointer;
}
#btn-begin:hover { background: #57b85a; }

/* ---- dialogue ---- */
#dlg-speaker {
  display: inline-block;
  background: #ffd866; color: #1a1c2c;
  font-weight: bold; padding: 2px 10px;
  margin: -26px 0 8px -6px;
  border: 3px solid #1a1c2c;
}
#dlg-speaker:empty { display: none; }
#dlg-text { font-size: 17px; line-height: 1.5; white-space: pre-wrap; }
#dlg-more { text-align: right; color: #ffd866; animation: bob 0.7s infinite alternate; }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(4px); } }
#dlg-choices { margin-top: 10px; }
.dlg-choice { padding: 3px 8px; font-size: 16px; color: #94b0c2; }
.dlg-choice.sel { color: #ffd866; background: #3a4466; }
.dlg-choice.sel::before { content: "\25B6 "; }
.dlg-choice.locked { color: #566c86; font-style: italic; }
.dlg-choice.locked.sel { color: #566c86; background: transparent; }

/* ---- panel (quest board / report / assignments) ---- */
#panel-card {
  background: #262b44; border: 4px solid #f4f4f4;
  box-shadow: 0 0 0 4px #1a1c2c;
  padding: 22px 30px; min-width: 560px; max-width: 760px;
  max-height: 520px; overflow-y: auto;
  /* always reserve the scrollbar gutter so a short panel (e.g. Relics) lines up
     with a tall one that scrolls — the frame/content width stays identical */
  scrollbar-gutter: stable;
}
/* Character-menu hub views (Character / Inventory / Skills / Relics / Help) share
   ONE fixed footprint so switching tabs never resizes the window. Content scrolls
   inside if it's taller. */
#panel-card.panel-hub {
  box-sizing: border-box;
  width: 720px; min-width: 720px; max-width: 720px;
  height: 520px; max-height: 520px;
}
#panel-card h2 {
  margin: 0 0 14px; color: #ffd866; letter-spacing: 2px;
  border-bottom: 3px solid #3a4466; padding-bottom: 8px;
}
#panel-card h3 { color: #a7f070; margin: 14px 0 4px; }
#panel-card .quest { margin-bottom: 12px; }
#panel-card .quest .qdesc { color: #94b0c2; font-size: 14px; }
#panel-card .qdone { color: #566c86; text-decoration: line-through; }
#panel-card .row { display: flex; justify-content: space-between; padding: 3px 6px; }
#panel-card .row.sel { background: #3a4466; color: #ffd866; }

/* ---- split list + side detail popout (upgrade/build menus) ----
   Fixed geometry so selecting different items NEVER resizes the menu: the list
   column and the detail box are both fixed-size and scroll internally. */
#panel-card .panel-split { display: flex; gap: 14px; align-items: stretch; margin-top: 6px; width: 664px; height: 340px; }
#panel-card .panel-list { flex: 0 0 410px; width: 410px; overflow-y: auto; overflow-x: hidden; position: relative; }
#panel-card .panel-detail {
  flex: 0 0 240px; height: 340px; box-sizing: border-box; overflow-y: auto; overflow-x: hidden;
  background: rgba(16,18,30,0.55); border: 2px solid #3a4466; border-radius: 4px;
  padding: 12px 14px; color: #cfd3dc; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere;
}
#panel-card .panel-detail .pd-title { color: #ffd866; font-weight: bold; letter-spacing: 1px; margin-bottom: 8px; }
#panel-card .panel-detail .pd-benefit { color: #a7f070; }
#panel-card .panel-detail .pd-cost { color: #ffd866; margin-top: 8px; }
#panel-card .panel-detail .pd-note { color: #94b0c2; font-style: italic; margin-top: 8px; }
/* ---- Character View paper-doll: the pastor with equipment slots on the body ---- */
#panel-card .char-sheet { display: flex; gap: 18px; align-items: flex-start; margin: 8px 0 4px; }
#panel-card .char-doll { position: relative; width: 132px; height: 132px; flex: 0 0 132px;
  background: radial-gradient(circle at 50% 42%, rgba(125,185,232,0.14), rgba(16,18,30,0.2) 70%);
  border: 2px solid #3a4466; border-radius: 6px; }
#panel-card .char-doll canvas { position: absolute; top: 6px; left: 6px; width: 120px; height: 120px; image-rendering: pixelated; }
#panel-card .doll-slot { position: absolute; min-width: 22px; height: 22px; padding: 0 4px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1;
  background: rgba(16,18,30,0.88); border: 1px solid #7884a4; border-radius: 4px; color: #f4f4f4; }
#panel-card .doll-slot.empty { color: #566c86; border-style: dashed; border-color: #3a4466; }
#panel-card .char-meters { flex: 1 1 auto; min-width: 0; }
#panel-card .grade { font-weight: bold; font-size: 18px; }
#panel-card .ga { color: #a7f070; } #panel-card .gb { color: #ffd866; }
#panel-card .gc { color: #ef7d57; } #panel-card .gd, #panel-card .gf { color: #b13e53; }
#panel-card .delta-up { color: #a7f070; } #panel-card .delta-down { color: #b13e53; }
#panel-card .hint { color: #566c86; font-size: 13px; margin-top: 14px; }
#panel-card .verse { color: #94b0c2; font-style: italic; font-size: 14px; margin-top: 12px; }
/* small "?" help badge — hover for the tooltip, click to toast the description */
.help-q { display: inline-block; width: 17px; height: 17px; line-height: 16px; text-align: center;
  border-radius: 50%; background: #3a4466; color: #ffd866; font-size: 11px; font-weight: bold;
  cursor: help; vertical-align: middle; user-select: none; }
.help-q:hover { background: #4a5680; color: #fff; }
.siteplan-wrap { text-align: center; margin: 6px 0 10px; }
#siteplan {
  image-rendering: pixelated;
  width: 420px; max-width: 100%; height: auto;
  border: 3px solid #1a1c2c; box-shadow: 0 0 0 3px #41434f;
  background: #1a1c2c;
}
#plan-info { min-height: 34px; }

/* ---- toast ---- */
#toast {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  background: #1a1c2c; color: #ffd866;
  border: 3px solid #ffd866; padding: 6px 18px;
  font-size: 15px; font-weight: bold; z-index: 30;
  white-space: nowrap;
}

/* ---- Sunday live feed (right side): scrolling concerns & resolutions ---- */
#sundayfeed {
  position: absolute; top: 108px; right: 12px; width: 260px;
  max-height: 300px; z-index: 28;
  background: rgba(16,18,30,0.78);
  border: 2px solid rgba(120,132,164,0.55);
  border-radius: 4px; padding: 6px 8px 8px;
  display: flex; flex-direction: column;
}
#sundayfeed-title {
  color: #ffd866; font-size: 12px; font-weight: bold;
  letter-spacing: 1px; padding: 2px 2px 6px;
  border-bottom: 1px solid rgba(120,132,164,0.4); margin-bottom: 4px;
}
#sundayfeed-list {
  overflow-y: auto; max-height: 250px;
  display: flex; flex-direction: column; gap: 3px;
  scrollbar-width: thin; scrollbar-color: #566c86 transparent;
}
#sundayfeed-list::-webkit-scrollbar { width: 6px; }
#sundayfeed-list::-webkit-scrollbar-thumb { background: #566c86; border-radius: 3px; }
.sf-item {
  font-size: 12px; line-height: 1.25; padding: 3px 5px;
  border-left: 3px solid #566c86; background: rgba(8,10,20,0.5);
  color: #cfd3dc; word-break: break-word;
}
.sf-warn { border-left-color: #ef7d57; color: #ffcdb6; }
.sf-fail { border-left-color: #b13e53; color: #f0a8b6; }
.sf-ok   { border-left-color: #a7f070; color: #cdeaa8; }
.sf-info { border-left-color: #7db9e8; color: #c4ddf2; }

/* ---- viewport-fixed toolbar (INV / SKILLS), always available ---- */
#toolbar {
  position: fixed; top: 8px; right: 10px;
  display: flex; gap: 8px; z-index: 50;
}
.tb-btn {
  font-family: inherit; font-weight: bold; font-size: 18px; line-height: 1;
  color: #cfd3dc; background: rgba(16,18,30,0.86);
  border: 2px solid #41434f; border-radius: 6px;
  width: 36px; height: 34px; padding: 0; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.tb-btn:hover { color: #ffd866; border-color: #ffd866; }
.tb-btn:active { transform: translateY(1px); }

/* ---- touch controls (hidden unless body.touch) ---- */
#touch { display: none; }
body.touch #touch {
  display: block;
  position: fixed; inset: 0;
  pointer-events: none; z-index: 45;
}
#dpad {
  position: absolute; left: max(16px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 168px; height: 168px;
}
#dpad .td {
  position: absolute; width: 56px; height: 56px;
  font-size: 22px; color: #f4f4f4;
  background: rgba(38,43,68,0.82); border: 2px solid #6b7185; border-radius: 10px;
  pointer-events: auto; user-select: none; -webkit-tap-highlight-color: transparent;
  display: flex; align-items: center; justify-content: center;
}
#dpad .td:active { background: rgba(91,109,201,0.92); }
#dpad .up    { left: 56px; top: 0; }
#dpad .left  { left: 0; top: 56px; }
#dpad .right { left: 112px; top: 56px; }
#dpad .down  { left: 56px; top: 112px; }
#abtns {
  position: absolute; right: max(20px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 14px;
}
#abtns .ta {
  pointer-events: auto; user-select: none; -webkit-tap-highlight-color: transparent;
  border-radius: 50%; border: 2px solid #6b7185;
  background: rgba(38,43,68,0.82); color: #f4f4f4;
  display: flex; align-items: center; justify-content: center;
}
#abtns .ta { width: 56px; height: 56px; font-size: 18px; }
#abtns .ta.big { width: 84px; height: 84px; font-size: 30px; font-weight: bold;
  background: rgba(59,93,201,0.85); border-color: #ffd866; color: #ffd866; }
#abtns .ta:active { transform: translateY(2px); }

/* Character-menu hub: clickable/tappable tab bar (Character/Inventory/Skills/Relics/Help) */
.menu-tabs { display: flex; gap: 4px; margin: 0 0 8px; flex-wrap: wrap; }
.menu-tab {
  flex: 1 1 auto; min-width: 64px; padding: 7px 8px; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: bold; letter-spacing: 0.5px;
  background: #1a1f33; color: #94b0c2; border: 1px solid #3a4466; border-radius: 4px;
}
.menu-tab:hover { background: #232a44; color: #cfd3dc; }
.menu-tab.active { background: #3b5dc9; color: #ffd866; border-color: #ffd866; }
.menu-tab:active { transform: translateY(1px); }

/* Quick-item pouch slots in the Character View — clickable to assign (not eat) */
.pouch-slot {
  display: inline-block; min-width: 70px; margin: 2px 8px 2px 0; padding: 4px 9px; cursor: pointer;
  font-family: inherit; font-size: 13px; color: #cfd3dc;
  background: #10121c; border: 1px solid #3a4466; border-radius: 4px; text-align: left;
}
.pouch-slot:hover { background: #232a44; border-color: #7db9e8; }
.pouch-slot:active { transform: translateY(1px); }

/* Relics view — normal slots + the special Mantle slot */
.relic-slots { display: flex; gap: 6px; margin: 4px 0 8px; flex-wrap: wrap; }
.relic-slot {
  width: 40px; height: 40px; border: 2px solid #3a4466; border-radius: 5px;
  background: #10121c; display: flex; align-items: center; justify-content: center;
}
.relic-slot.filled { border-color: #a7f070; }
.relic-slot.mantle { border-color: #b98cff; width: 46px; height: 46px; }
.relic-slot.mantle.filled { border-color: #ffd866; box-shadow: 0 0 6px rgba(255,216,102,0.5); }
.relic-slot img { width: 30px; height: 30px; image-rendering: pixelated; }
