/* Heart of the Frontier — worn-paper frontier UI */
:root {
  --paper: #e6d5ac;
  --paper-dark: #cbb98a;
  --ink: #2e2010;
  --red: #8a2121;
  --gold: #c8a24a;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0d0b08; }
body { font-family: var(--serif); color: var(--ink); }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: absolute; inset: 0; pointer-events: none; }

/* ---------- overlays ---------- */
.paper-tex {
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(120, 80, 20, 0.14), transparent 55%),
    radial-gradient(ellipse at 85% 80%, rgba(100, 70, 20, 0.16), transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 244, 200, 0.25), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.42 0 0 0 0 0.32 0 0 0 0 0.16 0 0 0 0.10 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  border: 1px solid rgba(60, 40, 12, 0.55);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55), inset 0 0 60px rgba(120, 85, 30, 0.18);
}
.screen {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20, 14, 6, 0.45), rgba(8, 5, 2, 0.88));
  pointer-events: auto; opacity: 1; transition: opacity 0.5s;
  z-index: 40;
}
.screen.hidden, .hidden { opacity: 0 !important; pointer-events: none !important; }
.panel {
  max-width: 620px; width: min(92vw, 620px); padding: 44px 52px 36px;
  text-align: center; position: relative;
}
.panel::before, .panel::after {
  content: ''; position: absolute; left: 18px; right: 18px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--ink), transparent);
  opacity: 0.5;
}
.panel::before { top: 12px; } .panel::after { bottom: 12px; }
h1.brand {
  font-size: clamp(34px, 5.4vw, 58px); letter-spacing: 0.06em; font-variant: small-caps;
  color: var(--ink); text-shadow: 0 1px 0 rgba(255, 240, 200, 0.6); line-height: 1.05;
}
h1.brand .red { color: var(--red); }
.subtitle { font-style: italic; color: #5a4526; margin: 10px 0 26px; font-size: 17px; }
.rule { height: 1px; background: linear-gradient(90deg, transparent, #7a5c2c, transparent); margin: 16px 0; }
.btn {
  display: inline-block; font-family: var(--serif); font-variant: small-caps; letter-spacing: 0.1em;
  font-size: 20px; padding: 12px 34px; margin: 6px; cursor: pointer;
  color: var(--ink); background: rgba(120, 85, 30, 0.12);
  border: 1.5px solid rgba(60, 40, 12, 0.7); border-radius: 3px;
  transition: all 0.15s; pointer-events: auto; user-select: none;
}
.btn:hover { background: rgba(138, 33, 33, 0.14); border-color: var(--red); color: var(--red); transform: translateY(-1px); }
.btn.primary { background: var(--red); color: #f2e3c2; border-color: #5c1414; font-weight: bold; }
.btn.primary:hover { background: #a02b2b; color: #fff2dc; }
.keys-help { text-align: left; display: inline-block; margin: 8px auto 4px; font-size: 15.5px; line-height: 1.75; color: #443318; }
.keys-help b { display: inline-block; min-width: 110px; font-variant: small-caps; color: var(--red); }
.tiny { font-size: 12.5px; color: #6a5433; margin-top: 20px; font-style: italic; }

/* ---------- loading ---------- */
#loading .panel { max-width: 460px; }
.load-bar { height: 10px; border: 1.5px solid rgba(60,40,12,0.7); border-radius: 4px; overflow: hidden; margin: 18px 8px 6px; background: rgba(60,40,12,0.12); }
.load-fill { height: 100%; width: 0%; background: repeating-linear-gradient(45deg, var(--red), var(--red) 8px, #a8442a 8px, #a8442a 16px); transition: width 0.3s; }
#loading .tip { font-style: italic; color: #5a4526; font-size: 14.5px; margin-top: 10px; min-height: 20px; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; opacity: 1; transition: opacity 0.4s; z-index: 10; }
#compass-wrap {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  width: min(46vw, 520px); text-align: center;
}
#compass { width: 100%; height: 44px; display: block; }
#location {
  font-variant: small-caps; letter-spacing: 0.14em; color: #e9dcc0; font-size: 15px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); margin-top: 2px;
}
#clock { color: #cbb98a; font-size: 13px; letter-spacing: 0.1em; text-shadow: 0 1px 2px #000; }

/* cores bottom-left */
#cores { position: absolute; left: 22px; bottom: 20px; display: flex; flex-direction: column; gap: 7px; }
.core { display: flex; align-items: center; gap: 9px; }
.core .ic { width: 21px; height: 21px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8)); }
.core .bar { width: 150px; height: 8px; background: rgba(12, 9, 5, 0.72); border: 1px solid rgba(230, 213, 172, 0.35); border-radius: 4px; overflow: hidden; }
.core .fill { height: 100%; border-radius: 3px; transition: width 0.2s; }
.core.hp .fill { background: linear-gradient(90deg, #a02828, #d84f3a); }
.core.st .fill { background: linear-gradient(90deg, #2a7a48, #63b56b); }
.core.de .fill { background: linear-gradient(90deg, #8a6a1a, #e8c34a); }
#horse-cores { margin-top: 2px; padding-top: 5px; border-top: 1px solid rgba(230,213,172,0.25); display: none; }
#horse-cores.on { display: block; }
#horse-name { color: #e9dcc0; font-size: 13px; font-variant: small-caps; letter-spacing: 0.12em; text-shadow: 0 1px 2px #000; margin-left: 30px; }
.core.hs .fill { background: linear-gradient(90deg, #7a5aa0, #a98fd0); }
.core.bd .fill { background: linear-gradient(90deg, #a05a2a, #d0a05a); }

/* chips bottom-right */
#chips { position: absolute; right: 22px; bottom: 20px; display: flex; gap: 10px; }
.chip {
  padding: 6px 13px; font-size: 15px; font-variant: small-caps; letter-spacing: 0.06em;
  color: #efe2c0; background: rgba(16, 12, 6, 0.66); border: 1px solid rgba(230, 213, 172, 0.35);
  border-radius: 4px; text-shadow: 0 1px 2px #000;
}
.chip b { color: var(--gold); }

/* honor */
#honor {
  position: absolute; right: 22px; top: 16px; font-size: 13.5px; font-variant: small-caps;
  letter-spacing: 0.12em; color: #e9dcc0; text-shadow: 0 1px 3px #000;
  padding: 5px 12px; background: rgba(16,12,6,0.55); border: 1px solid rgba(230,213,172,0.25); border-radius: 4px;
}

/* prompt */
#prompt {
  position: absolute; left: 50%; bottom: 17%; transform: translateX(-50%);
  font-size: 17px; color: #f4e8cc; text-shadow: 0 1px 4px #000;
  background: rgba(16, 12, 6, 0.68); padding: 8px 20px; border-radius: 4px;
  border: 1px solid rgba(230, 213, 172, 0.4); letter-spacing: 0.04em;
  opacity: 0; transition: opacity 0.2s; white-space: nowrap;
}
#prompt.show { opacity: 1; }
#prompt b { color: var(--gold); font-variant: small-caps; }

/* crosshair */
#crosshair {
  position: absolute; left: 50%; top: 50%; width: 18px; height: 18px;
  transform: translate(-50%, -50%); opacity: 0; transition: opacity 0.15s;
}
#crosshair.on { opacity: 1; }
#crosshair::before, #crosshair::after {
  content: ''; position: absolute; background: rgba(240, 225, 190, 0.9);
  box-shadow: 0 0 3px #000;
}
#crosshair::before { left: 8px; top: 0; width: 2px; height: 18px; }
#crosshair::after { left: 0; top: 8px; width: 18px; height: 2px; }
.mark-dot {
  position: absolute; width: 10px; height: 10px; border: 2px solid var(--red);
  border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 6px rgba(138,33,33,0.9), inset 0 0 4px rgba(138,33,33,0.9);
}

/* toasts */
#toasts { position: absolute; top: 108px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.toast {
  padding: 10px 26px; font-variant: small-caps; letter-spacing: 0.08em; font-size: 17px;
  color: var(--ink); animation: toastIn 0.4s ease-out; text-align: center;
}
.toast small { display: block; font-size: 13px; letter-spacing: 0.04em; color: #5a4526; font-variant: normal; font-style: italic; }
.toast.gold { border-color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
.toast.out { transition: opacity 0.6s, transform 0.6s; opacity: 0; transform: translateY(-10px); }

/* letterbox, flashes, deadeye tint */
#letterbox-top, #letterbox-bottom {
  position: absolute; left: 0; right: 0; height: 0; background: #060402; z-index: 20;
  transition: height 0.45s cubic-bezier(.6,0,.3,1);
}
#letterbox-top { top: 0; } #letterbox-bottom { bottom: 0; }
.letterboxed #letterbox-top, .letterboxed #letterbox-bottom { height: 11vh; }
#damage-flash { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 40%, rgba(160, 20, 10, 0.55)); opacity: 0; z-index: 25; transition: opacity 0.12s; }
#deadeye-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(180,140,40,0.05) 30%, rgba(60,40,8,0.42)); opacity: 0; z-index: 15; transition: opacity 0.3s; }
#sleep-fade { position: absolute; inset: 0; background: #050302; opacity: 0; z-index: 35; transition: opacity 0.7s; pointer-events: none; display:flex; align-items:center; justify-content:center; color:#cbb98a; font-style:italic; font-size:22px; letter-spacing:0.08em; }

/* death screen */
#death h1 { font-size: clamp(44px, 7vw, 80px); color: var(--red); font-variant: small-caps; letter-spacing: 0.12em; }

/* journal rows */
.crow { display: flex; justify-content: space-between; padding: 7px 6px; border-bottom: 1px dashed rgba(90, 66, 26, 0.4); font-size: 16px; }
.crow.done { color: #7a8a4a; text-decoration: line-through; }
.crow small { color: #6a5433; }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 22px; font-size: 15px; text-align: left; margin-top: 8px; }
.statgrid b { color: var(--red); float: right; }
h3.sec { font-variant: small-caps; letter-spacing: 0.12em; color: var(--red); margin: 18px 0 6px; font-size: 19px; }
