*{ box-sizing: border-box; }

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:#0b1220;
  color:#e7eefc;
}

.wrap{
  max-width: 1200px;
  margin:0 auto;
  padding: 18px;
}

/* ---------- Top bar ---------- */
.top{
  display:flex;
  gap:16px;
  align-items:flex-start;
  justify-content:space-between;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.04);
}

h1{
  margin:0;
  font-size: 20px;
  letter-spacing:.2px;
}

.sub{
  margin-top:6px;
  opacity:.8;
  font-size: 13px;
}

/* ---------- Event Log ---------- */

#event-log {
  overflow: auto;
  min-width: 220px;
  min-height: 100px;
}

#event-log-body {
  max-height: 140px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.35;
  padding: 4px;
  background: #0f1115;
  border-radius: 4px;
}

.event-log-line {
  padding: 2px 4px;
  margin-bottom: 2px;
  color: #ddd;
  font-family: monospace;
  white-space: pre-wrap;
}

/* ---------- Event Log Colors ---------- */

.event-log-line.illegal {
  color: #ff4d4d;      /* strong red */
  font-weight: 600;
}

.event-log-line.twitch {
  color: #c084fc;      /* purple */
  font-weight: 500;
}



/* ---------- Controls ---------- */
.controls{
  display:flex;
  gap:14px;
  align-items:flex-end;
  flex-wrap:wrap;
}

.row{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width: 180px;
}

label{
  font-size: 12px;
  opacity:.8;
}

select,
input[type="range"]{
  width: 220px;
}

button{
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08);
  color:#e7eefc;
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
}

button:hover{
  background: rgba(255,255,255,.12);
}

button.ghost{
  background: transparent;
}

.buttons{
  flex-direction:row;
  gap:10px;
}

#placeBtn,
#clearBtn {
	opacity: 1;
	filter: none;
	cursor: pointer;
}

#placeBtn:disabled,
#clearBtn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.Innings2Btn {
	margin-left: auto;
	padding: 8px 12px;
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 10px;
	background: rgba(110, 80, 255, 0.22);
	color: #ffffff;
	font-weight: 700;
	cursor: pointer;
}

.Innings2Btn:hover {
	background: rgba(110, 80, 255, 0.36);
}

.Innings2Btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}


#rollD6Btn, #rollD12Btn, #rollD20Btn {
  overflow: visible !important;
}

/* Keep dice canvases above nearby UI controls */
#d6Canvas, #d12Canvas, #d20Canvas {
  position: relative;
  z-index: 5;
  pointer-events: none; /* clicks still go to the roll button */
}


#d6Canvas, #d12Canvas, #d20Canvas {
  overflow: visible !important;
}

#dice3DRow { position: relative; z-index: 10; }
#playstyleSel { position: relative; z-index: 1; }
#d6Canvas, #d12Canvas, #d20Canvas { pointer-events: none; }

#d6Canvas, #d12Canvas, #d20Canvas { position: relative; top: -8px; }




button.ghost {
  background: rgba(255,255,255,.08);
}

button.ghost:hover {
  background: rgba(255,255,255,.12);
}



/* ---------- Main layout ---------- */
.main{
  margin-top: 14px;
  display:grid;
  grid-template-columns: 1fr;
  gap: 14px;
  position: relative;
  display: block;
  min-height: calc(100vh - 160px);
}

/* =========================================================
   Scoreboard section wrapper
   ========================================================= */

#scoreboardSection,
#headerMusicSection {
	overflow: visible;
}


/* ---------- Score cards ---------- */
.score{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.card{
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.04);
}

.label{
  font-size: 12px;
  opacity:.75;
}

.big{
  font-size: 28px;
  margin-top:6px;
}

.small{
  margin-top:8px;
  font-size: 13px;
  opacity:.9;
}

.tag{
  display:inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  margin-right: 6px;
  font-size: 12px;
  opacity:.85;
}

/* =========================================================
   Scoreboard section
   ========================================================= */

.scoreboard {
	display: grid;
	grid-template-columns: minmax(300px, 1.35fr) minmax(170px, 1fr) minmax(90px, 0.45fr) minmax(70px, 0.35fr);
	gap: 8px;
	align-items: stretch;
}

.scoreboardChunk {
	min-width: 0;
	padding: 8px 10px;
}

.scoreboardBatters {
	grid-column: 1;
	grid-row: 1;

	display: flex;
	flex-direction: column;
	justify-content: center;
	min-width: 300px;
	overflow: visible;
}

.scoreboardMain {
	grid-column: 2;
	grid-row: 1;

	display: flex;
	flex-direction: column;
	justify-content: center;
	text-align: center;
	padding-left: 0;

	transform: translateX(-90px);
}

.scoreboardMain #scoreLine {
	font-size: 38px;
	font-weight: 800;
	line-height: 1;
}

.scoreboardInfo {
	grid-column: 3;
	grid-row: 1;

	display: flex;
	flex-direction: row;
	align-items: baseline;
	justify-content: center;
	gap: 8px;
}

.scoreboardLogo,
.scoreboardLogos {
	grid-column: 4;
	grid-row: 1;

	display: flex;
	flex-direction: column;
	justify-content: center;
}

.batterLine {
	display: flex;
	align-items: center;
	flex-wrap: nowrap;
	gap: 7px;
	width: max-content;
	max-width: none;
	white-space: nowrap;
	overflow: visible;
}

.batterLine > span {
	flex: 0 0 auto;
	white-space: nowrap;
	overflow: visible;
	text-overflow: clip;
}

#striker,
#nonStriker {
	flex: 0 0 auto;
	font-size: 1.25rem;
	font-weight: 800;
	line-height: 1.3;
	white-space: nowrap;
}

.batterMeters {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
	flex-wrap: nowrap;
	gap: 5px;
	margin-left: 4px;
	white-space: nowrap;
	vertical-align: middle;
}

.meterBox {
	flex: 0 0 58px;
	width: 58px;
	padding: 3px 4px;
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 7px;
	background: rgba(0, 0, 0, 0.18);
	box-sizing: border-box;
}

.meterHeader {
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 3px;
	font-size: 9px;
	line-height: 1;
}

.meterName {
	font-size: 9px;
	font-weight: 700;
	opacity: 0.9;
}

.meterValue {
	flex: 0 0 auto;
	font-size: 9px;
	font-variant-numeric: tabular-nums;
	opacity: 0.9;
}

.meterTrack {
	height: 5px;
	overflow: hidden;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.16);
}

.meterFill {
	width: 0%;
	height: 100%;
	border-radius: 999px;
	background: currentColor;
	transition: width 180ms ease;
}

.meterBox.flowMeter {
	color: #7ee7ff;
}

.meterBox.powerMeter {
	color: #ffb35c;
}

#battersTitle {
	display: none;
}

/* =========================================================
   Field image / field layers
   ========================================================= */

.fieldLayer {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;

  object-fit: contain;
}

.fieldBackgroundLayer {
  z-index: 0;
  display: none;
  opacity: 0.9;
}

.fieldImageLayer {
  z-index: 1;
}


/* ---------- Pins ---------- */


#controls,
#controls * {
  pointer-events: auto !important;
  z-index: 10;
  position: relative;
}

#pins {
  position: absolute;
  inset: 0;
  z-index: 2;

  /* Let clicks pass through the pins container to the field image */
  pointer-events: none;
}

.pin {
  position: absolute;
  transform: translate(-50%, -50%);

  /* Anchor point only */
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  background: transparent;

  /* Still allow children to show */
  overflow: visible;

  /* Keep your existing behavior */
  display: none !important;
}

/* Keep clickable */
#pins .pin {
  pointer-events: auto;
}

.pinLabel {
  display: none; /* you said you don’t want these */
}

.pinVal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);

  font-size: 13px;
  font-weight: 600;

  background: white;
  color: black;
  border-radius: 999px;
  padding: 4px 10px;

  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0,0,0,.35);
}

/* =========================================================
   Team logo card
   ========================================================= */

.scoreboardLogos {
  display: flex;
  gap: 10px;
  align-items: stretch;
  justify-content: center;
}

.teamLogoBox {
  flex: 1 1 0;
  min-width: 0;
}

#teamLogoWrap,
#fieldingTeamLogoWrap {
  display: flex;
  align-items: center;
  justify-content: center;

  height: 100%;
  min-height: 64px;
}

#teamLogoImg,
#fieldingTeamLogoImg {
  max-width: 100%;
  max-height: 80px;
  display: none;
}

#teamLogoFallback,
#fieldingTeamLogoFallback {
  font-size: 14px;
  font-weight: 700;
  opacity: .85;
  text-align: center;
}

/* =========================================================
   Score card metadata
   ========================================================= */

.bowlerThisOverTitle {
  font-size: 12px;
  opacity: .75;
  font-weight: 700;
  margin-bottom: 4px;
}

#bowlerThisOver {
  font-size: 12px;
  opacity: .8;
}

#bowlerLiveFigures {
  margin-top: 6px;
  font-size: 13px;
  opacity: .9;
  font-weight: 700;
}

.scoreboardMain #groundLine {
	margin-top: 7px;
	font-size: 14px;
	font-weight: 800;
	opacity: 0.9;
	text-align: center;
}

#requiredRunsWrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  margin-bottom: 8px;
}

#requiredRunsLine {
  font-size: 13px;
  opacity: .8;
  text-align: center;
}

#matchupLine {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .08em;
  opacity: .9;
  text-align: center;
  margin-bottom: 6px;
}

#matchNameLine {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#RequiredRunRate {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  font-weight: 800;
  opacity: 0.9;
}


/* =========================================================
   Playstyle control
   ========================================================= */

#playstyleControl {
  margin-top: 6px;
  font-size: 12px;
}

#playstyleControl label {
  opacity: .8;
}

#playstyleCap {
  margin-left: 6px;
  opacity: .6;
}


/* =========================================================
   Substitute overlay
   ========================================================= */

#subOverlay {
  position: fixed;
  inset: 0;

  background: rgba(0,0,0,0.75);

  display: none;
  align-items: center;
  justify-content: center;

  z-index: 9999;
}

.subOverlayCard {
  max-width: 420px;
  width: 90%;
  text-align: center;

  resize: none !important;
  overflow: visible;
}

.subOverlayTitle {
  margin-top: 0;
}

#subMessage {
  margin: 12px 0;
  opacity: .9;
}

.subSelectWrap {
  margin-top: 12px;
}

#subSelect {
  width: 100%;
  padding: 6px;
}

.batting_subby_select {
	background: var(--batting_primary);
	border-color: var(--batting_secondary);
	color: var(--batting_secondary);
}

.fielding_subby_select {
	background: var(--fielding_primary);
	border-color: var(--fielding_secondary);
	color: var(--fielding_secondary);
}


#subConfirmBtn {
  margin-top: 14px;
  width: 100%;
}
/* ---------- Field + legend ---------- */
.field {
  flex: 0 0 auto;
  position: relative;

  width: 720px;
  height: 720px;

  resize: none;
  overflow: hidden;

  min-width: 300px;
  min-height: 300px;
}

.fieldCanvas {
  position: relative;

  width: 100%;
  height: 100%;

  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  overflow: visible;

  resize: none;
}

.field.fieldSmall {
  width: 320px;
  height: 320px;
}

.fieldSizeToggle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 20;
}

.mainUI {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

#striker,
#nonStriker {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.3;
}



/* =========================================================
   Animated Ball
   ========================================================= */


.rollBall {
  position: absolute;
  z-index: 999;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transform: translate(-50%, -50%);

  background:
    radial-gradient(circle at 35% 35%,
      #ffffff 0%,
      #f4f4f4 16%,
      #d71920 18%,
      #9b0f16 72%,
      #5c070b 100%
    );

  box-shadow:
    0 0 0 2px rgba(255,255,255,0.85),
    0 5px 10px rgba(0,0,0,0.55);

  transition:
    left 850ms cubic-bezier(.12,.78,.18,1),
    top 850ms cubic-bezier(.12,.78,.18,1),
    opacity 250ms ease 950ms;

  pointer-events: none;
}

.rollBall::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 1px;
  width: 2px;
  height: 16px;
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  transform: rotate(22deg);
}


.rollBallDone {
  opacity: 0;
}

/* =========================================================
   Dice section / 3D dice row
   ========================================================= */

#diceSection {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #333;

  flex: 1 1 auto;
  min-width: 360px;
  max-width: none;
}

.diceSectionTitle {
  font-weight: bold;
}

#dice3DRow {
  margin-top: 10px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.dice3DBox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dice3DLabel {
  font-size: 12px;
  opacity: .75;
}

#d12Canvas,
#d6Canvas,
#missD20Canvas,
#runsD20Canvas {
  background: transparent;
  display: block;
}


/* =========================================================
   Dice section / dice result cards
   ========================================================= */

#diceSection {
  flex: 1 1 auto;   /* take all remaining space */
  min-width: 360px; /* don't get too squished */
  max-width: none;  /* remove old 420px cap */
}

#diceResults {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}


#diceResults {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.diceResultBox {
  border: 1px solid #333;
  border-radius: 10px;
  padding: 10px;
}

.diceResultLabel {
  opacity: .75;
  font-size: 12px;
}

.diceResultValue {
  font-size: 28px;
  font-weight: 800;
  margin-top: 4px;
}

/* custom layout for each result box */
.diceResultD12 {
  /* custom d12 tweaks go here */
}

.diceResultD6 {
  /* custom d6 tweaks go here */
}

.diceResultMissD20 {
  grid-column: 1 / span 2;
}

.diceResultRunsD20 {
  grid-column: 1 / span 2;
  margin-top: 10px;
}


/* Oval boundary */
.oval{
  position:absolute;
  left: 6%;
  top: 6%;
  width: 88%;
  height: 88%;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.12);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.18);
}


/* Side UI */


#fielderSelect {
	width: 170px;
	max-width: 170px;
	flex: 0 0 170px;
	min-height: 34px;
	padding: 5px 34px 5px 12px;

	border: 2px solid var(--fielding_primary);
	border-radius: 999px;

	background:
		linear-gradient(45deg, transparent 50%, var(--fielding_secondary) 50%),
		linear-gradient(135deg, var(--fielding_secondary) 50%, transparent 50%),
		var(--fielding_primary);

	background-position:
		calc(100% - 18px) 14px,
		calc(100% - 12px) 14px,
		0 0;

	background-size:
		6px 6px,
		6px 6px,
		100% 100%;

	background-repeat: no-repeat;

	color: var(--fielding_secondary);
	font-size: 13px;
	font-weight: 700;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);

	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.45),
		inset 0 -2px 5px rgba(0, 0, 0, 0.25),
		0 2px 5px rgba(0, 0, 0, 0.25);

	outline: none;
	cursor: pointer;

	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
}

#fielderSelect option {
	color: var(--fielding_secondary);
	background: var(--fielding_primary);
	font-weight: 700;
}




/* ---------- Legend / editor ---------- */
.legend{
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  display:flex;
  flex-direction:column;
  gap: 10px;
  width: fit-content;
  height: fit-content;
}

.legendTitle{
  font-size: 14px;
  font-weight:700;
}

.legendText{
  font-size: 13px;
  opacity:.85;
  line-height: 1.4;
}

.editor{
  border-top: 1px solid rgba(255,255,255,.10);
  padding-top: 10px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.editorRow{
  display:flex;
  gap:10px;
  align-items:center;
}

.posName{
  font-weight:700;
}

.hint{
  font-size: 12px;
  opacity:.8;
  min-height: 16px;
}

.hidden {
  display: none;
}


/* ---------- Responsive ---------- */
@media (max-width: 980px){
  .field{
    grid-template-columns: 1fr;
  }
  .score{
    grid-template-columns: 1fr;
  }
  select,
  input[type="range"]{
    width: 100%;
  }
  .row{
    min-width: 220px;
  }
  .fieldCanvas{
    height: 560px;
  }
  .pin{
    width: 160px;
  }
}



button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.diceEq {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.8;
}


/* --- Dice UX polish (authoritative overrides) --- */
#rollD6Btn, #rollD12Btn, #rollD20Btn {
  width: 150px;
  height: 150px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Let the canvases receive clicks (we roll on canvas click now) */
#d6Canvas, #d12Canvas, #d20Canvas {
  pointer-events: auto !important;
  cursor: pointer;
}


.wicket {
  color: #e53935; /* red */
  font-weight: bold;
}

.four {
  color: #2e7d32; /* green */
  font-weight: bold;
}

.six {
  color: #8e24aa; /* purple (Erika-approved 💜) */
  font-weight: bold;
}

/* ---------- Hint / error message styling ---------- */

#hint {
  font-size: 13px;
  line-height: 1.35;
  color: rgba(0, 0, 0, 0.75);
}

#hint.hintError {
  color: #d65a5a;   /* softer red */
  font-weight: 600;
}

/* Non-error hint (e.g. "Currently: X") */
#hint:not(.hintError) {
  color: #4a6fa5;   /* readable blue-grey */
  font-weight: 500;
}


/* =======================================================
   Universal resizable panels
   ======================================================= */

/* Any major UI section or card */
.card,
.legend,
#event-log {
  resize: both;
  overflow: auto;

  /* Prevent collapse */
  min-width: 220px;
  min-height: 140px;
}

/* Allow resizable children inside grid/flex layouts */
.main > * {
  min-width: 0;
  min-height: 0;
}

/* ---------- Resizable (non-draggable) UI windows ---------- */
.ui-window{
  position: absolute;
  resize: both;          /* native resize handle */
  overflow: auto;
  min-width: 220px;
  min-height: 140px;
  border-radius: 14px;
  z-index: 20;
  pointer-events: auto;
}

/* Header is now visual-only (no drag behavior) */
.ui-header{
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-bottom: none;
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  background: rgba(255,255,255,.06);
  cursor: default;       /* no move cursor */
  user-select: auto;     /* normal text selection */
  font-size: 12px;
  opacity: .9;
  pointer-events: none;  /* disables drag initiation */
}

.ui-window .ui-content{
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* =========================================================
   Player profile card
   ========================================================= */

.player-card {
  position: fixed;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.18);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 240px;
  max-width: 360px;
  z-index: 999999;
}

.player-card.hidden {
  display: none !important;
}

.player-card-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.player-card-img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: rgba(0,0,0,0.06);
  flex: 0 0 48px;
}

.player-card-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.player-card-name {
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#player-card-desc-toggle {
	position: absolute;
	right: 10px;
	bottom: 10px;
	width: 28px;
	height: 28px;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	border-radius: 999px;
}

#player-card-desc-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

#player-card-desc {
  margin-top: 8px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
}

#player-card-desc[hidden] {
  display: none;
}

.player-card-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,0.06);
  cursor: pointer;
  font-size: 18px;
  line-height: 28px;
}

.player-card-close:hover {
  background: rgba(0,0,0,0.10);
}

/* =========================================================
   Player Template
   ========================================================= */


.templateOverlay {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(0, 0, 0, 0.55);
	backdrop-filter: blur(4px);
}

.templateOverlay.hidden {
	display: none;
}

.templateCard {
	width: min(780px, 96vw);
	max-height: 90vh;
	overflow: auto;
	border-radius: 18px;
	padding: 18px;
	background: rgba(18, 18, 24, 0.96);
	border: 1px solid rgba(255, 255, 255, 0.14);
	box-shadow: 0 22px 80px rgba(0, 0, 0, 0.45);
	color: white;
    position: relative;
}

.templateHeader {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 16px;
}

.templateKicker {
	font-size: 12px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	opacity: 0.7;
}

.templateHeader h2 {
	margin: 2px 0 0;
	font-size: 24px;
	line-height: 1.1;
}

.closeButton {
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.1);
	color: white;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

.closeButton:hover {
	background: rgba(255, 255, 255, 0.18);
}


.linkPlayerInputWrap {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin-top: 6px;
}

.linkPlayerInputWrap .closeButton {
	width: 30px;
	height: 30px;
	font-size: 22px;
	flex: 0 0 auto;
}


#templateCloseMount {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 2;
}

#templateFields {
	align-items: start;
}

.templateBody {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.templateGrid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
}

.templateField {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.templateField span {
	font-size: 13px;
	opacity: 0.78;
}

.templateField input,
.templateField select {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-radius: 12px;
	padding: 10px 12px;
	background: rgba(255, 255, 255, 0.08);
	color: white;
	font-size: 15px;
	outline: none;
}

.templateField select {
	cursor: pointer;
}

.templateField select[multiple] {
	min-height: 190px;
	padding: 8px;
	cursor: default;
}

.templateField select option {
	color: black;
}

.templateCheckboxField {
	display: inline-flex;
	flex-direction: row;
	align-items: center;
	justify-content: flex-start;
	gap: 0.55rem;

	width: max-content;
	max-width: max-content;
	min-width: 0;
	min-height: 0;
	height: auto;

	padding: 0.35rem 0.55rem;
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.08);
}

.templateCheckboxField span {
	opacity: 0.78;
	white-space: nowrap;
}

.templateCheckboxLabel {
	display: inline;
	width: auto;
	max-width: none;
	min-height: 0;
	height: auto;
	padding: 0;
	box-sizing: border-box;
}

.templateCheckbox {
	width: 1.05rem;
	height: 1.05rem;
	min-width: 1.05rem;
	max-width: 1.05rem;
	flex: 0 0 1.05rem;
	margin: 0;
}


input[data-key="batting"],
input[data-key="bowling"],
input[data-key="fielding"],
.templateField:has(input[data-key="batting"]),
.templateField:has(input[data-key="bowling"]),
.templateField:has(input[data-key="fielding"]) {
	width: 3.5rem;
	max-width: 3.5rem;
}

.templateMultiCheckboxLabel {
	font-weight: 600;
}

.templateMultiCheckbox {
	display: grid;
	grid-column: 1 / -1;
	align-self: start;
	justify-items: start;

	gap: 0.35rem;
	width: max-content;
	max-width: 100%;
	max-height: 8rem;
	overflow-y: auto;
	box-sizing: border-box;
}

.templateMultiCheckboxRow {
	display: inline-grid;
	grid-template-columns: max-content 1.05rem;
	align-items: center;
	justify-content: start;
	gap: 0.35rem;
	width: max-content;
}

.templateMultiCheckboxName {
	white-space: nowrap;
}

.templateMultiCheckboxInput {
	width: 1.05rem;
	height: 1.05rem;
	min-width: 1.05rem;
	max-width: 1.05rem;
	margin: 0;
	justify-self: start;
}

.templateField input:focus,
.templateField select:focus {
	border-color: rgba(255, 255, 255, 0.42);
	background: rgba(255, 255, 255, 0.12);
}


.templateWide {
	width: 100%;
}

.templateActions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 18px;
}

.templateBtn {
	border: 0;
	border-radius: 12px;
	padding: 10px 16px;
	font-weight: 700;
	cursor: pointer;
}

.templateBtn.ghost {
	background: rgba(255, 255, 255, 0.1);
	color: white;
}

.templateBtn.primary {
	background: white;
	color: #14141a;
}

.templateBtn:hover {
	filter: brightness(1.08);
}

.templateBtn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	filter: none;
}

@media (max-width: 700px) {
	.templateOverlay {
		padding: 12px;
	}

	.templateGrid {
		grid-template-columns: 1fr;
	}

	.templateCard {
		width: 100%;
		max-height: 94vh;
	}
}

.templateMultiButtons {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.templateMultiChoice {
	padding: 6px 10px;
	border: 1px solid #777;
	border-radius: 8px;
	background: #222;
	color: white;
	cursor: pointer;
}

.templateMultiChoice.selected {
	background: #2563eb;
	border-color: #60a5fa;
	color: white;
}

#templateHint {
	margin-top: 8px;
	white-space: pre-wrap;
}


/* =========================================================
   Hint / error messages
   ========================================================= */

#hint {
  font-size: 13px;
  line-height: 1.35;
  color: rgba(0,0,0,0.75);
  width: 100%;
}

#hint.hintError {
  color: #b00020;
  font-weight: 600;
}

/* =========================================================
   Header Pages
   ========================================================= */

#HeaderDiv {
	position: relative;

	min-width: 760px;
	height: 184px;

	resize: both;
	overflow: auto;

	padding: 12px 14px;
	border: 1px solid rgba(255,255,255,.08);
	border-radius: 14px;
	background: rgba(255,255,255,.04);
}

/* Radio buttons store the current page, but are never seen */
.headerPageRadio {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

/* Default: all header pages hidden unless selected below */
.headerPage {
	display: none;
	width: 100%;
	height: 100%;
	min-width: 0;
	min-height: 0;
}

/* Page 1: scoreboard */
#headerPageScoreboard:checked ~ #scoreboardSection {
	display: block;
}

/* Page 2: music */
#headerPageMusic:checked ~ #headerMusicSection {
	display: block;
}

/* Arrow buttons */
.headerArrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 20;

	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;

	border: 0;
	border-radius: 999px;
	background: transparent;
	cursor: pointer;
	user-select: none;
}

#headerArrowRight {
	right: 8px;
}

#headerArrowLeft {
	left: 8px;
}

.headerArrow img {
	width: 24px;
	height: 24px;
	display: block;
	pointer-events: none;
}

.headerArrow[hidden] {
	display: none;
}

/* On scoreboard page: show right arrow only */
#headerPageScoreboard:checked ~ #headerArrowRight {
	display: flex;
}

#headerPageScoreboard:checked ~ #headerArrowLeft {
	display: none;
}

/* On music page: show left arrow only */
#headerPageMusic:checked ~ #headerArrowRight {
	display: none;
}

#headerPageMusic:checked ~ #headerArrowLeft {
	display: flex;
}

/* Temporary music page styling */
#headerMusicSection {
	min-height: 100%;
}



/* =========================================================
   Music Player Controls
   ========================================================= */

.mainUI > .controls {
	flex-direction: column;
	align-items: flex-start;
}

.soundControls {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 8px;
}


.headerMusicControls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	margin: 0;
	padding: 0;
	border-radius: 0;
	background: transparent;
}

.musicControls {
	margin-top: 8px;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
	padding: 6px;
	border-radius: 10px;
	background: transparent;
}

.musicIconBtn {
	width: 40px;
	height: 40px;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: transparent;
	box-shadow: none;
	outline: none;
	cursor: pointer;
}

.musicIconBtn:hover {
	background: rgba(255, 255, 255, 0.16);
	transform: translateY(-1px);
}

.musicIconBtn:active {
	transform: translateY(0);
	background: rgba(255, 255, 255, 0.22);
}

.musicIconBtn img {
	max-width: 40px;
	max-height: 40px;
	width: auto;
	height: auto;
	display: block;
	pointer-events: none;
}

.soundControls {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 8px;
	margin-top: 8px;
}

#MusicNia {
	display: grid;
	grid-template-columns: max-content max-content;
	grid-template-rows: auto auto auto;
	column-gap: 12px;
	row-gap: 6px;
	align-items: center;
	justify-content: center;
	min-width: 0;
	overflow: hidden;
}

.musicIconImage {
	display: none;
	grid-column: 2;
	grid-row: 1 / -1;
	justify-self: end;
	align-self: center;
	width: 64px;
	height: 64px;
	object-fit: contain;
	border-radius: 12px;
}

.musicInfoLine {
	grid-column: 1;
	width: 100%;
	min-width: 0;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 12px;
	line-height: 1.25;
	font-weight: 600;
	opacity: 0.9;
}

.musicNowPlaying {
	display: inline;
	width: auto;
	min-width: 0;
	text-align: inherit;
	white-space: inherit;
	overflow: visible;
	text-overflow: clip;
	opacity: 0.85;
}

.musicPlayerName {
	display: inline;
	width: auto;
	min-width: 0;
	text-align: inherit;
	white-space: inherit;
	overflow: visible;
	text-overflow: clip;
	font-weight: 800;
	color: #dd9cf7;
}

.musicPlayerName::before {
	content: " (";
}

.musicPlayerName::after {
	content: ")";
}

.musicPlayerName:empty::before,
.musicPlayerName:empty::after {
	content: "";
}

#LinkPlayerToSong,
#UnlinkPlayerFromSong {
	grid-row: 2;
	justify-self: center;
	align-self: center;
}

#LinkPlayerToSong {
	grid-column: 1;
}

#UnlinkPlayerFromSong {
	grid-column: 2;
	background: #b3261e;
	border-color: #b3261e;
	color: white;
}

#MusicNia .linkPlayerInputWrap {
	grid-column: 1 / 3;
	grid-row: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-width: 0;
}



#musicPlaylistMenu {
	height: 34px;
	min-width: 150px;
	padding: 4px 34px 4px 12px;

	border: 2px solid #4fc3ff;
	border-radius: 999px;

	background:
		linear-gradient(180deg, #2fb8ff 0%, #0578d8 48%, #0359ad 100%);
	color: white;

	font-size: 13px;
	font-weight: 700;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);

	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.45),
		inset 0 -2px 5px rgba(0, 0, 0, 0.25),
		0 2px 5px rgba(0, 0, 0, 0.25);

	outline: none;
	cursor: pointer;

	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;

	background-image:
		linear-gradient(45deg, transparent 50%, white 50%),
		linear-gradient(135deg, white 50%, transparent 50%),
		linear-gradient(180deg, #2fb8ff 0%, #0578d8 48%, #0359ad 100%);

	background-position:
		calc(100% - 18px) 14px,
		calc(100% - 12px) 14px,
		0 0;

	background-size:
		6px 6px,
		6px 6px,
		100% 100%;

	background-repeat: no-repeat;
}

#musicPlaylistMenu:hover {
	filter: brightness(1.08);
}

#musicPlaylistMenu:focus {
	border-color: white;
	box-shadow:
		0 0 0 2px rgba(79, 195, 255, 0.45),
		inset 0 1px 0 rgba(255, 255, 255, 0.45),
		inset 0 -2px 5px rgba(0, 0, 0, 0.25);
}

#musicPlaylistMenu option {
	color: #06264f;
	background: #dff5ff;
	font-weight: 700;
}

#headerMusicSection {
	gap: 12px;
	align-items: stretch;
	justify-content: center;
}

#headerPageMusic:checked ~ #headerMusicSection {
	display: flex;
}

.linkPlayerToSongBtn {
	margin-top: 6px;
	padding: 6px 10px;
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.12);
	color: white;
	font-size: 0.85rem;
	font-weight: 700;
	cursor: pointer;
}

.linkPlayerToSongBtn:hover {
	filter: brightness(1.15);
}

.linkPlayerToSongBtn:active {
	transform: translateY(1px);
}

.linkPlayerToSongBtn[hidden] {
	display: none;
}


.linkPlayerInput {
	margin-top: 6px;
	width: 100%;
	max-width: 180px;
	padding: 6px 8px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.28);
	background: rgba(0, 0, 0, 0.35);
	color: white;
	font-size: 0.85rem;
	font-weight: 600;
	text-align: center;
	outline: none;
}

.linkPlayerInput::placeholder {
	color: rgba(255, 255, 255, 0.55);
}

.linkPlayerInput:focus {
	border-color: rgba(255, 255, 255, 0.55);
}


.headerMusicPanel {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.uploadButtons {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 8px;
	margin-top: 8px;
}

.fileUploadMount {
	display: flex;
	align-items: center;
	justify-content: center;
}

.uploadButtons button {
	padding: 6px 10px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.18);
	background: rgba(255, 255, 255, 0.08);
	color: inherit;
	cursor: pointer;
	font-size: 12px;
	font-weight: 700;
}

.uploadButtons button:hover {
	background: rgba(255, 255, 255, 0.16);
	transform: translateY(-1px);
}

.uploadButtons button:active {
	background: rgba(255, 255, 255, 0.22);
	transform: translateY(0);
}

.teamDefaultIcon {
	width: 64px;
	height: 64px;
	object-fit: contain;
	display: block;
	margin: auto;
}

.yesNoBox {
	position: fixed;
	inset: 0;
	z-index: 99999;

	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;

	background: rgba(0, 0, 0, 0.72);
	padding: 24px;
}

.yesNoBox[hidden] {
	display: none;
}

.yesNoTextBox {
	max-width: 620px;
	padding: 18px 22px;
	border: 2px solid rgba(255, 80, 80, 0.9);
	border-radius: 14px;
	background: rgba(80, 0, 0, 0.92);
	color: #ffe5e5;
	font-size: 1.25rem;
	font-weight: 800;
	text-align: center;
	line-height: 1.35;
	box-shadow: 0 0 26px rgba(255, 60, 60, 0.35);
}

.yesNoActions {
	display: flex;
	gap: 12px;
}

.yesNoButton {
	min-width: 120px;
	padding: 10px 16px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.3);
	cursor: pointer;
	font-weight: 800;
}

.yesButton {
	background: rgba(220, 40, 40, 0.95);
	color: white;
}

.noButton {
	background: rgba(255, 255, 255, 0.16);
	color: white;
}

.yesNoButton:hover {
	filter: brightness(1.15);
}


.fileUploadMount {
	padding: 0 18px 12px;
	display: flex;
	justify-content: center;
}

.templateFileUploadBtn {
	padding: 8px 14px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.25);
	background: rgba(255, 255, 255, 0.12);
	color: white;
	font-weight: 700;
	cursor: pointer;
}

.templateFileUploadBtn:hover {
	filter: brightness(1.15);
}

.templateFileUploadBtn:active {
	transform: translateY(1px);
}

.templateFileUploadBtn[hidden] {
	display: none;
}

.templateTupleField {
	display: grid;
	grid-template-columns: 1fr 72px 72px;
	gap: 8px;
	align-items: center;
}

.templateTupleInput {
	width: 72px;
}

.templateMultiInt {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px 48px;
	align-items: center;
}

.templateMultiIntTitle {
	grid-column: 1 / -1;
}

.templateMultiIntRow {
	display: grid;
	grid-template-columns: 1fr 56px;
	align-items: center;
	gap: 12px;
}

.templateMultiIntInput {
	width: 48px;
	text-align: center;
	padding: 2px 4px;
}


.templatePageRadio {
	display: none;
}

#TemplatePage1:not(:checked) ~ #TemplatePage1Panel {
	display: none;
}

#TemplatePage2:not(:checked) ~ #TemplatePage2Panel {
	display: none;
}

.templateArrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 20;

	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;

	border: 0;
	border-radius: 999px;
	background: transparent;
	cursor: pointer;
	user-select: none;
}

.templateArrow[hidden] {
	display: none;
}

#templateArrowRight {
	right: 8px;
}

#templateArrowLeft {
	left: 8px;
}

.templateArrow img {
	width: 24px;
	height: 24px;
	display: block;
	pointer-events: none;
}


/* =========================================================
   Score / overs mini text (formerly injected in renderTop)
   ========================================================= */

.oversMini {
  font-size: 12px;
  opacity: 0.85;
  margin-left: 6px;
}

.targetMini {
  font-size: 12px;
  opacity: 0.85;
  margin-left: 6px;
}



/* ---------------------------------
   Player card swap / restore action
   --------------------------------- */

/* Player card action buttons */
.player-card-swap .player-card-action {
	padding: 6px 12px;
	border: 1px solid transparent;
	border-radius: 6px;

	font-size: 0.85rem;
	font-weight: 700;
	cursor: pointer;

	transition:
		filter 0.15s ease,
		transform 0.05s ease;
}

.player-card-swap .player-card-action:hover {
	filter: brightness(1.12);
}

.player-card-swap .player-card-action[data-action="wk"] {
	background: #0abf3d;
	color: #eeff57;
}

.player-card-swap .player-card-action[data-action="captain"] {
	background: #d261ff;
	color: #dd9cf7;
}

.player-card-swap .player-card-action[data-action="subby"] {
	background: #1f51c4;
	color: white;
}

.player-card-swap .player-card-action[data-action="bond"] {
	background: #8a6a00;
	color: white;
}

.player-card-swap .player-card-action:active {
	transform: translateY(1px);
}

/* Optional: disabled state (if you ever want it later) */
.player-card-swap .player-card-action[disabled] {
	opacity: 0.5;
	cursor: not-allowed;
}

.player-card-img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: #222;
  border: 1px solid rgba(255,255,255,.2);
}



/* Coin toss overlay */



.coinTossOverlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.coinTossOverlay.hidden {
  display: none;
}

.coinTossCard {
  width: min(420px, calc(100vw - 32px));
  padding: 22px;
  border-radius: 18px;
  background: rgba(20, 20, 24, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.coinTossHeader {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.coinTossMessage {
  min-height: 28px;
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 12px;
}

#coinCanvas {
  width: 260px;
  height: 260px;
  display: block;
  margin: 0 auto 14px auto;
}

#coinChoiceA,
#coinChoiceB {
  min-width: 120px;
  padding: 10px 18px;
  margin: 8px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 14px;
  background: rgba(20, 20, 30, 0.92);
  color: white;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

#coinChoiceA:hover,
#coinChoiceB:hover {
  transform: translateY(-1px);
  background: rgba(40, 40, 60, 0.96);
}

#coinChoiceA:active,
#coinChoiceB:active {
  transform: translateY(1px);
}

#coinHint {
  min-height: 22px;
  margin-top: 8px;
  color: #ffd1d1;
  font-size: 14px;
  font-weight: 700;
}

/* Wicket overlay */

.wicketOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 24px;
}

.wicketCard {
  width: min(560px, 92vw);
  background: #161616;
  border: 2px solid #7a1f1f;
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  padding: 22px 22px 18px;
  color: #f4f4f4;
}

.wicketHeader {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ff8e8e;
  opacity: 0.95;
  margin-bottom: 8px;
}

.wicketTitle {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.15;
  color: #fff3f3;
}

.wicketMessage {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.45;
  color: #f2dede;
}

.wicketField {
  margin-top: 12px;
}

.wicketLabel {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wicketSelect {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #6e3a3a;
  background: #242424;
  color: #fff;
  font-size: 15px;
}

.wicketSelect:focus {
  outline: 2px solid #c94b4b;
  outline-offset: 2px;
}

.wicketStatus {
  min-height: 22px;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 700;
  color: #ffb0b0;
}

.wicketActions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.wicketConfirmBtn {
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-radius: 12px;
  background: #a52d2d;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.wicketConfirmBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* Row for title + icon */
.legendTitleRow {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* The tiny info button */
.hintToggle {
  width: 16px;
  height: 16px;

  font-size: 11px;
  line-height: 16px;
  text-align: center;

  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 50%;

  background: rgba(255,255,255,0.08);
  color: #fff;

  cursor: pointer;
  padding: 0;

  opacity: 0.7;
}

.hintToggle:hover {
  opacity: 1;
  background: rgba(255,255,255,0.18);
}