/* =======================================================
   CSS CUSTOM PROPERTIES
======================================================= */

:root {
  --teamAcolour: #ffff00;
  --teamBcolour: #00ffff;
  --bg: #000;
  --white: #ffffff;
  --spectating: rgb(255, 0, 0);
  --text-color: #ffffff;
  --input-bg: #1a1a1a;
  --input-border: #444;
  --modal-bg: rgba(0, 0, 0, 0.9);
}

body.light-mode {
  --bg: #f5f5f5;
  --white: #000000;
  --text-color: #000000;
  --input-bg: #ffffff;
  --input-border: #cccccc;
  --modal-bg: rgba(255, 255, 255, 0.95);
  --teamAcolour: #ad7535;
  --teamBcolour: #0a91ac;
}

/* =======================================================
   GLOBAL RESET
======================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  /* Do NOT set overflow: hidden globally — it blocks menu page scroll.
     Each page controls its own overflow. */
}

body {
  background: var(--bg);
  color: var(--white);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
}

button {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  touch-action: manipulation;
}

/* =======================================================
   MENU PAGE
======================================================= */

.menu-page {
  width: 100%;
  min-height: 100svh;
  height: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* Center content vertically if space allowed */
  align-items: center;
  padding: 40px 20px;
  gap: 15px;
  color: white;
  position: relative;
  overflow: hidden;
  text-align: center;
}

.menu-page::after {
  content: "";
  position: absolute;
  inset: -10%;
  z-index: -1;
  background: url("../media/img/bk_dark.webp") no-repeat center;
  background-size: cover;
  animation: bgZoom 10s infinite alternate ease-in-out;
  pointer-events: none;
}

body.light-mode .menu-page::after {
  background-image: url("../media/img/bk_light.webp");
}

@keyframes bgZoom {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.2);
  }
}

.logo {
  width: clamp(160px, 30vw, 300px);
  height: auto;

  animation: logoanimation 6s ease-in-out infinite;

  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  margin-top: 2%;
}

body.light-mode .menu-page {
  color: black;
}

.menu-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 0;
}

body.light-mode .menu-page::before {
  background: rgba(255, 235, 137, 0.1);
}

.menu-page>* {
  position: relative;
  z-index: 1;
}

.app-title {
  font-family: "Arial";
  text-transform: uppercase;
  font-size: clamp(2.5rem, 10vw, 5rem);
  font-weight: 900;
  max-width: 95%;
  color: white;
  margin: 0;
  background: white;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: apptitleanimation 8s infinite;
}

body.light-mode .app-title {
  -webkit-text-fill-color: white;
  animation: apptitleanimation 8s infinite;
}

.app-subtitle {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 400;
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.5px;
  animation: subtitleanimation 8s infinite;
}

.menu-buttons {
  margin-top: clamp(40px, 8vh, 100px);
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(15px, 3vw, 30px);
  width: 100%;
  max-width: 800px;
  padding-bottom: 40px;
}

@media (max-width: 600px) {

  .menu-buttons {
    flex-direction: column;
    align-items: center;
  }

  .menu-btn {
    width: clamp(180px, 70vw, 260px);
  }

}

.menu-btn {
  width: clamp(180px, 40vw, 260px);
  text-decoration: none;
  padding: clamp(10px, 2vh, 20px) clamp(20px, 4vw, 40px);
  border-radius: 20px;
  font-size: clamp(1rem, 3.5vw, 1.5rem);
  font-weight: 600;
  border: 2px solid white;
  color: white;
  transition: all 0.2s ease;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  cursor: pointer;
}

.menu-btn:hover {
  background: white;
  color: black;
  border-color: white;
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(255, 255, 255, 0.2);
}

body.light-mode .menu-btn {
  border-color: rgba(0, 0, 0, 0.5);
  color: rgba(0, 0, 0, 0.9);
  background-color: rgb(255, 255, 255);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

body.light-mode .menu-btn:hover {
  background: #000;
  color: #fff;
  border-color: #000;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* =======================================================
   SCOREBOARD PAGE — TOP-LEVEL CONTAINER
   Flex column: header | body (fills remaining space)
======================================================= */

#scoreboardPage {
  width: 100%;
  height: 100svh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* =======================================================
   SIDEBAR / HEADER (sidebar-left)
   Portrait: column (top header)
   Landscape: row (left sidebar)
======================================================= */

.sidebar-left {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(6px, 1.2vmin, 12px);
  padding: clamp(6px, 1.2vmin, 12px) clamp(8px, 1.5vmin, 14px);
  z-index: 30;
  background: rgba(0, 0, 0, 0.0);
}

@media (orientation: landscape) {
  .sidebar-left {
    flex-direction: column;
    width: clamp(50px, 8vmin, 85px);
    height: 100%;
    padding: clamp(10px, 2vmin, 20px) 0;
    justify-content: space-between;
  }
}

/* Court name in the sidebar/header. Grouped with badge. */
#courtTitle {
  text-align: left;
  font-size: clamp(1.1rem, 5vmin, 2.5rem);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--white);
  pointer-events: none;
}

@media (orientation: landscape) {
  #courtTitle {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    margin-top: 10px;
    text-align: center;
  }
}

.header-right-slot {
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-right-slot:empty {
  display: none;
}

@media (orientation: landscape) {
  .header-right-slot {
    min-width: 100%;
    min-height: clamp(40px, 6vmin, 60px);
  }
}

/* =======================================================
   SCOREBOARD BODY
   Portrait  → flex column: scoreboard on top, controls row at bottom
   Landscape → flex row:    scoreboard on left, controls column on right
   No fixed positioning — everything is in normal document flow.
======================================================= */

.scoreboard-body {
  flex: 1;
  min-height: 0;
  display: flex;

  /* ---- Portrait (default) ---- */
  flex-direction: column;
}

@media (orientation: landscape) {
  .scoreboard-body {
    flex-direction: row;
  }
}

/* =======================================================
   APP & SCOREBOARD  (fills remaining space in the body)
======================================================= */

.app {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scoreboard {
  flex: 1;
  min-height: 0;
  display: flex;
  /* Portrait default: stack cards vertically to fill screen */
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: clamp(4px, 1vmin, 10px);
  /* Enough padding so card borders are never clipped */
  padding: clamp(6px, 1.5vmin, 14px);
  position: relative;
  /* visible so borders are not cut; .app clips any animation overflow */
  overflow: visible;
}

/* =======================================================
   TEAM CARD
======================================================= */

.team {
  /* Portrait default: fill full width, share height equally — NOT square */
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  /* No aspect-ratio in portrait — maximise screen use */
  padding: clamp(4px, 1vmin, 12px);
  border-radius: clamp(12px, 2vmin, 22px);
  position: relative;
  overflow: hidden;

  display: flex;
  flex-direction: column;
  align-items: center;

  container-type: inline-size;
}

.team-a {
  border: clamp(3px, 0.6vmin, 6px) solid var(--teamAcolour);
  color: var(--teamAcolour);
}

.team-b {
  border: clamp(3px, 0.6vmin, 6px) solid var(--teamBcolour);
  color: var(--teamBcolour);
}

/* Swap order classes — still driven by JS */
.team-a {
  order: 1;
}

.team-b {
  order: 2;
}

.scoreboard.swapped .team-a {
  order: 2;
}

.scoreboard.swapped .team-b {
  order: 1;
}

/* =======================================================
   LANDSCAPE: restore side-by-side cards with square aspect ratio
======================================================= */

@media (orientation: landscape) {
  .scoreboard {
    flex-direction: row;
    align-items: center;
    justify-content: space-evenly;
  }

  .team {
    /*
     * Maximize vertical presence in landscape
     */
    flex: 0 0 auto;
    height: 98%;
    aspect-ratio: 1 / 1;
    max-width: 48%;
    min-width: 0;
  }
}

/* =======================================================
   TEAM NAME
======================================================= */

.team-name {
  height: auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  padding: clamp(3px, 0.6vmin, 8px) clamp(8px, 1.5vmin, 16px);
  border-radius: 10px;

  overflow: hidden;
  z-index: 10;
  position: relative;
}

.team-name .name-text {
  display: inline-block;
  white-space: nowrap;
  /* Use container query unit so text scales with the card size */
  font-size: clamp(0.9rem, 8cqi, 4rem);
  font-weight: 700;

  transform-origin: center center;
  transition: transform 0.15s ease;
}

.team-name:hover {
  background: rgba(255, 255, 255, 0.25);
}

.team-name-input {
  width: 100%;
  text-align: center;
  font-size: clamp(0.9rem, 8cqi, 4rem);
  font-weight: 700;
  background: transparent;
  border: 2px solid currentColor;
  border-radius: 10px;
  padding: 4px 8px;
  color: inherit;
  outline: none;
}

body.spectating-mode .team-name {
  pointer-events: none;
  cursor: default;
}

body.spectating-mode .team-name:hover {
  background: none;
}

/* =======================================================
   META (SETS & GAMES)
======================================================= */

.meta {
  width: 100%;
  flex-shrink: 1;
  min-height: 0;
}

.row {
  padding: 0 clamp(6px, 1.5vmin, 20px);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  /* Scale with card width via container query */
  font-size: clamp(0.6rem, 4cqi, 2.5rem);
}

.row span:first-child {
  font-weight: 300;
  color: var(--white);
}

.row span:last-child {
  font-weight: 700;
  font-size: clamp(0.75rem, 6cqi, 3.5rem);
  color: inherit;
}

/* =======================================================
   SET & GAME DOTS
======================================================= */

#setsA,
#setsB,
#gamesA,
#gamesB {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  /* Dots gap scales with card width */
  gap: clamp(4px, 2cqi, 24px);
  color: var(--white);
  flex-wrap: wrap;
  justify-content: flex-start;
}

body.light-mode #setsA,
body.light-mode #gamesA {
  color: var(--teamAcolour);
}

body.light-mode #setsB,
body.light-mode #gamesB {
  color: var(--teamBcolour);
}

.set-dot,
.game-dot {
  /* Dots scale with card width */
  width: clamp(12px, 5.5cqi, 56px);
  height: clamp(12px, 5.5cqi, 56px);
  border-radius: 50%;
  background: #e0e0e0;
  flex-shrink: 0;
}

.game-dot {
  border-style: solid;
  border-width: clamp(2px, 0.6cqi, 5px);
  background-color: rgba(0, 0, 0, 0);
  border-color: #e0e0e044;
  opacity: 1;
}

body.light-mode .game-dot {
  border-color: #e0e0e0;
  opacity: 1;
}

.set-dot {
  border: clamp(1px, 0.4cqi, 3px) solid #e0e0e0;
  background: transparent;
  opacity: 0;
}

body.light-mode .set-dot {
  background: #e0e0e0;
  opacity: 0;
  border: none;
}

.game-dot.filled {
  opacity: 1;
  border: none;
}

.set-dot.filled[data-team="A"] {
  background: var(--teamAcolour);
  border-color: var(--teamAcolour);
  opacity: 1;
}

.set-dot.filled[data-team="B"] {
  background: var(--teamBcolour);
  border-color: var(--teamBcolour);
  opacity: 1;
}

.game-dot.filled {
  background: white;
}

body.light-mode .game-dot.filled {
  background: black;
}

/* =======================================================
   POINTS DISPLAY
======================================================= */

.points-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.points {
  /* Score is always the biggest; fills blank space for distance reading */
  font-size: clamp(3rem, 55cqi, 35rem);
  font-weight: 800;
  text-align: center;
  color: inherit;
  line-height: 1;
}

.indicator {
  position: absolute;
  bottom: 4%;
  right: 4%;
  height: clamp(14px, 2.4vmin, 24px);
  width: clamp(14px, 2.4vmin, 24px);
  border-radius: 50%;
  border: clamp(2px, 0.4vmin, 4px) solid var(--white);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  background-color: transparent;
}

/* =======================================================
   TEAM TAP ZONE
======================================================= */

.team .ref-zone {
  position: absolute;
  inset: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 1;
}

.team-name {
  z-index: 10;
  position: relative;
}

.team-a .ref-zone:active {
  background: rgba(255, 255, 0, 0.15);
}

.team-b .ref-zone:active {
  background: rgba(0, 255, 255, 0.15);
}

/* =======================================================
   FLOATING BUTTONS — SHARED (all circular)
======================================================= */

.floating-btn {
  /* Perfect circle */
  --btn-size: clamp(40px, 7vmin, 58px);
  width: var(--btn-size);
  height: var(--btn-size);
  border-radius: 50%;
  padding: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ccc;
  background: transparent;
  color: #ccc;
  font-weight: 600;
  font-size: clamp(1rem, 2.5vmin, 1.4rem);
  backdrop-filter: blur(6px);
  opacity: 0.6;
  position: relative;
  overflow: hidden;
  transition: opacity 0.2s ease,
    background 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  cursor: pointer;
}

.floating-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  opacity: 1;
}

body.light-mode .floating-btn:hover {
  color: black;
  border: 2px solid black;
  opacity: 1;
}

#resetBtn {
  transition: opacity 0.2s ease,
    background 0.2s ease;
}

/* =======================================================
   FLOATING CONTROLS CONTAINER
   Portrait  → horizontal row at the bottom of .scoreboard-body
   Landscape → vertical column on the right of .scoreboard-body
   Both are in normal document flow — zero overlap guaranteed.
======================================================= */

/* --- Portrait (default) --- */
.floating-controls {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2.5vw, 22px);
  padding: clamp(8px, 1.5vh, 16px) clamp(10px, 2vw, 20px);
}

/* --- Landscape --- */
@media (orientation: landscape) {
  .floating-controls {
    flex-direction: column;
    justify-content: flex-start;
    gap: clamp(6px, 2vh, 18px);
    padding: clamp(8px, 1.5vw, 16px) clamp(8px, 1.5vw, 14px);
  }
}

.btn-separator {
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

body.light-mode .btn-separator {
  background: rgba(0, 0, 0, 0.1);
}

/* Portrait spacing/sizing */
.btn-separator {
  width: 1px;
  height: clamp(20px, 4vh, 30px);
  margin: 0 clamp(2px, 0.5vw, 5px);
}

.btn-separator.type-sep {
  background: rgba(255, 255, 255, 0.3);
  /* Slightly more visible for group transition */
}

/* Landscape spacing/sizing */
@media (orientation: landscape) {
  .btn-separator {
    width: clamp(20px, 4vw, 30px);
    height: 1px;
    margin: clamp(2px, 0.5vh, 5px) 0;
  }
}

/* =======================================================
   SCORE ANIMATION
======================================================= */

.team.score-animate {
  animation: team-pop 0.6s cubic-bezier(0.2, 1.4, 0.3, 1);
}

.team.score-animate::before {
  content: "";
  position: absolute;
  inset: -50%;
  background: currentColor;
  opacity: 0.25;
  animation: burst 0.6s ease-out forwards;
}

@keyframes team-pop {
  0% {
    transform: scale(1);
  }

  35% {
    transform: scale(1.035);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes burst {
  0% {
    transform: scale(0);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0;
  }
}

/* =======================================================
   RESET MODAL
======================================================= */

.reset-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

body.light-mode .reset-modal {
  background: rgba(255, 255, 255, 0.75);
}

.reset-modal.hidden {
  display: none;
}

.reset-box {
  background: #600000;
  padding: 24px;
  border-radius: 14px;
  text-align: center;
  width: clamp(280px, 90vw, 420px);
  color: white;
}

body.light-mode .reset-box {
  background: #ffeb3b;
  color: black;
}

.reset-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.reset-actions button {
  flex: 1;
  min-width: 80px;
  padding: 10px;
  border-radius: 8px;
  border: none;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body.light-mode .reset-actions button {
  background: black;
  color: white;
}

body.light-mode .reset-actions button:hover {
  opacity: 0.8;
}

/* =======================================================
   UNDO ANIMATION
======================================================= */

.points.undo-flash {
  animation: undo-flash 0.4s ease;
}

@keyframes undo-flash {
  0% {
    opacity: 1;
  }

  25% {
    opacity: 0.25;
  }

  50% {
    opacity: 0.75;
  }

  75% {
    opacity: 0.5;
  }

  100% {
    opacity: 1;
  }
}

/* =======================================================
   CREATE / PLAY / SPECTATE PAGES
======================================================= */

.create-page {
  height: 100svh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
  color: white;
  overflow: auto;
}

body.light-mode .create-page {
  background: #f5f5f5;
  color: black;
}

.create-card {
  position: relative;
  width: clamp(280px, 85vw, 420px);
  padding: 25px 35px 20px 35px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid white;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  transition: all 0.3s ease;
  max-height: 95svh;
  overflow-y: auto;
}

body.light-mode .create-card {
  background: rgba(0, 0, 0, 0.05);
  border: 2px solid black;
}

.create-card .close-btn,
.edit-card .close-btn,
.prompt-card .close-btn {
  position: absolute;
  top: 15px;
  right: 20px;
  background: none;
  border: none;
  font-size: 22px;
  color: white;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  z-index: 10;
}

body.light-mode .close-btn {
  color: black;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group input {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid white;
  background: black;
  color: white;
  font-size: 14px;
}

body.light-mode .form-group input {
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: black;
}

body.light-mode .form-group label {
  color: black;
}

.error {
  font-size: 13px;
  color: rgb(255, 255, 0);
  min-height: 18px;
  margin-top: 4px;
  margin-bottom: 8px;
}

body.light-mode .error {
  color: #c41e3a;
}

.primary-btn {
  padding: 13px;
  border-radius: 10px;
  border: 2px solid white;
  background: white;
  color: black;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  width: 100%;
  box-sizing: border-box;
  margin-top: 6px;
  font-size: 15px;
}

body.light-mode .primary-btn {
  border: 2px solid black;
  background: black;
  color: white;
}

.secondary-btn {
  padding: 12px;
  border-radius: 10px;
  border: 2px solid white;
  background: transparent;
  color: white;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* =======================================================
   COURT LIST
======================================================= */

.court-list {
  /* Scale with viewport height so it's usable on short landscape screens */
  max-height: clamp(80px, 28vh, 300px);
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  margin-bottom: 8px;
  scrollbar-color: #ffffff rgba(0, 0, 0, 0.3);
  scrollbar-width: thin;
}

/*
 * In landscape (mobile landscape), give the list enough room.
 * Use a side-by-side layout for Play/Spectate screens to maximize space.
 */
@media (orientation: landscape) and (max-height: 520px) {
  .create-card {
    padding: 14px 20px 12px 20px;
    gap: 8px;
  }

  #playPage .create-card,
  #spectatePage .create-card {
    width: clamp(500px, 85vw, 850px);
    max-height: 96svh;
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    grid-template-rows: auto auto 1fr auto;
    gap: 8px 24px;
    padding: 20px 30px;
    align-items: start;
    overflow-y: auto;
  }

  #playPage .create-card h2,
  #spectatePage .create-card h2 {
    grid-column: 1 / -1;
    margin: 0 0 5px 0;
  }

  /* Left column elements */
  #playPage .create-card .form-group:first-of-type,
  #spectatePage .create-card .form-group:first-of-type {
    grid-column: 1;
    grid-row: 2;
  }

  #playPage #playPasswordSection {
    grid-column: 1;
    grid-row: 3;
  }

  #playPage .error,
  #spectatePage .error {
    grid-column: 1;
    grid-row: 4;
    margin: 0;
  }

  /* Right column elements (Court List) */
  #playPage .court-list,
  #spectatePage .court-list {
    grid-column: 2;
    grid-row: 2 / span 3;
    max-height: clamp(140px, 60vh, 400px);
    height: 100%;
    margin-bottom: 0;
  }

  .form-group {
    gap: 3px;
  }

  .form-group input {
    padding: 8px;
  }
}

body.light-mode .court-list {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.8);
  scrollbar-color: #333 rgba(255, 255, 255, 0.8);
}

.court-list::-webkit-scrollbar {
  width: 10px;
}

.court-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
}

.court-list::-webkit-scrollbar-thumb {
  background: #ffff00;
  border-radius: 8px;
  border: 2px solid rgba(0, 0, 0, 0.3);
}

.court-list::-webkit-scrollbar-thumb:hover {
  background: #ffff00;
  box-shadow: 0 0 8px #ffff00;
}

.loading {
  padding: 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
}

body.light-mode .loading {
  color: #666;
}

.no-courts {
  padding: 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
}

.court-item {
  padding: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body.light-mode .court-item {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.court-item:last-child {
  border-bottom: none;
}

.court-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

body.light-mode .court-item:hover {
  background: rgba(0, 0, 0, 0.08);
}

.court-item.active {
  background: rgba(255, 255, 255, 0.0);
  border: 2px solid #ffff00;
  padding-left: 15px;
  padding-right: 15px;
  margin-left: 5px;
  margin-right: 5px;
  border-radius: 12px;
  box-shadow: 0 0 12px #ffff00;
}

body.light-mode .court-item.active {
  border: 2px solid #ffff00;
  box-shadow: 0 0 8px rgba(255, 255, 0, 0.5);
}

.court-item.active .court-item-name {
  color: #ffff00;
  font-weight: 700;
}

body.light-mode .court-item.active .court-item-name {
  color: black;
}

.court-item-name {
  font-weight: 600;
  color: white;
  margin-bottom: 4px;
}

body.light-mode .court-item-name {
  color: #1a1a1a;
  font-weight: 700;
}

.court-item-info {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

body.light-mode .court-item-info {
  color: rgba(0, 0, 0, 0.6);
}

/* =======================================================
   SPECTATOR BADGE
   Still fixed-positioned, sits at top-right.
   The header row prevents scorecards from reaching that area.
======================================================= */

.spectator-badge {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--spectating);
  font-weight: 700;
  letter-spacing: 2px;
  font-size: clamp(12px, 3vmin, 22px);
  z-index: 10000;
  pointer-events: none;
  white-space: nowrap;
  padding: 4px 8px;
  animation: spectatorGlow 6s ease-in-out infinite;

  /* Smooth rendering properties */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  backface-visibility: hidden;
  transform: translateZ(0);
  /* Hardware acceleration */
}

@keyframes spectatorGlow {
  0% {
    opacity: 0.2;
    filter: drop-shadow(0 0 2px var(--spectating));
  }

  25% {
    opacity: 1;
    filter: drop-shadow(0 0 6px var(--spectating));
  }

  75% {
    opacity: 1;
    filter: drop-shadow(0 0 8px var(--spectating));
  }


  100% {
    opacity: 0.2;
    filter: drop-shadow(0 0 2px var(--spectating));
  }
}

/* Hide the raw emoji from JS - we replace it with a CSS pulse dot */
.spectator-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  text-shadow: 0 0 0 var(--spectating);
}

.spectator-badge::before {
  content: "";
  width: 15px;
  height: 15px;
  background-color: var(--spectating);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--spectating);
}

@media (orientation: landscape) {
  .sidebar-left {
    gap: 25px;
  }

  .spectator-badge {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    flex-direction: row;
  }
}

/* .left and .right subclasses for spectator-badge are preserved for JS compatibility but empty as positioning is now handled by flex container */
.spectator-badge.left {
  display: block;
}

.spectator-badge.right {
  display: block;
}

/* =======================================================
   NFC COOLDOWN BANNER
======================================================= */

.nfc-cooldown {
  position: fixed;
  bottom: clamp(70px, 14vh, 120px);
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 12px;
  background: rgba(255, 0, 0, 0.85);
  color: white;
  font-weight: bold;
  font-size: clamp(14px, 2.5vmin, 18px);
  z-index: 9999;
}

.hidden {
  display: none;
}

/* =======================================================
   ALERT MODAL
======================================================= */

.alert-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

body.light-mode .alert-modal {
  background: rgba(255, 255, 255, 0.75);
}

.alert-modal.hidden {
  display: none;
}

.alert-box {
  background: #222;
  padding: 30px;
  border-radius: 14px;
  text-align: center;
  border: 2px solid #ff6b6b;
  width: clamp(260px, 85vw, 400px);
}

body.light-mode .alert-box {
  background: #fff;
  border: 2px solid #333;
}

.alert-box h2 {
  color: #ff6b6b;
  margin: 0 0 12px 0;
  font-size: clamp(1.1rem, 3.5vmin, 1.5rem);
}

body.light-mode .alert-box h2 {
  color: #333;
}

.alert-box p {
  color: #fff;
  margin: 0 0 20px 0;
  font-size: clamp(0.85rem, 2.5vmin, 1rem);
}

body.light-mode .alert-box p {
  color: black;
}

.alert-btn {
  padding: 10px 24px;
  border-radius: 8px;
  border: 2px solid #fff;
  background: #fff;
  color: #000;
  font-weight: bold;
  cursor: pointer;
  font-size: clamp(0.85rem, 2.5vmin, 1rem);
}

body.light-mode .alert-btn {
  border: 2px solid black;
  background: black;
  color: white;
}

.alert-btn:hover {
  background: #f0f0f0;
}

#alertMessage {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* =======================================================
   THEME TOGGLE BUTTON (Menu page / global)
======================================================= */

.global-controls {
  position: absolute;
  top: clamp(10px, 2vh, 24px);
  right: clamp(10px, 3vw, 30px);
  display: flex;
  gap: 12px;
  z-index: 1000;
}

.theme-toggle-btn {
  width: clamp(40px, 8vmin, 55px);
  height: clamp(40px, 8vmin, 55px);
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: clamp(18px, 4vmin, 26px);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  user-select: none;
  opacity: 0.9;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
  opacity: 1;
}

.theme-toggle-btn:active {
  transform: scale(0.95);
}

body.light-mode .theme-toggle-btn {
  color: black;
  border-color: rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.05);
  opacity: 0.9;
}

body.light-mode .theme-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.1);
  opacity: 1;
}

/* =======================================================
   TOAST NOTIFICATIONS
======================================================= */

.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  font-weight: 600;
  font-size: 0.95rem;
  animation: toastFadeIn 0.3s ease, toastFadeOut 0.3s ease 2.7s forwards;
  min-width: 200px;
  text-align: center;
}

.toast.success {
  border-color: #2ecc71;
  color: #2ecc71;
}

.toast.error {
  border-color: #e74c3c;
  color: #e74c3c;
}

.toast.info {
  border-color: #3cb7e7;
  color: #3cb7e7;
}

@keyframes toastFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastFadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* =======================================================
   ADMIN DASHBOARD ENHANCEMENTS
======================================================= */


.score-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.8rem;
}

.score-summary-team {
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 6px;
}

.score-summary-team .pts {
  font-weight: 800;
  font-size: 1rem;
  color: var(--white);
}

.score-summary-team .meta {
  font-size: 0.7rem;
  color: #888;
  margin-left: 4px;
}

/* Status Select Styling */
.select-wrapper {
  position: relative;
  width: 100%;
}

.select-wrapper select {
  width: 100%;
  appearance: none;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--white);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.select-wrapper select:focus {
  border-color: var(--white);
}

.select-wrapper::after {
  content: "▼";
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  pointer-events: none;
  color: #888;
}

/* =======================================================
   ADMIN DASHBOARD
======================================================= */

.admin-dashboard-container {
  position: relative;
  background: var(--modal-bg);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  height: 100%;
  width: 95%;
  max-width: 1200px;
  max-height: 95svh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  color: var(--text-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  min-height: 0;
}

@media (min-width: 769px) {
  .admin-dashboard-container {
    width: 88%;
    max-height: 90svh;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .admin-dashboard-container {
    padding: 9px 14px;
  }
}

/* Header: title + create button */
.admin-dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--input-border);
}

.admin-dashboard-header h2 {
  flex: 1;
  text-align: center;
  margin: 0;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
}

.admin-dashboard-header .primary-btn {
  flex-shrink: 0;
  width: auto;
  padding: 8px 16px;
  font-size: 0.85rem;
  margin: 0;
}

@media (orientation: landscape) and (max-height: 520px) {
  .admin-dashboard-header {
    margin-bottom: 6px;
    padding-bottom: 6px;
  }
}

/* Search + filter row */
.admin-dashboard-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: nowrap;
}

.admin-dashboard-controls .search-wrapper {
  flex: 3;
  min-width: 0;
}

.admin-dashboard-controls .search-wrapper input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--white);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
}

.admin-dashboard-controls .filter-wrapper {
  flex: 1;
  min-width: 105px;
  position: relative;
}

.admin-dashboard-controls .filter-wrapper select {
  width: 100%;
  padding: 8px 28px 8px 12px;
  border-radius: 8px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--white);
  font-size: 0.88rem;
  font-family: inherit;
  appearance: none;
  cursor: pointer;
  outline: none;
}

.admin-dashboard-controls .filter-wrapper::after {
  content: "▼";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.58rem;
  color: #888;
  pointer-events: none;
}

@media (orientation: landscape) and (max-height: 520px) {
  .admin-dashboard-controls {
    margin-bottom: 7px;
  }
}

/* Scrollable court list */
.admin-court-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-right: 3px;
  scrollbar-width: thin;
}

/* ================================================================
   COURT CARD — Mobile Portrait (default)
================================================================ */

.admin-court-item {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 11px 13px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 40% 35% 20%;
  gap: 5px 8px;
  align-items: center;
  font-size: 0.88rem;
}

/* Full-width name header row */
.admin-court-item .aci-name {
  grid-column: 1 / -1;
  padding-bottom: 7px;
  margin-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.admin-court-item .aci-name strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.admin-court-item .aci-name .aci-id {
  font-size: 0.7rem;
  color: #888;
  word-break: break-all;
}

.admin-court-item .aci-label {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  white-space: nowrap;
}

.admin-court-item .aci-value {
  font-size: 0.88rem;
  word-break: break-word;
}

.admin-court-item .aci-actions .edit-btn {
  width: 100%;
  margin-top: 5px;
  font-size: 0.83rem;
}

.admin-court-item .aci-field {
  display: block;
}

@media (orientation: portrait) {
  #courtsTab .teams-cell {
    display: none;
  }
}

/* ================================================================
   COURT CARD — Landscape mobile (short viewport)
   Collapses to a compact horizontal row.
================================================================ */
@media (orientation: landscape) and (max-height: 520px) {
  .admin-court-list {
    gap: 5px;
  }

  .admin-court-item {
    display: grid;
    grid-template-columns: 1.5fr 1fr 0.85fr 0.85fr auto;
    grid-template-rows: auto;
    gap: 0 10px;
    padding: 7px 11px;
    align-items: center;
    font-size: 0.82rem;
  }

  .admin-court-item .aci-name {
    grid-column: span 1;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
  }

  .admin-court-item .aci-name strong {
    font-size: 0.82rem;
  }

  .admin-court-item .aci-name .aci-id {
    font-size: 0.6rem;
  }

  /* Each field div becomes a simple block */
  .admin-court-item .aci-field {
    display: block;
  }

  .admin-court-item .aci-label {
    display: block;
    font-size: 0.5rem;
    margin-bottom: 2px;
  }

  .admin-court-item .aci-value {
    font-size: 0.8rem;
  }

  .admin-court-item .aci-actions {
    grid-column: span 1;
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  .admin-court-item .aci-actions .edit-btn {
    width: auto;
    padding: 4px 10px;
    font-size: 0.76rem;
  }
}

/* ================================================================
   COURT CARD — Desktop (>= 769px)
   Full horizontal 5-column row.
================================================================ */
@media (min-width: 769px) {
  .admin-court-item {
    display: grid;
    grid-template-columns: 1.8fr 1.2fr 0.9fr 1fr auto;
    grid-template-rows: auto;
    gap: 0 16px;
    padding: 12px 16px;
    align-items: center;
    font-size: 0.88rem;
  }

  .admin-court-item .aci-name {
    grid-column: span 1;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
  }

  .admin-court-item .aci-field {
    display: block;
  }

  .admin-court-item .aci-label {
    display: block;
    font-size: 0.58rem;
    margin-bottom: 3px;
  }

  .admin-court-item .aci-value {
    font-size: 0.88rem;
  }

  .admin-court-item .aci-actions {
    grid-column: span 1;
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  .admin-court-item .aci-actions .edit-btn {
    width: auto;
    padding: 6px 14px;
    font-size: 0.85rem;
  }

  #courtsTab .teams-cell {
    display: block;
  }
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.status-open {
  background: #2ecc71;
  color: #fff;
}

.status-closed {
  background: #e74c3c;
  color: #fff;
}

.status-private {
  background: #3c7be7;
  color: #fff;
}

/* Edit / danger buttons */
.edit-btn {
  background: transparent;
  border: 1px solid var(--white);
  color: var(--white);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  touch-action: manipulation;
  font-family: inherit;
}

.edit-btn:hover {
  background: var(--white);
  color: var(--bg);
}

.edit-card textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--white);
  padding: 10px;
  border-radius: 8px;
  font-family: monospace;
}

.danger-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: white;
  transition: opacity 0.2s;
  touch-action: manipulation;
}

.danger-btn:hover {
  opacity: 0.8;
}

/* Global floating controls (theme toggle / admin lock) */
.global-controls {
  position: fixed;
  top: clamp(10px, 2vh, 20px);
  right: clamp(10px, 2vw, 20px);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.5vh, 14px);
  z-index: 1000;
}

/* --- REUSABLE CLOSE BUTTON (Flex-compatible) --- */
.close-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--input-border);
  color: var(--white);
  font-size: 1.2rem;
  width: 38px;
  height: 38px;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--white);
}

body.light-mode .close-btn {
  color: black;
  border-color: #ccc;
}

@media (max-width: 480px) {
  .admin-dashboard-header {
    gap: 10px;
  }

  .admin-dashboard-header h2 {
    font-size: 0.9rem;
  }

  .admin-dashboard-header .primary-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
  }

  .close-btn {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }
}

/* =======================================================
   MENU PAGE — LIGHT MODE TEXT READABILITY
======================================================= */

body.light-mode .app-subtitle {
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.25);
}

body.light-mode .app-title {
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.25);
}

/* =======================================================
   MENU PAGE — LANDSCAPE COMPACT LAYOUT
   Shows more elements without affecting portrait/desktop
======================================================= */

@media (orientation: landscape) and (max-height: 520px) {

  .menu-page {
    padding: 18px 20px;
    gap: 8px;
    justify-content: flex-start;
  }

  .logo {
    width: clamp(120px, 18vw, 220px);
    margin-bottom: 0px;
  }

  .app-title {
    font-size: clamp(2rem, 4vw, 3.2rem);
  }

  .app-subtitle {
    font-size: clamp(0.9rem, 2.2vw, 1.2rem);
  }

  .menu-buttons {
    margin-top: 18px;
    gap: 12px;
    padding-bottom: 10px;
  }

  .menu-btn {
    padding: 8px 18px;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
  }

}

.menu-btn {
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.2),
    inset 0 -1px 2px rgba(0, 0, 0, 0.4);
}

.menu-btn::before {
  content: "";
  position: absolute;
  top: -200%;
  left: -80%;
  width: 60%;
  height: 500%;

  background: linear-gradient(120deg,
      transparent 0%,
      rgba(255, 255, 255, 0.05) 40%,
      transparent 100%);

  transform: rotate(25deg);
  pointer-events: none;

  animation: glassSweep 4s ease-in-out infinite;
}

body.light-mode .menu-btn::before {
  content: "";
  position: absolute;
  top: -200%;
  left: -80%;
  width: 60%;
  height: 500%;

  background: linear-gradient(120deg,
      transparent 0%,
      rgba(255, 255, 0, 0.06) 46%,
      rgba(0, 200, 255, 0.05) 54%,
      transparent 100%);

  transform: rotate(25deg);
  pointer-events: none;

  animation: glassSweep 4s ease-in-out infinite;
}

.menu-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

@keyframes glassSweep {

  /* idle */
  0% {
    left: -80%;
    opacity: 0;
  }

  60% {
    left: -80%;
    opacity: 0;
  }

  /* reflection passes */
  65% {
    opacity: 1;
  }

  80% {
    left: 140%;
    opacity: 1;
  }

  /* fade away */
  85% {
    opacity: 0;
  }

  /* reset */
  100% {
    left: 140%;
    opacity: 0;
  }

}

body.light-mode .menu-btn:nth-child(1)::before,
.menu-btn:nth-child(1)::before {
  animation-delay: 0s;
}

body.light-mode .menu-btn:nth-child(2)::before,
.menu-btn:nth-child(2)::before {
  animation-delay: 1.5s;
}

body.light-mode .menu-btn:nth-child(3)::before,
.menu-btn:nth-child(3)::before {
  animation-delay: 3s;
}

body.light-mode .menu-btn:nth-child(4)::before,
.menu-btn:nth-child(4)::before {
  animation-delay: 4.5s;
}

/* Admin Tabs Styling */
.admin-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.tab-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--white);
  color: var(--bg);
  font-weight: bold;
}

body.light-mode .tab-btn.active {
  background: #000;
  color: #fff;
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* Ensure tab content displays correctly */
.tab-content {
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex: 1;
  min-height: 0;
}

/* --- Portrait / Mobile Adjustments --- */
@media (max-width: 600px) {
  .admin-dashboard-header {
    flex-direction: column;
    /* Stack the title and buttons */
    align-items: flex-start;
    position: relative;
    padding-bottom: 15px;
    gap: 15px;
  }

  .admin-dashboard-header h2 {
    font-size: 1.5rem;
    align-self: center;
  }

  #closeAdminDashboardBtn {
    position: absolute;
    top: -15%;
    scale: 90%;
  }

  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Puts buttons side-by-side, equal width */
    gap: 10px;
  }

  .header-actions .primary-btn {
    padding: 5px 0px;
    font-size: 0.9rem;
    width: 100%;
    margin: 0;
  }
}

.admin-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
}

.tab-btn {
  text-align: center;
}

/* Ensure the dashboard container takes up available space but doesn't exceed screen */
.admin-dashboard-container {
  max-height: 90vh;
  /* Prevents it from going off-screen */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* We want the lists to scroll, not the whole card */
}

/* Make the list containers scrollable */
.admin-court-list {
  flex: 1;
  overflow-y: auto;
  /* This enables scrolling */
  padding-right: 5px;
  /* Space for scrollbar */
  min-height: 0;
  /* Ensures there is an area to scroll even if empty */
  -webkit-overflow-scrolling: touch;
  /* Smooth scrolling on iOS */
}

/* Custom scrollbar for a cleaner look */
.admin-court-list::-webkit-scrollbar {
  width: 6px;
}

.admin-court-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

body.light-mode .admin-court-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
}

/* Tabs Light Mode */
body.light-mode .tab-btn {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: #333;
}

body.light-mode .tab-btn.active {
  background: #000;
  color: #fff;
}

/* Device/Court Items Light Mode */
body.light-mode .admin-court-item {
  background: #ffffff;
  border: 1px solid #dddddd;
  color: #333;
}

body.light-mode .aci-name strong {
  color: #000;
}

body.light-mode .aci-id {
  color: #666;
}

/* Search Inputs Light Mode */
body.light-mode #adminDeviceSearch,
body.light-mode #adminCourtSearch {
  background: #fff;
  color: #000;
  border: 1px solid #ccc;
}

@media (max-width: 600px) {
  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  /* Ensure the container doesn't get too tall on small phones */
  .admin-dashboard-container {
    width: 95%;
    max-height: 95vh;
  }
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: flex;
}

@keyframes apptitleanimation {
  0% {
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.4));
  }

  75% {
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.7));
  }

  100% {
    filter: drop-shadow(0 0 15px rgba(0, 0, 0, 0.4));
  }
}

@keyframes subtitleanimation {
  0% {
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.4));
  }

  75% {
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.7));
  }

  100% {
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.4));
  }
}

@keyframes logoanimation {
  0% {
    filter: drop-shadow(0 0px 15px rgba(0, 0, 0, 0.4));
    transform: translateY(0px);
  }

  50% {
    filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.5));
    transform: translateY(-12px);
  }

  100% {
    filter: drop-shadow(0 0px 15px rgba(0, 0, 0, 0.4));
    transform: translateY(0px);
  }
}