:root {
  --green: #006747; --dark: #01402C; --gold: #F2C230; --gold2: #B8862B; --light: #E8F1EC; --cream: #FFFDF5; --ink: #1b1b1b; --mut: #5c6b63; --line: #c9d6cd; --red: #b3261e;
  --hf: 'Playfair Display', Georgia, serif; --bf: 'Montserrat', system-ui, -apple-system, Arial, sans-serif;
  --nav: 62px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--bf); color: var(--ink); background: #f3f6f4; font-size: 15px; line-height: 1.45; padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom)); }
a { color: var(--green); }
h1, h2, h3, .hf { font-family: var(--hf); color: var(--green); margin: 0 0 .4rem; line-height: 1.15; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; } h4 { margin: 1rem 0 .3rem; color: var(--dark); font-size: .95rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--mut); } .small { font-size: .82rem; } .gold { color: var(--gold2); }
.kick { font-family: var(--hf); letter-spacing: 2px; font-size: .72rem; color: var(--gold2); text-transform: uppercase; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top)); background: #fff; border-bottom: 2px solid var(--gold); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { height: 42px; } .brand-text { height: 34px; }
.sync { border: 0; background: none; font-size: 1.1rem; color: #bbb; padding: 6px; }
.sync.on { color: #2e9e5b; } .sync.err { color: var(--red); }

/* layout */
.app { max-width: 820px; margin: 0 auto; padding: 14px 14px 24px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 0 0 14px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card.green { background: var(--green); color: #fff; border-color: var(--green); } .card.green h2, .card.green h3 { color: var(--gold); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; padding: 10px 14px; font: 600 .92rem var(--bf); background: var(--green); color: #fff; text-decoration: none; cursor: pointer; }
.btn.gold { background: var(--gold); color: var(--dark); } .btn.ghost { background: var(--light); color: var(--green); } .btn.sm { padding: 7px 10px; font-size: .8rem; } .btn.danger { background: var(--red); }
.btn:active { transform: translateY(1px); }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; background: var(--light); color: var(--green); font-size: .75rem; font-weight: 600; }
.pill.gold { background: var(--gold); color: var(--dark); } .pill.red { background: #fde7e5; color: var(--red); }
.tbl { width: 100%; border-collapse: collapse; font-size: .85rem; margin: .5rem 0 .8rem; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 6px 7px; text-align: left; vertical-align: top; }
.tbl th { background: var(--green); color: var(--gold); font-family: var(--hf); font-weight: 600; font-size: .8rem; }
.tbl td.num, .tbl th.num { text-align: center; }
.tbl tr.hi td { background: #fff4cc; font-weight: 700; }
.tbl tr.lo td { background: #fde7e5; }
.scrollx { overflow-x: auto; -webkit-overflow-scrolling: touch; }
input, select, textarea { font: inherit; }
input.num { width: 100%; padding: 8px 4px; text-align: center; border: 1px solid var(--line); border-radius: 8px; background: var(--cream); font-size: 1rem; }
input.txt, select.txt, textarea.txt { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--cream); }
label.lbl { display: block; font-size: .78rem; color: var(--mut); margin: 8px 0 3px; font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav) + 18px); transform: translateX(-50%); background: var(--dark); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .85rem; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.25); }

/* bottom nav */
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--green); z-index: 30; box-shadow: 0 -2px 12px rgba(0,0,0,.15); }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #cfe3d8; text-decoration: none; font-size: .68rem; font-weight: 600; }
.bottomnav a span { font-size: 1.25rem; line-height: 1; }
.bottomnav a.active { color: var(--gold); }

/* hero */
.hero { position: relative; border-radius: 16px; overflow: hidden; min-height: 300px; display: flex; align-items: flex-end; color: #fff; margin-bottom: 14px; background: var(--dark) center/cover no-repeat; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(1,64,44,.05) 20%, rgba(1,64,44,.88) 100%); }
.hero > div { position: relative; padding: 18px; }
.hero h1 { color: #fff; font-size: 2rem; } .hero .kick { color: var(--gold); }
.hero p { color: #e6efe9; margin: 0; }
.stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat div { background: var(--light); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-family: var(--hf); font-size: 1.4rem; color: var(--green); }
.stat span { font-size: .72rem; color: var(--mut); }
.sched { display: grid; gap: 8px; }
.sched a { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.sched .rn { font-family: var(--hf); color: var(--green); font-size: 1.3rem; text-align: center; line-height: 1; } .sched .rn small { display: block; font-family: var(--bf); font-size: .62rem; color: var(--mut); letter-spacing: 1px; }
.sched b { display: block; } .sched .state { font-size: .72rem; }

/* rules accordion */
details.rule { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
details.rule summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; align-items: center; gap: 10px; font-family: var(--hf); color: var(--green); font-weight: 600; font-size: 1rem; }
details.rule summary::-webkit-details-marker { display: none; }
details.rule summary::after { content: "+"; margin-left: auto; color: var(--gold2); font-size: 1.3rem; } details.rule[open] summary::after { content: "–"; }
details.rule .body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
details.rule ul, details.rule ol { padding-left: 1.2rem; } details.rule li { margin: .25rem 0; }

/* teams */
.teamgrid { display: grid; gap: 10px; }
.team { border: 2px solid var(--line); border-radius: 14px; padding: 10px; background: #fff; }
.team.A { border-color: var(--gold); } .team.B { border-color: var(--green); } .team.C { border-color: #7a9e8c; }
.team h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 36px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 999px; background: var(--light); color: var(--dark); font-size: .85rem; font-weight: 600; border: 0; cursor: pointer; }
.chip.sel { background: var(--green); color: #fff; } .chip.ghost { background: #f1f3f2; color: #8a948f; }
.chip .x { opacity: .6; }
.hat { position: relative; }
.hat.shake { animation: shake .6s ease; }
@keyframes shake { 0%,100% { transform: rotate(0) } 20% { transform: rotate(-8deg) } 40% { transform: rotate(8deg) } 60% { transform: rotate(-5deg) } 80% { transform: rotate(5deg) } }

/* scorecard */
.holes { display: grid; grid-template-columns: 34px 30px 1fr 1fr; gap: 6px 6px; align-items: center; }
.holes .hd { font-size: .7rem; color: var(--mut); font-weight: 600; text-align: center; }
.holes .hn { font-family: var(--hf); font-weight: 700; color: var(--green); text-align: center; background: var(--light); border-radius: 8px; padding: 8px 0; }
.holes .par { text-align: center; font-size: .85rem; color: var(--mut); }
.holes .sub { grid-column: 1 / -1; display: flex; justify-content: space-between; background: var(--gold); border-radius: 8px; padding: 6px 10px; font-weight: 700; color: var(--dark); font-size: .85rem; }
select.tee { width: 100%; padding: 8px 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--cream); font-size: .85rem; }
.tally { display: grid; gap: 6px; }
.tally div { display: flex; justify-content: space-between; align-items: center; background: var(--light); border-radius: 10px; padding: 8px 10px; font-size: .9rem; }
.tally b.ok { color: #2e9e5b; } .tally b.bad { color: var(--red); }
.result { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result div { background: var(--cream); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.result b { display: block; font-family: var(--hf); font-size: 1.5rem; color: var(--green); } .result span { font-size: .72rem; color: var(--mut); }
.result div.net { background: var(--green); border-color: var(--green); } .result div.net b { color: var(--gold); } .result div.net span { color: #cfe3d8; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; }
.tabs a { flex: 1; text-align: center; padding: 9px 6px; border-radius: 10px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--green); font-weight: 600; font-size: .85rem; white-space: nowrap; }
.tabs a.active { background: var(--green); color: #fff; }

/* kangaroo court */
.court-hero { background: var(--dark) url(assets/tanah-lot.jpg) center/cover; border-radius: 16px; padding: 18px; color: #fff; position: relative; overflow: hidden; margin-bottom: 12px; }
.court-hero::before { content: ""; position: absolute; inset: 0; background: rgba(1,64,44,.78); } .court-hero > * { position: relative; }
.kitty { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.kitty div { background: rgba(255,255,255,.1); border-radius: 12px; padding: 8px; text-align: center; }
.kitty b { display: block; font-family: var(--hf); font-size: 1.35rem; color: var(--gold); } .kitty span { font-size: .68rem; color: #cfe3d8; }
.shots { font-size: 1.3rem; letter-spacing: 2px; line-height: 1.2; word-break: break-all; }
.offences { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.off { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 10px 6px; text-align: center; cursor: pointer; transition: transform .15s; user-select: none; }
.off:active { transform: scale(.94); }
.off .ic { font-size: 1.8rem; display: block; } .off .lb { font-size: .7rem; font-weight: 600; color: var(--dark); display: block; margin-top: 4px; line-height: 1.2; }
.off .ct { position: absolute; }
.off.wobble { animation: wobble .5s ease; }
@keyframes wobble { 0%,100% { transform: rotate(0) scale(1) } 25% { transform: rotate(-6deg) scale(1.06) } 75% { transform: rotate(6deg) scale(1.06) } }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet > div { background: #fff; border-radius: 18px 18px 0 0; width: 100%; max-width: 820px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .25s ease; max-height: 85vh; overflow: auto; }
@keyframes up { from { transform: translateY(40px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.gavel { font-size: 3.2rem; display: inline-block; transform-origin: 80% 80%; }
.gavel.slam { animation: slam .55s cubic-bezier(.2,.9,.3,1.3); }
@keyframes slam { 0% { transform: rotate(-45deg) translateY(-14px) } 55% { transform: rotate(10deg) translateY(4px) } 70% { transform: rotate(-4deg) } 100% { transform: rotate(0) } }
.stamp { position: fixed; left: 50%; top: 40%; transform: translate(-50%,-50%) rotate(-14deg) scale(3); opacity: 0; font-family: var(--hf); font-weight: 700; font-size: 3rem; color: var(--red); border: 6px solid var(--red); padding: 6px 22px; border-radius: 10px; letter-spacing: 4px; z-index: 60; pointer-events: none; text-transform: uppercase; background: rgba(255,255,255,.85); }
.stamp.show { animation: stamp .9s cubic-bezier(.1,.9,.2,1) forwards; }
@keyframes stamp { 0% { opacity: 0; transform: translate(-50%,-50%) rotate(-14deg) scale(3) } 30% { opacity: 1; transform: translate(-50%,-50%) rotate(-14deg) scale(1) } 80% { opacity: 1 } 100% { opacity: 0; transform: translate(-50%,-60%) rotate(-14deg) scale(1) } }
.confetti { position: fixed; top: -10px; width: 8px; height: 14px; z-index: 55; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .2 } }
.feed { display: grid; gap: 6px; }
.feed div { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: .85rem; }
.feed .ic { font-size: 1.3rem; text-align: center; }
.feed small { color: var(--mut); display: block; }
.rap { display: grid; gap: 6px; }
.rap div { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: .85rem; }
.bar { height: 8px; border-radius: 4px; background: var(--light); overflow: hidden; width: 90px; } .bar i { display: block; height: 100%; background: var(--gold); transition: width .6s; }
.pulse { animation: pulse 1.2s ease; } @keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(242,194,48,.8) } 100% { box-shadow: 0 0 0 18px rgba(242,194,48,0) } }
.rollnum { display: inline-block; transition: transform .3s; }

/* leaderboard */
.lb .rank { font-family: var(--hf); font-size: 1.1rem; color: var(--green); text-align: center; width: 34px; }
.lb .pts { font-family: var(--hf); font-size: 1.2rem; text-align: center; color: var(--green); }
.lb tr.champ td { background: #fff4cc; } .lb tr.spoon td { background: #fde7e5; }
.award { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.award b { display: block; font-family: var(--hf); color: var(--green); } .award small { color: var(--mut); }
.award .who { font-weight: 700; color: var(--dark); text-align: right; max-width: 45%; }
.winner-badge { height: 90px; float: right; margin: 0 0 6px 10px; }

/* printable team card */
.printcard { background: #fff; }
.printcard .ph { display: grid; grid-template-columns: 30px 28px 1fr 1fr 1fr; gap: 4px; align-items: center; font-size: .8rem; padding: 3px 0; border-bottom: 1px solid var(--line); }
.printcard .ph b { font-family: var(--hf); color: var(--green); text-align: center; }
.printcard .box { height: 22px; border: 1px solid var(--line); border-radius: 4px; background: var(--cream); }
@media print {
  body { background: #fff; padding: 0; font-size: 11px; } .topbar, .bottomnav, .noprint, .toast { display: none !important; }
  .app { max-width: none; padding: 0; } .card { break-inside: avoid; box-shadow: none; }
  @page { size: A4; margin: 10mm; }
}
@media (min-width: 700px) {
  .offences { grid-template-columns: repeat(6, 1fr); }
  .teamgrid { grid-template-columns: repeat(3, 1fr); }
  .hero { min-height: 380px; } .hero h1 { font-size: 2.6rem; }
}

/* ---------- the buggy ---------- */
.buggy { display: block; height: 100%; width: auto; overflow: visible; }
.brand-logo { display: inline-block; height: 44px; cursor: pointer; }
.brand-logo .buggy { height: 44px; }
.buggy g { transform-box: fill-box; }
.buggy #wheelF, .buggy #wheelR { transform-origin: center; }
.buggy #cork { transform-origin: center; }
.buggy #spray { transform-origin: 60% 90%; }
.buggy #lines { transform-origin: right center; }
.brand-logo:hover #wheelF, .brand-logo:hover #wheelR, .brand-logo.go #wheelF, .brand-logo.go #wheelR { animation: spin .6s linear infinite; }
.brand-logo:hover #lines, .brand-logo.go #lines { animation: lines .5s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes lines { 0%,100% { transform: scaleX(1); opacity: 1 } 50% { transform: scaleX(.72); opacity: .55 } }

.driveby { position: fixed; left: 0; bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 24px); width: min(72vw, 420px); z-index: 70; pointer-events: none; filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 2px #fff) drop-shadow(0 10px 14px rgba(0,0,0,.3)); animation: drive 4.6s cubic-bezier(.3,0,.2,1) forwards; }
.driveby .buggy { height: auto; width: 100%; }
.driveby #wheelF, .driveby #wheelR { animation: spin .35s linear infinite; }
.driveby.stopped #wheelF, .driveby.stopped #wheelR { animation-play-state: paused; }
.driveby #lines { animation: lines .35s ease-in-out infinite; }
.driveby.stopped #lines { animation: linesOff .4s ease forwards; }
.driveby.leaving #lines { animation: linesOn .3s ease forwards, lines .3s ease-in-out .3s infinite; }
@keyframes linesOff { to { transform: scaleX(0); opacity: 0 } }
@keyframes linesOn { from { transform: scaleX(0); opacity: 0 } to { transform: scaleX(1); opacity: 1 } }
@keyframes drive { 0% { transform: translateX(-110%) } 32% { transform: translateX(calc(50vw - 50%)) } 36% { transform: translateX(calc(50vw - 50% - 10px)) rotate(-2deg) } 40% { transform: translateX(calc(50vw - 50%)) rotate(0) } 68% { transform: translateX(calc(50vw - 50%)) } 100% { transform: translateX(110vw) } }
.driveby.popped #cork { animation: cork 1.6s cubic-bezier(.15,.8,.3,1) forwards; }
@keyframes cork { 0% { transform: translate(0,0) rotate(0) } 60% { transform: translate(-70px,-150px) rotate(-540deg); opacity: 1 } 100% { transform: translate(-130px,-80px) rotate(-900deg); opacity: 0 } }
.driveby #spray { opacity: 0; }
.driveby.popped #spray { animation: spray 1.1s ease-out forwards; }
@keyframes spray { 0% { transform: scale(.2); opacity: 0 } 25% { transform: scale(1.25); opacity: 1 } 100% { transform: scale(1.6) translate(-6px,-10px); opacity: 0 } }
.driveby.popped #body { animation: recoil .5s ease; }
@keyframes recoil { 30% { transform: translate(1.5px,2px) } }
.fizz { position: fixed; z-index: 69; width: 8px; height: 8px; border-radius: 50%; background: #F2C230; box-shadow: 0 0 0 2px rgba(255,255,255,.7); pointer-events: none; animation: fizz 1.3s ease-out forwards; }
@keyframes fizz { 0% { transform: translate(0,0) scale(.6); opacity: 1 } 100% { transform: translate(var(--dx), var(--dy)) scale(1.2); opacity: 0 } }
.pop { position: fixed; z-index: 71; font-family: var(--hf); font-weight: 700; color: var(--gold); font-size: 2rem; text-shadow: 0 2px 0 var(--dark); pointer-events: none; animation: pop 1s ease-out forwards; }
@keyframes pop { 0% { transform: scale(.4) rotate(-10deg); opacity: 0 } 25% { transform: scale(1.2) rotate(4deg); opacity: 1 } 100% { transform: scale(1) translateY(-30px); opacity: 0 } }
@media (prefers-reduced-motion: reduce) { .driveby, .brand-logo:hover #wheelF, .brand-logo:hover #wheelR, .brand-logo:hover #lines { animation: none !important; } .driveby { display: none; } }
