@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&family=Roboto+Mono:wght@400;700&display=swap');

/* ─── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --white: #FFFFFF;
  --off-white: #F7F7F5;
  --ink: #1A1A1A;
  --navy: #1B2A4A;
  --red: #C0392B;
  --gold: #E0A830;
  --mid-grey: #8A8A8A;
  --border: #E4E4E0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 4px 16px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 6px;
  --mono: 'Roboto Mono', monospace;
  --sans: 'Inter', sans-serif;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  background: var(--off-white);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: var(--sans);
  cursor: pointer;
  border: none;
  outline: none;
}

input {
  font-family: var(--sans);
  outline: none;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.page-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

/* ─── Nav header ─────────────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  height: 40px;
  width: 40px;
  object-fit: contain;
}

.nav-title {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.nav-sub {
  font-size: 0.8rem;
  color: var(--mid-grey);
  font-family: var(--mono);
}

.nav-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--navy);
  color: var(--white);
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-danger {
  background: var(--red);
  color: var(--white);
}

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

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--ink);
}

.btn-gold {
  background: var(--gold);
  color: var(--navy);
}

.btn-gold:hover {
  opacity: 0.88;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ─── Form inputs ────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--mid-grey);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--off-white);
  font-size: 0.95rem;
  color: var(--ink);
  width: 100%;
  transition: border-color 0.15s;
}

.input:focus {
  border-color: var(--navy);
  background: var(--white);
}

.input-mono {
  font-family: var(--mono);
  letter-spacing: 0.1em;
}

/* ─── Status badge ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-live {
  background: #fdecea;
  color: var(--red);
}

.badge-setup {
  background: #eef2ff;
  color: #3b5bdb;
}

.badge-half {
  background: #fff8e1;
  color: #b7791f;
}

.badge-full {
  background: #f1f3f5;
  color: var(--mid-grey);
}

/* Pulsing live dot */
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {

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

  50% {
    opacity: 0.4;
    transform: scale(0.7);
  }
}

/* ─── Mono score / timer ─────────────────────────────────────────────────── */
.score-num {
  font-family: var(--mono);
  font-weight: 700;
  line-height: 1;
}

.timer-display {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
}

/* ─── Match directory card ───────────────────────────────────────────────── */
.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.match-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
}

.match-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.match-card-teams {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 8px;
}

.team-pill {
  flex: 1;
  text-align: center;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-score {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.match-meta {
  font-size: 0.75rem;
  color: var(--mid-grey);
  font-family: var(--mono);
  margin-top: 4px;
}

/* ─── Section headings ───────────────────────────────────────────────────── */
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mid-grey);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--mid-grey);
}

.empty-state img {
  width: 100px;
  opacity: 0.7;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 0.95rem;
}

/* ─── Overlay / modal ────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(247, 247, 245, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.overlay-card {
  width: min(380px, 92vw);
}

/* ─── Spectator screen ───────────────────────────────────────────────────── */
.spectator-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--off-white);
  transition: background 0.5s;
  padding: 24px;
}

.spectator-teams {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: min(860px, 100%);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
}

.spectator-team {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  color: var(--white);
}

.spectator-team-name {
  font-size: clamp(1rem, 4vw, 1.6rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.9;
  margin-bottom: 8px;
  text-align: center;
}

.spectator-score {
  font-family: var(--mono);
  font-size: clamp(5rem, 18vw, 11rem);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.spectator-divider {
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--white);
  gap: 6px;
  flex-shrink: 0;
  padding: 16px 8px;
}

.spectator-half-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--mid-grey);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.spectator-timer {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
}

.spectator-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 10px 20px;
  background: var(--white);
  border-radius: 99px;
  box-shadow: var(--shadow);
}

/* Countdown overlay */
.countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 42, 74, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--white);
  z-index: 50;
}

.countdown-label {
  font-size: 0.9rem;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.countdown-time {
  font-family: var(--mono);
  font-size: clamp(4rem, 20vw, 10rem);
  font-weight: 700;
  line-height: 1;
}

/* Sponsor / idle screen */
.idle-screen {
  position: fixed;
  inset: 0;
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.idle-screen img {
  width: 140px;
  margin-bottom: 24px;
}

.idle-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.idle-sub {
  color: var(--mid-grey);
  margin-top: 6px;
  font-size: 0.95rem;
}

/* ─── Admin layout ───────────────────────────────────────────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}

@media (max-width: 640px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.team-card {
  border-left: 5px solid var(--border);
}

.scoring-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.score-big {
  font-family: var(--mono);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  margin: 8px 0;
}

.log-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}

.log-entry {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--off-white);
}

.log-entry-time {
  font-family: var(--mono);
  color: var(--mid-grey);
  min-width: 48px;
}

.log-entry-type {
  font-weight: 600;
}

.log-entry-pts {
  font-family: var(--mono);
  margin-left: auto;
  color: var(--mid-grey);
}

/* Timer row */
.timer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* Countdown input row */
.countdown-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.countdown-row input[type=number] {
  width: 80px;
}

/* Status control */
.status-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.status-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}

.status-btn.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

/* Color preview swatch */
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
}

input[type=color] {
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

/* Confirm reset */
#confirm-reset-btn {
  display: none;
}

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-8 {
  gap: 8px;
}

.gap-16 {
  gap: 16px;
}

.mt-4 {
  margin-top: 4px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

.text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

.text-mono {
  font-family: var(--mono);
}

.text-mid {
  color: var(--mid-grey);
}

.text-navy {
  color: var(--navy);
}

.fw-bold {
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.w-full {
  width: 100%;
}

/* ─── Mobile admin layout ────────────────────────────────────────────────── */
.admin-body {
  padding-bottom: 80px;
}

/* space for sticky bar */

.admin-content {
  padding: 0 0 16px;
}

/* Desktop control bar */
.desktop-control-bar {
  margin: 16px 16px 0;
}

.control-bar-inner {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.control-group {
  min-width: 160px;
}

/* Desktop log */
.desktop-log {
  margin: 0 16px;
}

/* ─── Team tabs ──────────────────────────────────────────────────────────── */
.team-tabs-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--white);
  position: sticky;
  top: 57px;
  z-index: 90;
  margin-top: 16px;
}

.team-tab {
  flex: 1;
  padding: 14px 8px;
  font-size: 0.875rem;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--mid-grey);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.team-tab.active {
  color: var(--navy);
  border-bottom-color: var(--navy);
}

/* ─── Team panels ────────────────────────────────────────────────────────── */
.teams-container {
  position: relative;
}

.team-panel {
  display: none;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}

.team-panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Panel header — coloured strip with name + score (fully interactive) */
.team-panel-header {
  border-radius: var(--radius);
  padding: 16px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
  color: var(--white);
  box-shadow: var(--shadow);
  cursor: pointer;
  position: relative;
  transition: filter 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.team-panel-header:active {
  filter: brightness(0.92);
}

/* Name section — left side of header */
.header-name-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.team-panel-name {
  font-size: 1.3rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.95;
  cursor: text;
  border-bottom: 1.5px solid transparent;
  transition: border-color 0.15s;
  display: inline-block;
}

.team-panel-name:hover {
  border-bottom-color: rgba(255, 255, 255, 0.4);
}

/* Inline name edit input — shown when tapping the name */
.team-name-inline {
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  color: var(--white);
  font-family: var(--sans);
  font-size: 1.2rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  outline: none;
  width: 100%;
  max-width: 160px;
}

.team-name-inline::placeholder {
  opacity: 0.5;
}

.team-name-inline:focus {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.8);
}

/* Score — right side, also a colour-picker trigger */
.team-panel-score {
  font-family: var(--mono);
  font-size: 3.6rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}

.team-panel-score:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Subtle colour hint strip under header */
.colour-hint {
  font-size: 0.68rem;
  color: var(--mid-grey);
  text-align: right;
  padding: 3px 6px 8px;
  opacity: 0.6;
  letter-spacing: 0.03em;
}

/* ─── Big scoring buttons ────────────────────────────────────────────────── */
.score-action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.score-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 18px 8px;
  cursor: pointer;
  transition: opacity 0.12s, transform 0.08s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 90px;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(27, 42, 74, 0.2);
}

.score-action-btn.away {
  background: var(--red);
  box-shadow: 0 2px 8px rgba(192, 57, 43, 0.2);
}

.score-action-btn:active {
  opacity: 0.8;
  transform: scale(0.96);
}

.score-action-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.85;
}

.score-action-pts {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

/* ─── Correction row ─────────────────────────────────────────────────────── */
.correction-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--border);
}

/* ─── Settings section (collapsible appearance on mobile) ────────────────── */
.team-settings {
  padding-top: 16px;
}

/* Mobile controls section (inside settings tab) */
.mobile-controls-section {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

/* ─── Sticky bottom timer bar ────────────────────────────────────────────── */
.sticky-timer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: var(--navy);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.15);
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

.sticky-timer-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sticky-half-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sticky-timer {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
  min-width: 90px;
}

.sticky-status {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sticky-timer-controls {
  display: flex;
  gap: 10px;
}

.sticky-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, opacity 0.12s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sticky-btn:active {
  transform: scale(0.92);
}

.sticky-btn-start {
  background: var(--gold);
  color: var(--navy);
}

.sticky-btn-stop {
  background: rgba(255, 255, 255, 0.15);
  color: var(--white);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

/* ─── Desktop: 3-column layout (Controls | Home | Away) ─────────────────── */
@media (min-width: 768px) {
  .admin-body {
    padding-bottom: 0;
  }

  /* No sticky bar needed on desktop */
  .sticky-timer-bar {
    display: none;
  }

  /* Hide tabs — all panels shown simultaneously */
  .team-tabs-bar {
    display: none;
  }

  /* 3-column grid */
  .teams-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    padding: 16px;
    align-items: start;
  }

  /* Show all panels, no animation needed */
  .team-panel {
    display: block !important;
    padding: 0;
  }

  /* Column order: Controls (left) · Home (centre) · Away (right) */
  #panel-settings {
    order: 1;
  }

  #panel-home {
    order: 2;
  }

  #panel-away {
    order: 3;
  }

  /* Slightly smaller score on desktop since 3 columns are narrower */
  .team-panel-score {
    font-size: 2.6rem;
  }

  .score-action-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .score-action-btn {
    min-height: 68px;
    padding: 10px 6px;
  }

  .score-action-pts {
    font-size: 1.5rem;
  }
}

/* ─── Tap feedback flash ─────────────────────────────────────────────────── */
@keyframes scoreFlash {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  30% {
    opacity: 0.6;
    transform: scale(0.94);
  }

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

.score-action-btn.flashing {
  animation: scoreFlash 0.25s ease;
}