* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #12301b;
  font-family: -apple-system, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  color: #eefbf0;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
canvas#game { position: fixed; inset: 0; display: block; touch-action: none; }

/* ============ screens ============ */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 10; background: rgba(6,20,11,.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); overflow-y: auto; }
.panel { text-align: center; padding: 22px 18px; width: min(420px, 94vw); animation: pin .3s ease; }
@keyframes pin { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.logo { font-size: 52px; line-height: 1.1; filter: drop-shadow(0 6px 18px rgba(81,207,102,.35)); }
h1 { font-size: 42px; font-weight: 900; letter-spacing: 2px; line-height: 1; }
h1 span { display: block; font-size: 22px; letter-spacing: 7px; background: linear-gradient(135deg, #a9e34b, #51cf66, #ffd43b); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.tag { color: rgba(238,251,240,.62); font-weight: 600; margin: 8px 0 14px; font-size: 14px; }

/* tier picker */
.tierRow { margin: 2px 0 14px; }
.tierRow .lbl { display: block; color: rgba(238,251,240,.6); font-size: 12px; font-weight: 800; letter-spacing: 1px; margin-bottom: 8px; }
.segs { display: flex; gap: 8px; justify-content: center; }
.segs button {
  flex: 1; border: 2px solid #245c31; background: #163a20; color: #eefbf0;
  border-radius: 14px; padding: 9px 4px; font-weight: 800; font-size: 13px; cursor: pointer;
  min-height: 48px;
}
.segs button small { display: block; font-size: 10px; font-weight: 700; opacity: .65; margin-top: 1px; }
.segs button.sel { border-color: #ffd43b; box-shadow: 0 0 16px rgba(255,212,59,.28); background: #1d4527; }
.segs button.lock { opacity: .45; }

button.big {
  display: block; width: 100%; margin: 10px 0; padding: 15px 0 13px;
  font-size: 19px; font-weight: 900; letter-spacing: 1px;
  color: #0b3313; background: linear-gradient(135deg, #a9e34b, #51cf66);
  border: none; border-radius: 18px; cursor: pointer;
  box-shadow: 0 5px 0 #2f9e44, 0 10px 24px rgba(0,0,0,.45);
  min-height: 60px;
}
button.big small { display: block; font-size: 11px; font-weight: 700; opacity: .75; margin-top: 3px; letter-spacing: .2px; }
button.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #2f9e44; }
button.big.alt { color: #2a1354; background: linear-gradient(135deg, #d0bfff, #9775fa); box-shadow: 0 5px 0 #6741d9, 0 10px 24px rgba(0,0,0,.45); }
button.big.alt:active { box-shadow: 0 2px 0 #6741d9; }
.ghost { display: inline-block; background: none; border: none; color: rgba(238,251,240,.62); font-size: 14px; font-weight: 700; margin-top: 10px; text-decoration: none; padding: 10px; cursor: pointer; }
.best { color: #ffd43b; font-weight: 800; margin-top: 10px; min-height: 20px; font-size: 13px; line-height: 1.6; }

/* how-to strip on menu */
.howRow { display: flex; gap: 8px; margin: 4px 0 6px; }
.howCard { flex: 1; border-radius: 14px; padding: 10px 6px 9px; font-size: 11.5px; font-weight: 700; line-height: 1.45; color: rgba(238,251,240,.85); background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); }
.howCard b { display: block; font-size: 13px; margin-bottom: 2px; }
.howCard.leg b { color: #ffc078; }
.howCard.off b { color: #a5d8ff; }
.howCard.time b { color: #a9e34b; }

/* ============ HUD ============ */
#hud { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 0; right: 0; display: flex; align-items: center; gap: 6px; padding: 0 12px; z-index: 5; pointer-events: none; }
.chip { font-weight: 900; font-size: 13px; letter-spacing: .4px; background: rgba(5,18,9,.62); border: 1px solid rgba(255,255,255,.14); border-radius: 20px; padding: 7px 12px; white-space: nowrap; }
#scoreChip { color: #fff; font-size: 16px; }
#overChip { color: #a9e34b; }
#targetChip { color: #ffd43b; flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; }
#quitBtn { pointer-events: auto; position: relative; width: 36px; height: 36px; flex-shrink: 0; border-radius: 11px; border: 1px solid rgba(255,255,255,.14); background: rgba(5,18,9,.62); color: #eefbf0; font-size: 15px; font-weight: 800; cursor: pointer; }
#quitBtn::after { content: ''; position: absolute; inset: -6px; }

#commentary {
  position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 46px); left: 50%; transform: translateX(-50%);
  font-weight: 900; font-size: 15px; color: #eefbf0;
  text-shadow: 0 3px 12px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 6;
  background: rgba(5,18,9,.55); border-radius: 16px; padding: 7px 16px;
  white-space: nowrap; max-width: 94vw; overflow: hidden; text-overflow: ellipsis;
}
#commentary.show { opacity: 1; }

#bigMsg {
  position: fixed; top: 32%; left: 50%; transform: translate(-50%,-50%);
  font-size: min(48px, 11vw); font-weight: 900; font-style: italic; letter-spacing: 1px;
  text-shadow: 0 8px 26px rgba(0,0,0,.7); opacity: 0; pointer-events: none; z-index: 8;
  white-space: nowrap; max-width: 96vw;
}
#bigMsg.show { animation: bigPop 1.3s ease; }
#bigMsg.mega { font-size: min(58px, 12.5vw); }
@keyframes bigPop { 0% { transform: translate(-50%,-50%) scale(.25); opacity: 0; } 20% { transform: translate(-50%,-50%) scale(1.22); opacity: 1; } 78% { opacity: 1; transform: translate(-50%,-50%) scale(1); } 100% { transform: translate(-50%,-50%) scale(.98); opacity: 0; } }

/* ============ bottom: over strip + shot buttons ============ */
#bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6;
  padding: 0 12px max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
#overStrip {
  display: flex; gap: 6px; justify-content: center; align-items: center;
  min-height: 26px;
}
#overStrip .lab { font-size: 10px; font-weight: 900; letter-spacing: 1.5px; color: rgba(238,251,240,.55); margin-right: 4px; }
.ob {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 900;
  background: rgba(5,18,9,.55); border: 1.5px solid rgba(255,255,255,.18); color: rgba(238,251,240,.85);
  transition: transform .15s;
}
.ob.empty { background: rgba(5,18,9,.3); border-style: dashed; color: transparent; }
.ob.b4 { background: #2b8a3e; border-color: #51cf66; color: #fff; }
.ob.b6 { background: #b0872a; border-color: #ffd43b; color: #fff; box-shadow: 0 0 10px rgba(255,212,59,.5); }
.ob.bw { background: #a03030; border-color: #ff8787; color: #fff; }
.ob.pop { animation: obPop .3s ease; }
@keyframes obPop { 40% { transform: scale(1.45); } }

#controls { display: flex; gap: 10px; pointer-events: auto; }
.shotBtn {
  flex: 1; min-height: 68px; padding: 12px 0 10px; position: relative;
  border: none; border-radius: 20px;
  font-weight: 900; font-size: 22px; letter-spacing: 1px;
  cursor: pointer; touch-action: none;
  transition: filter .1s;
}
.shotBtn small { display: block; font-size: 10.5px; font-weight: 800; opacity: .72; margin-top: 2px; letter-spacing: .5px; }
#btnLeg { background: linear-gradient(135deg, #ffc078, #ff922b); box-shadow: 0 5px 0 #d9480f; color: #47200a; }
#btnOff { background: linear-gradient(135deg, #a5d8ff, #4dabf7); box-shadow: 0 5px 0 #1c7ed6; color: #0b2d4a; }
.shotBtn:active { transform: translateY(3px); box-shadow: none !important; }
.shotBtn.glow { animation: btnGlow .5s ease-in-out infinite; }
#btnLeg.glow { box-shadow: 0 5px 0 #d9480f, 0 0 26px 4px rgba(255,146,43,.75); }
#btnOff.glow { box-shadow: 0 5px 0 #1c7ed6, 0 0 26px 4px rgba(77,171,247,.75); }
@keyframes btnGlow { 50% { filter: brightness(1.22); } }
