* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --grass-dark: #1c7a37;
  --grass-light: #229244;
  --line-white: rgba(255, 255, 255, 0.55);
  --panel: rgba(0, 0, 0, 0.45);
  --accent: #ffd21e;
  --danger: #e5473c;
  --save: #2ecc71;
}

html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    repeating-linear-gradient(
      90deg,
      var(--grass-dark) 0px,
      var(--grass-dark) 90px,
      var(--grass-light) 90px,
      var(--grass-light) 180px
    );
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(#111a, #1118);
  border-bottom: 3px solid var(--accent);
  position: relative;
  z-index: 2;
}

.brand { display: flex; align-items: center; gap: 10px; }
.ball { font-size: 1.8rem; }

.brand h1 {
  font-size: 1.5rem;
  letter-spacing: 3px;
  font-weight: 800;
  text-shadow: 0 2px 4px #0008;
}

.var-badge {
  background: var(--accent);
  color: #111;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 1.1rem;
  letter-spacing: 2px;
}

.top-right { display: flex; align-items: center; gap: 14px; }

.camera-select {
  background: #222;
  color: #fff;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 6px 8px;
  max-width: 200px;
  font-size: 0.85rem;
}

.icon-btn {
  background: #222;
  color: #fff;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 1.05rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

.live-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #111;
  border: 1px solid #444;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 0.85rem;
}

.live-pill.off { opacity: 0.4; }

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink 1.2s infinite;
}

@keyframes blink { 50% { opacity: 0.25; } }

.clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.1rem;
  background: #111;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid #444;
}

/* ---------- pitch ---------- */
.pitch { flex: 1; position: relative; padding: 22px 16px 40px; }

.pitch-lines { position: absolute; inset: 0; pointer-events: none; opacity: 0.6; }

.center-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(52vw, 460px);
  aspect-ratio: 1;
  border: 4px solid var(--line-white);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.center-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  background: var(--line-white);
  transform: translateX(-50%);
}

/* ---------- match bar ---------- */
.matchbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap; /* scoreboard + end-match need room on narrow screens */
  width: min(96vw, 900px);
  margin: 0 auto 18px;
  background: var(--panel);
  border-radius: 12px;
  padding: 10px 46px 10px 16px;
  backdrop-filter: blur(4px);
}

.mb-team { text-align: center; min-width: 0; }

.mb-name {
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 1px;
  color: var(--accent);
  text-shadow: 0 2px 4px #0008;
}

.mb-players { font-size: 0.82rem; opacity: 0.85; min-height: 1em; }

.mb-vs { font-size: 1.3rem; }

/* ---------- scoreboard ---------- */
.mb-score { display: flex; align-items: center; gap: 6px; }
.mb-score.hidden { display: none; }

.score-num {
  font-size: 2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  min-width: 1.4em;
  text-align: center;
  color: var(--accent);
  text-shadow: 0 2px 4px #0008;
}

.score-btn {
  border: none;
  border-radius: 10px;
  background: #ffffff22;
  color: #fff;
  width: 42px;
  height: 42px;
  font-size: 1.4rem;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.score-btn.plus { background: var(--save); color: #06290f; }
.score-btn:active { filter: brightness(1.25); }

.mb-end {
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #111;
  font-weight: 800;
  padding: 9px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mb-end.hidden { display: none; }

.mb-edit {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: #ffffff1e;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 1rem;
}

.teams-panel {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  width: min(96vw, 900px);
  margin: -8px auto 18px;
  background: #0e1a12ee;
  border: 1px solid #ffffff22;
  border-radius: 12px;
  padding: 14px;
}

.teams-panel.hidden { display: none; }

.tp-side { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 200px; }

.tp-side input {
  background: #0b120d;
  border: 1px solid #ffffff33;
  border-radius: 8px;
  color: #fff;
  padding: 10px 12px;
  font-size: 1rem;
}

.tp-side input.tp-name { font-weight: 700; border-color: var(--accent); }

/* ---------- title & suggestions ---------- */
.title-row { display: flex; gap: 8px; }

.title-row input {
  flex: 1;
  background: #0b120d;
  border: 1px solid #ffffff33;
  border-radius: 10px;
  color: #fff;
  padding: 11px 14px;
  font-size: 1.05rem;
}

.suggestions { display: flex; gap: 8px; flex-wrap: wrap; }

.suggestions button {
  border: none;
  border-radius: 999px;
  background: #ffffff16;
  border: 1px solid #ffffff2c;
  color: #ffdf6b;
  padding: 7px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.suggestions button:active { background: #ffffff30; }

/* ---------- saved list title edit ---------- */
.replay-item .title-edit {
  width: 100%;
  background: #0b120d;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  padding: 6px 8px;
  font-size: 0.95rem;
}

/* ---------- stage ---------- */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 1;
}

.video-frame {
  position: relative;
  width: min(96vw, 900px);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 40px #0007, 0 0 0 5px #ffffff22;
}

.video-frame video { width: 100%; height: 100%; object-fit: cover; }

.video-overlay-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  font-size: 1.1rem;
  background: #000c;
}

.video-overlay-msg.hidden { display: none; }

.buffer-badge {
  position: absolute;
  bottom: 10px;
  right: 12px;
  background: #000a;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- replay button ---------- */
.replay-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 18px 64px;
  border: none;
  border-radius: 999px;
  background: radial-gradient(circle at 50% 25%, #ff6a5e, var(--danger) 70%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 0 #90261e, 0 14px 30px #0007;
  transition: transform 0.08s, box-shadow 0.08s;
  -webkit-tap-highlight-color: transparent;
}

.replay-btn:active:not(:disabled) {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #90261e, 0 6px 14px #0007;
}

.replay-btn:disabled { filter: grayscale(0.8); opacity: 0.6; cursor: not-allowed; }

.replay-icon { font-size: 2.2rem; line-height: 1; }
.replay-text { font-size: 1.7rem; font-weight: 900; letter-spacing: 5px; }
.replay-sub { font-size: 0.85rem; opacity: 0.9; letter-spacing: 1px; }

/* ---------- saved replays shelf ---------- */
.shelf {
  position: relative;
  z-index: 1;
  margin: 34px auto 0;
  width: min(96vw, 900px);
  background: var(--panel);
  border-radius: 14px;
  padding: 16px 18px 18px;
  backdrop-filter: blur(4px);
}

.shelf h2 { font-size: 1.05rem; letter-spacing: 1px; margin-bottom: 12px; }

.replay-list { display: flex; flex-direction: column; gap: 8px; }

.empty-msg { opacity: 0.7; font-size: 0.95rem; padding: 6px 2px; }

.replay-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0006;
  border: 1px solid #ffffff1c;
  border-radius: 10px;
  padding: 10px 12px;
}

.replay-item .meta { flex: 1; min-width: 0; }
.replay-item .title { font-weight: 700; font-size: 0.98rem; }
.replay-item .sub { font-size: 0.8rem; opacity: 0.65; }

.replay-item button, .replay-item a {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: #ffffff22;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.replay-item button.play { background: var(--save); color: #06290f; }
.replay-item button.del { background: #e5473c33; color: #ffb3ad; }

/* ---------- replay overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: #000d;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 14px;
}

.overlay.hidden { display: none; }

.overlay-inner {
  width: min(96vw, 1000px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.replay-banner {
  align-self: center;
  background: var(--accent);
  color: #111;
  font-weight: 900;
  letter-spacing: 6px;
  font-size: 1.3rem;
  padding: 6px 34px;
  border-radius: 8px;
  transform: skewX(-12deg);
  box-shadow: 0 4px 18px #0009;
  animation: bannerPulse 1.6s infinite;
}

@keyframes bannerPulse { 50% { box-shadow: 0 4px 30px #ffd21e66; } }

.overlay-inner video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  outline: 3px solid #ffffff2a;
}

.overlay-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.spacer { flex: 1; }

.rate-group { display: flex; border-radius: 10px; overflow: hidden; border: 1px solid #ffffff33; }

.rate-group button {
  border: none;
  background: #ffffff14;
  color: #fff;
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.rate-group button.active { background: var(--accent); color: #111; }

.ctrl-btn {
  border: none;
  border-radius: 10px;
  background: #ffffff1e;
  color: #fff;
  padding: 11px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn.save { background: var(--save); color: #06290f; }
.ctrl-btn.slack, .replay-item button.slack { background: #4a154b; color: #fff; }
.ctrl-btn.danger { background: var(--danger); }
.ctrl-btn.hidden { display: none; }

/* ---------- standings ---------- */
.standings-box {
  background: #16211a;
  border: 1px solid #ffffff2a;
  border-radius: 16px;
  padding: 20px 22px;
  width: min(96vw, 860px);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 18px 50px #000a;
}

.standings-head { display: flex; align-items: center; justify-content: space-between; }
.standings-head h2 { font-size: 1.3rem; letter-spacing: 1px; }

.standings-cols { display: flex; gap: 20px; flex-wrap: wrap; }
.standings-col { flex: 1; min-width: 260px; }
.standings-col h3 { font-size: 1rem; margin-bottom: 8px; letter-spacing: 1px; }

.standings-col table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.standings-col th, .standings-col td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid #ffffff18;
}

.standings-col th { opacity: 0.6; font-size: 0.8rem; letter-spacing: 1px; }
.standings-col th.l, .standings-col td.l { text-align: left; }
.standings-col tr:nth-child(2) td { color: var(--accent); } /* leader row */

.match-log { display: flex; flex-direction: column; gap: 6px; }

.match-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0006;
  border: 1px solid #ffffff1c;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.92rem;
}

.match-row .ml-when { opacity: 0.6; font-size: 0.82rem; white-space: nowrap; }
.match-row .ml-result { flex: 1; font-weight: 700; }

.match-row .ml-del {
  border: none;
  border-radius: 8px;
  background: #e5473c33;
  color: #ffb3ad;
  padding: 7px 11px;
  cursor: pointer;
}

/* ---------- pin gate ---------- */
.pin-box {
  background: #16211a;
  border: 1px solid #ffffff2a;
  border-radius: 16px;
  padding: 28px 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(90vw, 320px);
  box-shadow: 0 18px 50px #000a;
}

.pin-title { font-size: 1.15rem; font-weight: 800; letter-spacing: 1px; text-align: center; }

.pin-box input {
  background: #0b120d;
  border: 1px solid #ffffff33;
  border-radius: 10px;
  color: #fff;
  font-size: 1.4rem;
  text-align: center;
  letter-spacing: 6px;
  padding: 12px;
}

.pin-error { color: #ffb3ad; text-align: center; font-size: 0.9rem; }
.pin-error.hidden { display: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #111e;
  border: 1px solid #ffffff33;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 20;
  transition: opacity 0.3s;
}

.toast.hidden { opacity: 0; pointer-events: none; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .brand h1 { font-size: 1.1rem; }
  .clock { display: none; }
  .camera-select { max-width: 120px; }
  .replay-btn { padding: 14px 44px; }
}
