/* Game look shared by the practice table and live games: chunky glossy buttons, round icon
   buttons, the stage with the table, the pull-back power bar with a cue inside it, and the spin
   picker. Our own art throughout. On an upright phone the table stands lengthways and the power
   bar lies under it. */
/* The club's typefaces, served from this site. The club's own design is set in plain Arial, with
   small labels in a fixed-width face and the banner in Georgia. None of the three is on every
   phone, and none is sure to have Hebrew, so each has a stand-in here that does: Heebo for
   everything that is read, Cousine for the small labels, Frank Ruhl Libre for the banner. All
   three are under the SIL Open Font License (web/fonts/LICENSE-*.txt). */
@font-face {
  font-family: "Heebo Variable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(./fonts/heebo-hebrew-wght-normal.woff2) format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: "Heebo Variable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(./fonts/heebo-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Cousine"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(./fonts/cousine-hebrew-700-normal.woff2) format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: "Cousine"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(./fonts/cousine-latin-700-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Frank Ruhl Libre Variable"; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url(./fonts/frank-ruhl-libre-hebrew-wght-normal.woff2) format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: "Frank Ruhl Libre Variable"; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url(./fonts/frank-ruhl-libre-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* River Club's colours, taken from the club's own design: near-black, flat dark panels with a thin
   line round them, lime for whatever can be pressed or is on, and gold for prizes and numbers. */
:root {
  --night: #0c0e0f; --night-2: #101212; --glow: #141718;
  --panel-top: #16191b; --panel-bottom: #16191b; --card-top: #16191b; --card-bottom: #16191b;
  --line: #2a2d2e; --line-strong: #3b3f40; --well: #101212; --lift: #1a1c1d; --rim: #050606;
  --ink: #f5f6f3; --ink-dim: #a9adab;
  --accent: #b6f48e; --accent-ink: #172312; --accent-soft: #242e22; --accent-line: #536e45;
  --gold: #e7c885; --gold-light: #f3ead9; --gold-deep: #c9a45c; --gold-dark: #554632;
  --green: #27a95c; --green-dark: #14653c; --mint: #b6f48e;
  --blue: #6fb4ee; --blue-dark: #2c5f8c; --aqua: #bddef8; --aqua-soft: #1d2c3b; --aqua-line: #3a4c61;
  --red: #e0584f; --red-dark: #8f2a24; --rose: #ff9aa2;
  --game-font: "Heebo Variable", "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  --display-font: var(--game-font);
  --label-font: "Cousine", "Courier New", monospace;
  --serif-font: Georgia, "Frank Ruhl Libre Variable", "Times New Roman", serif;
}
h1, h2, h3 { font-family: var(--display-font); }

/* The club's name, the way the club writes it. */
.club-brand {
  display: inline-flex; align-items: center; gap: 5px; direction: ltr; color: #fff; text-decoration: none; white-space: nowrap;
  font: italic 900 22px/1 Arial, Helvetica, sans-serif; letter-spacing: -1.3px;
}
.club-brand b { color: var(--accent); font-weight: 900; }
.club-brand img { width: 31px; height: 31px; margin-right: 4px; }
[hidden] { display: none !important; }

/* Buttons: flat, lime, the way the club draws them. The other colours are for a second action
   beside the main one, or for a warning. */
.btn {
  --fill: var(--accent); --text: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 22px; border: 0; border-radius: 8px; cursor: pointer;
  font: 700 1.02rem/1.1 var(--game-font); color: var(--text); background: var(--fill); text-decoration: none; transition: filter .12s, transform .06s;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.green { --fill: var(--green); --text: #fff; }
.btn.blue { --fill: var(--aqua-soft); --text: var(--aqua); box-shadow: inset 0 0 0 1px var(--aqua-line); }
.btn.red { --fill: var(--red); --text: #fff; }
.btn.gold { --fill: var(--gold); --text: #17140e; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, .spin-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The keys beside the table: square, as the club's cue arena draws its own. Green by default,
   red for leaving, gold for the two that move the cue ball and name a pocket. */
.icon-btn {
  width: 52px; height: 48px; border-radius: 8px; border: 2px solid #aad17b; cursor: pointer; display: grid; place-items: center;
  color: #fff; background: linear-gradient(#65c845, #29711c); box-shadow: 0 2px 4px rgba(0, 0, 0, .6);
}
.icon-btn:active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.icon-btn.red { border-color: #f3aaa4; background: linear-gradient(#ea6a60, var(--red-dark)); }
.icon-btn.gold { border-color: #fff0c0; background: linear-gradient(#f3d98d, #b98a31); color: #3a2600; }
.icon-btn svg { width: 26px; height: 26px; }

/* Stage and table. */
.stage { direction: ltr; display: flex; align-items: center; justify-content: center; gap: 16px; }
.table-wrap { position: relative; flex: 0 1 auto; min-width: 0; display: flex; justify-content: center; }
/* Small balls around the table: what each player has left, and the row of balls in the pockets. */
.mini-ball {
  --d: 22px; flex: none; display: grid; place-items: center; width: var(--d); height: var(--d); border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .7), inset 0 -2px 3px rgba(0, 0, 0, .25);
}
.mini-ball b {
  display: grid; place-items: center; width: 56%; height: 56%; border-radius: 50%;
  background: #fbf8ef; color: #111; font: 800 calc(var(--d) * .36)/1 var(--game-font);
}
/* The row under the table with the balls that went down, in order. */
.tray {
  align-self: center; display: flex; align-items: center; gap: 10px; max-width: 100%; min-height: 36px; padding: 6px 14px;
  border-radius: 9px; background: rgba(16, 24, 36, .81);
}
.tray-label { font-size: .8rem; font-weight: 700; color: #d1d9df; white-space: nowrap; }
.tray-balls { display: flex; flex-wrap: wrap; gap: 4px; min-width: 22px; }
.tray-balls:empty::after { content: "עוד אין"; font-size: .8rem; color: #d1d9df; opacity: .7; }
@media (max-width: 700px) {
  .tray { gap: 8px; min-height: 30px; padding: 5px 10px; }
  .tray .mini-ball { --d: 17px; }
  .tray-balls { gap: 3px; }
}

/* With a mouse: a crosshair while the cue follows the pointer, a plain arrow once the aim is locked. */
.stage canvas[data-aim=free] { cursor: crosshair; }
.stage canvas {
  display: block; max-width: 100%; height: auto; border-radius: 22px;
  touch-action: none; cursor: crosshair; box-shadow: 0 22px 50px rgba(0, 0, 0, .6), 0 0 0 3px rgba(0, 0, 0, .35);
}

/* Power bar: a framed slot with the cue inside; pulling slides the cue back. */
/* --table-h is the table's height, set by the page when it fits the table to the window: the bar
   and the tools on the other side are never taller than the table. */
.power { position: relative; flex: none; width: 54px; height: min(300px, var(--table-h, 300px)); touch-action: none; cursor: ns-resize; user-select: none; }
.power .pb-track {
  position: absolute; inset: 0; border-radius: 27px; overflow: hidden;
  background: linear-gradient(90deg, #0d131d, #1c2634 50%, #0d131d);
  box-shadow: inset 0 3px 12px rgba(0, 0, 0, .8), 0 0 0 3px #52443c, 0 0 0 6px #0d131d, 0 10px 20px rgba(0, 0, 0, .5);
}
.power .pb-fill {
  position: absolute; left: 0; right: 0; top: 0; height: calc(var(--p, 0) * 100%);
  background: linear-gradient(180deg, rgba(87, 201, 133, .85), rgba(240, 200, 75, .85) 60%, rgba(229, 83, 63, .9));
}
.power .pb-grip {
  position: absolute; left: 50%; width: 12px; margin-left: -6px; height: 88%;
  top: calc(10px + var(--p, 0) * 52%); border-radius: 6px 6px 4px 4px;
  background: linear-gradient(180deg, #3f74d6 0 3%, #f2eee4 3% 7%, #f2dcae 7%, #c99d5f 60%, #d7b35a 60% 62%, #3a1f10 62% 96%, #111 96%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 3px 4px 6px rgba(0, 0, 0, .5);
}
.power .pb-track::after {
  content: ""; position: absolute; left: 50%; bottom: 12px; width: 12px; height: 12px; margin-left: -6px;
  border-right: 3px solid rgba(255, 255, 255, .45); border-bottom: 3px solid rgba(255, 255, 255, .45); transform: rotate(45deg);
}
.power.off { opacity: .45; cursor: default; }
.power:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 27px; }

.btn, .icon-btn, .spin-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* Tools beside the table: the spin button above the fine-aim wheel. */
.side-tools { flex: none; display: flex; flex-direction: column; align-items: center; gap: 16px; max-height: var(--table-h, none); }
.fine-aim {
  --roll: 0px;
  position: relative; flex: 0 1 220px; width: 50px; min-height: 60px; border-radius: 25px; touch-action: none; cursor: ns-resize; user-select: none;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .55), transparent 30%, transparent 70%, rgba(0, 0, 0, .55)),
    repeating-linear-gradient(180deg, #6f7576 0 3px, #232627 3px 11px) 0 var(--roll) / 100% 22px,
    #232627;
  box-shadow: inset 0 6px 10px rgba(0, 0, 0, .7), inset 0 -6px 10px rgba(0, 0, 0, .7), 0 0 0 3px #52443c, 0 0 0 6px #0d131d, 0 10px 20px rgba(0, 0, 0, .5);
}
.fine-aim.off { opacity: .45; cursor: default; }
.fine-aim:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
.side-tools .label { font: 700 .75rem var(--game-font); color: #d1d9df; text-align: center; }

/* Spin: a cue-ball button beside the table opens a big ball to pick the contact point. */
.spin-btn {
  position: relative; flex: none; width: 58px; height: 58px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: radial-gradient(circle at 34% 30%, #ffffff, #f3efe3 45%, #b8b09b);
  box-shadow: 0 0 0 3px #0d131d, 0 0 0 5px #e7c774, 0 8px 14px rgba(0, 0, 0, .55);
}
.spin-ball {
  position: relative; border-radius: 50%; touch-action: none; cursor: pointer;
  background: radial-gradient(circle at 34% 30%, #ffffff, #f3efe3 45%, #b8b09b);
  box-shadow: 0 12px 26px rgba(0, 0, 0, .55), inset 0 -6px 12px rgba(0, 0, 0, .15);
}
.spin-ball::before, .spin-ball::after { content: ""; position: absolute; background: rgba(0, 0, 0, .14); pointer-events: none; }
.spin-ball::before { left: 50%; top: 10%; bottom: 10%; width: 1px; }
.spin-ball::after { top: 50%; left: 10%; right: 10%; height: 1px; }
.spin-dot {
  position: absolute; left: 50%; top: 50%; width: 22%; height: 22%; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 35%, #ff8a80, #c62828); box-shadow: 0 0 0 2px rgba(255, 255, 255, .8);
}
.spin-picker { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(2, 8, 14, .72); padding: 16px; }
.spin-card {
  display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 22px 24px; border-radius: 22px; max-width: 360px; width: 100%;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom)); box-shadow: 0 0 0 3px var(--line-strong), 0 20px 40px rgba(0, 0, 0, .6);
  color: var(--ink); font-family: var(--game-font); text-align: center; direction: rtl;
}
.spin-card h2 { margin: 0; font-size: 1.3rem; font-weight: 800; }
.spin-card p { margin: 0; color: var(--ink-dim); font-size: .95rem; }
.spin-card .spin-ball { width: min(230px, 62vw); aspect-ratio: 1; max-width: 100%; }
.spin-card .spin-dot { width: 14%; height: 14%; }
.spin-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* A narrow, tall window on a computer: the table stands upright and the power bar lies under it. */
@media (max-width: 700px) and (orientation: portrait) and (hover: hover) and (pointer: fine) {
  .stage { flex-wrap: wrap; gap: 12px; }
  .table-wrap { order: 0; flex: 0 0 100%; }
  .power { order: 1; flex: 1 1 0; width: auto; height: 50px; cursor: ew-resize; }
  .spin-btn { order: 2; }
  .power .pb-fill { left: auto; right: 0; top: 0; bottom: 0; height: auto; width: calc(var(--p, 0) * 100%); background: linear-gradient(270deg, rgba(87, 201, 133, .85), rgba(240, 200, 75, .85) 60%, rgba(229, 83, 63, .9)); }
  .power .pb-grip {
    left: auto; top: 50%; margin: -6px 0 0; height: 12px; width: 88%; right: calc(10px + var(--p, 0) * 52%);
    border-radius: 4px 6px 6px 4px;
    background: linear-gradient(270deg, #3f74d6 0 3%, #f2eee4 3% 7%, #f2dcae 7%, #c99d5f 60%, #d7b35a 60% 62%, #3a1f10 62% 96%, #111 96%);
  }
  .power .pb-track::after { left: 14px; top: 50%; bottom: auto; margin: -6px 0 0; transform: rotate(135deg); }
  .spin-btn { width: 50px; height: 50px; }
  .side-tools { display: contents; }
  .side-tools .label { display: none; }
  .fine-aim {
    order: 3; flex: 0 0 100%; width: auto; height: 40px; border-radius: 20px; cursor: ew-resize;
    background:
      linear-gradient(180deg, rgba(0, 0, 0, .55), transparent 30%, transparent 70%, rgba(0, 0, 0, .55)),
      repeating-linear-gradient(90deg, #6f7576 0 3px, #232627 3px 11px) var(--roll) 0 / 22px 100%,
      #232627;
  }
}
/* A phone lying on its side: the screen is short, so the tools beside the table are slim and as
   tall as the table, and the table takes everything that is left. */
@media (orientation: landscape) and (max-height: 520px) {
  .stage { gap: 10px; align-items: stretch; }
  .power { width: 44px; height: auto; }
  .side-tools { max-height: none; }
  .power .pb-track { border-radius: 22px; box-shadow: inset 0 3px 12px rgba(0, 0, 0, .8), 0 0 0 2px var(--line-strong), 0 0 0 4px var(--rim); }
  .side-tools { gap: 8px; }
  .side-tools .label { display: none; }
  .spin-btn { width: 44px; height: 44px; box-shadow: 0 0 0 2px var(--night-2), 0 0 0 4px var(--gold); }
  .fine-aim { flex: 1 1 0; width: 44px; height: auto; min-height: 60px; border-radius: 22px; box-shadow: inset 0 6px 10px rgba(0, 0, 0, .7), inset 0 -6px 10px rgba(0, 0, 0, .7), 0 0 0 2px var(--line-strong), 0 0 0 4px var(--rim); }
  .stage canvas { border-radius: 14px; box-shadow: 0 8px 20px rgba(0, 0, 0, .6), 0 0 0 2px rgba(0, 0, 0, .35); }
  .icon-btn { width: 36px; height: 36px; box-shadow: 0 3px 0 var(--edge), 0 4px 8px rgba(0, 0, 0, .45), inset 0 2px 0 rgba(255, 255, 255, .35); }
  .icon-btn svg { width: 18px; height: 18px; }
  .tray { display: none; }
}

/* On a phone the table is played lying down. While the phone stands upright, this covers the
   table and asks for the phone to be turned. */
.turn-phone { display: none; }
@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  .turn-phone {
    position: fixed; inset: 0; z-index: 70; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px;
    text-align: center; background: var(--night); color: var(--ink); font-family: var(--game-font);
  }
  .turn-phone svg { width: 84px; height: 84px; color: var(--accent); animation: turn-phone 2.6s ease-in-out infinite; }
  .turn-phone strong { font-size: 1.35rem; font-weight: 700; }
  .turn-phone span { max-width: 30ch; line-height: 1.5; color: var(--ink-dim); }
  .turn-phone a { color: var(--accent); font-weight: 700; }
}
@keyframes turn-phone { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn, .icon-btn { transition: none; }
  .turn-phone svg { animation: none; }
}
