/* ── Sundown Reaches · tack-and-leather UI ─────────────────────────────────── */
@font-face { font-family: 'Rye'; src: url('../fonts/rye.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Special Elite'; src: url('../fonts/special-elite.woff2') format('woff2'); font-display: swap; }

:root {
  --leather: #2a1a10;
  --leather2: #4a2e1b;
  --brass: #c8a24a;
  --parch: #e8d5a8;
  --ink: #3a2a18;
  --blood: #8c2f1d;
  --gold: #d9a53f;
  --hud: #f0dfb8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #1a0f08; }
body { font-family: 'Special Elite', 'Courier New', monospace; color: var(--hud); }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }

/* damage vignette */
#dmgvig { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 30;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(140,20,10,0.55) 100%); }
#dmgvig.hit { animation: dmgflash 0.6s ease-out; }
@keyframes dmgflash { 0% { opacity: 1; } 100% { opacity: 0; } }

#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 1.2s; z-index: 90; }
#fade.on { opacity: 1; pointer-events: all; }

/* ── HUD ── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#hud > * { position: absolute; }

#compass { left: 50%; top: 10px; transform: translateX(-50%); }
#wanted { left: 50%; top: 58px; transform: translateX(-50%); color: #ff5a3a; font-size: 20px;
  letter-spacing: 4px; text-shadow: 0 0 8px rgba(255,60,20,0.6); font-family: Georgia, serif; }
#wanted .bounty { color: #ffb060; font-size: 13px; letter-spacing: 1px; margin-left: 8px; }

#banner { left: 50%; top: 18%; transform: translateX(-50%); text-align: center; opacity: 0;
  transition: opacity 1.2s; }
#banner.in { opacity: 1; }
#banner h1 { font-family: 'Rye', Georgia, serif; font-size: 44px; letter-spacing: 6px; color: var(--parch);
  text-shadow: 0 2px 0 #2a1a10, 0 0 24px rgba(217,165,63,0.4); }
#banner-sub { font-size: 14px; letter-spacing: 3px; color: var(--brass); margin-top: 4px; }

#cores { left: 18px; bottom: 16px; }
#coreCanvas { display: block; }
#horseBar { width: 110px; height: 5px; background: rgba(20,12,6,0.6); border: 1px solid var(--leather2);
  border-radius: 3px; margin-left: 10px; margin-top: -4px; transition: opacity 0.4s; }
#horseBar i { display: block; height: 100%; background: var(--gold); border-radius: 3px; transition: width 0.3s; }

#purse { right: 20px; top: 14px; text-align: right; }
#money { font-family: Georgia, serif; font-size: 20px; color: var(--parch); text-shadow: 0 1px 0 #000; }
#honorChip { display: block; font-size: 11px; letter-spacing: 1px; opacity: 0.9; margin-top: 2px; }

#ammo { right: 20px; bottom: 18px; text-align: right; font-family: Georgia, serif; }
#ammoMag { font-size: 30px; color: var(--parch); }
#ammoRes { font-size: 14px; color: var(--brass); margin-left: 4px; }
#weaponName { font-size: 11px; letter-spacing: 1px; opacity: 0.8; }

#reticle { left: 50%; top: 50%; transform: translate(-50%,-50%); opacity: 0; transition: opacity 0.15s; }
#ret-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--parch); box-shadow: 0 0 4px #000, 0 0 0 10px rgba(0,0,0,0); margin: auto; }
#ret-x { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%) scale(0.5); color: #ff7a50;
  font-size: 18px; opacity: 0; }
#ret-x.show { opacity: 1; transform: translate(-50%,-50%) scale(1.3); transition: transform 0.1s; }

#prompt { left: 50%; bottom: 15%; transform: translateX(-50%); font-size: 16px;
  background: rgba(26,15,8,0.72); border: 1px solid var(--leather2); padding: 7px 18px; border-radius: 3px;
  text-shadow: 0 1px 0 #000; }
#prompt:empty, #promptAlt:empty { display: none; }
#prompt b { color: var(--parch); }
#promptAlt { left: 50%; bottom: calc(15% - 34px); transform: translateX(-50%); font-size: 13px;
  background: rgba(40,16,10,0.72); border: 1px solid #6a2a1a; padding: 5px 14px; border-radius: 3px; color: #e8a080; }

#toasts { left: 18px; bottom: 140px; width: 300px; }
.toast { margin-top: 6px; padding: 7px 12px; background: rgba(26,15,8,0.78); border-left: 3px solid var(--brass);
  font-size: 13px; opacity: 0; transform: translateX(-12px); transition: all 0.4s; }
.toast.in { opacity: 1; transform: none; }
.toast.gain { border-color: #7ab84a; }
.toast.warn { border-color: #d9a53f; }
.toast.wanted { border-color: #d94a2a; color: #ffb9a0; }

#objective { left: 50%; top: 76px; transform: translateX(-50%); font-size: 13px; color: var(--brass);
  text-shadow: 0 1px 0 #000; letter-spacing: 1px; }
#clockChip { left: 20px; top: 14px; font-size: 12px; color: var(--brass); letter-spacing: 1px; text-shadow: 0 1px 0 #000; }

.bubble { position: fixed; transform: translate(-50%, -100%); background: rgba(232,213,168,0.92); color: #2a1a10;
  font-size: 12px; padding: 4px 10px; border-radius: 8px; pointer-events: none; max-width: 240px;
  border: 1px solid #8a6a3a; box-shadow: 0 2px 6px rgba(0,0,0,0.4); z-index: 25; }
.bubble b { color: #7a4018; margin-right: 4px; font-family: Georgia, serif; }
.bubble.law { background: #d8d0e0; }
.bubble:after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -4px;
  border: 4px solid transparent; border-top-color: rgba(232,213,168,0.92); }

/* ── modals / panels ── */
#modal { position: fixed; inset: 0; display: none; z-index: 40; background: rgba(10,6,3,0.55); }
#modal.open { display: flex; align-items: center; justify-content: center; }
.panel { position: relative; min-width: 420px; max-width: 720px; max-height: 86vh; overflow: auto;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.04), transparent 40%),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.06) 0 2px, transparent 2px 6px),
    var(--leather);
  border: 2px solid var(--leather2); outline: 1px solid var(--brass); outline-offset: -6px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.7), inset 0 0 80px rgba(0,0,0,0.45);
  padding: 26px 30px; border-radius: 4px; }
.panel h2 { font-family: 'Rye', Georgia, serif; color: var(--brass); letter-spacing: 3px; font-size: 24px;
  border-bottom: 1px solid var(--leather2); padding-bottom: 10px; margin-bottom: 14px; }
.panel h3 { font-family: Georgia, serif; color: var(--parch); letter-spacing: 2px; font-size: 15px; margin-bottom: 8px; }
.xbtn { position: absolute; right: 12px; top: 12px; background: none; border: 1px solid var(--leather2);
  color: var(--parch); width: 28px; height: 28px; cursor: pointer; font-size: 13px; border-radius: 3px; }
.xbtn:hover { background: var(--leather2); }
.dim { color: #a89878; font-size: 13px; }

.wbtn { font-family: 'Special Elite', monospace; font-size: 14px; letter-spacing: 1px; cursor: pointer;
  background: linear-gradient(180deg, #5a3a22, #3a2415); color: var(--parch); border: 1px solid var(--brass);
  padding: 9px 18px; border-radius: 3px; margin: 4px 6px 4px 0; text-shadow: 0 1px 0 #000;
  box-shadow: 0 2px 0 #1a0f08; }
.wbtn:hover { background: linear-gradient(180deg, #6a4a2c, #4a2e1b); }
.wbtn.gold { border-color: var(--gold); color: var(--gold); }
.wbtn.danger { border-color: #a04030; color: #e8a090; }
.wbtn.big { font-size: 20px; padding: 14px 38px; }
.wbtn.sm { font-size: 12px; padding: 4px 10px; margin: 0; }

.srow { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 6px 4px; border-bottom: 1px dashed rgba(200,162,74,0.25); font-size: 14px; }
.srow b { color: var(--gold); }
.srow i { color: #a89878; font-size: 11px; }
.shop-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.shop-money { margin-top: 12px; text-align: right; font-size: 14px; }
.shop-money b { color: var(--gold); }

/* poker */
.poker-table { text-align: center; }
.poker-pot { font-family: Georgia, serif; font-size: 18px; color: var(--gold); margin-bottom: 10px; }
.poker-ops { display: flex; gap: 18px; justify-content: center; margin-bottom: 14px; }
.poker-op { opacity: 0.95; }
.poker-op.folded { opacity: 0.4; }
.poker-op > span { font-size: 12px; color: var(--brass); display: block; margin-bottom: 4px; }
.poker-cards { display: flex; gap: 4px; justify-content: center; min-height: 52px; }
.pcard { width: 40px; height: 54px; background: #efe4c8; color: #222; border-radius: 4px;
  border: 1px solid #8a7a5a; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: Georgia, serif; font-size: 15px; cursor: default; box-shadow: 0 2px 4px rgba(0,0,0,0.4); }
.pcard i { font-style: normal; font-size: 16px; }
.pcard.red { color: #a02818; }
.pcard.down { background: repeating-linear-gradient(45deg, #5a3a3a, #5a3a3a 4px, #4a2e2e 4px, #4a2e2e 8px);
  color: #c8a24a; font-size: 20px; }
.pcard.sel { transform: translateY(-8px); outline: 2px solid var(--gold); }
.poker-cards .pcard { cursor: pointer; }
.poker-msg { min-height: 40px; font-size: 13px; color: var(--parch); margin: 10px 0; }
.poker-actions { margin-top: 6px; }

/* ── pause overlay ── */
#overlay { position: fixed; inset: 0; display: none; z-index: 35;
  background: rgba(12,8,4,0.6); backdrop-filter: blur(3px); }
#overlay.open { display: flex; align-items: center; justify-content: center; }
.pause-panel { width: min(940px, 94vw); max-height: 90vh; display: flex; flex-direction: column;
  background: linear-gradient(160deg, rgba(255,255,255,0.03), transparent 40%), var(--leather);
  border: 2px solid var(--leather2); outline: 1px solid var(--brass); outline-offset: -6px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.8); border-radius: 4px; padding: 20px 26px; }
.pause-head { display: flex; justify-content: space-between; align-items: baseline; }
.ptitle { font-family: 'Rye', Georgia, serif; font-size: 28px; color: var(--brass); letter-spacing: 4px; }
.pdim { font-size: 12px; color: #a89878; }
.pause-tabs { display: flex; gap: 6px; margin: 14px 0; border-bottom: 1px solid var(--leather2); padding-bottom: 8px; }
.ptab { background: none; border: none; color: #a89878; font-family: Georgia, serif; letter-spacing: 2px;
  font-size: 14px; cursor: pointer; padding: 4px 10px; }
.ptab.on { color: var(--gold); border-bottom: 2px solid var(--gold); }
.pause-body { overflow: auto; min-height: 300px; }
.pause-foot { margin-top: 12px; display: flex; justify-content: flex-end; gap: 8px; }
#bigmap { width: 100%; border: 1px solid var(--leather2); box-shadow: inset 0 0 40px rgba(0,0,0,0.3); }
.map-legend { font-size: 11px; color: #a89878; margin-top: 6px; text-align: center; }
.journal-cols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 22px; }
.jscroll { max-height: 320px; overflow: auto; }
.jent { font-size: 13px; padding: 5px 0; border-bottom: 1px dashed rgba(200,162,74,0.2); }
.jent span { color: var(--brass); margin-right: 8px; font-size: 11px; }
.jobj { font-size: 13px; padding: 4px 0; }
.jobj.done { color: #7ab84a; text-decoration: line-through; }
.jstats div { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0;
  border-bottom: 1px dashed rgba(200,162,74,0.2); }
.jstats b { color: var(--gold); }
.ctl-grid { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; font-size: 13px; }
.ctl-grid b { color: var(--gold); font-family: Georgia, serif; }
input[type=range] { accent-color: var(--gold); }

/* ── title & death ── */
#title { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 110%, rgba(140,60,20,0.28), transparent 60%),
              linear-gradient(180deg, rgba(16,8,4,0.82) 0%, rgba(16,8,4,0.35) 45%, rgba(16,8,4,0.8) 100%); }
#title.on { display: flex; }
.title-inner { text-align: center; pointer-events: none; }
#title .wbtn { pointer-events: all; }
.title-kicker { font-size: 15px; letter-spacing: 8px; color: var(--brass); }
.title-logo { font-family: 'Rye', Georgia, serif; font-size: 88px; line-height: 0.95; color: var(--parch);
  letter-spacing: 10px; margin: 14px 0 10px;
  text-shadow: 0 3px 0 #4a2010, 0 6px 0 #2a1408, 0 0 60px rgba(217,140,60,0.5); }
.title-rule { color: var(--gold); letter-spacing: 12px; font-size: 12px; margin: 8px 0 16px; }
.title-sub { font-size: 15px; color: var(--parch); margin-bottom: 26px; }
.title-controls { margin-top: 30px; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap;
  font-size: 12px; color: #b09878; }
.title-controls b { color: var(--gold); }
.title-foot { margin-top: 18px; font-size: 11px; color: #7a6a55; letter-spacing: 1px; }

#dead { position: fixed; inset: 0; z-index: 55; display: none; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(60,8,4,0.55), rgba(8,2,1,0.92)); }
#dead.on { display: flex; }
.dead-inner { text-align: center; }
.dead-inner h1 { font-family: 'Rye', Georgia, serif; font-size: 110px; color: #a02818; letter-spacing: 18px;
  text-shadow: 0 0 80px rgba(160,40,24,0.8); }
.dead-inner p { color: #b09070; margin-bottom: 26px; }

/* ── touch controls ── */
#touch-layer { position: fixed; inset: 0; pointer-events: none; z-index: 28; display: none; }
body.touch-mode #touch-layer { display: block; }
#joy { position: absolute; left: 26px; bottom: 90px; width: 120px; height: 120px; border-radius: 50%;
  border: 2px solid rgba(232,213,168,0.35); background: rgba(26,15,8,0.3); pointer-events: none; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px;
  border-radius: 50%; background: rgba(200,162,74,0.5); border: 1px solid var(--brass); }
.tbtn { position: absolute; width: 58px; height: 58px; border-radius: 50%; background: rgba(26,15,8,0.55);
  border: 2px solid var(--brass); color: var(--parch); font-size: 18px; display: flex; align-items: center;
  justify-content: center; pointer-events: all; font-family: Georgia, serif; }
#tb-act { right: 30px; bottom: 150px; }
#tb-fire { right: 104px; bottom: 80px; }
#tb-aim { right: 30px; bottom: 230px; }
#tb-run { right: 110px; bottom: 160px; }
#tb-map { left: 30px; top: 70px; width: 48px; height: 48px; font-size: 11px; }
#tb-pause { right: 30px; top: 70px; width: 48px; height: 48px; }

@media (max-width: 760px) {
  .panel { min-width: 0; width: 94vw; padding: 18px; }
  .title-logo { font-size: 52px; }
  .shop-cols, .journal-cols { grid-template-columns: 1fr; }
  #compass { width: 320px; }
}
