/* Night-pitch board: dark green turf, chalk lines, LED-amber clock. */

:root {
  --pitch-950: #0A120D;
  --pitch-900: #111C15;
  --pitch-800: #1B2B21;
  --pitch-750: #23372A;
  --line: rgba(237, 243, 236, 0.16);
  --chalk: #EDF3EC;
  --chalk-dim: #8FA396;
  --amber: #FFB43A;
  --team-a: #5BC8F5;
  --team-b: #F0704D;
  --go: #46C97C;
  --danger: #E4574F;
  --radius: 14px;
  --font-cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-mono: "Chivo Mono", "Consolas", monospace;
  --font-body: "Barlow", system-ui, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 70% at 50% 0%, #142219 0%, var(--pitch-950) 60%),
    var(--pitch-950);
  color: var(--chalk);
  font-family: var(--font-body);
  padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  gap: 10px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ---- top bar ------------------------------------------------------------ */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.eyebrow {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--chalk-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.half-tag {
  font-family: var(--font-cond);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--chalk-dim);
  border: 1px solid var(--line);
}
.icon-btn:active { background: var(--pitch-800); }

/* ---- clock -------------------------------------------------------------- */

.clock-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.adjust {
  flex: 1;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--pitch-900);
  color: var(--chalk-dim);
  font-family: var(--font-mono);
  font-size: 13px;
}
.adjust:active { background: var(--pitch-750); color: var(--chalk); }

.clock {
  flex: 2.6;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #060B08;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.7);
}

.clock-digits {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(30px, 9vw, 44px);
  line-height: 1;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--chalk-dim);
  transition: color 0.2s, text-shadow 0.2s;
}

.clock-hint {
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--chalk-dim);
  opacity: 0.7;
}

.clock.running .clock-digits {
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255, 180, 58, 0.45);
}
.clock.running .clock-hint { color: var(--go); }

/* ---- halfway line ------------------------------------------------------- */

.halfway-line {
  height: 0;
  border-top: 2px dashed var(--line);
  position: relative;
  margin: 2px 0;
}
.halfway-line::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -6px;
  width: 10px;
  height: 10px;
  transform: translateX(-50%);
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--pitch-950);
}

/* ---- teams -------------------------------------------------------------- */

.teams {
  flex: 1;
  display: flex;
  gap: 10px;
  min-height: 0;
}

.teams.flipped { flex-direction: row-reverse; }

.team {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--pitch-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 10px 10px;
  gap: 4px;
}

.team-name {
  font-family: var(--font-cond);
  font-weight: 800;
  font-size: clamp(18px, 5.4vw, 26px);
  line-height: 1.05;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-align: center;
  min-height: 2.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-wrap: anywhere;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--team-a);
}
.team-b .team-name { border-bottom-color: var(--team-b); }

.team-score {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(56px, 19vw, 96px);
  line-height: 1.05;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.team-score.bump { animation: bump 0.45s ease-out; }
@keyframes bump {
  0% { transform: scale(1); }
  30% { transform: scale(1.14); color: var(--amber); }
  100% { transform: scale(1); }
}

.pads {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.pad {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-radius: 11px;
  background: var(--pitch-800);
  border: 1px solid var(--line);
  border-left: 4px solid var(--team-a);
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: transform 0.06s;
}
.team-b .pad { border-left-color: var(--team-b); }

.pad:active {
  transform: scale(0.97);
  background: var(--pitch-750);
}

.pad .pts {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  color: var(--chalk-dim);
}

/* ---- bottom bar --------------------------------------------------------- */

.bottom {
  display: flex;
  gap: 10px;
}

.bar-btn {
  flex: 1;
  min-height: 56px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--pitch-900);
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-btn:disabled { opacity: 0.4; }
.bar-btn:active:not(:disabled) { background: var(--pitch-750); }

.bar-btn.accent {
  border-color: rgba(255, 180, 58, 0.5);
  color: var(--amber);
}

.bar-btn.confirm {
  background: var(--amber);
  border-color: var(--amber);
  color: #201500;
}

/* ---- settings sheet ------------------------------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 6, 0.8);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.overlay.hidden { display: none; }

.sheet {
  width: min(560px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--pitch-900);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  padding: 20px 18px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sheet h2 {
  font-family: var(--font-cond);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sheet label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--chalk-dim);
}

.sheet input {
  font: 600 17px var(--font-body);
  color: var(--chalk);
  background: var(--pitch-950);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  user-select: text;
}

.sheet-btn {
  min-height: 50px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--pitch-800);
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sheet-btn.primary { background: var(--amber); border-color: var(--amber); color: #201500; }
.sheet-btn.danger { color: var(--danger); border-color: rgba(228, 87, 79, 0.5); }
.sheet-btn.danger.confirm { background: var(--danger); color: #fff; }
.sheet-btn.small { min-height: 40px; padding: 0 14px; flex: none; }

.vmix-block {
  border-top: 1px dashed var(--line);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.vmix-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--chalk-dim);
}
.vmix-row { display: flex; gap: 8px; align-items: center; }
.vmix-row code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--pitch-950);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  overflow-x: auto;
  white-space: nowrap;
  user-select: all;
}
.vmix-note { font-size: 13px; color: var(--chalk-dim); }

/* ---- connection banner --------------------------------------------------- */

.offline {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  font: 600 13px var(--font-body);
  padding: 6px 14px;
  border-radius: 999px;
  z-index: 30;
}
.offline.hidden { display: none; }

/* ---- larger screens ------------------------------------------------------ */

@media (min-width: 700px) {
  body { padding: 20px 24px; max-width: 900px; margin: 0 auto; width: 100%; }
  .pad { min-height: 60px; font-size: 20px; }
  .overlay { align-items: center; }
  .sheet { border-radius: 18px; border-bottom: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
