:root {
  --bg: #0b1114;
  --bg-2: #121b1f;
  --card: #162127;
  --line: #22323a;
  --text: #e9f1f4;
  --muted: #8ba3ad;
  --green: #16c964;
  --green-dark: #0f9a4c;
  --amber: #f0a92b;
  --red: #ec4646;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

body { padding-bottom: env(safe-area-inset-bottom); }

a { color: var(--green); }

/* ---------------------------------------------------------------- topo */
header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(11, 17, 20, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .2px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(22,201,100,.7); }
.spacer { flex: 1; }

.top .who { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.3; }

.iconbtn {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
  cursor: pointer;
}
.iconbtn:active { background: #1b262c; }

/* --------------------------------------------------------------- layout */
main { padding: 14px; max-width: 780px; margin: 0 auto; }

.banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.45;
  border: 1px solid transparent;
}
.banner.warn { background: rgba(240,169,43,.12); border-color: rgba(240,169,43,.35); color: #ffd58f; }
.banner.err  { background: rgba(236,70,70,.12);  border-color: rgba(236,70,70,.35);  color: #ffb3b3; }
.banner.info { background: rgba(22,201,100,.10); border-color: rgba(22,201,100,.3);  color: #b7f5d1; }
.hidden { display: none !important; }

/* ------------------------------------------------------- modo partida */
.match-off {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 20px 22px;
  text-align: center;
  margin-bottom: 14px;
}
.match-off .match-icon { font-size: 44px; line-height: 1; margin-bottom: 10px; }
.match-off h2 { margin: 0 0 6px; font-size: 19px; }
.match-off p { margin: 0 auto; max-width: 330px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.match-off p.tiny { font-size: 12px; margin-top: 12px; }
.primary.big { max-width: 320px; margin: 20px auto 0; padding: 17px; font-size: 17px; }

.match-off input[type=text] { max-width: 320px; margin: 18px auto 0; text-align: center; }

.match-on {
  background: rgba(236,70,70,.10);
  border: 1px solid rgba(236,70,70,.35);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 14px;
}
.match-on-topo { display: flex; align-items: center; gap: 10px; }
.match-on-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.match-on-txt strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-on-txt span { font-size: 11.5px; color: var(--muted); }

.btn-marcar {
  width: 100%; margin-top: 10px;
  border: 1px solid rgba(240,169,43,.5); background: rgba(240,169,43,.14); color: #ffd58f;
  border-radius: 10px; padding: 13px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-marcar:active { transform: scale(.99); background: rgba(240,169,43,.25); }
.btn-marcar:disabled { opacity: .6; }
.rec-dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--red);
  animation: pulse 1.6s ease-in-out infinite; flex: none;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.btn-stop {
  margin-left: auto;
  border: 1px solid rgba(236,70,70,.5); background: transparent; color: #ffadad;
  border-radius: 9px; padding: 8px 13px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.btn-stop:active { background: rgba(236,70,70,.15); }
.ctl.share { background: var(--green); color: #04210f; border-color: var(--green); }

/* ------------------------------------------------------------- replay */
.replay-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.cams-strip {
  display: flex; flex-wrap: wrap; gap: 7px 15px;
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.cams-strip .cam-item { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.cams-strip .cam-item.on { color: var(--text); }
.cams-strip .cam-item .obs { font-size: 11px; opacity: .85; }
.replay-dica { margin: 13px 13px 0; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.4; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.on  { background: var(--green); box-shadow: 0 0 8px rgba(22,201,100,.8); }
.status-dot.off { background: var(--red); }

.btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; }

/* abas de câmera no player */
.abas { display: flex; gap: 6px; padding: 0 2px 8px; overflow-x: auto; }
.aba {
  border: 1px solid var(--line); background: var(--bg-2); color: var(--muted);
  border-radius: 10px; padding: 9px 13px; font-size: 13px; font-weight: 650;
  cursor: pointer; white-space: nowrap; flex: none;
}
.aba.ativa { background: var(--green); color: #04210f; border-color: var(--green); }
.aba:disabled { opacity: .45; cursor: not-allowed; }
.aba .carregando { font-weight: 500; font-size: 11px; opacity: .8; }

.replay-btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--green) 0%, var(--green-dark) 100%);
  color: #04210f;
  font-size: 17px;
  font-weight: 750;
  padding: 16px 6px;
  cursor: pointer;
  transition: transform .06s ease, filter .15s ease;
  line-height: 1.15;
}
.replay-btn small { display: block; font-size: 10px; font-weight: 600; opacity: .75; margin-top: 3px; letter-spacing: .4px; }
.replay-btn:active { transform: scale(.96); }
.replay-btn:disabled { filter: grayscale(.7) brightness(.6); cursor: not-allowed; }

/* --------------------------------------------------- gravações guardadas */
.sec-head { display: flex; align-items: baseline; gap: 8px; margin: 26px 2px 12px; flex-wrap: wrap; }
.sec-head h2 { margin: 0; font-size: 16px; }
.sec-sub { font-size: 12px; color: var(--muted); }

.rec {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.rec-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 13px;
  cursor: pointer;
}
.rec-head .quando { font-weight: 650; font-size: 14.5px; }
.rec-head .info { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.rec-head .seta { margin-left: auto; color: var(--muted); font-size: 13px; transition: transform .18s ease; }
.rec.aberta .rec-head .seta { transform: rotate(90deg); }
.rec-body { display: none; padding: 0 13px 14px; border-top: 1px solid var(--line); }
.rec.aberta .rec-body { display: block; }

.rec-body label { margin-top: 14px; }
.slider-linha { display: flex; align-items: center; gap: 10px; }
input[type=range] { flex: 1; accent-color: var(--green); height: 30px; }
.momento {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px;
  min-width: 74px; text-align: right;
}
.chips { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  border-radius: 9px; padding: 9px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--green); color: #04210f; border-color: var(--green); }
.chip.baixar { text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.chip.baixar:active { background: var(--green); color: #04210f; border-color: var(--green); }
.rec-body .primary { margin-top: 14px; padding: 13px; font-size: 15px; }

/* miniatura do momento + marcações na linha do tempo */
.preview {
  position: relative;
  width: 100%; aspect-ratio: 16/9;
  background: #000 center/cover no-repeat;
  border-radius: 10px; border: 1px solid var(--line);
  margin-top: 8px; overflow: hidden;
}
.preview .vazio {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12.5px;
}
.preview .carimbo {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(0,0,0,.72); color: #fff; font-size: 12px; font-weight: 700;
  padding: 3px 8px; border-radius: 6px; font-variant-numeric: tabular-nums;
}

.trilha { position: relative; height: 16px; margin: 2px 2px 0; }
.pino {
  position: absolute; top: 0; transform: translateX(-50%);
  width: 16px; height: 16px; border: none; background: transparent;
  color: var(--amber); font-size: 13px; line-height: 16px; cursor: pointer; padding: 0;
}
.pino:active { transform: translateX(-50%) scale(1.25); }

.marcas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.marca-btn {
  border: 1px solid rgba(240,169,43,.4); background: rgba(240,169,43,.12); color: #ffd58f;
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.marca-btn.sel { background: var(--amber); color: #2a1c00; }
.marca-btn.destaque { border-color: rgba(22,201,100,.55); background: rgba(22,201,100,.14); color: #a8f0c8; }
.marca-btn.destaque.sel { background: var(--green); color: #04210f; }
.pino.destaque { color: var(--green); }

/* caixa do link temporário */
.link-box {
  border: 1px solid var(--line); background: var(--bg-2);
  border-radius: 12px; padding: 12px; margin-top: 10px;
}
.link-titulo { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.link-titulo span { font-weight: 500; color: var(--muted); font-size: 12px; }
.link-box input { font-size: 13px; }
.link-acoes { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 9px; }
.link-aviso { font-size: 11.5px; color: var(--muted); margin: 9px 0 0; line-height: 1.45; }

/* --------------------------------------------------------------- player */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: #04080a;
  display: flex; flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
}
.overlay .head { display: flex; align-items: center; gap: 10px; padding: 4px 4px 10px; }
.overlay .head .title { font-weight: 700; font-size: 15px; }
.overlay .head .sub { font-size: 11px; color: var(--muted); }

.videowrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background: #000; border-radius: 12px; overflow: hidden; min-height: 0;
}
.videowrap video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--green);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.controls { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 10px; justify-content: center; }
.ctl {
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  border-radius: 10px; padding: 11px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.ctl.active { background: var(--green); color: #04210f; border-color: var(--green); }
.ctl:active { transform: scale(.96); }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 22px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 26px 22px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=time], select, textarea {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text); font-size: 15px; font-family: inherit;
}
input:focus, select:focus { outline: 2px solid rgba(22,201,100,.4); outline-offset: 1px; }

.primary {
  width: 100%; margin-top: 18px; padding: 14px; border: none; border-radius: 11px;
  background: var(--green); color: #04210f; font-size: 16px; font-weight: 750; cursor: pointer;
}
.primary:active { transform: scale(.99); }
.primary:disabled { opacity: .6; }

/* ---------------------------------------------------------------- admin */
.tabs { display: flex; gap: 6px; padding: 12px 14px 0; max-width: 980px; margin: 0 auto; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); border-radius: 10px 10px 0 0; padding: 10px 14px; cursor: pointer; font-size: 14px; font-weight: 600; }
.tab.active { background: var(--card); color: var(--text); border-bottom-color: var(--card); }

.panel { max-width: 980px; margin: 0 auto; padding: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card p.hint { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; }

.pill { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.pill.ok { background: rgba(22,201,100,.16); color: #7ff0b2; }
.pill.bad { background: rgba(236,70,70,.16); color: #ffadad; }
.pill.wait { background: rgba(240,169,43,.16); color: #ffd58f; }

.btn-sm { border: 1px solid var(--line); background: var(--bg-2); color: var(--text); border-radius: 8px; padding: 7px 11px; font-size: 12.5px; cursor: pointer; font-weight: 600; }
.btn-sm.danger { border-color: rgba(236,70,70,.4); color: #ffadad; }
.btn-sm.go { background: var(--green); color: #04210f; border-color: var(--green); }

.win-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 7px; align-items: center; margin-bottom: 7px; }

dialog {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 16px; padding: 18px; width: min(520px, calc(100vw - 28px)); max-height: 88dvh;
}
dialog::backdrop { background: rgba(0,0,0,.7); }
dialog h3 { margin: 0 0 12px; font-size: 17px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom));
  background: #1d2b32; border: 1px solid var(--line); color: var(--text);
  padding: 12px 16px; border-radius: 12px; font-size: 14px; z-index: 90; max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast.err { border-color: rgba(236,70,70,.5); color: #ffbcbc; }
