:root { --cream:#fff1c4; --amber:#f1a33b; --dark:#172019; --moss:#526e42; --rust:#984630; }
* { box-sizing:border-box; }
html, body, #game, #game canvas { width:100%; height:100%; margin:0; overflow:hidden; }
body { color:white; background:#7ba7ac; font-family:"Courier New",monospace; user-select:none; touch-action:none; }
#game canvas { display:block; image-rendering:pixelated; }
#start-screen { position:fixed; inset:0; z-index:100; display:grid; place-items:center; padding:18px; background:linear-gradient(rgba(17,29,20,.15),rgba(17,29,20,.82)), radial-gradient(circle at 25% 20%,#91a668,#526d48 58%,#2c4033); }
.start-card { width:min(620px,100%); padding:30px 34px 27px; text-align:center; background:#1b251d; border:5px solid #0a100b; box-shadow:11px 11px 0 rgba(0,0,0,.4),inset 0 0 0 4px #3b4d38; }
.hand-mark { width:58px; height:58px; margin:0 auto 12px; display:grid; place-items:center; background:#d8a66c; border:5px solid #704a31; box-shadow:5px 5px 0 #0a100b; font-size:31px; filter:grayscale(.25); }
.eyebrow { margin:0 0 7px; color:#9caf87; font-weight:bold; font-size:11px; letter-spacing:3px; }
h1 { margin:0; color:var(--amber); font-size:clamp(42px,10vw,74px); line-height:1; letter-spacing:-5px; text-shadow:5px 5px 0 var(--rust); }
.tagline { margin:15px 0 20px; color:var(--cream); font-size:17px; font-weight:bold; letter-spacing:2px; line-height:1.5; }
.controls { display:grid; grid-template-columns:1fr 1fr; gap:5px 18px; padding:15px; text-align:left; background:#111712; border:3px solid #3e503a; color:#a9b9a0; font-size:11px; line-height:1.6; }
.controls b { display:inline-block; min-width:104px; color:var(--amber); }
.touch-controls { display:none; }
#play-button,#new-world-button { width:100%; margin-top:17px; padding:15px; color:#172016; background:var(--amber); border:0; border-bottom:7px solid #985727; font:bold 19px "Courier New"; cursor:pointer; }
#play-button:active,#new-world-button:active { transform:translateY(4px); border-bottom-width:3px; }
#new-world-button.secondary { display:none; margin-top:8px; padding:9px; color:#c8d3c2; background:#344532; border-bottom-color:#1f2c1e; font-size:12px; }
.save-note { min-height:13px; margin:12px 0 0; color:#70806c; font-size:10px; letter-spacing:1px; }
#hud { position:fixed; z-index:10; inset:0 0 auto; padding:16px 18px; pointer-events:none; text-shadow:2px 2px #000; }
.logo { color:var(--amber); font-size:20px; font-weight:900; }
.logo small { display:block; color:#fff; font-size:8px; letter-spacing:3px; }
.era { position:fixed; top:52px; right:18px; padding:7px 11px; text-align:right; background:rgba(15,22,16,.74); border-left:4px solid var(--amber); }
.era span { display:block; color:#a9b9a0; font-size:8px; letter-spacing:2px; }
.era b { color:var(--cream); font-size:14px; }
#settings-button { position:fixed; z-index:20; top:13px; right:18px; height:29px; padding:0 9px; display:flex; align-items:center; gap:5px; color:#d6decf; background:rgba(15,22,16,.78); border:2px solid rgba(255,255,255,.28); font:bold 9px "Courier New",monospace; letter-spacing:1px; cursor:pointer; }
#settings-button span { color:var(--amber); font-size:14px; line-height:1; }
#settings-button[aria-expanded="true"] { color:var(--cream); border-color:var(--amber); }
#settings-menu { position:fixed; z-index:45; top:49px; right:18px; width:230px; color:#fff; background:#1b251d; border:3px solid #0a100b; box-shadow:7px 7px 0 rgba(0,0,0,.34),inset 0 0 0 2px #3b4d38; }
#settings-menu[hidden], #viewpoint-menu[hidden], #settings-main[hidden] { display:none; }
.settings-header { min-height:42px; padding:8px 9px; display:grid; grid-template-columns:28px 1fr 28px; align-items:center; border-bottom:2px solid #3b4d38; }
.settings-header strong { grid-column:2; text-align:center; color:var(--cream); font-size:12px; letter-spacing:1px; }
.settings-header button { width:28px; height:28px; padding:0; color:#d6decf; background:#303e2f; border:2px solid #536451; cursor:pointer; }
.settings-header .settings-close { grid-column:3; font:bold 19px monospace; }
.settings-header .settings-back { grid-column:1; grid-row:1; font:bold 23px/1 monospace; }
.settings-row, .viewpoint-option { width:100%; min-height:52px; padding:9px 12px; display:flex; align-items:center; justify-content:space-between; gap:10px; color:#d6decf; background:#263226; border:0; border-bottom:1px solid #3d4d3b; text-align:left; cursor:pointer; }
.settings-row:hover, .viewpoint-option:hover { background:#344532; }
.settings-row span { display:grid; gap:3px; }
.settings-row b, .viewpoint-option span { color:var(--cream); font:bold 11px "Courier New",monospace; }
.settings-row small { color:#91a486; font:bold 8px "Courier New",monospace; letter-spacing:1px; }
.settings-row i { color:var(--amber); font:25px/1 monospace; }
.viewpoint-option b { visibility:hidden; color:var(--amber); font-size:14px; }
.viewpoint-option.active { background:#344532; box-shadow:inset 4px 0 var(--amber); }
.viewpoint-option.active b { visibility:visible; }
#quest { position:fixed; z-index:10; top:76px; left:18px; display:flex; gap:9px; align-items:center; padding:9px 12px; background:rgba(15,22,16,.78); border:3px solid rgba(255,255,255,.22); box-shadow:5px 5px 0 rgba(0,0,0,.22); pointer-events:none; }
#quest-number { color:var(--amber); font-size:22px; font-weight:bold; }
#quest small { display:block; color:#9caf87; font-size:8px; letter-spacing:2px; }
#quest strong { display:block; margin-top:2px; color:#fff; font-size:12px; }
#resources { position:fixed; z-index:12; top:133px; left:18px; display:grid; gap:4px; pointer-events:none; }
.resource { min-width:105px; padding:5px 8px; display:flex; justify-content:space-between; gap:18px; color:#d6decf; background:rgba(15,22,16,.66); border-left:3px solid #6f865d; font-size:11px; font-weight:bold; }
.resource b { color:var(--cream); }
#buffalo-status { position:fixed; z-index:12; left:18px; bottom:18px; display:grid; gap:4px; padding:7px 10px; color:#fff; background:rgba(15,22,16,.72); border-left:3px solid #8c5a3c; pointer-events:none; }
#health { color:#d86751; font-size:15px; letter-spacing:2px; text-shadow:1px 1px #000; }
#herd-status { color:#d6decf; font-size:9px; letter-spacing:1px; }
#crosshair { position:fixed; z-index:12; top:50%; left:50%; width:18px; height:18px; transform:translate(-50%,-50%); pointer-events:none; filter:drop-shadow(1px 1px #000); }
#crosshair::before,#crosshair::after { content:""; position:absolute; background:white; }
#crosshair::before { width:2px; height:18px; left:8px; }
#crosshair::after { width:18px; height:2px; top:8px; }
#target-label { position:fixed; z-index:12; top:calc(50% + 18px); left:50%; transform:translateX(-50%); padding:4px 8px; color:#fff; background:rgba(0,0,0,.64); border-bottom:2px solid var(--amber); font-size:10px; opacity:0; pointer-events:none; white-space:nowrap; }
#target-label.show { opacity:1; }
#toast { position:fixed; z-index:60; top:145px; left:50%; transform:translateX(-50%); padding:8px 17px; color:var(--cream); background:rgba(15,22,16,.9); border:3px solid var(--amber); font-weight:bold; opacity:0; transition:opacity .14s; pointer-events:none; }
#toast.show { opacity:1; }
#craft-panel { position:fixed; z-index:50; left:50%; bottom:28px; width:min(740px,calc(100% - 30px)); transform:translate(-50%,calc(100% + 60px)); padding:18px; background:#1b251d; border:4px solid #0a100b; box-shadow:8px 8px 0 rgba(0,0,0,.36),inset 0 0 0 3px #3b4d38; transition:transform .18s steps(3); }
#craft-panel.open { transform:translate(-50%,0); }
.craft-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:13px; }
.craft-header small { color:#9caf87; font-size:8px; letter-spacing:3px; }
.craft-header h2 { margin:2px 0 0; color:var(--cream); font-size:17px; }
#craft-close { width:34px; height:34px; color:white; background:#3d4c3b; border:2px solid #73836d; font:bold 24px monospace; cursor:pointer; }
#recipes { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; max-height:52vh; overflow:auto; padding-right:3px; }
.recipe { min-height:150px; padding:13px; display:flex; flex-direction:column; background:#263226; border:3px solid #536451; }
.recipe.ready { border-color:var(--amber); box-shadow:inset 0 0 0 2px #7b542c; }
.recipe.crafted { opacity:.7; background:#364634; border-color:#799267; }
.recipe.locked { opacity:.48; }
.recipe h3 { margin:0; color:var(--amber); font-size:14px; }
.recipe p { min-height:32px; margin:6px 0; color:#bdc9b8; font-size:10px; line-height:1.4; }
.cost { margin:auto 0 8px; color:var(--cream); font-size:10px; line-height:1.5; }
.recipe button { width:100%; padding:9px; color:#172016; background:var(--amber); border:0; border-bottom:4px solid #985727; font:bold 11px "Courier New"; cursor:pointer; }
.recipe button:disabled { color:#9aa596; background:#465345; border-bottom-color:#2d382d; cursor:not-allowed; }
#pause-hint { position:fixed; z-index:8; bottom:18px; left:50%; transform:translateX(-50%); padding:5px 9px; color:white; background:rgba(0,0,0,.55); font-size:10px; pointer-events:none; }
#knockout { position:fixed; z-index:90; inset:0; display:none; place-items:center; align-content:center; gap:10px; color:#fff; background:rgba(70,22,17,.84); text-align:center; }
#knockout.show { display:grid; }
#knockout strong { color:var(--cream); font-size:30px; text-shadow:4px 4px #38120f; }
#knockout span { font-size:12px; letter-spacing:2px; }
.touch-ui { display:none; }
@media (pointer:coarse) {
  .desktop-controls,#pause-hint { display:none; }
  .touch-controls { display:grid; grid-template-columns:1fr; }
  #touch-look { display:block; position:fixed; z-index:11; inset:0 0 0 42%; }
  #touch-move { display:block; position:fixed; z-index:16; left:18px; bottom:22px; width:108px; height:108px; border-radius:50%; background:rgba(15,22,16,.36); border:3px solid rgba(255,255,255,.24); }
  #touch-move .stick { position:absolute; left:30px; top:30px; width:44px; height:44px; border-radius:50%; background:rgba(255,240,194,.55); border:3px solid rgba(255,255,255,.48); }
  .touch-button { display:block; position:fixed; z-index:18; width:72px; height:48px; color:white; background:rgba(15,22,16,.7); border:3px solid rgba(255,255,255,.42); border-radius:7px; font:bold 10px "Courier New"; }
  #touch-jump { right:18px; bottom:22px; }
  #touch-gather { right:98px; bottom:22px; background:rgba(145,73,44,.78); }
  #touch-craft { right:18px; bottom:78px; background:rgba(83,110,60,.82); }
  #buffalo-status { left:auto; right:18px; bottom:139px; text-align:right; }
  #craft-panel { bottom:14px; }
}
@media (max-width:600px) {
  .start-card { padding:22px 17px; }
  .hand-mark { width:44px; height:44px; margin-bottom:9px; font-size:23px; border-width:4px; }
  .eyebrow { font-size:8px; letter-spacing:2px; }
  h1 { font-size:46px; }
  .tagline { margin:10px 0 13px; font-size:12px; }
  .controls { padding:10px; font-size:9px; }
  #play-button { margin-top:12px; padding:12px; font-size:16px; }
  #hud { padding:10px 9px; }
  .logo { font-size:16px; }
  .era { top:46px; right:9px; }
  #settings-button { top:9px; right:9px; }
  #settings-menu { top:44px; right:9px; width:210px; }
  #quest { top:63px; left:8px; padding:7px 9px; }
  #quest strong { font-size:10px; }
  #resources { top:116px; left:8px; }
  .resource { min-width:89px; padding:3px 6px; font-size:9px; }
  #recipes { grid-template-columns:1fr; max-height:53vh; overflow:auto; }
  .recipe { min-height:105px; }
  .recipe p { min-height:0; }
}
