:root {
  --bg: #0d1017;
  --panel: #151a24;
  --ink: #eef1f6;
  --dim: #8b93a7;
  --line: #232a38;
  --hot: #ffb43d;
  --cool: #4bc3ff;
  color-scheme: dark;
}
* { box-sizing: border-box; }

/* Every panel here sets display:flex, which outranks the user agent's
   [hidden]{display:none} and leaves the whole interface stacked on top of
   itself. Toggling .hidden via the attribute is the pattern used throughout
   app.js, so the attribute has to win. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

.panel {
  max-width: 26rem;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 100dvh;
  justify-content: center;
}
h1 { margin: 0; font-size: clamp(1.6rem, 6vw, 2.2rem); letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 1.3rem; }
.sub { margin: 0; color: var(--dim); font-size: 0.88rem; }
.or { text-align: center; color: var(--dim); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; }
.err { margin: 0; color: var(--hot); font-size: 0.85rem; }

.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; color: var(--dim); }
input {
  width: 100%; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink); font: inherit;
}
input:focus-visible { outline: 2px solid var(--cool); outline-offset: 1px; }
#code { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; font-weight: 600; }

button {
  padding: 0.75rem 1rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button:hover:not(:disabled) { border-color: #3a4457; }
button:disabled { opacity: 0.45; cursor: default; }
.primary { background: var(--hot); border-color: var(--hot); color: #14100e; }
.ghost { background: transparent; }
.joinrow { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; }

.seats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.seats li { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.8rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

main { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

.hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: max(0.6rem, env(safe-area-inset-top)) 0.7rem 0.6rem;
  pointer-events: none;
}
.pill { padding: 0.3rem 0.7rem; border-radius: 999px; background: rgba(13,16,23,0.78); border: 1px solid var(--line); font-size: 0.78rem; font-weight: 600; }
.scores { display: flex; gap: 0.35rem; margin-left: auto; flex-wrap: wrap; }
.score { display: flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.55rem; border-radius: 999px; background: rgba(13,16,23,0.78); border: 1px solid var(--line); font-size: 0.72rem; }
.score.out { opacity: 0.4; text-decoration: line-through; }
.score.turn { border-color: var(--cool); }
.hp { width: 34px; height: 4px; border-radius: 2px; background: #2b3242; overflow: hidden; }
.hp i { display: block; height: 100%; background: var(--hot); }

.bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; gap: 0.55rem;
  padding: 0.7rem 0.7rem max(0.7rem, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(13,16,23,0.96) 70%, rgba(13,16,23,0));
}
.bar.quiet { text-align: center; color: var(--dim); font-size: 0.85rem; }
.bar.quiet p { margin: 0; }
.pieces { display: flex; gap: 0.4rem; }
.piece { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.2rem; padding: 0.5rem 0.3rem; font-size: 0.72rem; }
.piece.on { border-color: var(--cool); background: rgba(75,195,255,0.12); }
.piece b { font-size: 0.95rem; }
.piece.gone { opacity: 0.35; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.hint { margin: 0; text-align: center; color: var(--dim); font-size: 0.75rem; }

.targets { display: flex; gap: 0.4rem; }
.targets button { flex: 1; font-size: 0.8rem; padding: 0.5rem; }
.targets button.on { border-color: var(--cool); background: rgba(75,195,255,0.12); }
.slider { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.75rem; color: var(--dim); }
.slider b { color: var(--ink); }
input[type=range] { width: 100%; padding: 0; background: transparent; border: 0; accent-color: var(--hot); height: 28px; }

.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.8rem; padding: 1.5rem;
  background: rgba(9,11,16,0.88); text-align: center;
}

.toast {
  position: absolute; left: 50%; top: 3.2rem; transform: translateX(-50%);
  margin: 0; padding: 0.5rem 0.9rem; border-radius: 10px;
  background: rgba(255,107,61,0.94); color: #17110d; font-size: 0.82rem; font-weight: 600;
  max-width: 88vw; text-align: center;
}

.ping {
  position: absolute; right: 0.6rem; bottom: 0.4rem;
  font-size: 0.68rem; color: var(--dim); pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.frame { font-size: 0.66rem; color: var(--dim); }

/* On a wide or short viewport the three stacked sliders take two thirds of the
   height, and a bowling lane is 26 m of vertical that has nowhere left to go.
   Laying them in a row gives that height back to the game. */
@media (min-width: 620px), (max-height: 560px) {
  #rollbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr) auto;
    align-items: end;
    gap: 0.75rem;
  }
  #rollbar .slider { min-width: 0; }
  #rollbar #throw { padding-inline: 2rem; }
}
