/* Team Buddies server status. Material 3 colour roles and motion, in the game's cartoon look: toy-army green,
   ink outlines, solid drop shadows, the crates the buddies stack. Rubik Bold: Copyright 2015 The Rubik Project
   Authors, SIL Open Font License 1.1 (the full text is next to the font in tbmatch_page.h). */
@font-face {
  font-family: "Rubik TB"; font-weight: 700; font-style: normal; font-display: swap;
  src: url(rubik-bold.woff2?v=ddca0faf) format("woff2");
}
:root {
  color-scheme: light dark;
  --display: "Rubik TB", "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif;
  --ink: #1b2012; --edge: #1b2012; --drop: #1b2012;
  --surface: #f6f1e1; --card: #fffdf6; --card-2: #f1ecda; --on-surface: #1b2012; --on-surface-variant: #535a43;
  --outline-variant: #ddd6bf;
  --primary: #3d7a17; --on-primary: #fff; --primary-container: #c8ee9c; --on-primary-container: #1f3d08;
  --relay: #2a6fdb; --label: #b45309; --peak: #1d5fc4;
  --error: #d32f2f; --on-error: #fff;
  --grass: #5fa52b; --crate: #529423; --crate-line: #46821c; --sun: #ffd84a;
  --t-quick: #ffd84a; --t-private: #9cc3ff; --t-battle: #ff9a73;
  --gap: #e9e3cd;
  --ease: cubic-bezier(.2, 0, 0, 1); --decel: cubic-bezier(.05, .7, .1, 1); --spring: cubic-bezier(.34, 1.56, .64, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --edge: #3d4631; --drop: #000;
    --surface: #12150d; --card: #1c2115; --card-2: #262c1d; --on-surface: #eef1e2; --on-surface-variant: #b8bea6;
    --outline-variant: #353c2b;
    --primary: #9bd765; --on-primary: #10260a; --primary-container: #2f5214; --on-primary-container: #c8ee9c;
    --relay: #6aa6ff; --label: #ffad5c; --peak: #7fb2ff;
    --error: #e5534b;
    --grass: #2f5a17; --crate: #2a5115; --crate-line: #234512;
    --gap: #2c3322;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surface); color: var(--on-surface);
  font: 400 14px/20px Roboto, "Segoe UI", system-ui, -apple-system, sans-serif; letter-spacing: .2px;
}
h1, h2, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
h2 { font: 700 17px/24px var(--display); text-transform: uppercase; letter-spacing: .4px; }

/* ---- hero: a field of crates under the title, rolling into the page */
.hero { position: relative; overflow: hidden; background: var(--grass); color: #fff; padding: 0 16px 64px; }
.field { position: absolute; left: -20%; top: 0; width: 140%; height: 110%; transform-origin: 50% 0;
  transform: perspective(520px) rotateX(38deg); }
.crate { fill: var(--crate); }
.crate-line { fill: none; stroke: var(--crate-line); stroke-width: 3; stroke-linejoin: round; }
.hero-bar, .hero-text { position: relative; max-width: 1040px; margin: 0 auto; }
.hero-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 18px/24px var(--display); text-shadow: 0 2px 0 #1b2012; }
.brand span { color: var(--sun); }
.brand img { display: block; }
.hero-text { padding: 18px 0 4px; }
h1 {
  font: 700 54px/1.05 var(--display); text-transform: uppercase; letter-spacing: 1px; color: #fff;
  -webkit-text-stroke: 8px #1b2012; paint-order: stroke fill; text-shadow: 0 6px 0 #1b2012;
}
.hero-text p { margin-top: 12px; font-size: 16px; line-height: 24px; font-weight: 500; text-shadow: 0 2px 0 #1b2012; }
.hills { position: absolute; left: 0; bottom: -1px; width: 100%; height: 56px; }
.hills-fill { fill: var(--surface); }
.hills-edge { fill: none; stroke: #1b2012; stroke-width: 3; vector-effect: non-scaling-stroke; }

.live {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px 0 12px; border-radius: 999px;
  background: #fff; color: #1b2012; border: 2.5px solid #1b2012; box-shadow: 0 3px 0 #1b2012;
  font: 700 13px/1 var(--display); text-transform: uppercase; letter-spacing: .6px; white-space: nowrap;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: #9aa08a; border: 2px solid #1b2012; }
.live[data-state="ok"] .dot { background: #4caf1f; }
.live[data-state="wait"] .dot { animation: wait 1s var(--ease) infinite alternate; }
.live[data-state="down"] { background: var(--error); color: #fff; }
.live[data-state="down"] .dot { background: #fff; }
/* one pulse per answer: the page is still asking */
.live[data-state="ok"].beat .dot { animation: beat .9s var(--ease); }
@keyframes beat {
  0% { transform: scale(1.5); box-shadow: 0 0 0 0 rgba(76, 175, 31, .6); }
  100% { transform: scale(1); box-shadow: 0 0 0 8px rgba(76, 175, 31, 0); }
}
@keyframes wait { from { opacity: .35; } to { opacity: 1; } }

/* ---- cards: ink outline, solid shadow */
main { position: relative; max-width: 1072px; margin: -12px auto 0; padding: 0 16px 40px; display: grid; gap: 20px; }
.card { padding: 20px; border-radius: 20px; background: var(--card); border: 2.5px solid var(--edge); box-shadow: 0 5px 0 var(--drop); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.count { font: 700 14px/20px var(--display); color: var(--on-surface-variant); }
.readout {
  padding: 4px 12px; border-radius: 999px; background: var(--primary-container); color: var(--on-primary-container);
  font: 700 13px/18px var(--display); font-variant-numeric: tabular-nums;
}

.offline { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 12px 12px 18px; background: var(--error); color: #fff; font-size: 15px; }
.offline[hidden] { display: none; }
.offline strong { font-family: var(--display); }
.btn {
  height: 40px; padding: 0 18px; border-radius: 999px; background: #fff; color: #1b2012; cursor: pointer;
  border: 2.5px solid #1b2012; box-shadow: 0 3px 0 #1b2012;
  font: 700 14px/1 var(--display); text-transform: uppercase; letter-spacing: .5px;
  transition: transform .1s var(--ease), box-shadow .1s var(--ease);
}
.btn:hover { background: #f4f4ec; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #1b2012; }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* ---- right now */
.now { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px 24px; margin-bottom: 22px; }
.now dt { font: 700 12px/16px var(--display); text-transform: uppercase; letter-spacing: 1px; color: var(--label); }
.now dd { margin-top: 4px; font: 700 42px/50px var(--display); }
.now .peak dd:not(.sub) { color: var(--peak); }
.now dd.sub { margin-top: 2px; font: 400 12px/16px Roboto, "Segoe UI", system-ui, sans-serif; letter-spacing: .3px; color: var(--on-surface-variant); }
.now dd.small { font-size: 32px; }
.stale .now dd, .stale .chart, .stale .rooms, .stale .sbar { opacity: .5; transition: opacity .3s var(--ease); }

/* ---- 24 h chart (SVG drawn by app.js) */
.chart { position: relative; height: 200px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid { stroke: var(--outline-variant); stroke-width: 1.5; stroke-dasharray: 3 6; }
.chart .ylab { fill: var(--on-surface-variant); font: 700 11px var(--display); }
.chart .area { fill: var(--primary-container); }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .gap { fill: var(--gap); }
.chart .cursor { stroke: var(--on-surface); stroke-width: 1.5; stroke-dasharray: 2 3; }
.chart .knob { fill: #fff; stroke: var(--ink); stroke-width: 2.5; }
.axis { display: flex; justify-content: space-between; margin-top: 8px; font: 700 11px/16px var(--display); color: var(--on-surface-variant); font-variant-numeric: tabular-nums; }
.axis-now { color: var(--primary); }
.gapnote { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; line-height: 16px; color: var(--on-surface-variant); }
.gapnote[hidden] { display: none; }

.split { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; align-items: start; }

/* ---- rooms */
.rooms li {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px;
  margin-top: 8px; padding: 10px 12px; border-radius: 14px; background: var(--card-2);
}
.rooms li:first-child { margin-top: 0; }
.ricon {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--t-private); color: #1b2012; border: 2.5px solid #1b2012; box-shadow: 0 3px 0 #1b2012;
}
.ricon[data-glyph="quick"] { background: var(--t-quick); }
.ricon.play { background: var(--t-battle); }
.ricon svg { width: 20px; height: 20px; fill: currentColor; }
.rmain { min-width: 0; }
.rtitle { font: 700 16px/22px var(--display); }
.rsub { color: var(--on-surface-variant); font-size: 13px; line-height: 18px; }
.slots { display: flex; gap: 4px; justify-content: flex-end; }
.slot { width: 11px; height: 20px; border-radius: 999px; border: 2px solid var(--on-surface-variant); }
.slot.on { background: var(--primary); border-color: var(--ink); }
.rcount { margin-top: 3px; text-align: right; font: 700 12px/16px var(--display); color: var(--on-surface-variant); }
.empty { padding: 8px 0 4px; color: var(--on-surface-variant); }
.empty[hidden], .more[hidden] { display: none; }
.empty-title { color: var(--on-surface); font: 700 16px/24px var(--display); margin-bottom: 4px; }
.more { margin-top: 10px; font: 700 13px/18px var(--display); color: var(--on-surface-variant); }

/* ---- direct vs relay */
.sbar { display: flex; height: 24px; border-radius: 999px; overflow: hidden; background: var(--card-2); border: 2.5px solid var(--edge); }
.seg { height: 100%; flex: 0 0 0; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .18); transition: flex-basis .9s var(--decel); }
.seg-direct, .key-direct { background: var(--primary); }
.seg-relay, .key-relay { background: var(--relay); }
.slegend { margin-top: 18px; display: grid; gap: 14px; }
.slegend > div { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center; }
.slegend dt { display: flex; align-items: center; gap: 10px; font: 700 15px/22px var(--display); }
.slegend dd { font: 700 22px/28px var(--display); }
.slegend dd.sub { grid-column: 1 / -1; padding-left: 26px; font: 400 12px/16px Roboto, "Segoe UI", system-ui, sans-serif; color: var(--on-surface-variant); }
.key { width: 16px; height: 16px; border-radius: 5px; flex: none; border: 2px solid var(--ink); }
.key-gap { background: var(--gap); border-color: var(--outline-variant); }
@media (prefers-color-scheme: dark) { .key { border-color: #000; } .key-gap { border-color: var(--outline-variant); } }

.side { display: grid; gap: 16px; }
.notes { padding: 0 6px; color: var(--on-surface-variant); font-size: 12px; line-height: 17px; display: grid; gap: 8px; max-width: 72ch; }

/* ---- motion: each one shows a change */
.overview, .split > .card, .side > .card { animation: rise .6s var(--spring) both; }
.split > .card { animation-delay: .08s; }
.side > .card { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.now dd .v { display: inline-block; }
.delta {
  display: inline-block; margin-left: 8px; vertical-align: 18px; padding: 0 7px; border-radius: 999px;
  font: 700 12px/20px var(--display); letter-spacing: .3px;
  background: var(--primary-container); color: var(--on-primary-container); opacity: 0;
}
.delta.down { background: var(--card-2); color: var(--on-surface-variant); }
.slegend .delta { vertical-align: 3px; }
.delta.show { animation: delta 2.6s var(--ease) both; }
@keyframes delta {
  0% { opacity: 0; transform: translateY(8px) scale(.8); }
  12%, 70% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-4px); }
}

/* the line is drawn from the left once, then the live end lands */
.chart .plot.reveal { animation: reveal 1.1s var(--decel) both; }
@keyframes reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.chart .now-dot { fill: #fff; stroke: var(--ink); stroke-width: 2.5; }
.chart .now-ring { fill: none; stroke: var(--primary); stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: ring 1.4s var(--decel) both; }
.chart .now-dot.late { animation: land .45s var(--spring) .9s both; transform-box: fill-box; transform-origin: center; }
.chart .now-ring.late { animation-delay: 1s; }
@keyframes ring { 0% { opacity: 0; } 1% { transform: scale(1); opacity: .8; } 100% { transform: scale(3.4); opacity: 0; } }
@keyframes land { from { transform: scale(0); } to { transform: scale(1); } }
@media (prefers-color-scheme: dark) { .chart .now-dot, .chart .knob { stroke: #000; } }

/* rooms come in, go out and slide (the sliding is done in app.js) */
.rooms { position: relative; }
.rooms li.enter { animation: enter .5s var(--spring) both; }
.rooms li.leave { position: absolute; left: 0; right: 0; margin: 0; pointer-events: none; animation: leave .3s var(--ease) forwards; }
@keyframes enter { from { opacity: 0; transform: translateY(-10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes leave { to { opacity: 0; transform: scale(.94); } }
/* a room whose battle starts turns from a circle into a flag tile */
.ricon { transition: border-radius .4s var(--ease), background-color .4s var(--ease); }
.ricon.play { border-radius: 12px; }
.ricon.swap { animation: swap .55s var(--spring); }
@keyframes swap { 0% { transform: scale(.6) rotate(-16deg); } 100% { transform: none; } }
/* a buddy taking a slot drops in; one leaving pops out */
.slot { transition: background-color .2s var(--ease), border-color .2s var(--ease); }
.slot.pop { animation: pop .5s var(--spring) both; }
.slot.drop { animation: drop .3s var(--ease) both; }
@keyframes pop { from { transform: translateY(-10px) scale(.4); } to { transform: none; } }
@keyframes drop { from { transform: scale(1.3); } to { transform: none; } }

.offline.enter, .empty.enter { animation: enter .4s var(--spring) both; }

/* first load: placeholders breathe until the first answer */
.loading .now dd:not(.sub), .loading .slegend dd:not(.sub) { color: transparent; }
.loading .now dd:not(.sub)::before, .loading .slegend dd:not(.sub)::before {
  content: ""; display: inline-block; width: 2.2em; height: .7em; border-radius: 999px; vertical-align: middle;
  background: var(--card-2); animation: wait 1s var(--ease) infinite alternate;
}
.loading .chart { border-radius: 14px; background: var(--card-2); animation: wait 1s var(--ease) infinite alternate; }

@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .now { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 40px; -webkit-text-stroke-width: 7px; text-shadow: 0 5px 0 #1b2012; }
  .now dd { font-size: 36px; line-height: 44px; }
  .now dd.small { font-size: 26px; }
}
@media (max-width: 400px) {
  .hero { padding-bottom: 52px; }
  .hero-bar { min-height: 64px; }
  .brand { font-size: 16px; }
  .hero-text { padding-top: 8px; }
  h1 { font-size: 32px; -webkit-text-stroke-width: 6px; text-shadow: 0 4px 0 #1b2012; }
  .hero-text p { font-size: 14px; line-height: 20px; }
  .card { padding: 16px; }
  .chart { height: 160px; }
  .rooms li { grid-template-columns: 40px 1fr auto; gap: 10px; padding: 10px; }
  .ricon { width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .chart .now-ring, .delta { display: none; }
}
