@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-style: normal; font-display: swap; src: url('../fonts/barlow-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-style: normal; font-display: swap; src: url('../fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-style: italic; font-display: swap; src: url('../fonts/barlow-condensed-latin-700-italic.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 800; font-style: normal; font-display: swap; src: url('../fonts/barlow-condensed-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 800; font-style: italic; font-display: swap; src: url('../fonts/barlow-condensed-latin-800-italic.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url('../fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url('../fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url('../fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-display: swap; src: url('../fonts/inter-latin-700-normal.woff2') format('woff2'); }

/* Warm and plain: dark glass plates over the sunny room, and a paper scorecard. */
:root {
  --ink: #f6f0e4;
  --dim: rgba(246, 240, 228, 0.66);
  --faint: rgba(246, 240, 228, 0.16);
  --glass: rgba(26, 20, 14, 0.58);
  --glass2: rgba(30, 24, 18, 0.8);
  --line: rgba(255, 244, 222, 0.14);
  --accent: #ffc94d;
  --felt: #2c7a3c;
  --red: #e0442f;
  --green: #6fd08c;
  --paper: #f3ebdb;
  --paper-ink: #2a241c;
  --paper-line: rgba(42, 36, 28, 0.16);
  --display: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --blur: blur(14px) saturate(1.15);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1c1712; color: var(--ink); font-family: var(--body); font-weight: 500; user-select: none; -webkit-user-select: none; touch-action: none; -webkit-font-smoothing: antialiased; }
canvas#gl, canvas#overlay { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas#overlay { pointer-events: none; z-index: 2; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.small { font-size: 0.85rem; }
kbd { display: inline-block; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.08); font: 600 0.78em var(--body); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--ink); }
h2 { font: italic 800 2rem/1 var(--display); text-transform: uppercase; letter-spacing: 0.02em; margin: 0; }
.ico { width: 1em; height: 1em; vertical-align: -0.12em; }

.panel { background: var(--glass2); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); }
.btn { border: 1px solid var(--line); border-radius: 10px; padding: 11px 20px; font: italic 800 1.1rem var(--display); letter-spacing: 0.06em; text-transform: uppercase; background: rgba(255, 255, 255, 0.07); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background 0.15s, transform 0.08s; }
.btn:hover { background: rgba(255, 255, 255, 0.14); }
.btn:active { transform: scale(0.98); }
.btn.yellow { background: var(--accent); color: #1f160a; border-color: transparent; }
.btn.yellow:hover { background: #ffd66e; }
.btn.ghost { background: transparent; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); font-size: 1.25rem; color: var(--ink); display: grid; place-items: center; padding: 0; }
.round.on { background: var(--accent); color: #1f160a; }
.col { display: flex; flex-direction: column; gap: 10px; }
.kicker { font: italic 700 0.85rem var(--display); letter-spacing: 0.3em; color: var(--accent); }
.wordmark { font: italic 800 clamp(3.4rem, 9vw, 7rem) / 0.86 var(--display); letter-spacing: -0.01em; color: #fff; text-transform: uppercase; text-shadow: 0 8px 40px rgba(0, 0, 0, 0.45); margin: 6px 0 0; }
.dot { display: inline-block; width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%; box-shadow: inset -3px -4px 6px rgba(0, 0, 0, 0.45), inset 3px 3px 5px rgba(255, 255, 255, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.15); }

/* ---------- screens ---------- */
#screens { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.screen { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); pointer-events: auto; overflow-y: auto; }
.screen.overlay { background: radial-gradient(ellipse at center, rgba(14, 11, 8, 0.25), rgba(14, 11, 8, 0.7)); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#s-loading { background: radial-gradient(ellipse at 30% 40%, #3a2e22, #120f0d 70%); }
.loading { width: min(520px, 90vw); }
.loading .wordmark { font-size: clamp(2.6rem, 8vw, 4.4rem); }
.loadbar { height: 2px; background: var(--faint); margin: 22px 0 12px; overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 35%; background: var(--accent); animation: load 1.2s ease-in-out infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
#loading-text { color: var(--dim); font-size: 0.92rem; margin: 0; }

/* menu */
#s-menu { place-items: center start; background: linear-gradient(90deg, rgba(14, 10, 7, 0.8) 0%, rgba(14, 10, 7, 0.5) 36%, rgba(14, 10, 7, 0) 64%); padding-left: max(16px, min(6vw, 96px)); }
.menu-wrap { width: min(430px, 100%); display: flex; flex-direction: column; gap: 20px; }
.brand .tagline { color: var(--dim); font-size: 0.98rem; line-height: 1.5; margin: 14px 0 0; max-width: 400px; }
.menu-card { display: flex; flex-direction: column; gap: 10px; }
.seg { display: flex; align-items: center; gap: 6px; }
.seg span { font: 700 0.68rem var(--body); letter-spacing: 0.18em; color: var(--dim); margin-right: 6px; }
.seg button { width: 42px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); font: italic 800 1.2rem var(--display); }
.seg button.on { background: var(--accent); color: #1f160a; border-color: transparent; }
.seg.course button { width: auto; flex: 1 1 0; min-width: 0; padding: 0 6px; font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
#m-players { display: flex; flex-direction: column; gap: 6px; }
.prow { display: flex; gap: 8px; align-items: center; }
.prow .skin { border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, 0.06); padding: 6px 8px; display: grid; place-items: center; }
.prow .skin .dot { width: 26px; height: 26px; }
.prow input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px; background: rgba(255, 255, 255, 0.06); font-weight: 600; outline: none; }
.prow input:focus { border-color: var(--accent); }
.mbtn { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%; padding: 14px 18px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, 0.06); text-align: left; transition: background 0.15s, transform 0.15s; }
.mbtn span { font: italic 800 1.6rem/1 var(--display); text-transform: uppercase; letter-spacing: 0.03em; }
.mbtn small { color: var(--dim); font-size: 0.8rem; }
.mbtn:hover { background: rgba(255, 255, 255, 0.12); transform: translateX(4px); }
.mbtn.primary { background: var(--accent); color: #1f160a; border-color: transparent; }
.mbtn.primary small { color: rgba(31, 22, 10, 0.7); }
.hole-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.hole-grid button { border: 1px solid var(--line); border-radius: 9px; background: rgba(255, 255, 255, 0.06); padding: 8px 10px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.hole-grid button b { font: italic 800 1.25rem/1 var(--display); }
.hole-grid button small { color: var(--dim); font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hole-grid button .g { color: #7fe6ff; }
.hole-grid .room-h { grid-column: 1 / -1; font: 700 0.64rem var(--body); letter-spacing: 0.18em; color: var(--dim); text-transform: uppercase; margin: 4px 0 -1px; }
.hole-grid .room-h:first-child { margin-top: 0; }
.roomload { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 30% 40%, #3a2e22, #120f0d 70%); opacity: 0; transition: opacity 0.3s; pointer-events: auto; }
.roomload.on { opacity: 1; }
.roomload p { color: var(--dim); font-size: 0.92rem; margin: 0; }
.menu-foot { display: flex; gap: 26px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; line-height: 1; }
.stat small { font: 700 0.62rem var(--body); letter-spacing: 0.16em; color: var(--dim); }
.stat b { font: italic 800 1.7rem var(--display); margin-top: 3px; }
.links { display: flex; gap: 18px; flex-wrap: wrap; }
.link { background: none; border: none; padding: 4px 0; color: var(--dim); font: 600 0.9rem var(--body); text-decoration: none; border-bottom: 1px solid transparent; }
.link:hover { color: var(--ink); border-bottom-color: var(--accent); }

/* dialogs */
.dialog { padding: 24px; width: min(440px, 100%); text-align: center; display: flex; flex-direction: column; gap: 16px; }
.dialog.wide { width: min(760px, 100%); }
.help { text-align: left; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 18px; }
.help-grid b { font: italic 800 1.15rem var(--display); text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
.help-grid p { margin: 4px 0 0; font-size: 0.9rem; line-height: 1.45; color: var(--dim); }
.keys { margin: 0; }
.form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.form label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 600; }
.form select { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.form select option { color: #111; }
.mix-row { display: grid; grid-template-columns: 1fr 140px; align-items: center; gap: 10px; font-size: 0.88rem; color: var(--dim); }
.mix-row input { width: 100%; accent-color: var(--accent); }
/* ---------- marble showroom (the 3D shelf fills the screen behind this; ported from LOST MARBLES) ---------- */
.screen.showroom { display: flex; flex-direction: column; justify-content: space-between; align-items: stretch; place-items: initial; padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(14px + var(--safe-b)) calc(16px + var(--safe-l)); background: linear-gradient(180deg, rgba(14, 10, 7, 0.6), transparent 20%, transparent 60%, rgba(14, 10, 7, 0.74)); overflow: hidden; }
.sr-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sr-head { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sr-head h2 { font-size: 1.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-head small { font-size: 0.8rem; }
.sr-wallet { margin-left: auto; display: flex; align-items: center; gap: 5px; font: italic 800 1rem var(--display); letter-spacing: 0.06em; color: var(--dim); text-transform: uppercase; white-space: nowrap; }
.sr-wallet b { color: #7fe6ff; font-size: 1.3rem; }
.sr-wallet .ico { color: #7fe6ff; }
.sr-arrow { position: absolute; top: 46%; width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); color: var(--ink); font-size: 1.6rem; display: grid; place-items: center; transform: translateY(-50%); padding: 0; }
.sr-arrow.left { left: calc(16px + var(--safe-l)); }
.sr-arrow.right { right: calc(16px + var(--safe-r)); }
.sr-arrow:disabled { opacity: 0.25; cursor: default; }
.sr-bottom { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.sr-info { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; max-width: 100%; }
.sr-info small { font: 700 0.72rem var(--body); letter-spacing: 0.2em; color: var(--accent); text-transform: uppercase; min-height: 1em; }
.sr-info h3 { margin: 0; font: italic 800 2.4rem/1 var(--display); text-transform: uppercase; color: #fff; text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6); }
.sr-how { margin: 2px 0 6px; min-height: 1.2em; font-size: 0.9rem; color: var(--ink); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85); }
.sr-how .ico { color: #7fe6ff; }
.sr-acts { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.sr-acts #sr-act { min-width: 200px; }
.sr-acts .btn.picked { background: rgba(111, 208, 140, 0.16); border: 1px solid var(--green); color: var(--green); }
.sr-acts .btn:disabled { cursor: default; }
.sr-acts .btn.yellow:disabled { background: rgba(255, 255, 255, 0.07); color: var(--dim); border-color: var(--line); }
.sr-strip { display: flex; gap: 10px; overflow-x: auto; max-width: 100%; padding: 6px 4px 8px; scroll-behavior: smooth; scrollbar-width: none; }
.sr-strip::-webkit-scrollbar { display: none; }
.sr-strip button { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: 2px solid transparent; padding: 0; position: relative; box-shadow: inset -5px -6px 10px rgba(0, 0, 0, 0.45), inset 5px 5px 8px rgba(255, 255, 255, 0.5); }
.sr-strip button.on { border-color: var(--accent); transform: scale(1.12); }
.sr-strip button.lock { filter: saturate(0.35) brightness(0.6); }
.sr-strip button.taken { opacity: 0.5; }
.sr-strip button .ico { position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; padding: 2px; border-radius: 50%; background: #111; color: var(--ink); }
.sr-strip button.mine .ico { background: var(--green); color: #08210f; }
.sr-strip button .who { position: absolute; right: -4px; bottom: -4px; min-width: 16px; height: 16px; border-radius: 8px; background: #111; color: var(--ink); font: 700 0.62rem/16px var(--body); text-align: center; }
/* Marble workshop: a sheet over the bottom of the showroom, the marble lifted above it. */
.showroom.working .sr-bottom, .showroom.working .sr-arrow, .showroom.working #mk-done, .showroom.working #sr-count { display: none; }
.showroom.working { background: linear-gradient(180deg, rgba(14, 10, 7, 0.6), transparent 16%); }
.sr-work { align-self: center; width: min(640px, 100%); display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 10px; border-radius: 16px; }
.sw-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn.tiny { min-width: 86px; min-height: 40px; padding: 7px 14px; font-size: 1rem; }
.sw-title { display: flex; flex-direction: column; align-items: center; min-width: 0; text-align: center; }
.sw-title small { font: 700 0.62rem var(--body); letter-spacing: 0.24em; color: var(--accent); }
.sw-title b { font: italic 800 1.35rem/1.05 var(--display); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sw-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.sw-tabs::-webkit-scrollbar { display: none; }
.sw-tab { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); color: var(--dim); font: italic 700 1rem var(--display); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.sw-tab i { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; box-shadow: inset -2px -3px 4px rgba(0, 0, 0, 0.45), inset 2px 2px 3px rgba(255, 255, 255, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.18); }
.sw-tab.on { color: var(--ink); border-color: var(--accent); background: rgba(255, 201, 77, 0.12); }
.sw-hint { min-height: 1.1em; font-size: 0.8rem; color: var(--dim); text-align: center; }
.sw-body.swatches { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 8px; }
.sw { position: relative; aspect-ratio: 1; width: 100%; min-width: 0; padding: 0; border-radius: 50%; border: 0; color: rgba(255, 255, 255, 0.9);
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.85) 0 7%, rgba(255, 255, 255, 0) 16%), var(--c);
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.85) 0 7%, rgba(255, 255, 255, 0) 16%), radial-gradient(circle at 50% 58%, var(--c) 0 42%, color-mix(in srgb, var(--c) 62%, #000) 100%);
  box-shadow: inset -3px -5px 8px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.14), 0 4px 10px rgba(0, 0, 0, 0.35); transition: transform 0.1s; }
.sw:active { transform: scale(0.92); }
.sw.on { box-shadow: inset -3px -5px 8px rgba(0, 0, 0, 0.35), 0 0 0 2px #15110c, 0 0 0 4px var(--accent); }
.sw.orig .ico { position: absolute; inset: 0; margin: auto; width: 46%; height: 46%; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8)); }
.sw-body.glass .sw { background: radial-gradient(circle at 34% 28%, #fff 0 7%, rgba(255, 255, 255, 0) 16%), var(--c);
  background: radial-gradient(circle at 34% 28%, #fff 0 7%, rgba(255, 255, 255, 0) 16%), radial-gradient(circle at 50% 62%, var(--c) 0 38%, color-mix(in srgb, var(--c) 55%, #3c4048) 100%); }
.sw-body.glass .sw.orig .ico { color: rgba(0, 0, 0, 0.55); filter: none; }
.sw-body.finishes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.sw-fin { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 8px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--ink); }
.sw-fin .ball { width: 46px; height: 46px; border-radius: 50%; box-shadow: inset -6px -8px 12px rgba(0, 0, 0, 0.45), inset 6px 6px 10px rgba(255, 255, 255, 0.5), 0 8px 16px rgba(0, 0, 0, 0.35); }
.sw-fin b { font: italic 800 1.05rem/1 var(--display); text-transform: uppercase; letter-spacing: 0.04em; }
.sw-fin small { display: inline-flex; align-items: center; gap: 4px; font: 700 0.66rem var(--body); letter-spacing: 0.1em; color: var(--dim); text-transform: uppercase; white-space: nowrap; }
.sw-fin.lock small { color: #7fe6ff; }
.sw-fin.on { border-color: var(--accent); background: rgba(255, 201, 77, 0.12); }
.sw-fin.on small { color: var(--green); }
.sw-fin.on.lock small { color: #7fe6ff; }
.sw-foot { display: flex; justify-content: center; gap: 26px; }
.sw-foot .link { min-height: 34px; display: inline-flex; align-items: center; gap: 6px; }
.sw-foot .link:disabled { opacity: 0.35; }
@media (max-width: 760px) {
  .sr-work { width: calc(100% + 8px); margin: 0 -4px; padding: 10px 10px 8px; }
  .sw-body.swatches { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px 9px; }
  .sw-body.finishes { gap: 6px; }
  .sw-fin .ball { width: 40px; height: 40px; }
  .sw-tabs { gap: 5px; }
  .sw-tab { flex: 1 1 0; flex-direction: column; gap: 3px; min-width: 56px; padding: 6px 4px 5px; font-size: 0.82rem; }
  .sr-acts { flex-wrap: nowrap; width: 100%; }
  .sr-acts #sr-act { min-width: 0; flex: 1 1 auto; max-width: 240px; }
}
@media (max-width: 520px) {
  .sr-arrow { width: 44px; height: 44px; top: 40%; }
  .sr-arrow.left { left: 8px; }
  .sr-arrow.right { right: 8px; }
  .sr-info h3 { font-size: 1.9rem; }
  .sr-top { align-items: flex-start; }
  .sr-head h2 { font-size: 1.45rem; white-space: normal; line-height: 0.95; }
  .sr-wallet { font-size: 0.85rem; padding-top: 10px; }
}
/* Phones on their side: keep the wide swatch grid, shrink the shelf chrome and let the workshop scroll. */
@media (max-height: 500px) and (orientation: landscape) {
  .screen.showroom { padding-top: calc(8px + var(--safe-t)); padding-bottom: calc(6px + var(--safe-b)); }
  .sr-head h2 { font-size: 1.4rem; }
  .sr-head small { display: none; }
  .sr-info h3 { font-size: 1.6rem; }
  .sr-info small { display: none; }
  .sr-how { margin: 0 0 4px; font-size: 0.82rem; }
  .sr-bottom { gap: 6px; }
  .sr-acts .btn { padding: 8px 16px; }
  .sr-strip { padding: 2px 4px 4px; }
  .sr-strip button { width: 36px; height: 36px; }
  /* A compact workshop sheet, so the marble above it stays in view. */
  .sr-work { width: min(560px, 100%); margin: 0 auto; gap: 5px; padding: 6px 10px 4px; }
  .sw-title small { display: none; }
  .sw-title b { font-size: 1.15rem; }
  .btn.tiny { min-height: 32px; padding: 4px 12px; }
  .sw-tab { min-height: 30px; padding: 3px 8px; font-size: 0.9rem; flex-direction: row; }
  .sw-hint { min-height: 0; font-size: 0.72rem; }
  .sw-body.swatches { grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 5px; }
  .sw-body { max-height: 34vh; overflow-y: auto; }
  .sw-fin { padding: 5px 4px 4px; gap: 2px; }
  .sw-fin .ball { width: 30px; height: 30px; }
  .sw-foot .link { min-height: 24px; padding: 0; }
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.plate { background: var(--glass); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
#hud-hole { position: absolute; left: calc(12px + var(--safe-l)); top: calc(12px + var(--safe-t)); display: flex; align-items: center; gap: 12px; padding: 7px 14px 7px 10px; }
.hole-n { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.hole-n small { font: 700 0.56rem var(--body); letter-spacing: 0.16em; color: var(--dim); }
.hole-n b { font: italic 800 2rem/0.95 var(--display); }
.hole-meta { display: flex; flex-direction: column; line-height: 1.1; }
.hole-meta b { font: italic 800 1.15rem var(--display); text-transform: uppercase; letter-spacing: 0.03em; }
.hole-meta span { font: 700 0.68rem var(--body); letter-spacing: 0.14em; color: var(--accent); }
.hole-meta i { font-style: normal; }
#hud-right { position: absolute; right: calc(12px + var(--safe-r)); top: calc(12px + var(--safe-t)); display: flex; gap: 8px; align-items: stretch; }
#hud-player { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; font: italic 800 1.05rem var(--display); text-transform: uppercase; }
#hud-stroke { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 5px 14px; line-height: 1; }
#hud-stroke small { font: 700 0.56rem var(--body); letter-spacing: 0.16em; color: var(--dim); }
#hud-stroke b { font: italic 800 1.8rem/0.95 var(--display); }
#hud-bag { position: absolute; left: calc(12px + var(--safe-l)); bottom: calc(30px + var(--safe-b)); display: flex; gap: 8px; pointer-events: auto; }
.slot { width: 58px; height: 58px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); display: grid; place-items: center; font-size: 1.6rem; position: relative; color: var(--ink); padding: 0; }
.slot.empty { opacity: 0.35; border-style: dashed; }
.slot.armed { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 24px rgba(255, 201, 77, 0.35); }
.slot small { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); white-space: nowrap; font: 700 0.6rem var(--body); letter-spacing: 0.1em; color: var(--ink); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8); text-transform: uppercase; }
#hud-buttons { position: absolute; right: calc(12px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.pill-btn { height: 46px; border-radius: 23px; border: 1px solid var(--line); background: var(--glass); backdrop-filter: var(--blur); padding: 0 16px; font: italic 800 1rem var(--display); letter-spacing: 0.05em; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
#hud-power { position: absolute; left: 0; top: 0; transform: translate(-50%, -140%); font: italic 800 1.5rem var(--display); text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7); }
#hud-power small { font-size: 0.8rem; margin-left: 1px; }
#hud-tap { position: absolute; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); padding: 10px 18px; border-radius: 24px; background: var(--accent); color: #1f160a; font: italic 800 1.15rem var(--display); letter-spacing: 0.06em; text-transform: uppercase; animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.06); } }
#hud-hint { position: absolute; left: 50%; bottom: calc(26px + var(--safe-b)); transform: translateX(-50%); width: min(560px, calc(100% - 300px)); text-align: center; color: var(--ink); font-size: 0.9rem; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85); transition: opacity 0.4s; }
#hud-hint:empty { opacity: 0; }
#banner { position: absolute; left: 0; right: 0; top: 30%; display: flex; flex-direction: column; align-items: center; gap: 4px; opacity: 0; transform: scale(0.94); transition: opacity 0.25s, transform 0.25s; text-align: center; padding: 0 16px; }
#banner.on { opacity: 1; transform: none; }
#banner b { font: italic 800 clamp(2.6rem, 9vw, 5.4rem)/0.9 var(--display); text-transform: uppercase; color: #fff; text-shadow: 0 6px 36px rgba(0, 0, 0, 0.55), 0 2px 4px rgba(0, 0, 0, 0.4); }
#banner span { font: italic 700 clamp(1rem, 3.6vw, 1.5rem) var(--display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7); }
#banner.skill b { font-size: clamp(1.9rem, 6.5vw, 3.6rem); color: var(--accent); }
#banner.skill span { color: #fff; }
/* A soft shade behind banner text so it reads over the bright room, without a box. */
#banner { isolation: isolate; }
#banner::before { content: ''; position: absolute; left: 50%; top: 50%; width: min(760px, 100%); height: calc(100% + 56px); transform: translate(-50%, -50%); background: radial-gradient(closest-side, rgba(22, 15, 9, 0.42), rgba(22, 15, 9, 0)); z-index: -1; pointer-events: none; }
#banner b, #banner span { max-width: 100%; overflow-wrap: anywhere; }

/* Instant replay: letterbox bars, a small REPLAY tag, and the playing HUD tucked away. */
#letterbox i { position: absolute; left: 0; right: 0; height: 7vh; background: #0d0a07; transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1); }
#letterbox i:first-child { top: 0; transform: translateY(-100%); }
#letterbox i:last-child { bottom: 0; transform: translateY(100%); }
#hud.replaying #letterbox i { transform: none; }
#hud-hole, #hud-right, #hud-bag, #hud-buttons, #hud-hint { transition: opacity 0.3s; }
#hud.replaying #hud-hole, #hud.replaying #hud-right, #hud.replaying #hud-bag, #hud.replaying #hud-buttons, #hud.replaying #hud-hint, #hud.replaying #banner { opacity: 0; pointer-events: none; }
#replay-tag { position: absolute; left: 50%; top: calc(7vh + 12px); transform: translateX(-50%); display: flex; align-items: baseline; gap: 10px; padding: 6px 14px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); white-space: nowrap; }
#replay-tag b { font: italic 800 1.1rem/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; }
#replay-tag small { font: 700 0.62rem var(--body); letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }
#replay-tag .rec { width: 8px; height: 8px; border-radius: 50%; background: #e2493b; align-self: center; animation: rec 1.1s ease-in-out infinite; }
@keyframes rec { 50% { opacity: 0.25; } }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 5; transition: opacity 0.5s; }
#toast { position: fixed; left: 50%; top: calc(84px + var(--safe-t)); transform: translate(-50%, -10px); background: var(--glass2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 16px; font-size: 0.9rem; opacity: 0; transition: opacity 0.25s, transform 0.25s; z-index: 40; pointer-events: none; max-width: calc(100% - 32px); text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- scorecard (paper) ---------- */
.scorecard { width: min(720px, 100%); background: var(--paper); color: var(--paper-ink); border-radius: 6px; padding: 20px 20px 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.06); display: flex; flex-direction: column; gap: 14px; background-image: linear-gradient(rgba(255, 255, 255, 0.35), rgba(0, 0, 0, 0.03)); }
.sc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sc-head small { font: 700 0.7rem var(--body); letter-spacing: 0.2em; color: rgba(42, 36, 28, 0.6); }
.sc-head h2 { font-size: clamp(2rem, 7vw, 3rem); color: var(--paper-ink); margin-top: 2px; }
.sc-head p { margin: 4px 0 0; color: rgba(42, 36, 28, 0.72); font-size: 0.92rem; }
.sc-gem { font: italic 800 1rem var(--display); color: #127b9a; letter-spacing: 0.06em; text-transform: uppercase; text-align: right; }
.sc-table-wrap { overflow-x: auto; }
.scorecard table { border-collapse: collapse; width: 100%; font: 600 0.92rem var(--body); font-variant-numeric: tabular-nums; }
.scorecard th, .scorecard td { border: 1px solid var(--paper-line); padding: 6px 4px; text-align: center; min-width: 30px; }
.scorecard th { font: 700 0.66rem var(--body); letter-spacing: 0.1em; color: rgba(42, 36, 28, 0.6); }
.scorecard td.name { text-align: left; padding-left: 8px; white-space: nowrap; font-weight: 700; min-width: 80px; }
.scorecard td.name .dot { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; }
.scorecard tr.par td { color: rgba(42, 36, 28, 0.6); font-weight: 600; }
.scorecard td.cur { background: rgba(255, 201, 77, 0.28); }
.scorecard td.tot { font-weight: 800; }
.scorecard td .s { display: inline-grid; place-items: center; width: 24px; height: 24px; }
.scorecard td .s.under { border: 1.5px solid #c42a1c; border-radius: 50%; color: #c42a1c; }
.scorecard td .s.ace { border: 1.5px solid #c42a1c; border-radius: 50%; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px #c42a1c; color: #c42a1c; }
.scorecard td .s.over { border: 1.5px solid rgba(42, 36, 28, 0.55); }
/* An 18-hole card is two stacked nines (OUT under the front, IN and TOT under the back), so it fits a phone. */
.scorecard table.half + table.half { margin-top: 8px; }
.scorecard th.sum, .scorecard td.sum { background: rgba(42, 36, 28, 0.05); font-weight: 800; }
.scorecard td.tot small { font-weight: 600; color: rgba(42, 36, 28, 0.62); }
.sc-foot { display: flex; justify-content: flex-end; gap: 10px; }
.scorecard .btn.ghost { color: var(--paper-ink); border-color: var(--paper-line); }
#fn-unlocks { display: flex; flex-wrap: wrap; gap: 8px; }
#fn-unlocks:empty { display: none; }
.unlock { display: flex; align-items: center; gap: 8px; background: rgba(42, 36, 28, 0.06); border-radius: 8px; padding: 6px 10px; font-size: 0.86rem; font-weight: 600; }

@media (max-width: 640px) {
  #s-menu { place-items: end center; padding-left: 16px; background: linear-gradient(0deg, rgba(14, 10, 7, 0.86) 0%, rgba(14, 10, 7, 0.6) 55%, rgba(14, 10, 7, 0) 85%); }
  .menu-wrap { gap: 14px; }
  .wordmark { font-size: 3.6rem; }
  .brand .tagline { font-size: 0.88rem; margin-top: 8px; }
  .mbtn { padding: 12px 14px; }
  .mbtn span { font-size: 1.35rem; }
  #hud-hole { padding: 5px 10px 5px 8px; gap: 9px; }
  .hole-n b { font-size: 1.6rem; }
  .hole-meta b { font-size: 0.98rem; max-width: 34vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #hud-player b { max-width: 22vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #hud-player { padding: 5px 9px 5px 6px; font-size: 0.95rem; }
  #hud-stroke b { font-size: 1.5rem; }
  #hud-hint { width: calc(100% - 32px); bottom: calc(100px + var(--safe-b)); font-size: 0.84rem; }
  .slot { width: 52px; height: 52px; }
  .scorecard { padding: 16px 12px 12px; }
  .scorecard th, .scorecard td { padding: 5px 2px; min-width: 24px; font-size: 0.82rem; }
}

/* Phones on their side: short screens. */
@media (max-height: 500px) {
  .menu-wrap { gap: 10px; }
  .wordmark { font-size: 2.8rem; }
  .brand .tagline { display: none; }
  .mbtn { padding: 9px 14px; }
  .mbtn span { font-size: 1.2rem; }
  .menu-foot .stat b { font-size: 1.3rem; }
  .scorecard { padding: 12px; gap: 8px; }
  .sc-head h2 { font-size: 1.8rem; }
  #hud-hint { width: min(420px, calc(100% - 320px)); }
}
/* Phones: a nine of the scorecard (9 holes + IN + TOT) fits 390 px without scrolling. */
@media (max-width: 440px) {
  .scorecard { padding: 14px 10px 10px; }
  .scorecard th, .scorecard td { padding: 4px 1px; min-width: 21px; font-size: 0.78rem; }
  .scorecard th { font-size: 0.6rem; letter-spacing: 0.04em; }
  .scorecard td .s { width: 20px; height: 20px; }
  .scorecard td.name { min-width: 0; max-width: 78px; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }
  .scorecard td.name .dot { width: 11px; height: 11px; margin-right: 4px; }
  .scorecard td.tot small { display: block; font-size: 0.64rem; line-height: 1.1; }
}
@media (max-width: 400px) {
  .hole-meta b { max-width: 26vw; }
  #hud-player b { max-width: 18vw; }
}
