/* Hand Cricket — night-match theme */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg1: #0a3527;
  --bg2: #062419;
  --gold: #f5c542;
  --gold-d: #d9a521;
  --green: #22c55e;
  --red: #ef4444;
  --card: rgba(255,255,255,.06);
  --line: rgba(255,255,255,.12);
  --txt: #f3f7f4;
  --dim: #9db8ab;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 800px at 50% -10%, var(--bg1), var(--bg2));
  color: var(--txt);
  min-height: 100vh;
  touch-action: manipulation;
}
.wrap { max-width: 480px; margin: 0 auto; padding: 18px 16px 60px; }

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand-ball {
  font-size: 40px; width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2f7d4f, #0d3b26);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--gold); box-shadow: 0 4px 18px rgba(245,197,66,.25);
}
.brand h1 { margin: 0; font-size: 26px; letter-spacing: .5px; }
.brand p { margin: 2px 0 0; color: var(--dim); font-size: 13px; }

.screen { display: none; }
.screen.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px; margin: 12px 0;
}
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card.center, .center { text-align: center; }

.lbl { display: block; font-size: 12px; color: var(--dim); margin: 10px 0 6px; text-transform: uppercase; letter-spacing: .8px; }
.inp {
  width: 100%; padding: 13px 14px; font-size: 17px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(0,0,0,.3); color: var(--txt);
  outline: none;
}
.inp:focus { border-color: var(--gold); }
.inp.code { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 700; font-size: 22px; }

.btn {
  display: block; width: 100%; margin-top: 12px; padding: 14px;
  font-size: 16px; font-weight: 700; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,.08); color: var(--txt);
  transition: transform .08s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-d));
  color: #3a2a00; border: none;
  box-shadow: 0 4px 16px rgba(245,197,66,.35);
}
.btn.ghost { background: transparent; opacity: .7; }
.btn.small { width: auto; display: inline-block; padding: 10px 16px; font-size: 14px; margin: 8px 4px 0; }
.btn.wa { background: #1faa53; border: none; color: #fff; }
.btn.hidden, .hidden { display: none !important; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.row .btn { width: auto; flex: 1; min-width: 130px; }

.conn { margin-top: 14px; font-size: 13px; color: var(--dim); text-align: center; }
.conn::before { content: "⏳ "; }

.howto { margin-top: 16px; font-size: 14px; color: var(--dim); }
.howto summary { cursor: pointer; color: var(--txt); font-weight: 600; }
.howto ul { padding-left: 20px; line-height: 1.7; }

.roomcode {
  font-size: 52px; font-weight: 800; letter-spacing: 12px; color: var(--gold);
  margin: 6px 0 4px; text-shadow: 0 2px 20px rgba(245,197,66,.4);
}
.players { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.player {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(0,0,0,.25); border-radius: 10px; font-size: 15px;
}
.player .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.player .tag { margin-left: auto; font-size: 11px; color: var(--dim); border: 1px solid var(--line); padding: 2px 8px; border-radius: 20px; }
.status { color: var(--dim); font-size: 14px; margin: 10px 0; line-height: 1.5; }

/* scoreboard */
.scoreboard {
  text-align: center; padding: 18px 10px; margin-bottom: 6px;
  background: linear-gradient(180deg, rgba(245,197,66,.10), transparent);
  border-radius: 16px; border: 1px solid var(--line);
}
.score-title { font-size: 34px; font-weight: 800; letter-spacing: 1px; }
.score-sub { color: var(--dim); font-size: 14px; margin-top: 2px; }
.target-line { color: var(--gold); font-weight: 700; font-size: 15px; margin-top: 6px; min-height: 20px; }
.role-line { font-size: 14px; margin-top: 4px; color: var(--txt); }

/* number pad */
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
.pbtn {
  aspect-ratio: 1; border-radius: 50%; font-size: 30px; font-weight: 800;
  border: 2px solid var(--gold); background: rgba(245,197,66,.08); color: var(--gold);
  cursor: pointer; transition: transform .08s ease, background .15s;
  max-width: 110px; width: 100%; justify-self: center;
}
.pbtn:active { transform: scale(.92); background: rgba(245,197,66,.25); }
.pbtn:disabled { opacity: .25; border-color: var(--dim); color: var(--dim); cursor: default; }

/* reveal */
.reveal-area { display: none; justify-content: center; align-items: center; gap: 14px; margin: 16px 0; }
.reveal-area.show { display: flex; animation: fadein .2s ease; }
.rcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 22px; text-align: center; min-width: 110px;
  transition: transform .3s ease;
}
.rcard.flip { transform: rotateY(360deg); border-color: var(--gold); }
.rname { font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.rnum { font-size: 46px; font-weight: 800; color: var(--gold); margin: 4px 0; }
.rrole { font-size: 11px; color: var(--dim); }
.vs { font-weight: 800; color: var(--dim); font-size: 14px; }

/* banner */
.banner {
  text-align: center; font-size: 40px; font-weight: 900; margin: 10px 0;
  min-height: 56px; opacity: 0; transform: scale(.6);
  transition: opacity .2s, transform .2s;
}
.banner.show { opacity: 1; transform: scale(1); }
.banner.four { color: #7dd3fc; text-shadow: 0 0 24px rgba(125,211,252,.6); }
.banner.six { color: var(--gold); text-shadow: 0 0 24px rgba(245,197,66,.7); }
.banner.out { color: var(--red); text-shadow: 0 0 24px rgba(239,68,68,.6); }

/* ball log */
.log { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-width: 38px; height: 38px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-weight: 800; font-size: 15px;
  background: rgba(255,255,255,.08); border: 1px solid var(--line);
}
.chip.b4 { background: rgba(125,211,252,.18); border-color: #7dd3fc; color: #7dd3fc; }
.chip.b6 { background: rgba(245,197,66,.18); border-color: var(--gold); color: var(--gold); }
.chip.w { background: rgba(239,68,68,.18); border-color: var(--red); color: var(--red); }
.chip.inn2 { outline: 1px dashed rgba(255,255,255,.25); outline-offset: 2px; }

.big { font-size: 24px; font-weight: 800; margin: 8px 0; }
.trophy { font-size: 64px; animation: bounce 1s ease infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.detail { font-size: 14px; color: var(--dim); line-height: 1.8; margin: 10px 0; }

/* toss overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.toss-box { text-align: center; background: var(--bg1); border: 1px solid var(--gold); border-radius: 20px; padding: 30px; }
.coin { font-size: 80px; animation: flip 1s ease-in-out infinite; display: inline-block; }
@keyframes flip { 0% { transform: rotateY(0); } 100% { transform: rotateY(360deg); } }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #132a20; border: 1px solid var(--gold); color: var(--txt);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 100;
  max-width: 90vw; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.5);
  animation: fadein .2s ease;
}
.toast.err { border-color: var(--red); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 10px; height: 14px; opacity: .9;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
