* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Arial, sans-serif;
  background-color: #010b1c;
  user-select: none;
}

/* === LAYOUT CONTAINERS === */

#demo-window {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2vw;
}

/* Base wrapper for display/control panes */
.program-wrapper {
  overflow: hidden;
  position: relative;
  transition: all 0.5s ease;
}

/* Program fills wrapper and centers content */
.program {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 2em;
}

.grid-container {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  grid-template-columns: repeat(13, 1fr);
  grid-template-rows: repeat(9, 1fr);
}

.grid-container::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-image:
    linear-gradient(to right, rgba(255,0,255,0.2) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,0,255,0.2) 1px, transparent 1px);
  background-size: calc(100% / 11) calc(100% / 7); /* <-- adjust columns and rows */
  pointer-events: none;
  z-index: 1;
}

.grid-item {
  display: flex;
  overflow: hidden;
  width: 100%;
  height: 100%;
  padding: 0.2em;
  justify-content: center;
  align-items: center;
  justify-self: center;
}

.grid-item.debug-outline {
	outline: 1px dashed rgba(255, 0, 0, 0.671);
}


/* Focus states maintain 16:9 aspect ratio with size scaling */
.focused {
  width: 66vw;
  padding-top: 37.125vw;
  font-size: 2.5em;
}

.unfocused {
  width: 26vw;
  padding-top: 14.625vw;
  font-size: 1em;
}

/* View toggle button */
#switch {
  position: fixed;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background-color: #164187;
  color: #9e810b;
  cursor: pointer;
  border-radius: 5px;
  font-size: 1em;
  font-weight: bold;
}

#switch:hover {
  background-color: #1f4b94;
}

#bz-logo {
  flex:1;
  max-height: 20%;
  min-height: 20%;
  object-fit: contain;
}
#bz-logo2 {
  height: 10vh;
}

#login {
  position: absolute;
  height: 100vh;
  width: 100vw;
  display:flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3vh;
}

#lbl-pword {
  display: flex;
  flex: 1;
  font-size: 5vmin;
  color: white;
  max-height: fit-content;
}

input[type="password"] {
  flex: 1;
  appearance: none;
  border: none;
  -webkit-appearance: none;
  width: 30vmin;
  max-height: fit-content;
  outline: none;
  font-size: 5vmin;
  padding-left: 0.3em;
  text-align: center;
}

#submit-pword {
  flex: 1;
  font-size: 5vmin;
  padding: 0.2em;
  max-height: fit-content;
}

#dummy-spacer {
  max-height: 10vh;
  min-height: 1vh;
  flex: 1;
  color: red;
  font-size: 3vmin;
}

input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  width: 20%;
  height: 68%;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 0 0 2px #ccc inset;
  transition: box-shadow 0.2s ease-in-out;
}

input[type="color"]:hover {
  box-shadow: 0 0 0 2px #888 inset;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

#demo-page-heading {
  position: fixed;
  left: 50%;
  top: 2%;
  transform: translateX(-50%);
  font-size: 200%;
  color: #7d7316;
}


/* Colors for each program */
#display-program {
  background-color: black;
}

#control-program {
  background-color: black;
}


/* === PAGE AND UI DISPLAY TOGGLES === */

/* Hide all pages and UIs by default */
.page, .ui {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Force flex layout inside pages and UIs */
.page *, .ui * {
  display: flex;
}

/* Show active page or UI */
.page.displayed, .ui.displayed {
  display: flex;
}



/* === SHARED UTILITY CLASSES === */

/* Full-size elements */
.fill {
  width: 100%;
  height: 100%;
}

/* Vertical stacking */
.vertical {
  flex-direction: column;
}

/* Center content in both axes */
.centered {
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Space between children */
.justified {
  justify-content: space-between;
}

.bg-cell {
  background: rgba(255, 255, 255, 0.02); /* or none */
  z-index: 0;
  pointer-events: none;
  display: none;
}

.grid-item.paneled {
  background-color: rgba(50,50,100,0.3);
  border: 0.03em solid black;
}

/* === MENU UI STYLES === */

.button-menu {
  width: 100%;
  height: 90%;
  padding: 1%;
  gap: 5%;
}

.button-menu > div {
  flex: 1;
  width: 35%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 40%;
}

.button {
  background-color: #164187;
  color: #9e810b;
  border-radius: 5px;
  justify-content: center;
  align-items: center;
  height: fit-content;
  justify-self: center;
}

/* General button hover style */
.button:hover {
  background-color: #1f4b94;
}

.button:active {
  background-color: #037eaa;
}

.label {
  justify-content: center;
  align-items: center;
  height: 100%;
}


.team-logo-control {
  flex: 1;
  min-width: 100%;
  min-height: 100%;
}

.team-name-control {
  flex: 1;
  font-size: 70%;
}


/* === DISPLAY AREA (VIEWER) === */

/* Background for display mode */
#display-program {
  background-color: black;
}

/* Layout container for pages like AFL, Standby */
.page > * {
  flex: 1;
  max-width: 33.3%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Team section: logo, name, score */
.page .logo {
  flex: 1.3;
  width: 100%;
  background-color: #1f4b94;
}

.page .name {
  flex: 0.7;
  width: 100%;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 1.2em;
}

.page .score {
  flex: 1.5;
  flex-direction: row;
  flex-wrap: wrap;
  width: 100%;
  justify-content: center;
  align-items: center;
  font-size: 2.8em;
}

/* Score subparts (optional use) */
.page .score .goals,
.page .score .behinds {
  flex: 1;
  min-width: 50%;
  font-size: 100%;
}

.page .score .points {
  flex: 2;
  min-width: 100%;
  order: 1;
  font-size: 200%;
}

/* Game timer section */
.page .timer {
  flex: 1.5;
  min-width: 100%;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  font-size: 1.8em;
}

.page .segment {
  flex: 1;
  justify-content: center;
  font-size: 120%;
}

.page .clock {
  flex: 1;
  justify-content: flex-start;
  font-size: 80%;
  padding-top: 5%;
}

/* Digital-style timer parts */
.colon {
  width: 0.5ch;
}

.minute,
.second {
  width: 2ch;
}

.minute {
  align-items: flex-end;
}

.second {
  align-items: flex-start;
}

/* AFL-specific layout */
#afl .score-breakdown {
  align-items: center;
  justify-content: space-evenly;
  width: 100%;
  font-size: 1.2em;
}

.afl-goals,
.afl-behinds {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  justify-content: center;
}

.afl-goals::after,
.afl-behinds::after {
  content: '';
  position: absolute;
  top: 3%;
  left: 1%;
  right: 1%;
  bottom: 3%;
  background: #052383;
  z-index: -1;
}


/* Standby screen */
#standby-message {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60%;
  height: 100%;
  max-width: 100%;
  text-align: center;
}



/* === CONTROL AREA (UI / FORMS) === */

/* Control container layout */
.ui .control-section-container {
  flex: 1;
  width: 100%;
}

.ui .control-section {
  display: flex;
  max-width: 100%;
  height: 100%;
}

/* Subsections: one for each team and one for controls */
.ui .control-subsection {
  flex: 1;
  min-width: 0;
  flex-direction: column;
}

/* Team identity: logo + name */
.ui .team-id {
  flex: 1;
}

.ui .team-id .name {
  width: 50%;
  justify-content: center;
  align-items: center;
  font-size: 0.6em;
}

.ui .team-id .logo {
  width: 50%;
  height: 100%;
  background-color: blue;
}

/* Score area */
.ui .team-score {
  padding-top: 5%;
  flex: 1;
}

.ui .team-score * {
  justify-content: center;
  align-items: center;
}

.ui .team-score .score {
  flex: 0.9;
  flex-wrap: wrap;
}

.ui .team-score .score-control {
  flex: 1.2;
  flex-direction: column;
  padding: 0 0.15em;
}

/* Score button labels and buttons */
.ui .team-score .score-control .label {
  font-size: 15%;

}

.ui .team-score .score-control * {
  flex: 1;
  width: 100%;
  justify-content: space-evenly;
  align-items: center;
}

.ui .team-score .score-control .point-button {
  width: 40%;
  font-size: 70%;
  height: fit-content;
}

/* AFL scores breakdown */
.ui .afl-scores {
  flex: 0.5;
  flex-direction: column;
  font-size: 0.5em;
}

/* Optional: show goals/behinds individually */
.ui .team-score .goals,
.ui .team-score .behinds {
  flex: 1;
  min-width: 50%;
  font-size: 50%;
  max-height: fit-content;
}

.ui .team-score .points {
  flex: 2;
  order: 1;
  font-size: 80%;
  max-height: fit-content;
}

/* Segment control */
.ui .control-segment {
  padding-top: 5%;
  justify-content: space-evenly;
  height: fit-content;
}

.ui .control-segment .segment {
  font-size: 50%;
  width: fit-content;
  height: fit-content;
}

.ui .control-segment .label {
  width: 15%;
}

.ui .control-segment .point-button {
  font-size: 70%;
  width: 12%;
  height: fit-content;
}

/* Timer display */
.ui .timer {
  padding-top: 5%;
  font-size: 1.2em;
  justify-content: center;
  height: fit-content;
}

/* Timer control buttons */
.ui .timer-buttons {
  padding-top: 5%;
  justify-content: space-evenly;
  height: max-content;
}

.ui .timer-buttons .point-button {
  font-size: 30%;
  width: 40%;
  padding: 1% 2%;
}

/* Game control buttons (RESET, END GAME) */
.ui .game-control {
  padding-top: 3%;
  gap: 5%;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
}

.ui .game-control .button {
  flex: 1;
  max-width: 25%;
  font-size: 30%;
  height: fit-content;
  padding: 0.5% 0;
}

/* === AFL SPECIFIC STYLES === */

#afl .score-breakdown {
  align-items: center;
  justify-content: space-evenly;
  width: 100%;
  font-size: 1.2em;
}

.afl-goals,
.afl-behinds {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  justify-content: center;
}

/* Highlight background effect */
.afl-goals::after,
.afl-behinds::after {
  content: '';
  position: absolute;
  top: 3%;
  left: 1%;
  right: 1%;
  bottom: 3%;
  background: #052383;
  z-index: -1;
}

#bball .label {
  font-size: 80%;
}

#bball .timeouts-container, #bball .fouls-container {
  flex-direction: column;
  flex: 1;
  align-content: center;
  font-size: 50%;
}