* {
  box-sizing:border-box
}
:root {
  --bg:#0b0b0f;--card:#11131a;--muted:#d1d5db;--brand:#22c55e;--brand2:#60a5fa;--danger: #ef4444;
}
html,body{height:100%}
.viewer-body{
  margin:0; font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,"Helvetica Neue",Arial;
  background:var(--bg); color:white; align-items:center; justify-content:center;
}

#externalOverlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 2147483647 !important; /* Maximum possible z-index */
    border: none !important;
    background: rgba(0, 0, 0, 0.9) !important;
    display: none; 
  }

  
.admin-body{
  margin:0; 
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,"Helvetica Neue",Arial;
  background:var(--bg); 
  color:white; 
  display:flex; 
  flex-direction: column;
  align-items:center; 
  justify-content:center;
  overflow-y: auto;
  height:auto;
  overflow-x: hidden;
}

.admin-page {
  width: 100%;
  display: flex;
  justify-content: center;
}

.viewer-page .container {
  width:100%; 
  max-width: 100%;
  margin:0 0 100px 0; 
  padding:clamp(10px, 3vw, 40px);
}

.admin-page .container {
  width:min(1200px,95vw); 
  margin:5px 20px 50px 20px; 
  padding:5px; 
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 1;
}

.grid {display:grid; gap:16px}
.card {
  margin: 5px; 
  border-radius:20px; 
  padding:15px; 
  box-sizing: border-box; /* Crucial: includes padding in width calculation */
  box-shadow:0 10px 30px rgba(0,0,0,.25);
}
.card1 { 
  padding: 5px;
}

.viewer-page .score-wrap {
  display:grid; 
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: clamp(20px, 5vw, 120px);
  align-items: stretch;
  margin-top: 60px;
}

.admin-page .score-wrap{display:grid; grid-template-columns:1fr 1fr; gap:100px; margin-top: 50px;}

.viewer-page .team {
  display:flex; 
  flex-direction:column; 
  align-items:center; 
  justify-content:center;
  min-height: clamp(180px, 30vh, 420px);
  
  padding:10px; 
  border-radius:16px; 
  background: rgba(0,0,0,0.5);
}
.admin-page .team{display:flex; flex-direction:column; align-items:center; justify-content:center; padding:10px; border-radius:16px; background: rgba(0,0,0,0.5);}

.viewer-page .team-a{border:5px solid var(--brand)}
.viewer-page .team-b{border:5px solid var(--brand2)}

.admin-page .team-a{border:5px solid var(--brand)}
.admin-page .team-b{border:5px solid var(--brand2)}


.viewer-page .team-name {
  font-size:clamp(40px,7.5vw,80px); 
  font-weight:900;
  text-align:center; 
  margin:0 0 8px;
  padding: clamp(10px, 2vw, 24px); 
  text-transform: uppercase;
  max-width: 100%;
}
.admin-page .team-name{font-size:clamp(20px,4vw,36px); font-weight:700; text-align:center; margin:0 0 8px; padding: 8px; text-transform: uppercase;}

.viewer-page .score {
  font-size:clamp(4rem,12vw,9rem);
  font-weight:800;
  line-height:1;
}

.admin-page .score{font-size:clamp(60px,14vw,160px); font-weight:800; line-height:1; letter-spacing:2px}

.meta{display:flex; gap:12px; justify-content:center; align-items:center; opacity:.9}
.badge{padding:8px 15px; border-radius:50px; background:#1f2937; font-size:20px}
.serving{filter:drop-shadow(0 0 10px rgba(255,255,255,.45));}
.row {
  display:flex; 
  gap:8px; 
  flex-wrap:wrap; 
  align-items:center; 
  justify-content: center;
}

button,input,select{font-size:20px}
button{padding:10px 40px; margin: 10px; border-radius:12px; border:1px solid #374151; background:#111827; color:white; cursor:pointer}
button:active{transform:scale(.98)}
button.primary{background:#16a34a; border-color:#166534}
button.warn{background:#991b1b; border-color:#7f1d1d}
input,select{padding:15px 12px; margin: 10px; border-radius:10px; border:1px solid #374151; background:#0b1220; color:white}
.sep{height:1px; background:#1f2937; margin:12px 0}
.footer{opacity:.7; font-size:14px; text-align:center; margin-top:8px}

/*.fullscreen{position:fixed; top:16px; right:16px}*/


/* Fullscreen button */
#fsBtn {
  position: absolute;
  top: -20px;
  right: 1vw;
  padding: 0.6vw 1.2vw;
  font-size: clamp(14px, 1.8vw, 28px);
  border-radius: 0.8vw;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.35);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: 0.25s ease;
  opacity: 0.25;
}
#fsBtn:hover,
#fsBtn:focus {
  opacity: 0.9;
  color: white;
  background: rgba(40,40,40,0.4);
  border-color: rgba(255,255,255,0.4);
}

#bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.3;
}

#headerBar,
#adminHeader {
  text-align: center;
  border-radius: 10px;
  margin: 5px;
  padding: 15px 0px;

}

#eventTitle {
  font-weight: 900;
  text-transform: uppercase;
  margin: 0;
  white-space: pre-line;
}

#adminHeader h1 {
  margin: 5px;
}

.status-label {
  padding: 8px 15px;
  border-radius: 6px;
}

.status-locked { background: var(--danger); }
.status-unlocked { background: var(--brand); color: black; }

.viewer-page,
.admin-page {
  position: relative;   /* REQUIRED */
  z-index: 1;
}

.mode-btn { 
  padding: 10px 20px; 
  border: 1px solid #ddd; 
  border-radius: 5px; 
  cursor: pointer; 
  font-weight: bold; 
  transition: 0.3s; 
}

.mode-btn.active { 
  background: #1e40af; 
  color: white; 
  border-color: #1e40af; 
}

.admin-controls-card { 
  padding: 5px; 
  border-radius: 12px; 
  box-shadow: 0 4px 6px rgba(0,0,0,0.1); 
  margin-top: 5px; 
}

.set-display-mini {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px; /* Pulls it closer to the main score */
    padding: 10px;
    color: #facc15; /* Professional yellow contrast */
    font-weight: bold;
    font-size: 2.5rem;
  }
  
#setIndicator {
  display: inline-block;
  padding: 8px 24px;       /* Horizontal breathing room */
  margin: 20px 0;          /* Space above and below the badge */
  background: #1e40af;     /* Professional blue */
  color: white;
  border-radius: 50px;     /* Pill shape */
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 1.5rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  text-align: center;
}

/* Connection Status Indicator */
.status-indicator {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
}
.online { background: #22c55e; color: white; }
.offline { background: #ef4444; color: white; }

/* Set Dots */
.dot-container { display: flex; gap: 20px; margin: 20px 0; justify-content: center; }
.dot { width: 25px; height: 25px; border-radius: 50%; background: #374151; border: 2px solid #4b5563; }
.dot.filled { background: #facc15; box-shadow: 0 0 10px #facc15; }

/* History Table */
.history-table { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: 14px; }
.history-table td { padding: 4px; border-bottom: 1px solid #333; text-align: center; }

/* Container for the previous set scores */
.history-row {
    display: flex;
    justify-content: center;
    gap: 50px;
    margin-top: 5px;
}

/* The individual box for each set */
.history-item {
    background: rgba(255, 255, 255, 0.1); /* Transparent glass look */
    padding: 8px 15px;
    border-radius: 8px;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    min-width: 80px;
}

/* The "SET 1" text inside the box */
.history-label {
    display: block;
    font-size: 0.7rem;
    color: #94a3b8; /* Muted blue-grey */
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

/* The actual score numbers */
.history-score {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 2.1rem;
}

/* Admin Serving Highlight */
.serving-now {
    border-left: 6px solid #fbbf24 !important; /* Bright Yellow/Gold */
    background: rgba(251, 191, 36, 0.1);      /* Light tint */
    padding-left: 10px;
    transition: all 0.3s ease;
}

/* Optional: Add a small indicator text in Admin */
.serving-now::before {
    content: "SERVING";
    display: block;
    font-size: 0.6rem;
    color: #fbbf24;
    font-weight: bold;
    margin-bottom: 2px;
}

.ball {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;  /* Prevents shrinking */
    min-height: 42px !important;
    border-radius: 50% !important;
    padding: 0 !important;       /* Removes global button padding override */
    margin: 3px !important;      /* Replaces heavy global margin */
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    border: none;
    cursor: pointer;
    box-sizing: border-box;
    flex-shrink: 0;             /* Ensures flex layout won't squeeze into oval */
}

.snooker-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

.foul-btn {
  background: #dc6f26;
  border-color: #b91c1c;
  padding: 5px 10px;
  font-size: 14px;
}

.undo-btn {
  background: #475569;
  border-color: #334155;
  padding: 4px 8px !important;
  margin: 2px !important;
  font-size: 13px !important;
  min-width: auto !important;
}

.pots-history {
  display: flex;
  flex-wrap: wrap;             /* Allows balls to wrap onto a second row if long */
  justify-content: center;     /* Centers balls within the team card */
  align-items: center;
  gap: 6px;                    /* Clean spacing between balls */
  margin: 10px 0;
  max-width: 90%;              /* Ensures it stays within team card borders */
  min-height: 28px;
  box-sizing: border-box;
}

.ball-mini {
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  min-height: 26px !important;
  border-radius: 50% !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 12px !important;
  font-weight: bold !important;
  color: white !important;
  flex-shrink: 0 !important;   /* Prevents distortion */
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.foul-badge {
  background: #dc6f26;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
}

.red{background:#d40000;}
.yellow{background:#facc15;color:black;}
.green{background:#16a34a;}
.brown{background:#7c4a1e;}
.blue{background:#2563eb;}
.pink{background:#ec4899;}
.black{background:#111;}