/* Jerry Sox "Matrix" theme — same tokens as the Jerry Sox app */
:root {
  --bg: #000000;
  --g: #00e33b;            /* brand green: accents, own name, primary actions */
  --t1: #d1fadc;           /* body text */
  --t2: #31964c;           /* secondary text, labels */
  --t3: #109132;           /* faint text, placeholders */
  --line: #00721e;         /* borders */
  --gdd: color-mix(in srgb, var(--bg) 86%, var(--g));   /* header bars, selected */
  --surf: color-mix(in srgb, var(--bg) 94%, var(--g));  /* panels */
  --faint: #064a18;
  --on: #000000;           /* text on solid green */
  --cyan: #2ee6c9;         /* other people's names, like the chat */
  --gold: #e8ff4a;         /* daily winners */
  --bad: #ff5c5c;
  --glow: 0 0 8px color-mix(in srgb, var(--g) 55%, transparent);
  --font: "Courier New", Courier, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  /* the faint dashed "rain" from the Jerry Sox icon */
  background-image: repeating-linear-gradient(180deg, transparent 0 6px, var(--bg) 6px 10px),
    repeating-linear-gradient(90deg, transparent 0 63px, color-mix(in srgb, var(--faint) 35%, transparent) 63px 64px);
  color: var(--t1);
  font: 15px/1.5 var(--font);
}
a { color: var(--g); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--g); outline-offset: 2px; }
::selection { background: var(--g); color: var(--on); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); border-left: 1px solid var(--gdd); }
::-webkit-scrollbar-thumb { background: var(--line); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--g); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none !important; }
.js-mark { width: 38px; height: 38px; flex: none; filter: drop-shadow(var(--glow)); }
.brand-text { display: grid; gap: 2px; }
.js-word {
  color: var(--g); font-weight: 700; font-size: 22px; letter-spacing: .32em; line-height: 1;
  text-shadow: var(--glow); display: inline-flex; align-items: center;
}
.cursor { display: inline-block; width: .55em; height: 1.05em; background: var(--g); margin-left: 2px; box-shadow: var(--glow); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }
.identity { color: var(--t2); font-size: 12px; letter-spacing: .08em; }
.identity b { color: var(--t1); font-weight: 700; border-bottom: 1px dashed var(--t2); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--g); box-shadow: var(--glow); margin-left: 4px; vertical-align: middle; }

.game-switch { margin-right: auto; }
nav { display: flex; gap: 6px; flex-wrap: wrap; }
/* boxed buttons with a thick left edge, like the app's Chat / Voice / Members */
nav a {
  color: var(--t1); padding: 7px 12px; text-decoration: none !important;
  border: 1px solid var(--line); border-left: 4px solid var(--line); background: var(--surf);
  letter-spacing: .06em;
}
nav a:hover { border-color: var(--g); color: var(--g); }
nav a.active { border-color: var(--g); border-left-color: var(--g); color: var(--g); background: var(--gdd); }
nav a.cta { background: var(--g); color: var(--on); border-color: var(--g); font-weight: 700; }
nav a.cta:hover { color: var(--on); box-shadow: var(--glow); }

main { max-width: 900px; margin: 0 auto; padding: 22px 16px 80px; }

/* ---------- type ---------- */
h1, h2, h3 { font-weight: 700; margin: 0; }
h1 { font-size: 24px; letter-spacing: .14em; text-transform: uppercase; color: var(--g); text-shadow: var(--glow); }
/* section titles look like the app's panel header bars */
h2 {
  font-size: 13px; font-weight: 400; color: var(--g); text-transform: uppercase; letter-spacing: .3em;
  margin: 28px 0 0; padding: 10px 14px; background: var(--gdd); border: 1px solid var(--line); border-bottom: 0;
}
h2 + * { border-top-left-radius: 0 !important; border-top-right-radius: 0 !important; }
h2 + .board, h2 + .row, h2 + p, h2 + .grid { border: 1px solid var(--line); padding: 12px; background: var(--surf); margin: 0; }
.muted { color: var(--t2); }
.dim { color: var(--t1); }
.center { text-align: center; }
.pad { padding: 40px 0; }
.big { font-size: 64px; font-weight: 700; line-height: 1; color: var(--g); text-shadow: var(--glow); letter-spacing: .02em; }
.cyan { color: var(--cyan); }
.gold { color: var(--gold); }
.good { color: var(--g); }
.bad { color: var(--bad); }
.num { font-variant-numeric: tabular-nums; }
.label { font-size: 11px; letter-spacing: .25em; text-transform: uppercase; color: var(--t2); }

/* ---------- layout bits ---------- */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.hero .sub { letter-spacing: .3em; color: var(--t2); font-size: 12px; text-transform: uppercase; }
.hero .sub::before { content: '> '; color: var(--g); }
.hero .cyan { color: var(--t1); }
.card { background: var(--surf); border: 1px solid var(--line); padding: 16px; }
.grid { display: grid; gap: 12px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile { background: var(--surf); border: 1px solid var(--line); border-left: 4px solid var(--line); padding: 12px 14px; }
.tile .v { font-size: 28px; font-weight: 700; color: var(--g); margin-top: 4px; line-height: 1.1; text-shadow: var(--glow); }
.tile .s { color: var(--t2); font-size: 12px; margin-top: 2px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---------- boards (styled like chat messages) ---------- */
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
h2 + .board { padding: 0; }
.board li {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--gdd); border-left: 3px solid transparent;
}
.board li:last-child { border-bottom: 0; }
.board li.me { border-left-color: var(--g); background: color-mix(in srgb, var(--bg) 90%, var(--g)); }
.rank { font-size: 18px; font-weight: 700; color: var(--t2); text-align: center; }
.rank.r1 { color: var(--gold); text-shadow: 0 0 8px color-mix(in srgb, var(--gold) 50%, transparent); }
.rank.r2 { color: var(--t1); }
.rank.r3 { color: var(--g); }
.who { min-width: 0; }
.who a { color: var(--cyan); font-weight: 700; }
.board li.me .who a, tr.me td:nth-child(2) a { color: var(--g); }
.who a.bad, td a.bad { color: var(--bad); font-weight: 400; }
.who .meta { color: var(--t2); font-size: 12px; }
.you { font-size: 11px; color: var(--t2); margin-left: 6px; letter-spacing: .05em; }
.score { font-size: 24px; font-weight: 700; color: var(--g); text-align: right; text-shadow: var(--glow); }
.score small { display: block; font-size: 11px; font-weight: 400; color: var(--t2); text-shadow: none; }
.crown { color: var(--gold); margin-left: 4px; }
.fire { color: #ffb347; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  background: var(--bg); border: 1px solid var(--line); font-size: 13px; color: var(--t1);
}
.thumb { width: 36px; height: 52px; object-fit: cover; object-position: top; border: 1px solid var(--line); cursor: zoom-in; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surf); }
h2 + .table-wrap { border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--gdd); }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
th { font-weight: 400; font-size: 11px; letter-spacing: .2em; color: var(--t2); text-transform: uppercase; cursor: pointer; user-select: none; background: var(--bg); }
th.sorted { color: var(--g); }
th.sorted::after { content: ' ▾'; }
td a { color: var(--cyan); }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: color-mix(in srgb, var(--bg) 92%, var(--g)); }
tr.unq td { color: var(--t3); }
tr.unq td a { color: var(--t3); }

/* ---------- controls ---------- */
.tabs { display: inline-flex; border: 1px solid var(--line); background: var(--bg); }
.tabs button {
  border: 0; border-right: 1px solid var(--gdd); background: none; padding: 7px 14px; cursor: pointer;
  font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--t2);
}
.tabs button:last-child { border-right: 0; }
.tabs button:hover { color: var(--g); }
.tabs button.on { color: var(--g); background: var(--gdd); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: transparent; color: var(--g);
  padding: 8px 16px; cursor: pointer; text-decoration: none !important;
  letter-spacing: .08em; text-transform: uppercase; font-size: 13px;
}
.btn:hover:not(:disabled) { background: var(--g); color: var(--on); border-color: var(--g); }
.btn.primary { background: var(--g); color: var(--on); border-color: var(--g); font-weight: 700; }
.btn.primary:hover:not(:disabled) { box-shadow: var(--glow); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, var(--bg)); border-style: dashed; }
.btn.danger:hover:not(:disabled) { background: var(--bad); color: var(--on); border-color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 11px; }
.pager { display: flex; align-items: center; gap: 8px; }
.pager .btn { padding: 6px 10px; }

form.stack { display: grid; gap: 14px; }
label.field { display: grid; gap: 6px; }
label.field > span { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--t2); }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); background: var(--bg);
  outline: none; font-size: 16px; color: var(--t1); caret-color: var(--g); border-radius: 0;
}
textarea { font: 16px/1.5 var(--font); resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--t3); }
input:focus, textarea:focus, select:focus { border-color: var(--g); box-shadow: 0 0 0 1px var(--g); }
input.auto { border-color: var(--g); background: var(--gdd); }
.err { color: var(--bad); min-height: 1.5em; }
.auth { max-width: 400px; margin: 24px auto; }
.auth .big { font-size: 40px; letter-spacing: .12em; }
.auth .switch { margin-top: 14px; text-align: center; color: var(--t2); }

/* ---------- upload ---------- */
.drop {
  display: grid; place-items: center; text-align: center; gap: 8px; min-height: 180px; padding: 24px;
  border: 1px dashed var(--line); background: var(--surf); cursor: pointer;
}
.drop.over { border-color: var(--g); background: var(--gdd); }
.upload-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 220px) 1fr; align-items: start; }
.upload-grid .preview img { border: 1px solid var(--line); }
.progress { height: 4px; background: var(--gdd); overflow: hidden; }
.progress > div { height: 100%; background: var(--g); width: 0; transition: width .2s; box-shadow: var(--glow); }
.tiers { letter-spacing: .1em; white-space: nowrap; }
.big-tiers { font-size: 20px; margin-top: 2px; }
.tile-v { font-size: 22px; font-weight: 700; color: var(--g); margin-top: 2px; text-shadow: var(--glow); }
.embed-wrap { border: 1px solid var(--line); overflow: hidden; background: var(--bg); }
.embed-wrap iframe { display: block; width: 100%; height: min(820px, 85vh); border: 0; }
.auto-status { margin-bottom: 12px; border-left: 4px solid var(--line); }
.auto-status.ok { border-color: var(--g); color: var(--g); }
.auto-status.muted { color: var(--t2); }

@media (max-width: 600px) {
  .upload-grid { grid-template-columns: 1fr; }
  .upload-grid .preview img { max-height: 260px; margin: 0 auto; }
  .big { font-size: 48px; }
  .js-word { font-size: 18px; letter-spacing: .24em; }
  .game-switch { margin-right: 0; }
  .board li { grid-template-columns: 26px 1fr auto; gap: 10px; padding: 10px; }
  .top { gap: 10px; }
  nav { width: 100%; display: grid; grid-template-columns: repeat(5, auto); gap: 4px; }
  nav a { padding: 6px 4px; font-size: 13px; text-align: center; border-left-width: 3px; }
}

/* ---------- chart ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--gdd); stroke-width: 1; }
.chart .axis-label { fill: var(--t2); font: 10px var(--font); }
.chart .series { fill: none; stroke: var(--g); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; filter: drop-shadow(0 0 3px color-mix(in srgb, var(--g) 60%, transparent)); }
.chart .area { fill: url(#areaFill); }
.chart .avg-line { stroke: var(--cyan); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .dot { fill: var(--g); stroke: var(--surf); stroke-width: 2; }
.chart .dot.won { fill: var(--gold); }
.chart .cross { stroke: var(--t2); stroke-width: 1; }
.tip {
  position: absolute; pointer-events: none; background: var(--bg); border: 1px solid var(--g);
  padding: 8px 10px; font-size: 12px; white-space: nowrap; transform: translate(-50%, calc(-100% - 12px));
}
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--t2); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--g); vertical-align: middle; margin-right: 6px; }
.legend i.avg { border-top: 1px dashed var(--cyan); }
.legend i.won { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--gold); }

/* ---------- awards ---------- */
.awards { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.award { border-left: 4px solid var(--g); }
.award .t { font-size: 13px; letter-spacing: .2em; color: var(--g); text-transform: uppercase; }
.award .b { color: var(--t2); font-size: 12px; margin: 2px 0 10px; }
.award .w { font-size: 18px; font-weight: 700; color: var(--cyan); }
.award .x { color: var(--t1); font-size: 13px; }
.award.empty { border-left-color: var(--line); }
.award.empty .t { color: var(--t2); }
.award.empty .w { color: var(--t3); font-weight: 400; font-size: 13px; }

/* ---------- members side panel (like the chat app's MEMBERS panel) ---------- */
.layout.with-panel {
  max-width: 1260px; margin: 0 auto; padding: 0 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 22px; align-items: start;
}
.layout.with-panel main { max-width: none; margin: 0; padding-left: 0; padding-right: 0; }
.members-panel {
  position: sticky; top: 76px; margin-top: 22px; max-height: calc(100vh - 100px); overflow-y: auto;
  border: 1px solid var(--line); background: var(--surf);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 8px 8px 14px; background: var(--gdd); border-bottom: 1px solid var(--line);
  color: var(--g); font-size: 13px; letter-spacing: .25em; text-transform: uppercase;
}
.hide-btn { border: 1px solid var(--line); background: var(--bg); color: var(--t2); padding: 3px 9px; font-size: 12px; cursor: pointer; letter-spacing: .05em; }
.hide-btn:hover { color: var(--g); border-color: var(--g); }
.members-show {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; cursor: pointer;
  border: 1px solid var(--g); border-left-width: 4px; background: var(--bg); color: var(--t1); padding: 8px 14px; font-size: 13px;
}
.members-show:hover { background: var(--gdd); }
.presence-on { color: var(--cyan); }
.members { list-style: none; margin: 0; padding: 6px 0; }
.member {
  display: grid; grid-template-columns: 16px minmax(0, 1fr); grid-template-areas: "dot name" "dot status" "dot played";
  gap: 1px 8px; padding: 7px 12px; border-left: 3px solid transparent;
}
.member.me { border-left-color: var(--g); }
.presence { grid-area: dot; color: var(--t3); line-height: 1.5; }
.member.online .presence { color: var(--cyan); text-shadow: 0 0 6px color-mix(in srgb, var(--cyan) 60%, transparent); }
.m-name { grid-area: name; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .m-name a { color: var(--cyan); }
.member:not(.online) .m-name a { color: var(--t2); }
.member.me .m-name a { color: var(--g); }
.m-status { grid-area: status; font-size: 12px; color: var(--t3); }
.member.online .m-status { color: var(--cyan); opacity: .8; }
.m-played { grid-area: played; display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.played { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--t3); border: 1px solid var(--gdd); padding: 0 5px; }
.played.on { color: var(--g); border-color: var(--line); }
.offline-toggle {
  display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--gdd); background: none; cursor: pointer;
  padding: 8px 14px; color: var(--t2); font-size: 12px; letter-spacing: .2em; text-transform: uppercase;
}
.offline-toggle:hover { color: var(--g); }

/* narrower screens: panel goes under the page content */
@media (max-width: 1000px) {
  .layout.with-panel { display: block; padding: 0; }
  .layout.with-panel main { padding: 22px 16px 24px; }
  .members-panel { position: static; max-height: none; margin: 0 16px 80px; }
}

/* ---------- full-screen moments (fx.js) ---------- */
.fx-overlay {
  position: fixed; inset: 0; z-index: 100; background: #000; display: grid; place-items: center;
  opacity: 0; transition: opacity .4s ease; cursor: pointer;
}
.fx-overlay.in { opacity: 1; }
.fx-overlay.out { opacity: 0; }
.fx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .55; }
.fx-canvas.crisp { opacity: .8; }
.fx-content { position: relative; padding: 24px; text-align: center; }
.fx-boot { display: grid; justify-items: center; gap: 14px; }
.fx-logo { width: 96px; height: 96px; filter: drop-shadow(0 0 18px #00e33b99); animation: fx-pop .7s cubic-bezier(.2, 1.6, .4, 1) both; }
.fx-title { color: var(--g); font-size: 30px; font-weight: 700; letter-spacing: .35em; text-shadow: var(--glow); display: inline-flex; align-items: center; animation: fx-rise .5s .2s both; }
.fx-lines {
  min-width: min(440px, 86vw); min-height: 7em; text-align: left; margin-top: 6px;
  background: #000c; border: 1px solid var(--line); border-left: 4px solid var(--g); padding: 12px 16px;
  color: var(--t1); font-size: 15px; line-height: 1.6;
}
.fx-line:last-child { color: var(--g); text-shadow: var(--glow); }
.fx-hint { color: var(--t3); font-size: 11px; letter-spacing: .25em; text-transform: uppercase; }

.fx-streak { display: grid; justify-items: center; gap: 8px; }
.fx-flame { font-size: 96px; line-height: 1; animation: fx-pop .8s cubic-bezier(.2, 1.8, .4, 1) both, fx-flicker 1.4s 1s ease-in-out infinite; filter: drop-shadow(0 0 24px #ffb34799); }
.fx-days {
  font-size: clamp(34px, 9vw, 72px); font-weight: 700; letter-spacing: .12em; color: var(--g);
  text-shadow: 0 0 12px #00e33b, 0 0 32px #00e33b88; animation: fx-rise .6s .25s both;
}
.fx-badge {
  border: 1px solid var(--gold); color: var(--gold); padding: 6px 16px; letter-spacing: .3em; text-transform: uppercase;
  background: #000c; box-shadow: 0 0 16px #e8ff4a55; animation: fx-rise .6s .45s both;
}
.fx-sub { color: var(--t1); animation: fx-rise .6s .6s both; }
.fx-btn { margin-top: 14px; animation: fx-rise .6s .8s both; }
.fx-value {
  font-size: clamp(44px, 12vw, 96px); font-weight: 700; color: #fff; line-height: 1;
  text-shadow: 0 0 10px #00e33b, 0 0 30px #00e33b; animation: fx-rise .5s .35s both; font-variant-numeric: tabular-nums;
}
.fx-score .fx-flame { animation: fx-pop .8s cubic-bezier(.2, 1.8, .4, 1) both; filter: drop-shadow(0 0 24px #2ee6c999); }
.fx-score.pb .fx-flame { filter: drop-shadow(0 0 24px #e8ff4a99); }
.fx-score.pb .fx-days { color: var(--gold); text-shadow: 0 0 12px #e8ff4a, 0 0 32px #e8ff4a88; }
@keyframes fx-pop { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fx-rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fx-flicker { 50% { transform: scale(1.06) rotate(-2deg); } }
@media (prefers-reduced-motion: reduce) {
  .fx-logo, .fx-title, .fx-flame, .fx-days, .fx-badge, .fx-sub, .fx-btn, .fx-value { animation: none; }
  .fx-canvas { display: none; }
}

/* ---------- misc ---------- */
#lightbox { position: fixed; inset: 0; background: #000e; display: grid; place-items: center; z-index: 50; cursor: zoom-out; padding: 16px; }
#lightbox img { max-height: 92vh; max-width: 100%; border: 1px solid var(--g); }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: .25s;
  background: var(--bg); border: 1px solid var(--g); color: var(--g); padding: 10px 16px; z-index: 60;
  max-width: calc(100% - 32px); box-shadow: var(--glow);
}
#toast::before { content: '> '; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty-state { text-align: center; padding: 28px 16px; color: var(--t2); border: 1px dashed var(--line); background: var(--surf); }
.empty-state .btn { margin-top: 12px; }
