/* Mode clar (per defecte): com la pantalla de pinyes d'APPsistència, fons blanc i
   caselles blanques amb vora grisa. Els colors d'assistència són els seus (pinyes.css). */
:root {
  --fons: #eef0f3;
  --panell: #ffffff;
  --vora: #d5d8de;
  --text: #15171c;
  --suau: #5d6270;
  --vermell: #d0202f;
  --capcalera: #ffffff;
  --caixa: #ffffff;
  --fila: #f1f2f5;
  --pastilla: #e3e5ea;
  --velo: rgba(20, 22, 28, .45);
  --llegenda: rgba(255, 255, 255, .92);
  --focus: #15171c;
  --c3: #d9a520;
  --buida: #c4c8d0;
  --ve: #ffffff;
  --ve-text: #111111;
  --ve-vora: #8a8f99;
  --baix-vora: #6b707b;
  --potser: #ff9800;
  --no-ve: #e0202f;
  --lesionat: #b22222;
  --nsnc: #e0202f;
  --problem: #000000;
  --problem-vora: transparent;
  --problem2: #808080;
  --problem3: #c8c8c8;
}

/* Mode fosc: fons fosc, però les caselles mantenen els colors de l'app. El blanc de
   «ve» és el que es llegeix millor de lluny, i el negre queda reservat a les
   restriccions (problem), que aquí porten una vora clara per no fondre's amb el fons. */
:root[data-tema="fosc"] {
  --fons: #101114;
  --panell: #17191e;
  --vora: #2a2d35;
  --text: #f1f1f3;
  --suau: #9a9ca5;
  --capcalera: #0b0c0f;
  --caixa: #14161b;
  --fila: #17191e;
  --pastilla: #2a2d35;
  --velo: rgba(0, 0, 0, .72);
  --llegenda: rgba(16, 17, 20, .85);
  --focus: #ffffff;
  --buida: #3a3e48;
  --ve: #f4f4f6;
  --ve-vora: transparent;
  --baix-vora: #7a7f8c;
  --problem-vora: #e6e6e6;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fons);
  color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  border-bottom: 3px solid var(--vermell);
  background: var(--capcalera);
}
body.sense-barra header { display: none; }

#castell { display: flex; align-items: baseline; gap: 14px; min-width: 260px; justify-content: center; }
#nom { font-size: 40px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; }
#posicio { font-size: 20px; color: var(--suau); }

button {
  font: inherit;
  color: var(--text);
  background: var(--panell);
  border: 2px solid var(--vora);
  border-radius: 10px;
  cursor: pointer;
}
button:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
.vista.activa, .fila.sel { color: #fff; }
.tema { width: auto; padding: 0 12px; font-size: 22px; display: inline-flex; align-items: center; white-space: nowrap; }
.tema b { font-size: 18px; color: var(--suau); margin-right: 6px; }
.ctl { font-size: 26px; width: 60px; height: 50px; }
#vistes { display: flex; gap: 8px; margin-left: 16px; flex-wrap: nowrap; }
.vista { font-size: 19px; padding: 9px 13px; white-space: nowrap; }
.vista b { color: var(--suau); margin-right: 6px; }
.vista.activa { background: var(--vermell); border-color: var(--vermell); }
.vista.activa b { color: #fff; }
#dreta { margin-left: auto; text-align: right; min-width: 0; }
#esdeveniment { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 380px; }
#estat { font-size: 14px; color: var(--suau); }
.obre { width: auto; padding: 0 14px; font-size: 24px; }
.obre b { font-size: 18px; color: var(--suau); margin-right: 6px; }
#estat.error { color: #ff7b7b; }

main {
  flex: 1;
  display: grid;
  gap: 6px;
  padding: 6px;
  min-height: 0;
}
/* La pinya és la que s'ha de veure de lluny: sempre s'emporta la part gran. */
main[data-vista="p"] { grid-template: "pinya" 1fr / 1fr; }
main[data-vista="pf"] { grid-template: "pinya folre" 1fr / 60fr 40fr; }
main[data-vista="pft"] { grid-template: "pinya folre" 58fr "pinya tronc" 42fr / 58fr 42fr; }
main[data-vista="pt"] { grid-template: "pinya tronc" 1fr / 70fr 30fr; }
main[data-vista="f"] { grid-template: "folre" 1fr / 1fr; }
main[data-vista="ft"] { grid-template: "folre tronc" 1fr / 60fr 40fr; }
main[data-vista="t"] { grid-template: "tronc" 1fr / 1fr; }

.panell {
  position: relative;
  background: var(--panell);
  border: 1px solid var(--vora);
  border-radius: 10px;
  overflow: hidden;
  min-height: 0;
}
.panell h2 {
  position: absolute;
  top: 8px; left: 12px;
  margin: 0;
  font-size: 18px;
  letter-spacing: 3px;
  color: var(--suau);
  z-index: 2;
}
.panell .buit {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--suau);
}
.llenc { position: absolute; transform-origin: 0 0; }

.pos {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  color: var(--ve-text);
  background: var(--ve);
  box-shadow: inset 0 0 0 1.5px var(--ve-vora);
}
/* Com a APPsistència: vents i crosses arrodonits, el baix amb la vora gruixuda. */
.pos.rodona { border-radius: 10px; }
.pos.baix { box-shadow: inset 0 0 0 3px var(--baix-vora); }
.pos.buida { background: transparent; box-shadow: inset 0 0 0 1.5px var(--buida); }
.pos.potser { background: var(--potser); color: #fff; box-shadow: none; }
.pos.no_ve { background: var(--no-ve); color: #fff; box-shadow: none; }
.pos.lesionat { background: var(--lesionat); color: #fff; box-shadow: none; }
.pos.nsnc { color: var(--nsnc); box-shadow: inset 0 0 0 3px var(--nsnc); }
/* Restriccions en aquesta prova (p. ex. «NO DISPONIBLE»): problem, problem2, problem3 */
.pos.problem { background: var(--problem); color: #fff; box-shadow: inset 0 0 0 2px var(--problem-vora); }
.pos.problem2 { background: var(--problem2); color: #fff; box-shadow: none; }
.pos.problem3 { background: var(--problem3); color: var(--nsnc); box-shadow: none; }

#llegenda {
  position: fixed; left: 14px; bottom: 12px; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 10px;
  background: var(--llegenda);
  font-size: 15px; color: var(--suau);
}
#llegenda .mostra { position: static; width: 26px; height: 16px; margin-left: 8px; }
#llegenda .mostra:first-child { margin-left: 0; }
body.sense-barra #llegenda { display: none; }

/* Selector d'assajos i diades */
#selector {
  position: fixed; inset: 0; z-index: 10;
  background: var(--velo);
  display: flex; align-items: center; justify-content: center;
}
#selector[hidden] { display: none; }
#selector .caixa {
  width: min(1500px, 92vw);
  background: var(--caixa);
  border: 2px solid var(--vora);
  border-top: 6px solid var(--vermell);
  border-radius: 18px;
  padding: 22px 28px 16px;
}
#selector .cap { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
#selector h2 { margin: 0; font-size: 32px; }
#pagina { font-size: 18px; color: var(--suau); }
#files { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fila {
  display: grid;
  grid-template-columns: 52px 210px 92px 1fr 130px;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--fila);
  cursor: pointer;
}
.fila .num { font-size: 26px; font-weight: 800; color: var(--suau); text-align: center; }
.fila .quan { font-size: 21px; }
.fila .quan small { display: block; font-size: 15px; color: var(--suau); }
.fila .hora { font-size: 21px; color: var(--suau); }
.fila .que { min-width: 0; }
.fila .desc { font-size: 23px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .cast { font-size: 16px; color: var(--suau); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .tipus { justify-self: end; font-size: 15px; font-weight: 700; letter-spacing: 1px; padding: 5px 12px; border-radius: 999px; background: var(--pastilla); }
.fila .tipus.diada { background: var(--c3); color: #111; }
.fila.actual { border-color: #555a66; }
.fila.actual .num { color: var(--text); }
.fila.sel { background: var(--vermell); border-color: var(--focus); }
.fila.sel .num, .fila.sel .quan small, .fila.sel .hora, .fila.sel .cast { color: #fff; }
.fila.avui .quan small { color: #d98a00; }
.fila.sel.avui .quan small { color: #ffe08a; }
#selector .ajuda { margin-top: 12px; font-size: 17px; color: var(--suau); text-align: center; }

/* Pantalla d'aparellament (tele sense autoritzar) */
#aparellament {
  position: fixed; inset: 0; z-index: 20;
  background: var(--fons);
  display: flex; align-items: center; justify-content: center;
}
#aparellament[hidden] { display: none; }
.caixa-codi { text-align: center; max-width: 1100px; padding: 40px; }
.caixa-codi h2 { font-size: 54px; margin: 0 0 30px; }
.caixa-codi p { font-size: 30px; margin: 10px 0; color: var(--suau); }
.caixa-codi .url { font-size: 40px; font-weight: 800; color: var(--text); }
#aparella-codi {
  margin: 36px auto 20px;
  font-size: 150px; font-weight: 800; letter-spacing: 18px;
  color: var(--vermell);
  font-variant-numeric: tabular-nums;
}
.caixa-codi .avis { font-size: 24px; }
