/* app.css (scoreboard + controller) — SCHOON (zonder dubbele overrides)
   Doelen:
   - Score (bigScore) blijft stabiel en komt NIET op logo's
   - Teamnamen + dots bovenin (absolute), main eronder
   - Logo’s zijn fixed, maar layout reserveert onderruimte (--logoSpace)
   - Teamkleuren via --t1Color/--t2Color (JS zet ze)
*/

:root{
  --bg:#000;
  --panel:#101010;
  --muted:#bdbdbd;
  --white:#fff;

  /* defaults (JS overschrijft via state) */
  --t1Color:#d40000;
  --t2Color:#2f6bff;

  --edge: 20px;
  --frame-pad: 18px;

  /* ruimte onderin zodat score nooit in logo/QR komt */
  --logoSpace: 280px; /* tune: 200-260 */
}

*{ box-sizing:border-box; font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial; }
html, body{ height:100%; }
body{ margin:0; background:var(--bg); color:var(--white); }

/* =======================
   SCOREBOARD
   ======================= */
body.scoreboard{
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Frame vult scherm en is kolom-layout */
body.scoreboard .frame{
  margin: 0;
  height: 100dvh;
  min-height: 100dvh;
  border-radius: 0;
  padding: 18px;
  box-sizing: border-box;

  border: 2px solid #2a2a2a;
  background: radial-gradient(1000px 600px at 50% 50%, #0b0b0b 0%, #000 60%);
  position: relative;

  display: flex;
  flex-direction: column;
}

/* Bovenkant: we reserveren hoogte voor teamnaam + dots */
body.scoreboard .top{
  position: relative;
  flex: 0 0 auto;
  height: 170px;          /* tune: 160-210 */
  padding-top: 20px;
  padding-bottom: 20px;
}

/* Teamnamen (absolute in top) */
body.scoreboard .teamName{
  position: absolute;
  top: 12px;
  font-weight: 900;
  font-size: clamp(48px, 5vw, 82px);
  letter-spacing: 0.5px;
  text-shadow: 0 4px 18px rgba(0,0,0,0.6);

  max-width: 45vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.scoreboard .teamName.left{
  left: var(--edge);
  color: var(--t1Color);
}

body.scoreboard .teamName.right{
  right: 20px;
  color: var(--t2Color);
  text-align: right;
}

/* Dots onder teamnaam */
body.scoreboard .teamDots{
  position: absolute;
  top: 120px;
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  max-width: 45vw;
  min-height: 18px;
  pointer-events: none;
  margin: 0;
  padding: 0;
}

body.scoreboard #team1Dots{
  left: var(--edge);
  justify-content:flex-start;
  color: var(--t1Color);
}

body.scoreboard #team2Dots{
  right: 28px;
  justify-content:flex-end;
  color: var(--t2Color);
}

body.scoreboard .teamDots .dot{
  width: 30px;
  height: 30px;
  border-radius: 999px;
  opacity: 0.18;
  background: currentColor;
}
body.scoreboard .teamDots .dot.on{ opacity: 1; }

/* Main vult alle resterende hoogte, en reserveert onderruimte voor logo/QR */
body.scoreboard .main{
  flex: 1 1 auto;
  min-height: 0;

  display:flex;
  align-items:stretch;
  justify-content:space-between;
  gap: 24px;

  padding-bottom: var(--logoSpace);
  box-sizing: border-box;
}

/* Links/rechts kolom */
body.scoreboard .side{
  flex: 1;
  min-width: 0;
  min-height: 0;

  display:flex;
  flex-direction:column;

  padding-left: 60px;
  padding-right: 60px; /* symmetrisch */
  align-items:flex-start;
}

body.scoreboard .side.right{
  align-items:flex-end;
  text-align:right;
}

/* Spelers boven score */
body.scoreboard .players{
  flex: 0 0 auto;
  font-size: clamp(50px, 4vw, 70px);  /* schaalt mee met scherm */
  font-weight: 700;
  opacity: .95;
  margin: 40px 0 18px 0;
  line-height: 1.15;
}

/* spelers kleuren mee per kant */
body.scoreboard #p1{ color: var(--t1Color); }
body.scoreboard #p2{ color: var(--t2Color); }

body.scoreboard .players {
  max-width: 800px; /* pas aan naar smaak per zijde */
}

body.scoreboard .players div {
  white-space: normal;       /* afbreken toestaan */
  word-break: break-word;   /* lange woorden afbreken */
  overflow-wrap: anywhere;  /* ook bij samengestelde namen */
}


/* Grote score: neemt rest van de kolom, centreert verticaal binnen de beschikbare ruimte */
body.scoreboard .bigScore{
  flex: 1 1 auto;
  min-height: 0;

  display:flex;
  align-items:center;        /* verticaal midden */
  justify-content:flex-start;

  width: 100%;
  font-size: 320px;
  line-height: 1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

body.scoreboard .side.right .bigScore{
  justify-content:flex-end;
}

body.scoreboard #big1{ color: var(--t1Color); }
body.scoreboard #big2{ color: var(--t2Color); }

/* Winner glow */
body.scoreboard.matchOver.winnerT1 #big1{
  text-shadow: 0 0 22px color-mix(in srgb, var(--t1Color) 55%, transparent);
}
body.scoreboard.matchOver.winnerT2 #big2{
  text-shadow: 0 0 22px color-mix(in srgb, var(--t2Color) 55%, transparent);
}

/* Set history (midden bovenin) */
body.scoreboard .setHistory{
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 40%;
  text-align: center;
  background: transparent;
  pointer-events: none;
}

body.scoreboard .setRow{
  display:flex;
  justify-content:center;
  align-items:center;
  margin: 10px 0;
}
body.scoreboard .setScoreBig{
  display: grid;
  grid-template-columns: 2ch 1ch 2ch;
  align-items: center;
  justify-items: center;

  font-size: 64px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;

  text-shadow: 0 8px 30px rgba(0,0,0,.65);
}
body.scoreboard .setScoreBig .dash{
  display:inline-block;
  width: 1.2ch;
  text-align:center;
  opacity: .9;
}
body.scoreboard .setRow.win-t1 .setScoreBig{ color: var(--t1Color); }
body.scoreboard .setRow.win-t2 .setScoreBig{ color: var(--t2Color); }

@media (min-width: 1200px){
  body.scoreboard .setScoreBig{ font-size: 78px; }
  body.scoreboard .setScoreBig .dash{ width: 1.25ch; }
}

/* Set history score: cijfers "naar het streepje toe" uitlijnen */
.setScoreBig{
  display: inline-grid;
  grid-template-columns: 2ch auto 2ch; /* 2 tekens breed voor cijfers */
  align-items: baseline;
  column-gap: .45ch;
  font-variant-numeric: tabular-nums; /* gelijke cijferbreedte */
}

.setScoreBig .setA{
  text-align: right;   /* links richting dash */
}

.setScoreBig .dash{
  text-align: center;
}

.setScoreBig .setB{
  text-align: left;    /* rechts richting dash */
}

/* Legacy QR (rechtsonder) */
body.scoreboard .qrWrap{
  position: fixed;
  right: calc(var(--edge) + var(--frame-pad));
  bottom: var(--edge);
  display:flex;
  align-items:flex-end;
  gap:14px;
  z-index: 9999;
}
body.scoreboard .qrText{ font-size:14px; color:#d9d9d9; text-align:right; opacity:.9; }
body.scoreboard .qrImg{ width:92px; height:92px; border-radius:8px; background:#fff; padding:6px; }

/* Fullscreen knop */
body.scoreboard .fsBtn{
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;

  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid #333;
  background: rgba(20,20,20,0.85);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  backdrop-filter: blur(6px);

  opacity: 1;
  transition: opacity .25s ease;
}
body.scoreboard .fsBtn:hover{ background: rgba(40,40,40,0.9); }
body.scoreboard.is-fullscreen .fsBtn{ opacity: 0; pointer-events:none; }
body.scoreboard.is-fullscreen.show-ui .fsBtn{ opacity: 1; pointer-events:auto; }

/* Club logo linksonder */
body.scoreboard #clubLogo,
body.scoreboard img#clubLogo,
body.scoreboard .clubLogo{
  position: fixed;
  left: calc(var(--edge) + var(--frame-pad));
  bottom: var(--edge);
  width: 180px;
  height: auto;
  opacity: 0.85;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.6));
  pointer-events: none;
  z-index: 9999;
  display: block;
}

/* Tegenstander logo rechtsonder (als hideQr aan staat) */
body.scoreboard .oppLogoWrap{
  position: fixed;
  right: calc(var(--edge) + var(--frame-pad));
  bottom: var(--edge);
  display:none;
  align-items:flex-end;
  justify-content:flex-end;
  pointer-events:none;
  z-index: 9999;
}

/* hideQr: QR uit, oppLogo aan */
body.hide-qr .qrWrap{ display:none !important; }
body.hide-qr .oppLogoWrap{ display:flex !important; }

body.scoreboard .oppLogoImg{
  width: 180px;
  height: 180px;
  object-fit: contain;
  opacity: 0.9;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.65));
}

/* Pairing overlay (scoreboard) */
body.scoreboard .pairOverlay{
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none; /* JS togglet */
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(6px);
}
body.scoreboard .pairCard{
  width: min(520px, 92vw);
  background: rgba(12,12,12,0.92);
  border: 1px solid #2a2a2a;
  border-radius: 18px;
  padding: 26px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
}
body.scoreboard .pairTitle{ font-size: 28px; font-weight: 900; margin-bottom: 8px; }
body.scoreboard .pairHint{ color:#d0d0d0; opacity:.95; font-size:16px; margin-top:10px; }
body.scoreboard .pairCode{
  font-size: 76px;
  font-weight: 1000;
  letter-spacing: 10px;
  font-variant-numeric: tabular-nums;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #333;
  background: #050505;
}
body.scoreboard .pairQrImg{
  width: 220px;
  height: 220px;
  object-fit: contain;
  margin: 14px auto 6px;
  display:block;
  border-radius: 14px;
  background: #fff;
  padding: 10px;
}

/* =======================
   CONTROLLER
   ======================= */
body.control{
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
  color: var(--white);
}

body.control button,
body.control .btn,
body.control input,
body.control select,
body.control textarea{
  touch-action: manipulation;
}

body.control *{ -webkit-user-select:none; user-select:none; }
body.control input, body.control textarea{ -webkit-user-select:text; user-select:text; }

.control .ctrlWrap{
  height: 100dvh;
  padding: 10px;
  max-width: 720px;
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  gap: 10px;

  padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
}

.control .contentNoScroll{
  flex: 0 0 auto;
  min-height: 0;
  display: block;
}

.headerRow{
  display:grid;
  grid-template-columns: 1fr 44px 1fr;
  align-items:center;
  gap: 10px;
}
.colTitle{ font-size:18px; color:#eaeaea; }
.iconBtn{
  height:38px;
  border-radius:12px;
  background:#1b1b1b;
  border:1px solid #333;
  color:#fff;
  font-size:20px;
}

.metaRow{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.metaCol{
  background:#0c0c0c;
  border:1px solid #2a2a2a;
  border-radius:14px;
  padding: 8px;
}
label{
  display:block;
  color:var(--muted);
  font-size:12px;
  margin-top: 6px;
}
input, select{
  width:100%;
  margin-top:6px;
  padding: 9px 10px;
  border-radius:12px;
  border:1px solid #333;
  background:#050505;
  color:#fff;
  font-size:15px;
}
select option:disabled{ color:#999; }

.control #games{ flex: 0 0 auto; min-height: 0; display: block; }
.control #matchScore{ flex: 0 0 auto; margin-top: 8px; }

.gameRow{
  margin-top: 8px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.gameCard{
  background:#0c0c0c;
  border:1px solid #2a2a2a;
  border-radius:14px;
  padding: 7px;
  box-shadow: none;
}
.gameCard:focus,
.gameCard:focus-visible,
.gameCard *:focus,
.gameCard *:focus-visible{ outline: none !important; }

.gameCard, .gameCard *{ -webkit-tap-highlight-color: transparent; }

.gameCard.wonLeft{
  border-color: var(--t1Color);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--t1Color) 35%, transparent) inset;
}
.gameCard.wonRight{
  border-color: var(--t2Color);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--t2Color) 35%, transparent) inset;
}

.gameHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 8px;
  margin-bottom: 6px;
  min-height: 28px;
  min-width: 0;
}
.gameTitle{
  color:#eaeaea;
  font-size:14px;
  margin: 0;
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gameTools{ display:flex; gap: 6px; }
.toolBtn{
  width: 34px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid #2f2f2f;
  background: #121212;
  color: #eaeaea;
  font-weight: 900;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.scorePad{
  display:grid;
  grid-template-columns: 48px 82px 48px;
  gap: 7px;
  align-items:center;
}

.btn{
  height:48px;
  border-radius:13px;
  border:0;
  font-size:28px;
  font-weight:900;
  background:#3a3a3a;
  color:#fff;
}

.box{
  height:48px;
  width:82px;
  border-radius:13px;

  display:flex;
  align-items:center;
  justify-content:center;

  padding: 0 12px;
  box-sizing:border-box;

  font-size:28px;
  font-weight:900;
  line-height:1;

  border:1.5px solid #444;
  background:#070707;

  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
}
.box.orange{
  border-color: var(--t1Color);
  color: var(--t1Color);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--t1Color) 22%, transparent) inset;
}
.box.blue{
  border-color: var(--t2Color);
  color: var(--t2Color);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--t2Color) 22%, transparent) inset;
}

button.disabled,
button:disabled{
  opacity: .35;
  pointer-events: none;
}
.box.locked{ opacity: .5; }

/* extras drawer */
details.extras{
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));

  max-width: 720px;
  margin: 0 auto;

  z-index: 999;
  background:#0c0c0c;
  border:1px solid #2a2a2a;
  border-radius:14px;
  padding: 10px;
  box-shadow: 0 18px 40px rgba(0,0,0,.55);

  overflow: hidden;
  will-change: height;
}
details.extras > summary{
  list-style: none;
  cursor: pointer;
  position: relative;
  padding-right: 34px;
  user-select: none;
  font-size: 15px;
  color: #eaeaea;
}
details.extras > summary::-webkit-details-marker{ display:none; }
details.extras > summary::after{
  content:"›";
  position:absolute;
  right:12px;
  top:50%;
  transform: translateY(-50%) rotate(90deg);
  font-size:22px;
  opacity:.9;
  transition: transform .18s ease, opacity .18s ease;
}
details.extras[open] > summary::after{
  transform: translateY(-50%) rotate(-90deg);
  opacity:1;
}
details.extras .extrasBody{ margin-top: 10px; }

details.extras .check{
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin-top: 10px;
  font-size: 15px;
  color: #eaeaea;
}
details.extras[open]{
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.danger{
  margin-top:10px;
  width:100%;
  height:44px;
  border-radius:12px;
  border:1px solid #533;
  background:#2a0f0f;
  color:#fff;
  font-size:15px;
}

/* PIN GATE (controller) */
.pinGate{
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(6px);
}
.pinCard{
  width: min(520px, 92vw);
  background: rgba(12,12,12,0.92);
  border: 1px solid #2a2a2a;
  border-radius: 18px;
  padding: 22px;
  text-align: center;
}
.pinTitle{ font-size: 18px; font-weight: 900; margin-bottom: 12px; }
.pinInput{
  width: 180px;
  text-align: center;
  font-size: 34px;
  letter-spacing: 8px;
  font-weight: 900;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #333;
  background: #050505;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.pinBtn{
  margin-top: 14px;
  width: 100%;
  height: 46px;
  border-radius: 14px;
  border: 1px solid #333;
  background: #1b1b1b;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
}
.pinErr{
  margin-top: 10px;
  color: #ff6b6b;
  font-weight: 800;
  display:none;
}

/* Safari/iOS: voorkom “grid overflow” */
.metaRow > *, .gameRow > *{ min-width: 0; }
.metaCol, .gameCard{ min-width: 0; }

/* iPhone small */
@media (max-width: 390px){
  .control .ctrlWrap{ padding: 8px; gap: 8px; }
  .headerRow{ grid-template-columns: 1fr 40px 1fr; }
  .iconBtn{ height:36px; font-size:18px; }

  .metaRow{ gap: 8px; }
  .metaCol{ padding: 7px; border-radius: 13px; }
  input, select{ font-size:14px; padding: 8px 9px; }

  .gameRow{ gap: 8px; }
  .toolBtn{ width: 32px; height: 26px; border-radius: 9px; }

  .scorePad{ grid-template-columns: 46px 78px 46px; gap: 6px; }
  .btn{ height:46px; font-size:26px; border-radius:12px; }
  .box{ height:46px; width:78px; font-size:26px; border-radius:12px; padding: 0 11px; }

  details.extras{ left: 8px; right: 8px; }
}

/* ✅ voorkomt “flash” op iOS: UI pas tonen na auth */
body.boot #app { display: none; }

/* pinGate altijd boven alles */
.pinGate{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
}

/* control boot: verberg de app totdat auth rond is */
body.control.boot #app { display: none; }


/* safety */
.control, .control *{ max-width: 100%; }
