:root {
  --saffron: #ff9933;
  --green: #138808;
  --chalk: #f5f1e6;
  --board: #23382c;
  --ink: #1c1410;
  --red: #e0352b;
  --gold: #ffd166;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--chalk); font-family: 'Baloo 2', system-ui, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#board {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px;
  background: linear-gradient(160deg, #2b4535, var(--board)); border: 3px solid #6b4a2b; border-radius: 10px;
  padding: 8px 14px 10px; font-family: 'Kalam', cursive; box-shadow: 0 6px 20px rgba(0,0,0,.45); min-width: 190px;
}
#board .teams { font-size: 13px; opacity: .85; letter-spacing: .5px; }
#board .teams span { color: var(--gold); }
#board .row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
#runs { font-size: 38px; font-weight: 700; line-height: 1; }
#overs { font-size: 16px; opacity: .9; }
#need { font-size: 15px; color: var(--gold); }
#overlog { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
#overlog i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid rgba(245,241,230,.6); display: grid; place-items: center; font-size: 12px; font-family: 'Baloo 2'; font-weight: 700; }
#overlog i.W { background: var(--red); border-color: var(--red); }
#overlog i.b4 { background: #2a7de1; border-color: #2a7de1; }
#overlog i.b6 { background: #8e44ad; border-color: #8e44ad; }
#overlog i.sep { border: none; width: 6px; }
#lives { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
#lives b { width: 14px; height: 14px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px rgba(255,255,255,.7), 0 2px 6px rgba(0,0,0,.5); }
#lives b.lost { background: transparent; opacity: .5; }
#bowlerTag { position: absolute; top: max(40px, calc(env(safe-area-inset-top) + 28px)); left: 50%; transform: translateX(-50%); font-weight: 600; font-size: 14px; text-shadow: 0 2px 6px rgba(0,0,0,.8); white-space: nowrap; }
.iconBtn { pointer-events: auto; position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); background: rgba(0,0,0,.35); color: #fff; display: grid; place-items: center; cursor: pointer; }
.iconBtn.off { opacity: .5; }
#skipBtn { pointer-events: auto; position: absolute; right: 12px; bottom: max(16px, env(safe-area-inset-bottom)); padding: 10px 18px; border-radius: 22px; border: 2px solid rgba(255,255,255,.6); background: rgba(0,0,0,.45); color: #fff; font: 700 16px/1 inherit; font-family: inherit; cursor: pointer; }

#banner {
  position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%) scale(.6); opacity: 0; pointer-events: none;
  font-weight: 800; font-size: clamp(40px, 9vw, 96px); line-height: .95; text-align: center; letter-spacing: 1px;
  color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 rgba(0,0,0,.35), 0 10px 30px rgba(0,0,0,.5); transition: transform .25s cubic-bezier(.2,1.6,.4,1), opacity .2s;
  width: 92vw;
}
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#banner.four { color: #4fc3ff; }
#banner.six { color: #e3a6ff; }
#banner.out { color: var(--red); }
#banner.gold { color: var(--gold); }
#banner.small { font-size: clamp(28px, 6vw, 56px); }

#timing { position: fixed; left: 50%; top: 48%; transform: translateX(-50%); font-weight: 800; font-size: 22px; opacity: 0; transition: opacity .2s; pointer-events: none; text-shadow: 0 2px 8px rgba(0,0,0,.8); white-space: nowrap; }
#timing.show { opacity: 1; }
#comment {
  position: fixed; left: 50%; bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px)); transform: translate(-50%, 20px); opacity: 0;
  background: rgba(20,14,10,.78); border-left: 5px solid var(--saffron); padding: 8px 16px; border-radius: 8px;
  font-family: 'Kalam', cursive; font-size: clamp(16px, 2.6vw, 22px); max-width: min(92vw, 640px); text-align: center; transition: all .3s; pointer-events: none;
}
#comment.show { opacity: 1; transform: translate(-50%, 0); }

#zones { position: fixed; inset: 0; pointer-events: none; display: flex; flex-direction: column; }
#zones .zone { flex: 1; display: grid; place-items: center; text-align: center; font-weight: 700; font-size: 14px; color: rgba(255,255,255,.85); text-shadow: 0 2px 6px rgba(0,0,0,.9); }
#zones .zone.top { flex: 0 0 45%; background: linear-gradient(rgba(255,153,51,.18), rgba(255,153,51,0)); border-bottom: 2px dashed rgba(255,255,255,.35); }
#zones .zone.bottom { background: linear-gradient(rgba(19,136,8,0), rgba(19,136,8,.18)); align-content: end; padding-bottom: 90px; }
#zones small { display: block; font-weight: 500; opacity: .8; }

.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(28,20,16,.35), rgba(28,20,16,.88)); overflow-y: auto; }
.card { width: min(440px, 100%); text-align: center; padding: 22px 20px; }
.hindi { font-family: 'Kalam', cursive; font-size: 30px; color: var(--saffron); margin-bottom: -8px; }
h1 { font-size: clamp(56px, 16vw, 92px); line-height: .85; margin: 6px 0 10px; font-weight: 800; letter-spacing: 2px;
  color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--saffron), 0 12px 0 var(--green), 0 16px 30px rgba(0,0,0,.6); }
.tag { font-family: 'Kalam', cursive; font-size: 20px; margin: 18px 0 6px; opacity: .95; }
.best { color: var(--gold); font-weight: 700; min-height: 1.2em; margin: 0 0 12px; }
button.big, button.ghost { display: block; width: 100%; margin: 10px 0; padding: 14px 18px; border-radius: 14px; font-family: 'Baloo 2'; font-weight: 800; font-size: 22px; cursor: pointer; letter-spacing: 1px; }
button.big { background: var(--saffron); color: var(--ink); border: none; box-shadow: 0 5px 0 #b35f00, 0 10px 24px rgba(0,0,0,.4); }
button.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #b35f00; }
button.ghost { background: rgba(255,255,255,.08); color: var(--chalk); border: 2px solid rgba(245,241,230,.5); font-size: 18px; }
.controls { margin-top: 14px; font-size: 14px; opacity: .85; line-height: 1.5; }
.controls kbd { background: rgba(255,255,255,.15); border-radius: 4px; padding: 0 6px; font-family: inherit; }
.chalkcard { background: linear-gradient(160deg, #2b4535, var(--board)); border: 6px solid #6b4a2b; border-radius: 14px; font-family: 'Kalam', cursive; text-align: left; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.chalkcard h2 { text-align: center; margin: 0 0 8px; font-size: 32px; }
.chalkcard ol { padding-left: 22px; margin: 0 0 8px; font-size: 17px; line-height: 1.45; }
.chalkcard b { color: var(--gold); }
.endTitle { font-weight: 800; font-size: clamp(44px, 12vw, 72px); line-height: 1; color: var(--gold); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 rgba(0,0,0,.4); }
.endTitle.lose { color: #ff8a80; }
.endScore { font-family: 'Kalam', cursive; font-size: 26px; margin: 6px 0 12px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stats div { background: rgba(255,255,255,.08); border-radius: 10px; padding: 8px 4px; }
.stats b { display: block; font-size: 26px; line-height: 1; }
.stats span { font-size: 12px; opacity: .85; }
.endLine { font-family: 'Kalam', cursive; font-size: 19px; font-style: italic; opacity: .95; margin: 8px 0 14px; }
.shareMsg { min-height: 1.2em; color: var(--gold); font-size: 14px; }

#loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; background: var(--ink); font-family: 'Kalam', cursive; font-size: 20px; z-index: 10; transition: opacity .4s; }
#loading.gone { opacity: 0; pointer-events: none; }
.spinner { width: 42px; height: 42px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff6b5e, #b3201a); position: relative; animation: bounce .6s infinite alternate cubic-bezier(.5,0,1,.5); }
.spinner::after { content: ''; position: absolute; left: 0; right: 0; top: 45%; height: 10%; background: #f0f0f0; }
@keyframes bounce { to { transform: translateY(-30px); } }
@media (max-width: 520px) {
  #board { min-width: 0; padding: 6px 10px 8px; }
  #runs { font-size: 30px; }
  #bowlerTag { top: auto; bottom: 80px; }
}
