/* Billard237 Learn & Play — layout fixes loaded after game.css (kept separate so they apply on top of any game.css).
   Shot controls under the table adapt to their own width rather than the screen's: on a computer the coach panel
   beside the table makes them narrower than the window, and one squeezed row made Power, the aim arrows, Guide and
   Shoot overlap. Full-screen play is not affected (its controls float over the table). */
.pg-game:not(.pg-immersive):not(.pg-applayout) .pg-g-controls { container: pgctl / inline-size; }

/* Medium width (computer with the coach panel, tablets): aim + power on the first row, contact, guide and Shoot on the second. */
@container pgctl (max-width: 940px) {
  .pg-ctrl { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "aim power power" "tools tools shoot"; align-items: center; gap: .45rem .7rem; }
  .pg-c-aim { grid-area: aim; }
  .pg-c-power { grid-area: power; min-width: 0; }
  .pg-c-tools { grid-area: tools; justify-self: start; }
  .pg-shoot { grid-area: shoot; justify-self: end; }
}

/* Narrow: aim + Shoot on the first row, power, contact and guide on the second (same as phones). */
@container pgctl (max-width: 520px) {
  .pg-ctrl { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "aim shoot" "power tools"; gap: .4rem .5rem; padding: .4rem; }
  .pg-c-aim { justify-content: space-between; }
  .pg-c-power .pg-c-label { display: none; }
  .pg-c-tools { justify-self: end; }
  .pg-contact-lines, .pg-guide-btn span { display: none; }
  .pg-contact-btn, .pg-guide-btn { min-width: 44px; padding: .2rem .35rem; }
  .pg-shoot { min-width: 88px; padding: 0 .7rem; }
}

/* One full-screen button on the table, not two. Where the browser supports full screen, the table's corner button
   opens the full-screen game, so the extra "play full screen" button (which sat under the View button) is hidden.
   Where it does not (iPhone Safari), that button moves to the free bottom-right corner. */
.pg-game:not(.pg-immersive):not(.pg-applayout) .pg-g-stage:has(.pg-tools-b) .pg-imm-enter { display: none; }
.pg-game:not(.pg-immersive):not(.pg-applayout) .pg-g-stage:not(:has(.pg-tools-b)) .pg-imm-enter { left: auto; right: 8px; bottom: 8px; }

/* Full-screen game: the suggestion bulb moves to the bottom-right corner. Bottom left belongs to the View camera
   panel, which covered the bulb when it was opened. */
.pg-game.pg-immersive .pg-hint-btn:not([hidden]) { left: auto; right: 14px; bottom: max(16px, env(safe-area-inset-bottom)); }

/* Rail calculation walkthrough (railcalc.js): a caption card over the top of the table while the steps are drawn. */
.pg-railcalc { position: absolute; z-index: 7; left: 50%; top: 10px; transform: translateX(-50%); width: min(520px, calc(100% - 20px)); box-sizing: border-box;
  padding: .6rem .8rem .7rem; border-radius: 14px; background: rgba(6, 26, 20, .93); border: 1px solid rgba(102, 229, 178, .45); color: #f1fff8;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); backdrop-filter: blur(6px); font: 400 .92rem/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; animation: pg-rc-in .3s ease-out; }
.pg-railcalc.pg-rc-out { opacity: 0; transform: translateX(-50%) translateY(-8px); transition: opacity .35s, transform .35s; }
@keyframes pg-rc-in { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } }
.pg-rc-head { display: flex; align-items: center; gap: .3rem; margin-bottom: .2rem; }
.pg-rc-kind { flex: 1; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #66e5b2; }
.pg-rc-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .06); color: #fff; font: 700 .95rem/1 system-ui, sans-serif; cursor: pointer; padding: 0; }
.pg-rc-btn:hover, .pg-rc-btn:focus-visible { background: rgba(102, 229, 178, .25); outline: 2px solid #66e5b2; outline-offset: 1px; }
.pg-rc-title { display: block; font-size: 1.02rem; margin: .1rem 0 .15rem; }
.pg-rc-text { margin: 0; color: #d9efe6; }
.pg-rc-formula { margin: .45rem 0 0; padding: .4rem .55rem; border-radius: 8px; background: rgba(255, 214, 90, .12); border: 1px solid rgba(255, 214, 90, .45); color: #ffe7a0;
  font: 700 .95rem/1.35 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.pg-rc-formula[hidden] { display: none; }
.pg-rc-bar { height: 3px; margin-top: .5rem; border-radius: 2px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.pg-rc-bar i { display: block; height: 100%; width: 0; background: #66e5b2; }
.pg-game.pg-immersive .pg-railcalc { top: calc(max(8px, env(safe-area-inset-top)) + 56px); }
@media (max-width: 520px) { .pg-railcalc { font-size: .86rem; padding: .5rem .6rem .6rem; } .pg-rc-title { font-size: .95rem; } .pg-rc-formula { font-size: .82rem; } }
.pg-rc-open { margin-top: .5rem; grid-column: 1 / -1; justify-self: start; }
.pg-rc-open[hidden] { display: none; }
.pg-railcalc.pg-rc-below { position: relative; left: auto; top: auto; transform: none; width: 100%; margin: .5rem 0 0; animation: none; }
.pg-railcalc.pg-rc-below.pg-rc-out { transform: none; }
/* While the calculation is drawn, the view buttons fade so the diamond numbers under them stay readable. */
.pg-stage.pg-rc-active .pg-views, .pg-stage.pg-rc-active .pg-vset, .pg-stage.pg-rc-active .pg-camera-controls { opacity: .25; transition: opacity .3s; }
.pg-stage.pg-rc-active .pg-views:hover, .pg-stage.pg-rc-active .pg-views:focus-within { opacity: 1; }
/* Narrow full screen: the coaching strip spans the bottom, so the View panel and the bulb sit just above it. */
@media (max-width: 760px) {
  .pg-game.pg-immersive .pg-camera-controls { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 66px); }
  .pg-game.pg-immersive .pg-hint-btn:not([hidden]) { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 66px); }
}

/* Match advice: a short pill at the top of the table that fades by itself (the details are in the coach card). */
.pg-advice-pill { position: absolute; z-index: 6; left: 50%; top: 10px; transform: translateX(-50%); max-width: min(86%, 420px); box-sizing: border-box;
  padding: .32rem .75rem; border-radius: 999px; background: rgba(6, 26, 20, .82); border: 1px solid rgba(102, 229, 178, .5); color: #f1fff8;
  font: 700 .82rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif; text-align: center; pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35); animation: pg-pill-in .25s ease-out; transition: opacity .7s, transform .7s; }
.pg-advice-pill.out { opacity: 0; transform: translateX(-50%) translateY(-6px); }
@keyframes pg-pill-in { from { opacity: 0; transform: translateX(-50%) translateY(-6px); } }
.pg-game.pg-immersive .pg-advice-pill { top: calc(max(8px, env(safe-area-inset-top)) + 58px); }
@media (max-width: 520px) { .pg-game.pg-immersive .pg-advice-pill { top: calc(max(8px, env(safe-area-inset-top)) + 110px); } }

/* Full-screen view buttons: a short name under each icon (Player, Table, Overhead…), same button size. */
.pg-game.pg-immersive .pg-view-btn:not(.pg-view-gear) { flex-direction: column; justify-content: center; gap: 2px; min-width: 46px; padding: 2px 3px; }
.pg-game.pg-immersive .pg-view-btn:not(.pg-view-gear) .pg-ic { width: 18px; height: 18px; }
.pg-game.pg-immersive .pg-view-btn:not(.pg-view-gear) span { display: block; max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .58rem; font-weight: 700; line-height: 1; letter-spacing: .01em; }
@media (max-width: 640px) {
  .pg-game.pg-immersive .pg-view-btn:not(.pg-view-gear) { min-width: 42px; padding: 2px 2px; }
  .pg-game.pg-immersive .pg-view-btn:not(.pg-view-gear) span { font-size: .54rem; max-width: 44px; }
}

/* First few times: a small bubble under the view buttons, gone after a few seconds or on the first tap. */
.pg-view-hint { position: absolute; z-index: 8; padding: .3rem .65rem; border-radius: 10px; background: #ffd65a; color: #2b2200;
  font: 700 .78rem/1.25 system-ui, -apple-system, "Segoe UI", sans-serif; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); pointer-events: none;
  max-width: 220px; animation: pg-pill-in .25s ease-out, pg-hint-nudge 1.2s ease-in-out .3s 2; transition: opacity .45s; }
.pg-view-hint::before { content: ""; position: absolute; top: -6px; left: 18px; border: 6px solid transparent; border-top: 0; border-bottom-color: #ffd65a; }
.pg-view-hint.pg-right::before { left: auto; right: 18px; }
.pg-view-hint.out { opacity: 0; }
@keyframes pg-hint-nudge { 50% { transform: translateY(-3px); } }

/* Optional account: "Save my progress" after a lesson or drill (outside lessons and games), guest-progress choice. */
.pg-save-offer { position: fixed; z-index: 40; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(92vw, 440px);
  box-sizing: border-box; padding: .9rem 1rem; border-radius: 16px; background: #0d2a20; color: #f1fff8; border: 1px solid rgba(102, 229, 178, .45);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: pg-pill-in .3s ease-out; transition: opacity .4s; }
.pg-save-offer.out { opacity: 0; }
.pg-save-offer-t { margin: 0 0 .6rem; display: grid; gap: .2rem; font-size: .92rem; }
.pg-save-offer-a { display: flex; gap: .5rem; flex-wrap: wrap; }
.pg-save-offer-a .pg-btn { flex: 1 1 160px; min-height: 46px; justify-content: center; }
.pg-btn-ghost { background: transparent; border: 1px solid rgba(255, 255, 255, .35); color: inherit; }
.pg-guest-merge { margin: .75rem 0; padding: .9rem 1rem; border-radius: 14px; border: 1px solid rgba(102, 229, 178, .45); background: rgba(102, 229, 178, .1); }
.pg-guest-merge p { margin: 0 0 .6rem; display: grid; gap: .2rem; }
.pg-guest-merge .pg-row { gap: .5rem; flex-wrap: wrap; }
.pg-guest-merge .pg-btn { min-height: 44px; }
.pg-resume-drill { display: flex; align-items: center; gap: .75rem; margin: .5rem 0; padding: .75rem 1rem; border-radius: 14px; border: 1px solid var(--pg-border, rgba(255, 255, 255, .15)); text-decoration: none; color: inherit; min-height: 52px; }
.pg-resume-drill > span { display: grid; flex: 1; }
.pg-resume-drill svg:first-child { width: 22px; height: 22px; }
.pg-save-link { display: inline-block; margin: .25rem 0 .5rem; font-weight: 700; min-height: 44px; line-height: 44px; }

/* Phones, full screen: four named view buttons need more room, so the player names end before them. */
@media (max-width: 520px) { .pg-game.pg-immersive .pg-g-top { right: 208px; } }

/* Cartoon drawing shown in the lesson player (technique steps), with a Drawing / 3D model switch */
.pg-film-cartoon { position:absolute; inset:0; background:#eaf4ee; transition:transform .2s ease; transform-origin:35% 45%; }
.pg-film-cartoon[hidden] { display:none; }
.pg-film-cartoon svg { display:block; width:100%; height:100%; }
.pg-film-is-cartoon .pg-film-stage, .pg-page .pg-film-is-cartoon .pg-film-stage { aspect-ratio:400/260; }
.pg-film-video[hidden] { display:none; }
@media (prefers-reduced-motion:reduce) { .pg-film-cartoon { transition:none; } }

/* Account bar above Learn & Play (site shell): create an account / signed-in status. Hidden inside a lesson or a game. */
.pg-account-bar { display:flex; align-items:center; justify-content:space-between; gap:.75rem 1rem; flex-wrap:wrap; margin:0 0 1rem; padding:.8rem 1rem; border-radius:14px; background:#0f3327; border:1px solid #2f6b55; color:#e8fff4; }
.pg-account-bar-t { flex:1 1 220px; font-size:.95rem; line-height:1.35; }
.pg-account-bar-t strong { display:block; font-size:1.02rem; }
.pg-account-bar-a { display:flex; gap:.5rem; flex-wrap:wrap; }
.pg-account-bar .btn { min-height:44px; display:inline-flex; align-items:center; }
.pg-account-bar .btn-outline { color:#e8fff4; border-color:#5fa98c; background:transparent; }
.pg-account-bar .btn-primary, .pg-page .pg-account-bar .btn-primary { color:#06231a; background:#66e3b4; border-color:#66e3b4; font-weight:700; }
.pg-account-on { background:#0c2a20; border-color:#255444; }
body.pg-in-game .pg-account-bar, body.pg-focus .pg-account-bar { display:none; }
@media (max-width:520px) { .pg-account-bar-a, .pg-account-bar-a .btn { width:100%; justify-content:center; } .pg-account-bar-a .btn { flex:1 1 0; width:auto; } }

/* After a drill attempt: the aiming controls give way to one clear choice (Next drill / Try again) */
.pg-reviewbar { display:none; gap:.6rem; width:100%; }
.pg-reviewing .pg-g-controls > :not(.pg-reviewbar) { display:none !important; }
.pg-reviewing .pg-reviewbar { display:flex; flex-wrap:wrap; }
.pg-reviewbar .pg-btn { min-height:54px; flex:1 1 150px; justify-content:center; text-align:center; font-size:1.02rem; }
.pg-reviewbar .pg-rb-main { flex:2 1 220px; }
a.pg-next-drill { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:.05rem; text-decoration:none; line-height:1.2; }
a.pg-next-drill small { font-size:.72rem; font-weight:600; letter-spacing:.05em; text-transform:uppercase; opacity:.8; }
.pg-page a.pg-btn-primary, .pg-page a.pg-btn-primary:visited { color:#06231a; }
.pg-gactions a.pg-btn { text-decoration:none; text-align:center; }
/* The easy aiming rule (fractional ball) on the aim step */
.pg-quickaim { margin:.2rem 0 .7rem; padding:.6rem .8rem; border-radius:12px; border:1px solid #2f6b55; border-left:5px solid #66e3b4; background:rgba(102,227,180,.08); }
.pg-quickaim strong { display:block; font-size:.74rem; letter-spacing:.06em; text-transform:uppercase; color:#8fe9c6; }
.pg-quickaim p { margin:.15rem 0; font-size:1rem; line-height:1.35; }
.pg-quickaim small { opacity:.85; }
.pg-quickaim.pg-qa-medium { border-left-color:#ffd23f; }
.pg-quickaim.pg-qa-hard { border-left-color:#ff8a6a; }
.pg-rc-remember { margin:.3rem 0 0; font-size:.86rem; color:#ffe08a; }
.pg-rc-remember[hidden] { display:none; }
a.pg-next-drill > span { display:flex; flex-direction:column; align-items:center; gap:.05rem; }
