:root {
  --bg: #eef1f4; --card: rgba(255, 255, 255, 0.92); --line: #d3d9df; --ink: #1f2a33; --soft: #5b6873;
  --orange: #c96a0c; --blue: #1d64a8; --green: #1b8a4e; --red: #c0392b; --amber: #b7791f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 6px 12px; }
button:hover { border-color: #9fb0bf; }
button.primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; padding: 9px 20px; }
button.primary:hover { filter: brightness(1.07); }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border: 1px solid #b9c3cc; border-bottom-width: 2px; border-radius: 5px; background: #fff; font: 12px/1.5 ui-monospace, Consolas, monospace; text-align: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 18px rgba(40, 60, 80, 0.12); }
#hud .card { position: fixed; padding: 10px 12px; }
small { color: var(--soft); font-size: 11px; letter-spacing: 0.06em; }

/* job list */
#jobs { top: 12px; left: 12px; width: 250px; }
#jobs .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
#jobs ul { list-style: none; margin: 0; padding: 0; }
#jobs li { display: flex; justify-content: space-between; gap: 6px; padding: 3px 0; border-top: 1px solid #edf0f2; font-variant-numeric: tabular-nums; }
#jobs li .st { font-size: 12px; color: var(--soft); }
#jobs li.moving { color: var(--blue); font-weight: 600; }
#jobs li.done .st { color: var(--green); }
#jobs li.failed { color: var(--red); text-decoration: line-through; }
#jobs li.wrong .st, #jobs li.parked .st { color: var(--amber); }

/* score, map, views */
#side { top: 12px; right: 12px; width: 244px; }
.scoreRow { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.scoreRow b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.scoreRow button { margin-left: auto; padding: 4px 10px; }
#map { width: 220px; height: 150px; display: block; border-radius: 8px; background: #f6f7f5; border: 1px solid #e3e7ea; }
.views { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.views button { padding: 3px 8px; font-size: 12px; }
.views button.on { background: var(--blue); color: #fff; border-color: var(--blue); }

/* toasts */
#toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 560px)); min-width: 280px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--blue); border-radius: 8px; padding: 7px 10px; box-shadow: 0 3px 12px rgba(40, 60, 80, 0.15); font-size: 13px; transition: opacity 0.5s; display: flex; gap: 8px; }
.toast.bad { border-left-color: var(--red); }
.toast.good { border-left-color: var(--green); }
.toast.warn { border-left-color: var(--amber); }
.toast b { margin-left: auto; color: var(--red); font-variant-numeric: tabular-nums; }

/* hint */
#hint { left: 12px; bottom: 12px; width: min(440px, calc(100vw - 24px)); font-size: 15px; }
#hint small { display: block; color: var(--orange); font-weight: 700; }

/* height gauge */
#gaugeBox { right: 12px; top: 50%; transform: translateY(-50%); width: 96px; text-align: center; padding: 8px 6px; }
#gaugeBox .lbl { font-size: 10px; color: var(--soft); letter-spacing: 0.06em; }
#gauge { width: 75px; height: 280px; display: block; margin: 4px auto; }
#gaugeBox .big { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
#gaugeBox .sub { font-size: 11px; color: var(--soft); min-height: 30px; }
#gaugeBox .sub .ok { color: var(--green); font-weight: 600; }
#gaugeBox .sub .no { color: var(--red); font-weight: 600; }

/* dashboard */
#dash { left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; }
#dash .spd b { font-size: 28px; font-variant-numeric: tabular-nums; display: inline-block; min-width: 54px; text-align: right; }
#dash .limit { width: 40px; height: 40px; border-radius: 50%; border: 4px solid #d23a2e; display: grid; place-items: center; font-weight: 800; font-size: 16px; background: #fff; }
#dash .limit.over { animation: flash 0.5s infinite alternate; }
@keyframes flash { to { background: #ffd9d4; } }
#dash .dir span { display: inline-block; width: 22px; text-align: center; color: #aab4bd; font-weight: 700; }
#dash .dir span.on { color: var(--ink); background: #e7edf2; border-radius: 4px; }
#dash .meters { display: grid; grid-template-columns: 120px 120px; gap: 2px 14px; }
#dash .m small { display: block; font-size: 10px; }
#dash .m span { font-variant-numeric: tabular-nums; font-weight: 600; }
.bar { height: 9px; border-radius: 5px; background: #e7ecf0; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; width: 0; background: var(--green); transition: width 0.1s; }

/* fork camera frame (the picture is drawn by WebGL under it) */
#forkcam { position: fixed; right: 124px; bottom: 96px; width: 300px; height: 190px; border: 3px solid #fff; border-radius: 8px; box-shadow: 0 4px 18px rgba(40, 60, 80, 0.25); pointer-events: none; }
#forkcam span { position: absolute; top: 4px; left: 6px; font-size: 10px; font-weight: 700; color: #fff; background: rgba(30, 40, 50, 0.55); padding: 1px 5px; border-radius: 3px; letter-spacing: 0.06em; }
#forkcam i { position: absolute; background: rgba(255, 200, 40, 0.9); }
#forkcam i.v { left: 50%; top: 30%; width: 2px; height: 40%; margin-left: -1px; }
#forkcam i.hz { top: 50%; left: 30%; height: 2px; width: 40%; margin-top: -1px; }

/* overlays */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(226, 232, 238, 0.82); backdrop-filter: blur(3px); overflow: auto; padding: 16px; }
.overlay .card { padding: 22px 26px; max-width: 560px; width: 100%; }
.overlay .card.wide { max-width: 780px; }
h1 { margin: 0 0 6px; font-size: 34px; letter-spacing: -0.01em; }
h1::after { content: ''; display: block; width: 64px; height: 5px; margin-top: 6px; background: repeating-linear-gradient(45deg, #f2b705 0 8px, #3c4650 8px 16px); border-radius: 2px; }
h2 { margin: 0 0 8px; }
h3 { margin: 18px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--soft); }
.lead { font-size: 15px; margin: 6px 0; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.choice { text-align: left; padding: 10px 12px; border-radius: 10px; }
.choice b { display: block; font-size: 15px; }
.choice .lv { font-size: 12px; color: var(--orange); font-weight: 700; }
.choice p { margin: 4px 0 0; font-size: 12px; color: var(--soft); }
.choice .best { font-size: 11px; color: var(--green); margin-top: 4px; }
.choice.on { border: 2px solid var(--orange); background: #fff8ef; padding: 9px 11px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 0 4px; }
.go { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.how { margin-top: 16px; }
.how summary { cursor: pointer; font-weight: 600; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin: 10px 0; font-size: 13px; }
.rules { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.rules li { margin: 3px 0; }
.kind { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--orange); }
#endScore { font-size: 40px; font-weight: 800; margin: 6px 0; font-variant-numeric: tabular-nums; }
#endScore small { font-size: 16px; }
#endRows { width: 100%; border-collapse: collapse; font-size: 13px; }
#endRows td { padding: 3px 4px; border-top: 1px solid #edf0f2; }
#endRows td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#endRows tr.neg td:last-child { color: var(--red); }

@media (max-width: 900px) {
  #jobs { width: 200px; font-size: 12px; }
  #toasts { width: calc(100vw - 24px); top: auto; bottom: 150px; }
  #dash { bottom: 130px; flex-wrap: wrap; max-width: calc(100vw - 24px); }
  #dash .meters { grid-template-columns: 110px 110px; }
  #forkcam { width: 200px; height: 126px; right: 12px; bottom: 260px; }
  #side { width: 200px; }
  #map { width: 176px; height: 120px; }
  .keys { grid-template-columns: 1fr; }
}
