/* CRICKET APEX 26 — stadium UI, 3 themes, mobile-first controls */
:root {
  --bg: #04070f;
  --panel: rgba(140, 180, 255, 0.06);
  --panel-brd: rgba(140, 180, 255, 0.16);
  --text: #eaf1ff;
  --muted: #93a7cc;
  --accent: #facc15;
  --accent-2: #22d3ee;
  --good: #34d399;
  --bad: #fb7185;
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
}
html[data-theme="day"] {
  --bg: #0a1f14;
  --accent: #fde047;
  --panel: rgba(190, 255, 210, 0.07);
  --panel-brd: rgba(190, 255, 210, 0.18);
}
html[data-theme="sunset"] {
  --bg: #170a12;
  --accent: #fb923c;
  --accent-2: #f472b6;
  --panel: rgba(255, 190, 150, 0.06);
  --panel-brd: rgba(255, 190, 150, 0.17);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(
    700px 340px at 50% -8%,
    rgba(34, 211, 238, 0.1),
    transparent 65%
  );
}
html[data-theme="day"] body {
  background-image: radial-gradient(
    700px 340px at 50% -8%,
    rgba(74, 222, 128, 0.14),
    transparent 65%
  );
}
html[data-theme="sunset"] body {
  background-image: radial-gradient(
    700px 340px at 50% -8%,
    rgba(251, 146, 60, 0.14),
    transparent 65%
  );
}
.glass {
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}

/* Top bar */
.topbar {
  width: min(1060px, calc(100% - 20px));
  margin: 10px auto 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 13px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #1a1405;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.brand-mark svg {
  width: 21px;
  height: 21px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text strong {
  letter-spacing: 0.12em;
  font-size: 14.5px;
}
.brand-text small {
  color: var(--muted);
  font-size: 10.5px;
}
.theme-switch {
  display: flex;
  gap: 6px;
}
.theme-btn {
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-brd);
  padding: 8px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}
.theme-btn:hover {
  color: var(--text);
}
.theme-btn.is-active {
  color: #141005;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}
.icon-btn {
  width: 37px;
  height: 37px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-brd);
  cursor: pointer;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
.icon-btn[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

/* Scorebar */
.scorebar {
  width: min(1060px, calc(100% - 20px));
  margin: 10px auto 0;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 16px;
  flex-wrap: wrap;
}
.score-main {
  display: flex;
  align-items: baseline;
  gap: 13px;
}
.team {
  font-weight: 800;
  letter-spacing: 0.1em;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.bat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 10px var(--good);
  animation: blink 1.6s infinite;
}
@keyframes blink {
  50% {
    opacity: 0.35;
  }
}
.score {
  font-size: 31px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.overs {
  color: var(--muted);
  font-size: 12.5px;
  font-family: var(--mono);
}
.score-mid {
  margin-left: auto;
  text-align: right;
}
.target {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
}
.rates {
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.rates strong {
  color: var(--text);
  font-family: var(--mono);
}
.need {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.last-balls small {
  display: block;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  margin-bottom: 5px;
}
.ball-row {
  display: flex;
  gap: 5px;
}
.ball-chip {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-brd);
  color: var(--text);
}
.ball-chip.b4 {
  background: #2563eb;
  border-color: #60a5fa;
}
.ball-chip.b6 {
  background: #7c3aed;
  border-color: #a78bfa;
}
.ball-chip.bw {
  background: #be123c;
  border-color: #fb7185;
}
.ball-chip.b0 {
  color: var(--muted);
}

/* Stage */
.stage {
  position: relative;
  width: min(1060px, calc(100% - 20px));
  margin: 10px auto 0;
  padding: 8px;
  overflow: hidden;
}
.stage canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}
.banner {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  animation: bannerPop 0.35s cubic-bezier(0.22, 1.4, 0.36, 1) both;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.8);
}
.banner strong {
  display: block;
  font-size: clamp(34px, 7vw, 64px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.banner span {
  color: #fff;
  font-size: clamp(12px, 2.4vw, 17px);
  font-weight: 600;
}
@keyframes bannerPop {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.7);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}
.timing {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(520px, 86%);
}
.timing-track {
  position: relative;
  display: flex;
  height: 22px;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
.zone {
  display: grid;
  place-items: center;
  color: rgba(0, 0, 0, 0.65);
}
.zone-early {
  flex: 74;
  background: #f59e0b;
}
.zone-good {
  flex: 11;
  background: #38bdf8;
}
.zone-perfect {
  flex: 8;
  background: #34d399;
}
.zone-late {
  flex: 7;
  background: #f59e0b;
}
.needle {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 4px;
  margin-left: -2px;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 8px #fff;
}
.menu {
  position: absolute;
  inset: 8px;
  border-radius: 12px;
  background: rgba(3, 6, 14, 0.82);
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  gap: 10px;
}
.menu[hidden] {
  display: none;
}
.menu h1 {
  margin: 0;
  font-size: clamp(22px, 4.5vw, 34px);
  letter-spacing: 0.05em;
}
.menu p {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
  font-size: 13.5px;
  line-height: 1.55;
}
.menu p strong {
  color: var(--accent);
}
.mode-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}
.mode-btn {
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-brd);
  border-radius: 14px;
  padding: 13px 16px;
  min-width: 168px;
  transition: all 0.2s;
}
.mode-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.mode-btn strong {
  display: block;
  font-size: 15px;
}
.mode-btn small {
  color: var(--muted);
  font-size: 11.5px;
}
.career {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}

/* Controls */
.controls {
  width: min(1060px, calc(100% - 20px));
  margin: 10px auto 0;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: stretch;
}
.shot-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  grid-column: 1 / -1;
}
.shot {
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-brd);
  border-radius: 12px;
  padding: 10px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.18s;
}
.shot small {
  font-family: var(--mono);
  font-size: 9.5px;
  opacity: 0.6;
}
.shot:hover {
  color: var(--text);
}
.shot.is-active {
  color: #141005;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}
.mid-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}
.foot-btn {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-brd);
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  text-align: left;
}
.foot-btn strong {
  color: var(--accent);
}
.bowler-card {
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 9px 14px;
}
.bowler-card strong {
  color: var(--text);
}
.bowler-card small {
  display: block;
  font-size: 11px;
  margin-top: 1px;
}
.hit-btn {
  font: inherit;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #141005;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 16px;
  padding: 14px 42px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transition:
    transform 0.1s,
    filter 0.2s;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.hit-btn small {
  font-size: 9px;
  letter-spacing: 0.3em;
  opacity: 0.65;
}
.hit-btn:hover {
  filter: brightness(1.07);
}
.hit-btn:active,
.hit-btn.pressed {
  transform: scale(0.94);
}
.hit-btn:disabled {
  filter: grayscale(0.6) brightness(0.7);
  cursor: not-allowed;
}

/* Lower panels */
.lower {
  width: min(1060px, calc(100% - 20px));
  margin: 10px auto 0;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 10px;
}
.panel {
  padding: 15px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.wagon-panel canvas {
  width: 100%;
  max-width: 280px;
  height: auto;
  display: block;
  margin: 0 auto;
}
.wagon-legend {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 8px;
}
.lg {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  margin-left: 8px;
}
.lg-4 {
  background: #38bdf8;
}
.lg-6 {
  background: #a78bfa;
}
.lg-r {
  background: #facc15;
}
.stat-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.stat-list li {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 11px;
  padding: 9px 12px;
  font-size: 12px;
  color: var(--muted);
}
.stat-list li strong {
  display: block;
  color: var(--text);
  font-size: 17px;
  font-family: var(--mono);
}
.mini-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #141005;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  margin-right: 8px;
}
.mini-btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border: 1px solid var(--panel-brd);
}
.foot {
  width: min(1060px, calc(100% - 20px));
  margin: 14px auto 20px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11.5px;
}
.foot #clock {
  font-family: var(--mono);
  color: var(--accent);
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
  }
  .lower {
    grid-template-columns: 1fr;
  }
  .controls {
    grid-template-columns: 1fr;
  }
  .hit-btn {
    width: 100%;
    padding: 16px;
  }
  .score-mid {
    margin-left: 0;
    text-align: left;
  }
  .rates {
    justify-content: flex-start;
  }
  .brand-text small {
    display: none;
  }
  .theme-btn {
    padding: 7px 8px;
    font-size: 10.5px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
