/* One Over - daily cricket challenge */

:root {
  --bg: #0a0a14;
  --panel: #15152a;
  --panel-2: #1c1c36;
  --line: #2a2a4a;
  --text: #eceaf6;
  --muted: #9a9ac0;
  --accent: #5858FD;
  --amber: #ffb703;
  --green: #2ec46b;
  --red: #e23b3b;
}

* { box-sizing: border-box; }

/* A class that sets `display` beats the browser's own `[hidden]` rule, so an
   element hidden from JavaScript with `el.hidden = true` stays on screen and
   the code looks correct while doing nothing. This reset settles it. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
           max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

/* HUD */
.hud {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  flex-shrink: 0;
}
.hud-back { color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; }
.hud-back::before { content: "< "; }
.hud-back:hover { color: var(--text); }
.hud-stats { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-label {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  min-height: 40px;
}
.hud-btn:hover { color: var(--text); border-color: var(--accent); }
.hud-btn[aria-pressed="true"] { color: #ff8c8c; border-color: rgba(255, 140, 140, 0.35); }

/* Pitch */
.screen {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#pitch {
  display: block;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  background: #2b8f4e;
  max-width: 100%;
  max-height: 100%;
  touch-action: manipulation;
  cursor: pointer;
}
.call {
  margin: 0;
  min-height: 26px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.call.is-big { color: var(--amber); }
.call.is-run { color: var(--green); }
.call.is-out { color: var(--red); }
.call.is-dot { color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 13px; text-align: center; min-height: 18px; }

/* The six balls, filled in as they are bowled */
.marks { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}
.mark.is-done { color: var(--text); border-color: rgba(46, 196, 107, 0.5); }
.mark.is-out { color: #ffd0d0; border-color: rgba(226, 59, 59, 0.6); background: rgba(226, 59, 59, 0.16); }

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(6, 6, 14, 0.82);
}
.panel {
  width: min(520px, 100%);
  max-height: 88vh;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.6);
}
/* Three regions: only the body scrolls, so the buttons can never scroll away. */
.panel-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(46, 196, 107, 0.10), rgba(20, 20, 42, 0) 80%),
    linear-gradient(90deg, var(--green), var(--accent)) bottom / 100% 2px no-repeat;
}
.panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 22px 18px; }
.panel-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}
.panel-head h1 { margin: 0; font-size: 28px; letter-spacing: -0.6px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.kicker {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--green);
}
.link-back { color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; }
.link-back:hover { color: var(--text); }
.big { margin: 0 0 6px; font-size: 20px; font-weight: 700; }
.intro { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.score-big {
  margin: 0 0 12px;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.streak-note { margin: 10px 0 16px; color: var(--amber); font-size: 13.5px; }

.rules { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.rules li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}
.tag {
  flex: 0 0 auto;
  min-width: 66px;
  text-align: center;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.field-label {
  display: block;
  margin: 4px 0 6px;
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
}
.share {
  width: 100%;
  resize: none;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0e0e1c;
  color: var(--text);
  font: 13px/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace;
}
.share-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.btn {
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4646e0; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: default; }
.foot-note { color: var(--muted); font-size: 12px; }

/* Confetti on a good over. Decoration only, and skipped under reduced motion. */
.celebrate { position: relative; overflow: hidden; }
.confetti {
  position: absolute;
  top: -12px;
  width: 7px;
  height: 11px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
  pointer-events: none;
}
@keyframes confetti-fall {
  0% { opacity: 0; transform: translateY(-12px) rotate(0deg); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translateY(150px) rotate(420deg); }
}
@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 520px) {
  .hud { padding: 6px 10px; gap: 8px; }
  .hud-stats { gap: 12px; }
  .hud-back { display: none; }
  .stat-value { font-size: 14px; }
  .call { font-size: 18px; }
  .panel-head h1 { font-size: 24px; }
  .score-big { font-size: 34px; }
}

/* A short landscape phone has no room for a tall panel or a big call line. */
@media (max-height: 480px) {
  #shell { gap: 6px; }
  .call { font-size: 16px; min-height: 20px; }
  .hint { display: none; }
  .panel-head { padding-top: 12px; padding-bottom: 10px; }
  .panel-body { padding-top: 12px; padding-bottom: 12px; }
}
