:root {
    --bg: #0B0B0B;
    --card: #151515;
    --teal: #32CCCC;
    --teal-dim: #247171;
    --teal-deep: #012D31;
    --val: #ECFAFA;
    --val-dim: #A9B8B8;
    --cream: #F3E8D2;
    --muted: #6E7C7C;
    --label: #C9D6D6;
    --hair: rgba(50, 204, 204, .22);
    --font: Archivo, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  }

  * { box-sizing: border-box; }

  html { color-scheme: dark; }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--val);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
  }

  #bgpattern {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: url("assets/decorative-background.svg");
    background-size: 560px 315px;
    background-repeat: repeat;
    opacity: .32;
  }

  #shell {
    position: relative;
    z-index: 1;
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  /* ---------------------------------------------------------------- chrome */
  header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: 56px;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    background: rgba(11, 11, 11, .94);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--hair);
  }

  .bibe { height: 20px; width: auto; display: block; flex: none; }
  .wbc { height: 36px; width: auto; display: block; flex: none; }

  .strip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 32px;
    padding: 4px 16px;
  }

  .feed { display: flex; align-items: center; gap: 6px; }
  .feed .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--teal); box-shadow: 0 0 7px var(--teal); flex: none;
  }
  .feed .lab { font-size: 10px; font-weight: 800; letter-spacing: .09em; color: var(--teal); }
  .feed .sub { font-size: 9.5px; font-weight: 700; letter-spacing: .05em; color: var(--muted); }
  body.lost .feed .dot { background: var(--cream); box-shadow: none; }
  body.lost .feed .lab { color: var(--cream); }

  #banner {
    display: none;
    align-items: center;
    gap: 10px;
    margin: 4px 16px 0;
    padding: 8px 12px;
    border: 1px solid rgba(243, 232, 210, .45);
    background: rgba(243, 232, 210, .07);
    border-radius: 11px;
  }
  body.lost #banner { display: flex; }
  #banner .t { font-size: 12px; font-weight: 800; letter-spacing: .05em; color: var(--cream); }
  #banner .s { font-size: 10px; font-weight: 600; letter-spacing: .03em; color: var(--muted); margin-top: 2px; }

  #board {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 16px 0;
  }

  footer {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 46px;
    margin: 10px 16px 0;
    border-top: 1px solid var(--hair);
  }
  footer .pw { display: flex; align-items: center; gap: 7px; }
  footer .pw span { font-style: italic; font-weight: 700; font-size: 11px; color: #FFF; }


  /* ----------------------------------------------------------------- card */
  .machine {
    background: var(--card);
    border: 1.5px solid var(--teal);
    border-radius: 14px;
    overflow: hidden;
  }

  .mhead {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 12px;
    background: var(--teal);
    color: #000;
  }
  .mhead .st {
    font-size: 15px; font-weight: 800; letter-spacing: .04em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
  }

  .mbody { padding: 10px; }

  /* arrival flash — the only live signal */
  .sec {
    border: 1px solid rgba(50, 204, 204, 0);
    background: rgba(50, 204, 204, 0);
    border-radius: 9px;
  }
  @keyframes arriveOnce {
    0%   { background: rgba(50,204,204,.22); border-color: rgba(50,204,204,.90); }
    45%  { background: rgba(50,204,204,.13); border-color: rgba(50,204,204,.55); }
    100% { background: rgba(50,204,204,0);   border-color: rgba(50,204,204,0); }
  }
  .sec.flash { animation: arriveOnce 3s ease-out both; }

  @media (prefers-reduced-motion: reduce) {
    .sec.flash { animation-duration: .01s; background: rgba(50,204,204,.13); border-color: rgba(50,204,204,.5); }
  }

  /* a machine with nothing on any group head for 30 minutes */
  .machine.quiet { border-color: var(--teal-dim); }
  .machine.quiet .mhead { background: var(--teal-deep); color: var(--teal); }
  .machine.quiet .mhead svg { stroke: var(--teal); }
  .qbody { height: 156px; display: flex; align-items: center; gap: 16px; padding: 0 6px; }
  .qbody .qt {
    font-size: 16px; font-weight: 800; color: #FFF; line-height: 1.15; letter-spacing: -.01em;
  }
  .qbody .qt span { color: var(--muted); }
  .qbody .qs { font-size: 11px; font-weight: 700; letter-spacing: .03em; color: var(--teal); margin-top: 7px; }
  .qbody .ql {
    font-size: 9.5px; font-weight: 700; letter-spacing: .07em; color: var(--muted);
    margin-top: 10px; font-variant-numeric: tabular-nums;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .spin { animation: spin 1.5s linear infinite; }
  @media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

  .stale .val { color: var(--val-dim); }
  .stale .ts { color: var(--teal-dim); }

  /* a group head with no shot on record — em-dashes, never zeros */
  .sec.empty .val, .sec.empty .ts { color: var(--muted); }

  /* --------------------------------------------------- layout A: metric rows */
  .layA .grid {
    display: grid;
    grid-template-columns: minmax(62px, 80px) repeat(3, minmax(0, 1fr));
    gap: 6px;
    align-items: stretch;
  }
  .layA .rail { display: flex; flex-direction: column; gap: 8px; }
  .layA .rail .sp { height: 18px; }
  .layA .rail .rl {
    display: flex; align-items: center; gap: 6px; height: 30px;
  }
  .layA .rail .rl span {
    display: flex; flex-direction: column; min-width: 0;
    font-size: 11.5px; font-weight: 700; letter-spacing: .05em; color: var(--label); line-height: 1.12;
  }
  .layA .rail .rl span em {
    font-size: 10px; font-weight: 600; letter-spacing: .03em; color: var(--muted); font-style: normal;
  }
  .layA .rail .rt {
    height: 15px; display: flex; align-items: flex-end;
    font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--muted);
  }
  .layA .sec {
    display: flex; flex-direction: column; gap: 8px; padding: 0 2px; min-width: 0;
  }
  .layA .gh {
    height: 18px; display: flex; align-items: center; justify-content: center;
  }
  .layA .gid { font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--teal); }
  .layA .val {
    height: 30px; display: flex; align-items: center; justify-content: center;
    font-size: clamp(19px, 6.2vw, 27px); font-weight: 800; line-height: 1;
    font-variant-numeric: tabular-nums; color: var(--val);
  }
  .layA .ts {
    height: 15px; display: flex; align-items: flex-end; justify-content: center;
    font-size: 10px; font-weight: 700; letter-spacing: .03em; color: var(--teal);
    font-variant-numeric: tabular-nums;
  }

  /* ---------------------------------------------------- layout B: group rows */
  .layB .mbody { padding: 8px 8px 10px; display: flex; flex-direction: column; gap: 4px; }
  .layB .bh, .layB .sec {
    display: grid;
    grid-template-columns: minmax(52px, 62px) repeat(3, minmax(0, 1fr));
    gap: 6px;
    align-items: center;
    padding: 0 4px;
  }
  .layB .bh { height: 20px; }
  .layB .bh .k { font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
  .layB .bh .u {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--label);
  }
  .layB .sec { height: 36px; }
  .layB .glab { display: flex; flex-direction: column; justify-content: center; gap: 2px; }
  .layB .glab .r { display: flex; align-items: center; gap: 4px; }
  .layB .gid { font-size: 12px; font-weight: 800; letter-spacing: .08em; color: var(--teal); }
  .layB .ts {
    font-size: 9.5px; font-weight: 700; letter-spacing: .04em; color: var(--muted);
    font-variant-numeric: tabular-nums;
  }
  .layB .val {
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(17px, 5.6vw, 23px); font-weight: 800; line-height: 1;
    font-variant-numeric: tabular-nums; color: var(--val);
  }

  
  /* ----------------------------------------------------------- preview bar */
  #shell { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  #preview {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: rgba(6, 12, 12, .93);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, .10);
  }
  #preview .tag {
    font-size: 9px; font-weight: 800; letter-spacing: .12em; color: #5C6A6A;
    line-height: 1; margin-right: 2px;
  }
  #preview .seg { display: flex; gap: 6px; }
  #preview button {
    min-width: 46px; min-height: 44px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .16);
    background: transparent;
    color: #9FB0B0;
    font-family: var(--font);
    font-size: 12px; font-weight: 800; letter-spacing: .06em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  #preview button[aria-pressed="true"] {
    background: rgba(50, 204, 204, .16);
    border-color: var(--teal);
    color: var(--teal);
  }
  #preview .wide { min-width: 70px; font-size: 10px; letter-spacing: .06em; }

/* ------------------------------------------------------------------- 404 */
.notfound {
  flex: 1 1 auto; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 24px; padding: 0 30px; text-align: center;
}
.nf-ring { position: relative; width: 108px; height: 108px; flex: none; }
.nf-ring img { position: absolute; inset: 0; width: 100%; height: 100%; }
.nf-ring img + img { left: 24%; top: 24%; width: 52%; height: 52%; }
.nf-t { font-size: 24px; font-weight: 800; color: #FFF; letter-spacing: -.01em; }
.nf-s { font-size: 13px; font-weight: 700; color: var(--teal); }
.nf-s a { color: var(--teal); text-decoration: none; }
.nf-s a:hover { color: var(--val); }
