/* /pool/: 8-ball and 9-ball. Loads after /style.css and /play/play.css and
   uses their tokens, header, buttons and docket rows. */

:root{
  --cloth:#14675E;
  --gold:#8A6A00;
  /* Height taken by everything on the play screen but the table: the header,
     the player bar, the banner, the fine-aim strip and the shot row. */
  --chrome:268px;
}

.pool .rules{max-width:var(--measure);margin:2rem 0 0;border-top:1px solid var(--rule);padding-top:1rem}
.pool .rules summary,
.pool .keys summary{cursor:pointer;font-weight:500;min-height:44px;display:flex;align-items:center}
.pool .rules h2{font-family:Spectral,Georgia,serif;font-weight:600;font-size:1.15rem;margin:1.2rem 0 .3rem}
.pool .rules ul{margin:0;padding-left:1.2rem;color:var(--ink-soft)}
.pool .rules li{margin:.3rem 0}

/* Setup */
.setup{max-width:34rem}
.field{margin:0 0 1.2rem}
.field[hidden]{display:none}
.field label{display:block;font-weight:500;margin:0 0 .3rem}
.field input{
  width:100%;
  max-width:20rem;
  min-height:44px;
  padding:.5rem .7rem;
  border:1px solid var(--ink-soft);
  border-radius:2px;
  background:#fff;
  color:var(--ink);
  font:inherit;
}
#code{text-transform:uppercase;letter-spacing:.18em;font-variant-numeric:tabular-nums;max-width:12rem}
.field input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.hint{font-size:.9rem;color:var(--ink-soft);margin:.3rem 0 0}
.choice{border:0;border-top:1px solid var(--rule);margin:0 0 1rem;padding:.8rem 0 0}
.choice[hidden]{display:none}
.choice legend{font-weight:500;padding:0;float:left;width:100%;margin:0 0 .3rem}
.choice label{display:flex;flex-wrap:wrap;align-items:center;gap:0 .55rem;min-height:44px;cursor:pointer;clear:left}
.choice input{width:20px;height:20px;margin:0;accent-color:var(--accent)}
.choice input:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.choice-desc{flex-basis:100%;padding-left:calc(20px + .55rem);color:var(--ink-soft);font-size:.9rem;margin-top:-.55rem;padding-bottom:.4rem}

/* Waiting room */
.room-code{
  font-family:Spectral,Georgia,serif;
  font-weight:600;
  font-size:clamp(2.6rem,12vw,4rem);
  letter-spacing:.14em;
  margin:.2rem 0 .6rem;
  font-variant-numeric:tabular-nums;
}

/* Play screen */
.pool .game{padding-top:1rem}
#screen-play{padding-top:.2rem}
.players{
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:center;
  gap:.6rem;
  min-height:44px;
  font-size:.92rem;
  line-height:1.25;
}
.player{display:flex;flex-direction:column;min-width:0;padding-left:.55rem;border-left:3px solid transparent}
.player.turn{border-left-color:var(--accent)}
.player-right{align-items:flex-end;text-align:right;padding-left:0;padding-right:.55rem;border-left:0;border-right:3px solid transparent}
.player-right.turn{border-right-color:var(--accent)}
.player-name{font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
.player-group{color:var(--ink-soft);font-size:.85rem;white-space:nowrap}
.clock{display:flex;flex-direction:column;align-items:center;gap:2px;min-width:4.2rem;font-variant-numeric:tabular-nums}
.clock[hidden]{display:none}
.clock-text{font-weight:500}
.clock.low .clock-text{color:#A4210F}
.clock-bar{
  width:4.2rem;
  height:4px;
  border:0;
  border-radius:2px;
  background:var(--rule);
  color:var(--accent);
  -webkit-appearance:none;
  appearance:none;
}
.clock-bar::-webkit-progress-bar{background:var(--rule);border-radius:2px}
.clock-bar::-webkit-progress-value{background:var(--accent);border-radius:2px}
.clock-bar::-moz-progress-bar{background:var(--accent);border-radius:2px}
.clock.low .clock-bar::-webkit-progress-value{background:#A4210F}
.clock.low .clock-bar::-moz-progress-bar{background:#A4210F}

/* Two lines at most; the full sentence is also announced. */
.banner{
  min-height:2.6em;
  margin:.2rem 0 .3rem;
  font-size:.9rem;
  line-height:1.3;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.banner.foul{color:#A4210F;font-weight:500}

.table-box{display:flex;justify-content:center}
.table{
  display:block;
  touch-action:none;
  -webkit-tap-highlight-color:transparent;
  -webkit-user-select:none;
  user-select:none;
  cursor:crosshair;
  border-radius:4px;
}
.table.landscape{
  aspect-ratio:2.0912/1.1006;
  width:min(100%, calc((100vh - var(--chrome)) * 1.9001));
  width:min(100%, calc((100svh - var(--chrome)) * 1.9001));
}
.table.portrait{
  aspect-ratio:1.1006/2.0912;
  width:min(100%, calc((100vh - var(--chrome)) * .5263));
  width:min(100%, calc((100svh - var(--chrome)) * .5263));
  min-width:min(100%, 250px);
}
.table:focus-visible,
.wheel:focus-visible,
.spin-ball:focus-visible,
.spin-btn:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.table:focus:not(:focus-visible){outline:none}

/* Fine aim: a thin wheel between two nudge buttons */
.fine{
  display:grid;
  grid-template-columns:44px 1fr 44px;
  gap:.4rem;
  align-items:center;
  max-width:600px;
  margin:.5rem auto 0;
}
.fine-nudge{padding:0;font-size:1.3rem;line-height:1}
.wheel{
  display:block;
  width:100%;
  height:36px;
  touch-action:none;
  cursor:ew-resize;
  border-radius:3px;
}

/* Spin, power, shoot */
.shot-row{
  display:grid;
  grid-template-columns:48px 1fr auto;
  gap:.7rem;
  align-items:center;
  max-width:600px;
  margin:.5rem auto 0;
}
.spin-btn{
  width:48px;
  height:48px;
  padding:0;
  border:1px solid var(--rule);
  border-radius:50%;
  background:var(--paper);
  cursor:pointer;
}
.spin-mini{display:block;width:46px;height:46px}
.power{display:flex;flex-direction:column;gap:2px;min-width:0}
.power-label{font-size:.85rem;color:var(--ink-soft);font-variant-numeric:tabular-nums}
#power{
  width:100%;
  height:36px;
  margin:0;
  background:transparent;
  accent-color:var(--accent);
  cursor:pointer;
  -webkit-appearance:none;
  appearance:none;
}
#power::-webkit-slider-runnable-track{height:8px;border-radius:4px;background:linear-gradient(90deg,var(--rule),var(--accent) 70%,#A4210F)}
#power::-moz-range-track{height:8px;border-radius:4px;background:linear-gradient(90deg,var(--rule),var(--accent) 70%,#A4210F)}
#power::-webkit-slider-thumb{
  -webkit-appearance:none;
  appearance:none;
  width:28px;
  height:28px;
  margin-top:-10px;
  border-radius:50%;
  border:2px solid var(--ink);
  background:var(--paper);
}
#power::-moz-range-thumb{width:24px;height:24px;border-radius:50%;border:2px solid var(--ink);background:var(--paper)}
#power:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
#power:disabled{cursor:not-allowed;opacity:.5}
.shot-row .btn{padding:.6rem 1rem}
#skip{grid-column:2 / 4}
.shot-row.shooting .power,
.shot-row.shooting #shoot{display:none}

.spin-panel{
  max-width:600px;
  margin:.6rem auto 0;
  padding:.8rem 1rem 1rem;
  border:1px solid var(--rule);
  border-radius:3px;
  background:#fff;
}
.spin-panel[hidden]{display:none}
.spin-title{margin:0 0 .4rem;font-weight:500}
.spin-ball{display:block;width:180px;height:180px;margin:0 auto;touch-action:none;cursor:pointer;border-radius:50%}

.play-end{justify-content:center;margin:1rem 0 0}
.play-end[hidden]{display:none}
.pool .keys{max-width:600px;margin:.8rem auto 0}
.play-menu{max-width:600px;margin:.6rem auto 0;display:flex;justify-content:flex-end}
.btn-small{min-height:44px;padding:.4rem .9rem;font-size:.88rem}

/* The play screen trims the page chrome so the table gets the height. */
.playing .playhead{padding:.45rem 0 .35rem}
.playing .game{padding-top:.4rem}
.playing footer{margin-top:1rem}

@media (min-width:700px){
  :root{--chrome:280px}
}
@media (max-width:640px){
  .shot-row .btn{padding:.6rem .8rem}
}

/* Compact play screen for phones in portrait: the site header gives way to a
   small back button, the table goes nearly edge to edge with thin rails, the
   result line floats over the table for a few seconds, and every control
   sits in one row under the table. */
:root{--chrome-compact:98px}
.corner-back,.row-nudge{display:none}
body.compact .playhead{display:none}
body.compact .wrap{padding:0 4px}
body.compact .game{padding-top:0}
body.compact #screen-play{position:relative;padding-top:2px}
body.compact .players{grid-template-columns:40px 1fr auto 1fr;gap:.4rem;min-height:40px}
body.compact .corner-back{
  display:flex;
  align-items:center;
  justify-content:center;
  width:40px;
  height:40px;
  padding:0 0 3px;
  border:1px solid var(--rule);
  border-radius:50%;
  color:var(--ink);
  font-size:1.6rem;
  line-height:1;
}
body.compact .corner-back:hover{color:var(--accent);border-color:var(--accent)}
body.compact .banner{
  position:absolute;
  top:50px;
  left:14px;
  right:14px;
  z-index:2;
  min-height:0;
  margin:0;
  padding:.45rem .7rem;
  border-radius:4px;
  background:rgba(19,35,60,.9);
  color:var(--paper);
  pointer-events:none;
  transition:opacity .35s;
}
body.compact .banner.foul{color:#FFD9CF}
body.compact .banner.gone,
body.compact .banner:empty{opacity:0}
body.compact .table.portrait{
  aspect-ratio:1.0406/2.0312;
  width:min(100%, calc((100vh - var(--chrome-compact)) * .51231));
  width:min(100%, calc((100svh - var(--chrome-compact)) * .51231));
}
body.compact #fine{display:none}
body.compact .shot-row{grid-template-columns:44px 36px 36px 1fr auto;gap:6px;margin-top:4px}
body.compact .spin-btn{width:44px;height:44px}
body.compact .spin-mini{width:42px;height:42px}
body.compact .row-nudge{display:flex;align-items:center;justify-content:center;min-width:36px;width:36px;padding:0;font-size:1.3rem;line-height:1}
body.compact .power-label{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
body.compact #skip{grid-column:2 / 6}
body.compact .shot-row .btn:not(.row-nudge){padding:.6rem .75rem}
body.compact .spin-panel{position:fixed;left:8px;right:8px;bottom:60px;z-index:3;margin:0;box-shadow:0 6px 24px rgba(19,35,60,.25)}
@media (prefers-reduced-motion:reduce){
  body.compact .banner{transition:none}
}
