:root{color-scheme:light;--bg:#fff6e8;--panel:#fffdf7;--panel2:#d5f3eb;--ink:#173d49;--muted:#4d6971;--line:#a5c6c4;--accent:#c84927;--go:#116b69;--red:#ee573b;--yellow:#ffc633;--ratio:.6945;font-family:"Avenir Next","Trebuchet MS","Segoe UI",system-ui,sans-serif}
*{box-sizing:border-box}
[hidden]{display:none !important}
html,body{margin:0;background:var(--bg);color:var(--ink)}
body{line-height:1.45;overflow-x:clip;-webkit-text-size-adjust:100%}
button,a,canvas{-webkit-tap-highlight-color:transparent}
button{font:inherit;cursor:pointer;color:var(--ink);background:var(--panel);border:2px solid var(--line);border-radius:12px;padding:8px 14px;min-height:46px;min-width:46px;font-weight:650;line-height:1.25}
button:hover:not(:disabled){border-color:var(--ink)}
button:disabled{opacity:.5;cursor:default}
button:focus-visible,a:focus-visible,canvas:focus-visible{outline:3px solid var(--accent);outline-offset:3px}
.primary{background:var(--go);border-color:var(--go);color:#fff}
.primary:hover:not(:disabled){border-color:#fff}
.quiet{background:transparent;font-weight:550}
a{color:inherit;text-underline-offset:3px}
h1,h2{margin:0;line-height:1.15;text-wrap:balance}
p{margin:0 0 10px}
.small{font-size:.9rem;color:var(--muted)}
.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.notice{margin:16px;padding:14px;border:2px solid var(--accent);border-radius:12px}

.game{width:min(100%,520px);margin-inline:auto;padding:0 12px 8px}
html.is-playing body,.play,.game.is-fullscreen{user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.top{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:6px 0}
.title{font-size:1.35rem;font-weight:800;letter-spacing:.01em}
.game-name{display:inline-flex;align-items:center;gap:10px;min-height:44px;text-decoration:none;color:inherit}
.game-mark{width:36px;height:36px;flex:none;display:block}
.hud-button{min-height:44px;padding:4px 14px}
.lede{font-size:1.15rem;font-weight:700;margin:6px 0 6px}

/* Menu */
.levels{display:grid;gap:10px;margin:12px 0}
.level{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:2px 12px;text-align:left;padding:12px 14px;border-radius:14px}
.level .name{font-size:1.15rem;font-weight:800}
.level .meta{grid-column:1;font-size:.9rem;font-weight:550;color:var(--muted)}
.level .go{grid-column:2;grid-row:1/3;font-weight:800;color:var(--go)}
.level.last{border-color:var(--go);background:#d5f3eb}
.menu-tools{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}

/* Play */
/* The two score boxes share the first row with Menu and full screen; when enlarged text makes a box
   narrower than about four letters, the buttons move to a second row instead of covering the names. */
.hud{display:flex;flex-wrap:wrap;gap:6px;align-items:stretch;justify-content:flex-end}
.hud>button{flex:none}
.hud .hud-button{min-width:44px;padding:4px 6px}
.side{flex:1 1 4em;display:flex;flex-direction:column;align-items:flex-start;justify-content:center;gap:2px;padding:4px 6px;border:2px solid var(--line);border-radius:12px;min-height:44px;min-width:0}
.side.turn{background:#dcf5eb;border-color:#157774;box-shadow:0 3px 0 #b0dcd0}
.who{display:flex;align-items:center;gap:5px;font-weight:750;font-size:clamp(.78rem,3.6vw,.95rem);min-width:0;overflow-wrap:anywhere;line-height:1.1}
.who::before{content:"";flex:none;width:10px;height:10px;border-radius:50%;background:var(--red);border:2px solid var(--ink)}
.side[data-player="2"] .who::before{background:var(--yellow)}
.heat{display:inline-flex;gap:3px;align-items:center;flex:none}
.pip{width:16px;height:19px;display:block;fill:#9fbebb}
.pip.on{fill:var(--accent)}
.side.armed .pip{fill:#ffb347;animation:pulse .8s ease-in-out infinite alternate}
@keyframes pulse{to{transform:scale(1.18)}}
/* Two lines reserved so the table does not jump; longer text (enlarged sizes) grows the line instead of clipping. */
.line{margin:4px 0;font-size:.9rem;line-height:1.25;color:var(--muted);min-height:2.5em}
#table{display:block;width:min(100%,calc((100dvh - 185px) * var(--ratio)));min-width:230px;height:auto;margin-inline:auto;touch-action:none;border-radius:14px;user-select:none;-webkit-user-select:none}
.controls{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,3.3em),1fr));gap:6px;margin:6px 0 4px}
.controls button{min-height:44px;padding:4px 0;min-width:0;font-size:.9rem;overflow-wrap:anywhere}
.hud .fullscreen-toggle{display:inline-grid;place-items:center;min-width:44px;min-height:44px;padding:4px}
.fullscreen-label{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
@media (max-height:700px) and (orientation:portrait),(orientation:landscape) and (max-height:520px){html.is-playing .top{display:none}}
.sheet{margin:10px 0;padding:14px;border:2px solid var(--ink);border-radius:16px;background:var(--panel);display:grid;gap:8px}
/* The result floats over the controls so it is on screen without scrolling, the board stays visible above it. */
.play .sheet{position:fixed;left:50%;bottom:max(12px,env(safe-area-inset-bottom));transform:translateX(-50%);width:min(calc(100vw - 24px),360px);margin:0;z-index:4;grid-template-columns:1fr 1fr;box-shadow:0 10px 30px rgba(0,0,0,.55)}
.play .sheet h2,.play .sheet p{grid-column:1/-1}
.sheet h2{font-size:1.5rem}
.sheet p{margin:0}

/* Pause menu */
.pause{border:2px solid var(--ink);border-radius:18px;background:var(--panel);color:var(--ink);padding:16px;width:min(92vw,360px)}
.pause::backdrop{background:rgba(5,10,20,.7)}
.pause-actions{display:grid;gap:8px;margin-top:10px}
#leave-confirm{margin-top:10px;display:grid;gap:8px}

.site-footer{width:min(100%,520px);margin:6px auto 0;padding:0 12px 16px;font-size:.85rem;color:var(--muted)}
.site-footer nav{display:flex;flex-wrap:wrap;gap:4px 14px}
.site-footer nav a{display:inline-flex;align-items:center;justify-content:center;min-height:44px;min-width:44px}
.publisher{display:inline-flex;align-items:center;gap:6px;min-height:44px;font-weight:600;text-decoration:none}
.publisher img{width:20px;height:20px;border-radius:5px}
html.large-text .title,html.large-text .who{white-space:normal}

/* Tutorial colours */
:root{--rtgt-bg:#fffdf7;--rtgt-ink:#173d49;--rtgt-muted:#4d6971;--rtgt-line:#a5c6c4;--rtgt-tint:#e0f4ed;--rtgt-accent:#116b69;--rtgt-accent-ink:#fff}

/* Analytics card (shared prompt) */
.rtg-consent{background:var(--panel);color:var(--ink);border:2px solid var(--ink);border-radius:14px;padding:12px}
.rtg-consent button{min-height:44px}
.rtg-consent-floating{position:fixed;left:12px;right:12px;bottom:12px;z-index:5;max-width:420px}

/* Full screen: the whole game inside one screen; the table takes the space left. */
.fullscreen-fit{display:contents}
html.game-fullscreen-lock{overflow:hidden;overscroll-behavior:none}
.game.is-fullscreen{position:fixed;inset:0;z-index:2147483001;width:auto;max-width:none;margin:0;padding:max(8px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));background:var(--bg);overflow:auto;overscroll-behavior:none;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr) auto;align-content:stretch}
.game.is-fullscreen .top{display:none}
.game.is-fullscreen .view{display:contents}
.game.is-fullscreen .view[hidden]{display:none}
.game.is-fullscreen .line{margin:0;min-height:0}
.game.is-fullscreen .fullscreen-fit{display:grid;place-items:center;container-type:size;min-height:0;min-width:0}
.game.is-fullscreen #table{width:min(100cqw,calc(100cqh * var(--ratio)));max-height:none;height:auto;min-width:0}
/* Portrait full screen: each piece in its own row, so the table can never spill over the buttons. */
.game.is-fullscreen .hud{grid-row:1}
.game.is-fullscreen .line{grid-row:2}
.game.is-fullscreen .fullscreen-fit{grid-row:3;overflow:hidden}
.game.is-fullscreen .controls{grid-row:4}
.game.is-fullscreen .sheet{position:fixed;left:50%;bottom:max(16px,env(safe-area-inset-bottom));transform:translateX(-50%);width:min(92vw,340px);margin:0;z-index:2}
.fullscreen-tip{position:fixed;z-index:3;top:60px;left:50%;transform:translateX(-50%);width:min(92vw,400px);display:flex;align-items:center;gap:8px;padding:8px 6px 8px 14px;border-radius:12px;background:var(--ink);color:var(--bg)}
.fullscreen-tip p{margin:0;font-size:.9rem;line-height:1.35}
.fullscreen-tip button{flex:none;display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:10px;background:transparent;color:inherit}
@media (orientation:landscape) and (max-height:520px){
  .game.is-fullscreen{grid-template-columns:minmax(0,1fr) clamp(200px,38vw,330px);grid-template-rows:auto auto auto minmax(0,1fr);column-gap:12px}
  .game.is-fullscreen .fullscreen-fit{grid-column:1;grid-row:1/5}
  .game.is-fullscreen .hud{grid-column:2;grid-row:1}
  .game.is-fullscreen .line{grid-column:2;grid-row:2;font-size:.9rem}
  .game.is-fullscreen .controls{grid-column:2;grid-row:3;grid-template-columns:repeat(3,1fr)}
  .game.is-fullscreen .sheet{position:static;transform:none;width:auto;grid-column:2;grid-row:4;align-self:start;box-shadow:none}
  /* The Home Screen tip sits over the hoops, never over the buttons in the right column. */
  .fullscreen-tip{top:max(10px,env(safe-area-inset-top));left:max(10px,env(safe-area-inset-left));transform:none;width:min(calc(100vw - 360px),400px)}
}
@media (prefers-reduced-motion:reduce){.side.armed .pip{animation:none}}
/* Short landscape phones: the table on the left at the height left, everything else beside it. */
@media (orientation:landscape) and (max-height:520px){
  .game:not(.is-fullscreen){width:min(100%,900px)}
  .game:not(.is-fullscreen) .play:not([hidden]){display:grid;grid-template-columns:auto minmax(0,1fr);column-gap:14px;align-content:start;align-items:start}
  .play #table{grid-column:1;grid-row:1/6;width:calc((100dvh - 64px) * var(--ratio));min-width:0;max-width:60vw;margin:6px 0 0}
  .game:not(.is-fullscreen) .play .hud,.game:not(.is-fullscreen) .play .line,.game:not(.is-fullscreen) .play .controls,.game:not(.is-fullscreen) .play .sheet{grid-column:2}
  .game:not(.is-fullscreen) .play .sheet{left:auto;right:max(12px,env(safe-area-inset-right));transform:none;width:min(46vw,360px)}
  .game:not(.is-fullscreen) .play .controls{grid-template-columns:repeat(3,1fr)}
  .line{min-height:0}
}

/* Privacy and about pages */
.document{width:min(100%,680px);margin:0 auto;padding:8px 16px 24px}
.document-top{width:min(100%,680px);margin:0 auto;padding:6px 16px}
.document h1{font-size:1.7rem;margin:10px 0 12px}
.document h2{font-size:1.2rem;margin:20px 0 6px}
.document details{margin:0 0 12px}
.document summary{cursor:pointer;min-height:44px;display:flex;align-items:center}
.document label{display:flex;align-items:center;gap:10px;min-height:44px}

/* Online play: invite and join sheets, the shot clock, quick chat and the connection note.
   All of it sits outside the table: badges float over the HUD, never over the board.
   Say joins the HUD row only while a live match is on, so the grid adds columns as needed. */
.sheet-dialog{border:2px solid var(--ink);border-radius:18px;background:var(--panel);color:var(--ink);padding:16px;width:min(92vw,380px)}
.sheet-dialog::backdrop{background:rgba(5,10,20,.7)}
.sheet-dialog h2{font-size:1.35rem;margin:0 0 10px}
.sheet-dialog input{width:100%;min-height:46px;padding:0 12px;border:2px solid var(--line);border-radius:12px;background:var(--bg);color:var(--ink);font:inherit;margin:4px 0 10px}
.sheet-dialog input:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
.sheet-dialog label{font-weight:700}
.sheet-actions{display:flex;flex-wrap:wrap;gap:8px;margin:6px 0 10px}
.sheet-actions button{flex:1 1 8rem}
.sheet-error{color:#ad301e;font-weight:650}
.invite-status{color:var(--muted)}
.sheet-dialog{max-height:calc(100dvh - 24px);overflow-y:auto;overscroll-behavior:contain}
.sheet-dialog h3{font-size:1.05rem;margin:16px 0 6px}
.sheet-link{display:inline-flex;align-items:center;min-height:44px;color:var(--ink)}
.people{display:grid;gap:2px}
.people .small{margin:4px 0}
.person{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:2px 10px;padding:6px 0;border-bottom:1px solid var(--line)}
.person-name{font-weight:750;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.person-status{grid-column:1;grid-row:2;font-size:.85rem;color:var(--muted)}
.person-status.online{color:#147151}
.person-actions{grid-column:2;grid-row:1/3;display:flex;gap:6px}
.person-actions button{min-height:44px;padding:4px 12px}
.person-note{grid-column:1/-1;font-size:.85rem;color:var(--muted)}
.person-note:empty{display:none}
.find-form{display:flex;gap:8px}
.find-form input{flex:1 1 auto;min-width:0;margin:0}
.find-form button{flex:none;min-height:46px}
.result-social .sheet-actions{margin:2px 0 0;flex-wrap:nowrap;gap:6px}
.result-social .sheet-actions button{flex:1 1 0;min-width:0;min-height:44px;padding:4px 6px;font-size:.9rem}
.result-social .small{margin:4px 0 0}
.result-social .small:empty{display:none}
/* Online results carry the opponent's name in the buttons: the two actions sit side by side at
   normal text and stack when text is enlarged, labels wrap, and a tall card scrolls. */
.play .sheet{box-sizing:border-box;grid-template-columns:repeat(auto-fit,minmax(min(100%,8.5em),1fr));max-height:calc(100dvh - 24px);overflow-y:auto}
.play .sheet>button{min-width:0;white-space:normal;overflow-wrap:anywhere}
.play .sheet .result-social{grid-column:1/-1}
.result-social .sheet-actions{flex-wrap:wrap}
.result-social .sheet-actions button{flex:1 1 6em;overflow-wrap:anywhere}
.level.online .go{color:var(--accent)}
.side{position:relative}
.clock{position:absolute;top:-14px;right:6px;padding:0 7px;border-radius:9px;background:var(--ink);color:var(--bg);font-size:.8rem;font-weight:800;line-height:1.5;font-variant-numeric:tabular-nums}
.clock.low{background:var(--accent);color:#fff}
.bubble{position:absolute;z-index:2;top:calc(100% + 4px);left:6px;right:6px;padding:4px 10px;border-radius:12px;background:var(--ink);color:var(--bg);font-size:.9rem;font-weight:700;text-align:center}
.hud{position:relative;grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-auto-columns:auto;grid-auto-flow:column}
.who{display:block;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.who::before{display:inline-block;vertical-align:-1px;margin-right:5px}
.game[data-mode="online"] .hud{margin-top:14px}
@media (max-width:379px){
  .game[data-mode="online"] .hud{gap:4px}
  .game[data-mode="online"] .hud .hud-button{padding:4px}
  .game[data-mode="online"] .side{padding:4px}
  .game[data-mode="online"] .pip{width:12px;height:15px}
}
.net{position:absolute;z-index:3;left:50%;top:50%;transform:translate(-50%,-50%);margin:0;padding:4px 12px;border-radius:12px;background:var(--accent);color:#fff;font-weight:750;font-size:.9rem;white-space:nowrap}
.quick-chat{position:absolute;z-index:4;right:0;top:100%;display:grid;grid-template-columns:1fr 1fr;gap:8px;width:min(100%,320px);padding:10px;border:2px solid var(--ink);border-radius:14px;background:var(--panel)}
.quick-chat button{min-height:44px;font-size:.95rem;padding:6px 8px}
#result-series{margin:0}

/* Sunlit arcade: painted controls, warm paper and a cabinet that carries the colour. */
button{box-shadow:0 3px 0 #d0ded7;transition:transform .12s,box-shadow .12s,background .12s}
button:active:not(:disabled){transform:translateY(2px);box-shadow:0 1px 0 #d0ded7}
button:disabled{box-shadow:none}
.primary{box-shadow:0 3px 0 #084d50}
.primary:hover:not(:disabled){background:#0c5b5b;border-color:#084d50}
.quiet{box-shadow:none}
#table{box-shadow:0 5px 0 #c7dcd3,0 12px 28px #23514d14;border-radius:18px}
#table:focus:not(:focus-visible){outline:none}
#table:focus-visible{outline:3px solid #c84927;outline-offset:4px}
.side{background:#fffdf7}
.controls #shoot{background:#d7472c;border-color:#b43b24;color:white;box-shadow:0 3px 0 #963822}
.controls #shoot:hover:not(:disabled){background:#bd3e25}
.controls{margin-top:10px;margin-bottom:8px}
.play .sheet{box-shadow:0 6px 0 #b7d4ca,0 18px 45px #163d4930;border-color:#477976}
.sheet-dialog::backdrop,.pause::backdrop{background:#123c4b66;backdrop-filter:blur(4px)}
@media(prefers-reduced-motion:reduce){button{transition:none}}

@media(min-width:701px) and (min-height:521px){.game:not(.is-fullscreen) #table{width:min(100%,calc((100dvh - 225px) * var(--ratio)))}}
