/* Log Run. The house ground (warm dark, Space Grotesk, one green that means "you can act here"),
   and bars on the edges of the window: the game is the window, the chrome sits on its edges. */

@font-face { font-family: "Space Grotesk"; src: url("/fonts/SpaceGrotesk.ttf") format("truetype"); font-weight: 300 700; font-display: swap; }

:root {
  --bg: #262421; --panel: #21201dee; --solid: #21201d; --ink: #e4e1dd; --dim: #98948e; --edge: #3a3733;
  --go: #81b64c; --amber: #d9a13b; --red: #d8453b;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink); overflow: hidden;
  font-family: "Space Grotesk", system-ui, sans-serif; -webkit-font-smoothing: antialiased;
}
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }

button {
  font: inherit; font-weight: 600; font-size: 16px; color: var(--ink); background: #34312d;
  border: 0; border-radius: 6px; padding: 12px 18px; cursor: pointer; min-height: 44px;
}
button:hover { background: #403c37; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
button.go { background: var(--go); color: #16210b; }
button.go:hover { background: #8fc45a; }
button.quiet { background: none; color: var(--dim); font-weight: 400; }
button.small { font-size: 14px; padding: 6px 12px; min-height: 34px; }
button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
input {
  font: inherit; font-size: 16px; color: var(--ink); background: #1a1917; border: 1px solid var(--edge);
  border-radius: 6px; padding: 10px 12px; min-width: 0;
}

/* ---- home ------------------------------------------------------------------------------------ */
/* The landing page is the game's own art: the hero behind, the logo on top, and every piece of text
   on a bar of its own, because type on busy art is type nobody reads. */
.screen {
  position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: calc(20px + var(--safe-t)) 16px calc(20px + var(--safe-b)); background: #262421d8;
}
#home {
  background: #1d2b33 url("/hero.jpg") center 78% / cover no-repeat;
}
#home::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 30%, #0b141a33 0 26%, #0b141aa6 72%, #0b141ae0 100%);
}
#home > * { position: relative; }
.screen.on { display: flex; }
h1 { margin: 0; line-height: 0; }
h1 img { display: block; width: min(560px, 82vw); height: auto; filter: drop-shadow(0 16px 26px #0009); }
.lede {
  font-size: 19px; margin: 0; text-align: center; font-weight: 600; line-height: 1.5;
  background: #16120fb8; padding: 8px 16px; border-radius: 6px; backdrop-filter: blur(2px);
}
.lede span { color: var(--dim); font-weight: 400; }
.actions { display: flex; flex-direction: column; gap: 10px; width: min(360px, 100%); }
.actions .go { font-size: 22px; padding: 16px; }
.row { display: flex; gap: 8px; }
.row > input { flex: 1; }
.row.name { align-items: center; color: var(--dim); background: #16120fa8; border-radius: 6px; padding: 4px 10px; }
.howto { color: var(--dim); font-size: 14px; text-align: center; line-height: 1.8; background: #16120fa8; padding: 8px 14px; border-radius: 6px; max-width: min(620px, 92vw); }
.howto b { color: var(--ink); font-weight: 600; }
#level { color: var(--amber); font-size: 14px; font-weight: 600; white-space: nowrap; }
#credits-open { background: #16120fa8; border-radius: 6px; }
#credits-list { max-width: 560px; color: var(--dim); line-height: 1.6; font-size: 15px; }
#credits-list b { color: var(--ink); }
#credits-list p { margin: 0 0 10px; }

/* ---- the bar across the top -------------------------------------------------------------------- */
#bar {
  position: fixed; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 12px; padding: calc(6px + var(--safe-t)) calc(12px + var(--safe-r)) 6px calc(12px + var(--safe-l));
  background: var(--panel); border-bottom: 1px solid var(--edge); z-index: 5;
}
#bar .left, #bar .right { display: flex; align-items: center; gap: 10px; min-width: 0; }
#bar .right { justify-content: flex-end; }
#round { color: var(--dim); font-size: 14px; white-space: nowrap; }
.chip { font-weight: 700; font-size: 15px; padding: 4px 10px; border-radius: 4px; background: #34312d; white-space: nowrap; }
#bar .mid { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
#banked { font-size: 13px; font-weight: 700; color: var(--go); white-space: nowrap; }
#clock { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
#clock.low { color: var(--amber); }
#net { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* course progress, under the bar: where every log and runner is between the rack and the line */
#track {
  position: fixed; left: 0; right: 0; top: calc(52px + var(--safe-t)); height: 22px; z-index: 4;
  background: #21201dcc; border-bottom: 1px solid var(--edge);
}
#track-in { position: absolute; left: 16px; right: 16px; top: 0; bottom: 0; }
#track .mark { position: absolute; top: 3px; bottom: 3px; width: 2px; background: #5d5850; }
#track .mark.finish { background: var(--ink); width: 3px; }
#track .log { position: absolute; top: 5px; width: 16px; height: 12px; margin-left: -8px; border-radius: 6px; border: 2px solid #a0703f; }
#track .dot { position: absolute; top: 8px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; }
#track .me { outline: 2px solid var(--ink); }

#feed {
  position: fixed; right: calc(12px + var(--safe-r)); top: calc(84px + var(--safe-t)); z-index: 4;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none; max-width: 60vw;
}
#feed div { background: #21201dcc; padding: 4px 10px; border-radius: 4px; font-size: 14px; }

#banner {
  position: fixed; left: 50%; top: calc(96px + var(--safe-t)); transform: translateX(-50%); z-index: 4;
  background: var(--solid); padding: 8px 16px; border-radius: 6px; font-weight: 600; text-align: center;
}

/* the bottom bar: what your buttons do right now */
#hint {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center; align-items: center;
  flex-wrap: wrap; gap: 6px 18px; padding: 8px calc(12px + var(--safe-r)) calc(8px + var(--safe-b)) calc(12px + var(--safe-l));
  background: var(--panel); border-top: 1px solid var(--edge); font-size: 15px; color: var(--dim);
}
#hint b { color: var(--ink); }
#hint .act { color: var(--go); font-weight: 700; }
#hint .wait { color: var(--amber); font-weight: 700; }
#hint .cd { display: inline-flex; align-items: center; gap: 6px; }
#hint .cd i { display: inline-block; width: 36px; height: 6px; border-radius: 3px; background: #3a3733; overflow: hidden; }
#hint .cd i s { display: block; height: 100%; background: var(--go); text-decoration: none; }

#result {
  position: fixed; left: 0; right: 0; top: 30%; z-index: 6; background: var(--panel); border-top: 1px solid var(--edge);
  border-bottom: 1px solid var(--edge); padding: 18px 16px; text-align: center;
}
#result h2 { margin: 0 0 8px; font-size: clamp(28px, 5vw, 44px); }
#result-body { color: var(--dim); font-size: 15px; line-height: 1.7; }
#result-body b { color: var(--ink); }
#result-next { margin: 8px 0 0; color: var(--dim); }

/* ---- debug panel: a right-hand drawer ----------------------------------------------------------------- */
#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 10; background: var(--solid);
  border-left: 1px solid var(--edge); display: flex; flex-direction: column;
  padding-top: var(--safe-t); padding-bottom: var(--safe-b);
}
.panel-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--edge); }
.panel-head b { font-size: 18px; }
#table-code { color: var(--dim); font-size: 14px; flex: 1; }
#panel-body { overflow-y: auto; padding: 0 12px 24px; font-size: 14px; }
#panel h3 { font-size: 13px; color: var(--dim); font-weight: 600; margin: 18px 0 8px; letter-spacing: .04em; }
#panel .tune { display: grid; grid-template-columns: 1fr 64px; gap: 2px 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid #2c2a26; }
#panel .tune label { color: var(--ink); }
#panel .tune label em { color: var(--amber); font-style: normal; font-size: 12px; margin-left: 6px; }
#panel .tune input[type=number] { font-size: 14px; padding: 4px 6px; text-align: right; }
#panel .tune input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--go); }
#panel .tune select { font: inherit; font-size: 14px; background: #1a1917; color: var(--ink); border: 1px solid var(--edge); border-radius: 6px; padding: 4px; }
#panel .tune.changed label { color: var(--go); }
#panel .btns { display: flex; flex-wrap: wrap; gap: 6px; }
#panel .seat { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; padding: 3px 0; border-bottom: 1px solid #2c2a26; }
#panel .seat .sw { width: 14px; height: 14px; border-radius: 3px; }
#panel .seat.mine { color: var(--go); font-weight: 700; }
#panel .read { color: var(--dim); line-height: 1.6; font-variant-numeric: tabular-nums; }
#panel .read b { color: var(--ink); font-weight: 600; }
#panel pre { white-space: pre-wrap; font-size: 12px; color: var(--dim); background: #1a1917; padding: 8px; border-radius: 6px; max-height: 260px; overflow: auto; }
#panel a { color: var(--ink); }

@media (max-width: 700px) {
  #clock { font-size: 24px; }
  #net, #round { display: none; }
  #hint { font-size: 13px; }
}
