/* Letter Bowling (tricky letters): the scoreboard (the monitor over the lanes) on top, then the alley: the
   hood over the pins with the frame's goal, ten pins in a 4-3-2-1 triangle, the lane narrowing away from
   him, and him at the foul line with the ball, BOWL on his right and "grow the B" on his left.
   bowling.js places the pins, the lane and the buttons (layout()); --pw is a pin's width. */
.game.bowling { background: #17123a; }
.bowling button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.bowling .game-top { padding-top: 5px; padding-bottom: 5px; }
.bowling .bw-back { min-height: 56px; white-space: nowrap; }
.bowling .bw-stage { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; overflow: hidden; user-select: none; -webkit-user-select: none; }

/* ---------- the scoreboard ---------- */
.bowling .bw-board {
  --who: 138px; --tot: 64px; --line: #3d3478;
  flex: none; position: relative; z-index: 2; margin: 6px auto 0; width: min(1000px, calc(100% - 16px)); box-sizing: border-box;
  background: #0d0b24; color: #fff; border: 4px solid var(--ink); border-radius: 14px; padding: 3px 6px 4px;
  box-shadow: inset 0 0 0 2px #4b3cae, 0 4px 0 rgba(0, 0, 0, .3); font-variant-numeric: tabular-nums;
}
.bowling .bw-row { display: grid; grid-template-columns: var(--who) repeat(9, minmax(0, 1fr)) minmax(0, 1.45fr) var(--tot); }
.bowling .bw-row + .bw-row.rv { border-top: 2px solid var(--line); }
.bowling .bw-nums { font-size: 11px; line-height: 15px; color: #9d93d8; text-align: center; font-weight: 800; }
.bowling .bw-who { display: flex; align-items: center; gap: 6px; min-width: 0; padding-right: 4px; font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; }
.bowling .bw-who > svg { width: 28px; height: 28px; flex: none; }
.bowling .bw-who b { overflow: hidden; text-overflow: ellipsis; }
.bowling .bw-f { display: flex; flex-direction: column; min-width: 0; border-left: 2px solid var(--line); }
.bowling .bw-m { display: flex; justify-content: flex-end; height: 18px; }
.bowling .bw-m i { font-style: normal; flex: 0 1 22px; min-width: 0; text-align: center; font-size: 14px; font-weight: 800; line-height: 17px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.bowling .bw-m i.x { color: #ffd23f; }
.bowling .bw-m i.sp { color: #7dffb0; }
.bowling .bw-f > b { text-align: center; font-size: 16px; line-height: 21px; min-height: 21px; }
.bowling .bw-tot { display: grid; place-items: center; border-left: 2px solid var(--line); }
.bowling .bw-tot b { font-size: 21px; font-weight: 800; color: #ffd23f; }
.bowling .bw-row.me .bw-f.now { background: rgba(255, 210, 63, .2); }
.bowling .bw-row.rv { color: #c4bdee; }
.bowling .bw-row.rv .bw-tot b { color: #c4bdee; }
.bowling .bw-row.rv.flash { animation: bw-flash .9s ease-out; }
@keyframes bw-flash { 30% { background: rgba(125, 255, 176, .18); } }

/* ---------- the alley ---------- */
.bowling .bw-alley {
  --pw: 80px; --bz: 130px;
  flex: 1; min-height: 0; position: relative; overflow: hidden; margin-top: 6px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 126, 182, .22) 0 3px, transparent 4px) 0 0 / 52px 52px,
    radial-gradient(circle at 70% 70%, rgba(95, 211, 255, .2) 0 3px, transparent 4px) 0 0 / 64px 64px,
    radial-gradient(circle at 50% 50%, rgba(255, 210, 63, .14) 0 2px, transparent 3px) 13px 21px / 40px 40px,
    linear-gradient(#251c5c, #120e30);
}
.bowling .bw-gutter, .bowling .bw-lane { position: absolute; left: 0; right: 0; bottom: 0; }
.bowling .bw-gutter { background: linear-gradient(90deg, #6b7088, #2d3040 6%, #2d3040 94%, #6b7088); }
.bowling .bw-lane {
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0) 45%),
    repeating-linear-gradient(90deg, #efc68c 0 11px, #e6b97a 11px 22px);
}
.bowling .bw-lane > * { position: absolute; left: 0; right: 0; }
.bowling .bw-pindeck { top: 0; background: rgba(255, 244, 222, .45); border-bottom: 3px solid rgba(150, 90, 30, .35); }
.bowling .bw-approach { bottom: 0; background: rgba(255, 238, 205, .55); }
.bowling .bw-foul { height: 6px; margin-top: -3px; background: var(--ink); z-index: 1; }
.bowling .bw-arrows { left: 50%; right: auto; transform: translate(-50%, -50%); display: flex; justify-content: space-between; }
.bowling .bw-arrows i { width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 16px solid rgba(122, 64, 18, .5); }
.bowling .bw-arrows i:nth-child(1), .bowling .bw-arrows i:nth-child(7) { transform: translateY(18px); }
.bowling .bw-arrows i:nth-child(2), .bowling .bw-arrows i:nth-child(6) { transform: translateY(12px); }
.bowling .bw-arrows i:nth-child(3), .bowling .bw-arrows i:nth-child(5) { transform: translateY(6px); }

/* the hood over the pins, with the goal */
.bowling .bw-hood {
  position: absolute; left: 0; right: 0; top: 0; z-index: 20; height: 58px; box-sizing: border-box; padding: 0 10px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(#2f2577, #1a1446); border-bottom: 4px solid var(--ink); box-shadow: 0 6px 0 rgba(0, 0, 0, .25);
}
.bowling .bw-goal { display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; color: #fff; font-size: clamp(21px, 3vw, 30px); font-weight: 700; text-shadow: 0 0 14px rgba(120, 200, 255, .7); }
.bowling .bw-goal-l { display: inline-block; flex: none; width: 30px; height: 44px; padding: 2px 4px; background: #fff; border: 3px solid var(--ink); border-radius: 10px; }
.bowling .bw-goal-l.grow { animation: bw-pop .5s ease-out; }
.bowling .bw-say:not(.show) { display: none; }
.bowling .bw-say { flex: none; width: 48px; height: 48px; padding: 0; border-radius: 50%; border: 3px solid var(--ink); background: #fff; font-size: 22px; cursor: pointer; box-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.bowling .bw-say:active { transform: scale(.92); }

/* ---------- the pins ---------- */
.bowling .bw-deck { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.bowling .bw-pin { position: absolute; width: var(--pw); height: calc(var(--pw) * 1.7); margin: 0; padding: 0; border: 0; background: none; font: inherit; color: var(--ink); pointer-events: none; }
.bowling .bw-pin-in, .bowling .bw-pin-lift { position: absolute; inset: 0; transform-origin: 50% 96%; }
.bowling .bw-pin-lift { transition: transform .16s cubic-bezier(.2, 1.6, .4, 1), filter .16s; }
.bowling .bw-pin-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.bowling .bw-face { position: absolute; left: 12%; right: 12%; top: 44%; bottom: 7%; display: flex; align-items: center; justify-content: center; }
.bowling .bw-face .lt-svg { width: auto; height: 100%; }
.bowling .bw-word { font-size: calc(var(--pw) * .36); font-weight: 700; line-height: 1; white-space: nowrap; letter-spacing: .5px; }
.bowling .bw-kl { display: inline-block; width: .9em; height: 1.45em; vertical-align: -.36em; }
.bowling .bw-kl .lt-svg { width: 100%; height: 100%; }
.bowling .bw-key.k-b { color: #2c64d8; }
.bowling .bw-key.k-d { color: #d8392f; }
/* where a finger counts: the body and belly (not the head, which stands in front of the pins behind) */
.bowling .bw-hit { position: absolute; left: -5%; right: -5%; top: 27%; bottom: -3%; pointer-events: auto; cursor: pointer; border-radius: 45% 45% 30% 30%; }
.bowling .bw-pin.down .bw-hit { pointer-events: none; }
/* the ring on the lane at its foot: picked (yellow), wrong (red), should have gone (orange), right to leave (green) */
.bowling .bw-pin::after { content: ''; position: absolute; left: 6%; right: 6%; bottom: -5%; height: 14%; border-radius: 50%; border: 4px solid transparent; transition: border-color .15s, box-shadow .15s; }
.bowling .bw-pin.picked .bw-pin-lift { transform: translateY(-6%) rotate(-5deg); filter: drop-shadow(0 0 4px #ffd23f) drop-shadow(0 0 4px #ffd23f); }
.bowling .bw-pin.picked::after { border-color: #ffd23f; box-shadow: 0 0 12px #ffd23f; }
.bowling .bw-pin.wrong::after { border-color: #ff4d55; box-shadow: 0 0 10px #ff4d55; }
.bowling .bw-pin.missed::after { border-color: #ff9d2e; box-shadow: 0 0 12px #ff9d2e; }
.bowling .bw-pin.safe::after { border-color: #4be08a; box-shadow: 0 0 10px #4be08a; }
.bowling .bw-pin.down::after { opacity: 0; }
.bowling .bw-pin.wobble .bw-pin-in { animation: bw-wobble .85s ease-in-out; }
@keyframes bw-wobble { 0%, 100% { transform: none; } 15% { transform: rotate(-14deg); } 35% { transform: rotate(11deg); } 55% { transform: rotate(-7deg); } 75% { transform: rotate(3deg); } }
.bowling .bw-pin.nudge .bw-pin-in { animation: bw-nudge .5s ease-in-out; }
@keyframes bw-nudge { 30% { transform: translateY(-6%); } 60% { transform: translateY(1%); } }
.bowling .bw-pin.look .bw-pin-lift { animation: bw-look .5s ease-in-out 5 alternate; }
@keyframes bw-look { to { filter: drop-shadow(0 0 7px #fff) drop-shadow(0 0 5px #ff9d2e); } }

/* the sweep bar (between racks) */
.bowling .bw-sweep { position: absolute; left: 50%; top: 0; z-index: 18; height: 24px; transform: translate(-50%, -100%); pointer-events: none; background: linear-gradient(#80859c, #3a3d52); border: 3px solid var(--ink); border-radius: 6px; }

/* ---------- him, the ball, the buttons ---------- */
.bowling .bw-me { position: absolute; bottom: 2px; z-index: 22; pointer-events: none; }
.bowling .bw-me .avatar-svg { display: block; width: 100%; height: 100%; }
.bowling .bw-held { position: absolute; left: 60%; top: 50%; width: 46%; aspect-ratio: 1; transition: opacity .1s; }
.bowling .bw-held.gone { opacity: 0; }
.bowling .bw-ball-svg { display: block; width: 100%; height: 100%; }
.bowling .bw-me.throw { animation: bw-throw .7s ease-out; }
@keyframes bw-throw { 30% { transform: translateY(-7%) rotate(5deg); } }
.bowling .bw-ball { position: absolute; left: 0; top: 0; z-index: 19; opacity: 0; pointer-events: none; will-change: transform; }
.bowling .bw-ball.show { opacity: 1; }

.bowling .bw-bowl {
  position: absolute; bottom: 14px; z-index: 24; display: flex; align-items: center; gap: 8px; min-height: 76px; padding: 6px 22px 6px 10px; box-sizing: border-box;
  font: inherit; font-size: 28px; font-weight: 800; letter-spacing: 1px; color: var(--ink); cursor: pointer;
  background: #ffd23f; border: 4px solid var(--ink); border-radius: 999px; box-shadow: 0 6px 0 rgba(0, 0, 0, .35);
  opacity: 0; pointer-events: none; transform: scale(.8); transition: opacity .2s, transform .2s cubic-bezier(.2, 1.5, .4, 1), filter .2s;
}
.bowling .bw-bowl .bw-ball-svg { width: 52px; height: 52px; }
.bowling .bw-bowl.show { opacity: 1; pointer-events: auto; transform: none; filter: saturate(.45) brightness(.92); }
.bowling .bw-bowl.show.ready { filter: none; animation: bw-ready 1.4s ease-in-out infinite; }
.bowling .bw-bowl.show:active { transform: scale(.94); }
@keyframes bw-ready { 50% { box-shadow: 0 0 0 8px rgba(255, 210, 63, .35), 0 6px 0 rgba(0, 0, 0, .35); } }

/* grow the B */
.bowling .bw-hint {
  position: absolute; bottom: 16px; z-index: 24; width: 76px; height: 76px; padding: 0; border-radius: 50%; border: 4px solid var(--ink);
  background: #ffd23f; color: var(--ink); box-shadow: 0 5px 0 rgba(0, 0, 0, .35); font: inherit; font-weight: 800; cursor: pointer;
  opacity: 0; pointer-events: none; transform: scale(.7); transition: opacity .2s, transform .2s cubic-bezier(.2, 1.5, .4, 1);
}
.bowling .bw-hint.show { opacity: 1; pointer-events: auto; transform: none; }
.bowling .bw-hint.on { background: #fff4c2; }
.bowling .bw-hint.show:active { transform: scale(.92); }
.bowling .bw-hint.nudge { animation: bw-nudgehint .45s ease-in-out 4; }
@keyframes bw-nudgehint { 50% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(255, 210, 63, .5), 0 5px 0 rgba(0, 0, 0, .3); } }
.bowling .bw-hint-b { font-size: 44px; line-height: 1; font-family: 'Andika', var(--font); }
.bowling .bw-hint-q { position: absolute; right: 9px; top: 3px; font-size: 20px; }

/* the animal on the next lane */
.bowling .bw-rival { position: absolute; z-index: 9; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 86px; line-height: 1; pointer-events: none; }
.bowling .bw-rival b { font-size: 15px; color: #fff; background: rgba(0, 0, 0, .4); border-radius: 999px; padding: 1px 10px; }
.bowling .bw-rival.cheer > svg { animation: bw-hop .45s ease-in-out 2; }
@keyframes bw-hop { 40% { transform: translateY(-18%); } }

/* ---------- a pin he got wrong, big ---------- */
.bowling .bw-lesson { position: absolute; left: 50%; top: 50%; z-index: 30; transform: translate(-50%, -50%) scale(.6); opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s cubic-bezier(.2, 1.4, .4, 1); max-width: calc(100% - 24px); }
.bowling .bw-lesson.show { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }
.bowling .bw-ls-card { background: #fff; border: 5px solid var(--ink); border-radius: 26px; padding: 12px 22px 10px; text-align: center; box-shadow: 0 0 0 5px #ff4d55, 0 12px 0 rgba(0, 0, 0, .3); color: var(--ink); }
.bowling .bw-ls-card.missed { box-shadow: 0 0 0 5px #ff9d2e, 0 12px 0 rgba(0, 0, 0, .3); }
.bowling .bw-ls-face { display: flex; align-items: center; justify-content: center; gap: 12px; }
.bowling .bw-ls-glyph { display: block; width: clamp(84px, 15vh, 124px); aspect-ratio: 100 / 160; }
.bowling .bw-ls-glyph.sm { width: clamp(52px, 9vh, 78px); }
.bowling .bw-ls-word { font-size: clamp(46px, 8.5vh, 74px); font-weight: 700; line-height: 1; }
.bowling .bw-ls-cap { margin: 6px 0 0; font-size: 21px; font-weight: 800; white-space: nowrap; }
.bowling .bw-ls-cap .rd-word { font-size: 1.2em; }

/* ---------- banner ---------- */
.bowling .bw-banner {
  position: absolute; left: 50%; top: 40%; z-index: 31; transform: translate(-50%, -50%); opacity: 0; pointer-events: none; text-align: center; white-space: nowrap;
  font-size: clamp(34px, 6vw, 66px); font-weight: 800; line-height: 1.05; color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink);
}
.bowling .bw-banner.show { animation: bw-banner 1.2s ease-out forwards; }
.bowling .bw-banner.strike { color: #ffd23f; font-size: clamp(48px, 9vw, 96px); }
.bowling .bw-banner.spare { color: #7dffb0; font-size: clamp(44px, 8vw, 84px); }
.bowling .bw-banner.go { color: #ffd23f; }
.bowling .bw-banner.frame { color: #9fe0ff; }
@keyframes bw-banner { 0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; } 15% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; } 25%, 80% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(-50%, -60%) scale(.95); opacity: 0; } }
@keyframes bw-pop { 40% { transform: scale(1.25); } }

/* ---------- the start card ---------- */
.bowling .bw-start { position: absolute; inset: 0; z-index: 40; display: none; place-items: center; padding: 12px; overflow-y: auto; background: rgba(15, 10, 40, .55); }
.bowling .bw-start.show { display: grid; }
.bowling .bw-card { width: min(540px, 100%); box-sizing: border-box; padding: 16px 18px; text-align: center; background: #fff; border: 4px solid var(--ink); border-radius: 26px; box-shadow: var(--shadow); color: var(--ink); }
.bowling .bw-how { display: flex; align-items: flex-end; justify-content: center; gap: 12px; }
.bowling .bw-how-pin { position: relative; width: 64px; height: 109px; }
.bowling .bw-how-pin .bw-face { left: 13%; right: 13%; }
.bowling .bw-how-tap { position: absolute; right: -14px; bottom: 6px; font-size: 32px; }
.bowling .bw-how-arrow { align-self: center; font-size: 30px; font-weight: 800; color: var(--grape); }
.bowling .bw-how-bowl { align-self: center; display: flex; align-items: center; gap: 6px; padding: 4px 16px 4px 6px; background: #ffd23f; border: 4px solid var(--ink); border-radius: 999px; font-size: 22px; font-weight: 800; }
.bowling .bw-how-bowl .bw-ball-svg { width: 38px; height: 38px; }
.bowling .bw-how-text { margin: 10px 0 0; font-size: 20px; font-weight: 700; }
.bowling .bw-vs { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 8px 0 0; font-size: 18px; font-weight: 700; color: var(--ink-soft); }
.bowling .bw-vs > svg { width: 44px; height: 44px; flex: none; }
.bowling .bw-go { font-size: 30px; padding: 8px 46px; margin-top: 12px; min-height: 80px; }
.bowling .bw-off { font-weight: 700; color: var(--coral-dark); margin: 8px 0 0; }
.bowling .bw-bestline { margin: 10px 0 0; font-weight: 800; color: var(--ink-soft); }
.bw-res-rival { display: inline-block; width: 1.3em; height: 1.3em; vertical-align: -.3em; }
.bw-res-rival svg { width: 100%; height: 100%; }

/* ---------- smaller screens ---------- */
@media (max-width: 760px) {
  .bowling .bw-board { --who: 34px; --tot: 42px; padding: 2px 4px 3px; border-width: 3px; border-radius: 10px; }
  .bowling .bw-who b { display: none; }
  .bowling .bw-who > svg { width: 26px; height: 26px; }
  .bowling .bw-nums { font-size: 9px; line-height: 12px; }
  .bowling .bw-m { height: 14px; }
  .bowling .bw-m i { font-size: 11px; line-height: 13px; }
  .bowling .bw-f > b { font-size: 12px; line-height: 16px; min-height: 16px; }
  .bowling .bw-tot b { font-size: 15px; }
  .bowling .bw-hood { height: 52px; gap: 8px; }
  .bowling .bw-goal { font-size: 20px; gap: 6px; }
  .bowling .bw-goal-l { width: 24px; height: 36px; border-radius: 8px; }
  .bowling .bw-say { width: 44px; height: 44px; font-size: 20px; }
  .bowling .bw-bowl { font-size: 24px; min-height: 70px; padding: 5px 16px 5px 8px; }
  .bowling .bw-bowl .bw-ball-svg { width: 44px; height: 44px; }
  .bowling .bw-hint { width: 70px; height: 70px; }
}
@media (max-width: 600px) {
  .bowling .game-top h2 { display: none; }
  .bowling .game-top { grid-template-columns: auto 1fr; }
  .bowling .bw-goal { font-size: 18px; }
  .bowling .bw-ls-cap { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .bowling .bw-bowl.show.ready, .bowling .bw-pin.look .bw-pin-lift { animation: none !important; }
}
