@font-face { font-family: Shrikhand; src: url(../fonts/shrikhand.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: Figtree; src: url(../fonts/figtree.woff2) format('woff2'); font-weight: 400 800; font-display: swap; }

:root {
  --night: #0d1222;
  --panel: #161c31;
  --panel-2: #1f2742;
  --line: #2d3658;
  --cream: #f6eedc;
  --muted: #a1a9c4;
  --gold: #ffc94a;
  --coral: #ff6a55;
  --teal: #3fd0c9;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--cream); overflow: hidden; }
body {
  font: 16px/1.4 Figtree, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#lane { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* The scorecard along the top. */
.hud {
  position: fixed; left: 0; right: 0; top: 0;
  padding: calc(var(--safe-t) + 8px) 10px 0;
  display: flex; gap: 8px; align-items: flex-start;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.card {
  flex: 1; min-width: 0;
  background: rgba(13, 18, 34, 0.82); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px 7px 7px; text-align: left;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.who { display: flex; justify-content: space-between; align-items: baseline; padding: 0 2px 4px; font-size: 13px; color: var(--muted); }
.who b { color: var(--cream); font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.who b i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.icon {
  width: 44px; height: 44px; flex: none; border-radius: 12px;
  background: rgba(13, 18, 34, 0.82); border: 1px solid var(--line);
  display: grid; place-items: center;
}
.icon svg { width: 22px; height: 22px; stroke: var(--cream); stroke-width: 2; stroke-linecap: round; fill: none; }

/* A scorecard: ten frames and a total. */
.frames { display: grid; grid-template-columns: repeat(9, 1fr) 1.45fr 1.25fr; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.f { border-right: 1px solid var(--line); min-width: 0; }
.f:last-child { border-right: 0; }
.f .balls { display: flex; justify-content: flex-end; height: 15px; }
.f .balls span { width: 50%; max-width: 15px; text-align: center; font-size: 11px; line-height: 15px; font-weight: 700; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.f:nth-child(10) .balls span { width: 33.3%; }
.f .balls span:first-child:not(:only-child) { border-left-color: transparent; }
.f .balls .x { color: var(--gold); }
.f .balls .s { color: var(--teal); }
.f .tot { text-align: center; font-size: 11.5px; letter-spacing: -0.02em; line-height: 17px; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 17px; }
.f.now { background: rgba(255, 201, 74, 0.13); }
.f.sum { display: grid; place-items: center; font-size: 15px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.frames.roomy .f .balls { height: 20px; }
.frames.roomy .f .balls span { font-size: 13px; line-height: 20px; max-width: 20px; }
.frames.roomy .f .tot { font-size: clamp(10.5px, 2.9vw, 14px); letter-spacing: -0.02em; line-height: 22px; min-height: 22px; }
.frames.roomy .f.sum { font-size: 18px; }

.others {
  position: fixed; left: 10px; right: 10px; top: calc(var(--safe-t) + 74px);
  display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none;
}
.others span { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: rgba(13, 18, 34, 0.7); border: 1px solid var(--line); color: var(--muted); }
.others b { color: var(--cream); font-variant-numeric: tabular-nums; }

/* STRIKE! */
.call {
  position: fixed; left: 0; right: 0; top: calc(var(--safe-t) + 17%); text-align: center; pointer-events: none;
  font-family: Shrikhand, Georgia, serif; font-size: clamp(44px, 13vw, 92px); line-height: 1;
  color: var(--gold); text-shadow: 0 3px 0 #a3461c, 0 0 28px rgba(255, 140, 50, 0.55);
  opacity: 0;
}
.call small { display: block; font-family: Figtree, sans-serif; font-weight: 700; font-size: 18px; color: var(--cream); text-shadow: 0 1px 8px #000; margin-top: 10px; letter-spacing: 0.02em; }
.call.small { font-size: clamp(36px, 10vw, 64px); color: var(--cream); text-shadow: 0 3px 0 #39406a, 0 0 22px rgba(0, 0, 0, 0.7); }
.call.teal { color: var(--teal); text-shadow: 0 3px 0 #1d6b6b, 0 0 26px rgba(63, 208, 201, 0.5); }
.call.go { animation: pop 1.7s ease-out forwards; }
@keyframes pop {
  0% { opacity: 0; transform: scale(0.6) rotate(-6deg); }
  12% { opacity: 1; transform: scale(1.08) rotate(-3deg); }
  22% { transform: scale(1) rotate(-3deg); }
  80% { opacity: 1; transform: scale(1) rotate(-3deg); }
  100% { opacity: 0; transform: scale(1.04) rotate(-3deg) translateY(-12px); }
}

.hint, .readout {
  position: fixed; left: 0; right: 0; text-align: center; margin: 0; pointer-events: none;
  font-size: 14px; font-weight: 600; color: var(--cream); text-shadow: 0 1px 6px #000, 0 0 2px #000;
}
.hint { bottom: calc(var(--safe-b) + 18px); animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.55; } }
.readout { bottom: calc(var(--safe-b) + 18px); color: var(--gold); transition: opacity 0.4s; }

/* Sheets over the lane: the title, the menu, the scorecard, the end of a game. */
.sheet {
  position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: rgba(8, 11, 22, 0.66);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px);
}
.panel {
  margin: auto; width: 100%; max-width: 400px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 22px 20px 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.panel.wide { max-width: 560px; }
h1 {
  font-family: Shrikhand, Georgia, serif; font-weight: 400; font-size: 54px; line-height: 1.05; margin: 0;
  text-align: center; color: var(--gold); text-shadow: 0 3px 0 #a3461c;
  transform: rotate(-3deg);
}
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 20px 0 8px; font-weight: 700; }
.panel > h2:first-child { margin-top: 0; text-align: center; font-size: 26px; text-transform: none; letter-spacing: 0; color: var(--cream); font-family: Shrikhand, Georgia, serif; font-weight: 400; }
.panel > h2.score { font-size: 72px; line-height: 1; color: var(--gold); text-shadow: 0 3px 0 #a3461c; margin-top: 4px; }
.tag { text-align: center; color: var(--muted); margin: 8px 0 4px; }

.players { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.players li { display: flex; align-items: center; gap: 10px; }
.players .ball { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset -3px -4px 6px rgba(0, 0, 0, 0.45), inset 2px 2px 4px rgba(255, 255, 255, 0.3); }
.players input {
  flex: 1; min-width: 0; font: inherit; color: var(--cream); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.players input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.players button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 20px; flex: none; }

.big {
  display: block; width: 100%; margin: 18px 0 0; padding: 14px; border: 0; border-radius: 14px;
  background: var(--gold); color: #2a1a05; font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 0 #b37b14;
}
.big:active { transform: translateY(2px); box-shadow: 0 2px 0 #b37b14; }
#resume { background: var(--teal); color: #062a2a; box-shadow: 0 4px 0 #1d8a85; margin-top: 16px; }
.plain {
  display: block; width: 100%; margin: 10px 0 0; padding: 12px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--line); font-weight: 600;
}
.plain.danger { color: var(--coral); }
.link { background: none; border: 0; color: var(--teal); padding: 10px 0 0; font-weight: 600; }

.how { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.how summary { cursor: pointer; font-weight: 700; color: var(--cream); }
.how ul, .howlist { padding-left: 18px; margin: 10px 0 0; color: var(--muted); }
.how li, .howlist li { margin-bottom: 6px; }
.how b, .howlist b { color: var(--cream); }

.record { margin-top: 14px; color: var(--muted); font-size: 14px; }
.record .best { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding-top: 12px; }
.record .best b { color: var(--gold); font-size: 22px; font-variant-numeric: tabular-nums; }
.record ol { list-style: none; margin: 8px 0 0; padding: 0; }
.record li { display: flex; justify-content: space-between; padding: 3px 0; }
.record li b { color: var(--cream); font-variant-numeric: tabular-nums; }

.cards { display: grid; gap: 14px; margin-top: 12px; }
.cards .row .name { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 4px; }
.cards .row .name i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; }
.cards .row .name em { font-style: normal; color: var(--gold); font-size: 13px; }

.jd-foot { margin-top: 18px; text-align: center; font-size: 13px; color: var(--muted); }
.jd-foot a { color: inherit; text-decoration: none; }
.jd-foot a:hover, .jd-foot a:focus-visible { text-decoration: underline; }

.noscript { position: fixed; inset: auto 0 40% 0; text-align: center; }

@media (min-width: 700px) {
  .hud { left: 50%; right: auto; transform: translateX(-50%); width: 560px; }
  .others { left: 50%; right: auto; transform: translateX(-50%); width: 540px; top: calc(var(--safe-t) + 80px); }
}
@media (prefers-reduced-motion: reduce) {
  .hint { animation: none; }
}
