:root {
  --green: #0f3d2e; --green-2: #1b6b4f; --bg: #f4f6f4; --card: #fff; --ink: #14201b;
  --muted: #5d6b65; --line: #dfe5e1; --red: #c62828; --amber: #b26a00; --blue: #1f5fbf;
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px; background: var(--green); color: #fff; }
.bar h1 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { background: none; border: 0; color: #fff; font-size: 26px; line-height: 1; padding: 4px 8px; min-width: 40px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.18); white-space: nowrap; }
.pill.warn { background: var(--amber); } .pill.bad { background: var(--red); }
main { max-width: 560px; margin: 0 auto; padding: 12px 12px calc(env(safe-area-inset-bottom) + 24px); }
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.muted { color: var(--muted); } .small { font-size: 13px; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px; }
textarea { font: inherit; min-height: 84px; resize: vertical; }
.btn { display: block; width: 100%; padding: 14px; border: 0; border-radius: 12px; background: var(--green-2);
  color: #fff; font-weight: 600; font-size: 16px; margin-top: 14px; }
.btn.secondary { background: #e7ece9; color: var(--ink); }
.btn.danger { background: var(--red); }
.btn:disabled { opacity: .45; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.list a { display: block; text-decoration: none; color: inherit; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list a:last-child { border-bottom: 0; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #e7ece9; color: var(--muted); margin-left: 6px; vertical-align: middle; }
.badge.live { background: #ffe9e9; color: var(--red); }

/* Scoreboard */
.score { display: flex; align-items: baseline; justify-content: space-between; }
.score .big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.score .ov { font-size: 15px; color: var(--muted); }
.target { margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--blue); }
.result { font-size: 18px; font-weight: 700; color: var(--green-2); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: right; font-weight: 500; color: var(--muted); font-size: 12px; padding: 4px 4px; }
td { text-align: right; padding: 6px 4px; border-top: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
td .how { display: block; font-size: 12px; color: var(--muted); }
.strike::after { content: " *"; color: var(--green-2); font-weight: 700; }
.over { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.ball { min-width: 32px; height: 32px; padding: 0 6px; border-radius: 99px; background: #e7ece9; display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.ball.b4 { background: #dbe8ff; color: var(--blue); } .ball.b6 { background: #d9f2e5; color: var(--green-2); }
.ball.w { background: var(--red); color: #fff; } .ball.x { background: #fff1d6; color: var(--amber); }

/* Scoring pad */
.pad { position: sticky; bottom: 0; }
.extras { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.toggle { padding: 12px 4px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 600; font-size: 14px; }
.toggle.on { border-color: var(--amber); background: #fff1d6; color: var(--amber); }
.runs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.run { padding: 20px 0; border: 0; border-radius: 14px; background: var(--green-2); color: #fff; font-size: 26px; font-weight: 700; touch-action: manipulation; }
.run:active { transform: scale(.97); filter: brightness(1.1); }
.run.four { background: var(--blue); } .run.six { background: #12805a; }
.run:disabled { opacity: .35; }
.pad-actions { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin-top: 10px; }
.pad-actions .btn { margin: 0; }
.hint { font-size: 13px; color: var(--amber); min-height: 18px; margin-top: 8px; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 15px; }
.chip.on { border-color: var(--green-2); background: #e3f2ea; font-weight: 600; }
.chip:disabled { opacity: .4; }
details summary { cursor: pointer; font-weight: 600; padding: 4px 0; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: #f4f6f4; border-radius: 10px; padding: 10px; }
.stat .v { font-size: 22px; font-weight: 700; } .stat .k { font-size: 12px; color: var(--muted); }
.stat.bad .v { color: var(--red); }
pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: #f4f6f4; padding: 8px; border-radius: 8px; }

/* Sheet + toast */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-body { width: 100%; max-width: 560px; margin: 0 auto; background: #fff; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); max-height: 85vh; overflow: auto; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 30; max-width: 90vw; }
.toast.bad { background: var(--red); }
