@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,500&family=Syne:wght@700;800&display=swap");

:root {
  --bg: #070912;
  --bg2: #0c1020;
  --surface: #12172a;
  --surface2: #181e36;
  --border: #2a3354;
  --border-hot: rgba(54, 214, 195, 0.35);
  --text: #f4f1ea;
  --muted: #8f95ad;
  --accent: #36d6c3;
  --orange: #ff6a00;
  --danger: #ff4a3d;
  --ok: #3ddc97;
  --gold: #ffc23d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Syne", "DM Sans", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(255, 74, 61, 0.16), transparent 55%),
    radial-gradient(800px 480px at 100% 0%, rgba(54, 214, 195, 0.12), transparent 50%),
    linear-gradient(180deg, var(--bg2), var(--bg));
}
button, input, textarea, select { font: inherit; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: stretch;
  padding: 16px 18px calc(16px + env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(18, 23, 42, 0.96), rgba(12, 16, 32, 0.92));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
.brand {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
}
.score-line {
  margin-top: 6px;
  font-family: var(--display);
  font-size: clamp(26px, 7vw, 34px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--text);
}
.score-line .accent { color: var(--orange); }
.sub-line {
  margin-top: 5px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.35;
}
#btnUndo, .top-action {
  align-self: center;
  min-width: 84px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  padding: 14px 16px;
}

main {
  padding: 18px 16px 36px;
  max-width: 560px;
  margin: 0 auto;
}
.panel { display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none !important; }

h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 800;
}

.card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%),
    linear-gradient(180deg, var(--surface2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(54, 214, 195, 0.1);
  border: 1px solid var(--border-hot);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.hero-kicker i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(54, 214, 195, 0.15);
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
label .req {
  color: var(--danger);
  margin-left: 4px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
input, textarea, select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(7, 9, 18, 0.88);
  color: var(--text);
  padding: 14px 14px;
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(54, 214, 195, 0.55);
  box-shadow: 0 0 0 3px rgba(54, 214, 195, 0.12);
}
input.invalid, textarea.invalid, select.invalid {
  border-color: rgba(255, 74, 61, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 74, 61, 0.12);
}
textarea { resize: vertical; min-height: 168px; line-height: 1.45; }

.count-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 194, 61, 0.12);
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: none;
}
.hint, .hint-inline {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: 0;
}
.section-divider {
  margin: 6px 0 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 800;
}
.ready-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(61, 220, 151, 0.12);
  color: var(--ok);
  font-size: 12px;
  font-weight: 700;
}
.ready-pill.warn {
  background: rgba(255, 106, 0, 0.12);
  color: var(--orange);
}

.players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.player-pill {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 12px 12px;
}
.player-pill .role {
  font-size: 10px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.1em;
}
.player-pill .nm {
  margin-top: 5px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.player-pill .st {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.player-pill.striker {
  border-color: rgba(255, 106, 0, 0.5);
  background: rgba(255, 106, 0, 0.08);
}
.player-pill.striker .role { color: var(--orange); }
.meta-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.this-over {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.chip {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
}
.chip.hot {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.section-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 2px 2px 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.grid.extras { grid-template-columns: repeat(2, 1fr); }
#sheetRuns { grid-template-columns: repeat(3, 1fr); }
.grid.wickets { grid-template-columns: repeat(2, 1fr); }

button {
  border: 0;
  border-radius: 16px;
  padding: 18px 12px;
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(180deg, #232a48, #171d33);
  color: var(--text);
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.07);
  box-shadow: 0 10px 22px rgba(0,0,0,0.28);
  transition: transform 0.08s ease, filter 0.08s ease, border-color 0.12s ease;
}
button:active { transform: scale(0.97); filter: brightness(1.08); }
button.primary {
  background: linear-gradient(180deg, #ff8533, var(--orange));
  color: #fff;
  border: 0;
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 16px;
}
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  font-size: 14px;
  padding: 12px 14px;
  box-shadow: none;
}
button.accent {
  background: linear-gradient(180deg, rgba(54,214,195,0.22), rgba(54,214,195,0.08));
  color: #c9fff7;
  border-color: rgba(54,214,195,0.35);
  font-size: 15px;
}
button.danger {
  background: linear-gradient(180deg, rgba(255,74,61,0.38), rgba(255,74,61,0.14));
  color: #ffd4d0;
  border-color: rgba(255,74,61,0.42);
  font-size: 16px;
}
button.boundary {
  background: linear-gradient(180deg, rgba(61,220,151,0.28), rgba(61,220,151,0.1));
  color: #c8ffe4;
  border-color: rgba(61,220,151,0.35);
}
button.six {
  background: linear-gradient(180deg, rgba(255,194,61,0.3), rgba(255,194,61,0.1));
  color: #ffe9ad;
  border-color: rgba(255,194,61,0.4);
}

.sheet, .pickers {
  background: linear-gradient(180deg, #1a2240, #12182c);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}
.need-line {
  grid-column: 1 / -1;
  margin-top: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 106, 0, 0.12);
  border: 1px solid rgba(255, 106, 0, 0.28);
  color: var(--orange);
  font-size: 13px;
  font-weight: 800;
}
.result-cards { display: flex; flex-direction: column; gap: 8px; }
.result-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
}
.result-card .t { font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; }
.result-card .s { font-size: 20px; font-weight: 900; color: var(--orange); }
.result-card .o { font-size: 12px; color: var(--muted); font-weight: 700; }
.row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.flash {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(12, 16, 32, 0.96);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}
.flash.on { opacity: 1; }

.squad-grid {
  display: grid;
  gap: 8px;
}
.squad-slot {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
}
.squad-slot .num {
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(54, 214, 195, 0.1);
  border: 1px solid var(--border-hot);
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
}
.done-panel {
  text-align: center;
  padding: 10px 4px 4px;
}
.done-panel .big {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 800;
  margin: 8px 0 6px;
}
.done-panel .meta {
  color: var(--muted);
  font-weight: 600;
  line-height: 1.5;
}

@media (max-width: 420px) {
  .field-row { grid-template-columns: 1fr; }
  .score-line { font-size: 26px; }
}
