Skip to the content

Sugoroku双六

Play backgammon and its relatives with native rules, cube and match scoring, seeded dice and replayable records.

Sugoroku is the Japanese name 双六 for games of tables. About the name

Contents

Reference · Playable board

SUGOROKU_PLAY_STYLEconstant

THE STYLE a playable Sugoroku board wears (mountSugoroku, <sugoroku-board>): the drawing's own (SUGOROKU_STYLE), the board's box, its buttons and its lines of words. Colours are custom properties on .sugoroku-play (--sgp-ink, --sgp-muted, --sgp-rule, --sgp-surface, --sgp-accent, --sgp-good) so a page sets only what it wants different.

Nothing moves when something happens: the board is one box of one shape (set from the drawing's own proportions), the line of words keeps room for two lines, and the buttons are three of one size in the same places whatever they say. Nothing the player touches can be selected.

Import it

import { SUGOROKU_PLAY_STYLE } from "@johnmorrisdotca/sugoroku/play";

Definition

const SUGOROKU_PLAY_STYLE: "\n.sugoroku {\n  --sg-frame: #5b3a1f; --sg-felt: var(--felt, #2f5d4a); --sg-point-a: #e7d8b1; --sg-point-b: #8e3a2b; --sg-bar: #4a2f19; --sg-tray: #24493a;\n  --sg-white: #f6f0df; --sg-white-edge: #b3a888; --sg-black: #2b2724; --sg-black-edge: #0d0b0a;\n  --sg-number: #e8dcc0; --sg-selected: #ffd23f; --sg-target: #7fe3a1; --sg-die: #fbf8f1; --sg-pip: #1f2320; --sg-cube: #fbf8f1; --sg-cube-ink: #1f2320;\n  display: block; width: 100%; height: auto; overflow: visible;\n  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;\n  font-family: system-ui, -apple-system, \"Segoe UI\", sans-serif;\n}\n@media (prefers-color-scheme: dark) {\n  :root:not([data-theme=\"light\"]) .sugoroku:not([data-theme=\"light\"]) {\n    --sg-frame: #2b1c0e; --sg-felt: var(--felt, #1f4135); --sg-point-a: #bdad88; --sg-point-b: #6b2a1f; --sg-bar: #21160b; --sg-tray: #173026;\n    --sg-white: #e9e3d0; --sg-white-edge: #9a9078; --sg-number: #b9ae92; --sg-die: #e9e3d0; --sg-cube: #e9e3d0;\n  }\n}\n:root[data-theme=\"dark\"] .sugoroku:not([data-theme=\"light\"]), .sugoroku[data-theme=\"dark\"] {\n  --sg-frame: #2b1c0e; --sg-felt: var(--felt, #1f4135); --sg-point-a: #bdad88; --sg-point-b: #6b2a1f; --sg-bar: #21160b; --sg-tray: #173026;\n  --sg-white: #e9e3d0; --sg-white-edge: #9a9078; --sg-number: #b9ae92; --sg-die: #e9e3d0; --sg-cube: #e9e3d0;\n}\n.sugoroku * { user-select: none; -webkit-user-select: none; }\n.sugoroku .sg-frame { fill: var(--sg-frame); }\n.sugoroku .sg-felt { fill: var(--sg-felt); }\n.sugoroku .sg-rail, .sugoroku .sg-tray-well { fill: var(--sg-tray); }\n.sugoroku .sg-bar { fill: var(--sg-bar); }\n.sugoroku .sg-point[data-tone=\"a\"] .sg-triangle { fill: var(--sg-point-a); }\n.sugoroku .sg-point[data-tone=\"b\"] .sg-triangle { fill: var(--sg-point-b); }\n.sugoroku .sg-hit { fill: transparent; }\n.sugoroku .sg-bar-hit { fill: transparent; }\n.sugoroku .sg-tray { fill: rgba(0, 0, 0, .18); stroke: rgba(0, 0, 0, .25); stroke-width: 1; }\n.sugoroku .sg-number { fill: var(--sg-number); font-size: 11px; font-weight: 600; pointer-events: none; }\n.sugoroku .sg-checker { pointer-events: none; }\n.sugoroku .sg-checker[data-side=\"white\"] .sg-face { fill: var(--sg-white); stroke: var(--sg-white-edge); stroke-width: 2; }\n.sugoroku .sg-checker[data-side=\"black\"] .sg-face { fill: var(--sg-black); stroke: var(--sg-black-edge); stroke-width: 2; }\n.sugoroku .sg-checker[data-side=\"white\"] .sg-ring { fill: none; stroke: var(--sg-white-edge); stroke-width: 1.5; opacity: .7; }\n.sugoroku .sg-checker[data-side=\"black\"] .sg-ring { fill: none; stroke: var(--sg-black-edge); stroke-width: 1.5; opacity: .9; }\n.sugoroku .sg-gleam { fill: #fff; opacity: .16; }\n.sugoroku .sg-checker[data-side=\"white\"] .sg-count { fill: var(--sg-pip); }\n.sugoroku .sg-checker[data-side=\"black\"] .sg-count { fill: var(--sg-white); }\n.sugoroku .sg-count { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; pointer-events: none; }\n.sugoroku .sg-off[data-side=\"white\"] { fill: var(--sg-white); stroke: var(--sg-white-edge); stroke-width: 1.5; pointer-events: none; }\n.sugoroku .sg-off[data-side=\"black\"] { fill: var(--sg-black); stroke: var(--sg-black-edge); stroke-width: 1.5; pointer-events: none; }\n.sugoroku .sg-die { pointer-events: none; }\n.sugoroku .sg-die rect { fill: var(--sg-die); stroke: rgba(0, 0, 0, .35); stroke-width: 1.5; }\n.sugoroku .sg-die[data-spent=\"true\"] { opacity: .38; }\n.sugoroku .sg-pip { fill: var(--sg-pip); }\n.sugoroku .sg-cube { pointer-events: none; }\n.sugoroku .sg-cube rect { fill: var(--sg-cube); stroke: rgba(0, 0, 0, .35); stroke-width: 1.5; }\n.sugoroku .sg-cube-text { fill: var(--sg-cube-ink); font-size: 22px; font-weight: 800; pointer-events: none; }\n.sugoroku .sg-point[data-movable=\"true\"] .sg-triangle { stroke: rgba(255, 255, 255, .55); stroke-width: 3; stroke-linejoin: round; }\n.sugoroku .sg-bar-hit[data-movable=\"true\"] { fill: rgba(255, 255, 255, .14); }\n.sugoroku .sg-point[data-selected=\"true\"] .sg-triangle { stroke: var(--sg-selected); stroke-width: 4; stroke-linejoin: round; }\n.sugoroku .sg-point[data-target=\"true\"] .sg-triangle { stroke: var(--sg-target); stroke-width: 4; stroke-linejoin: round; }\n.sugoroku .sg-bar-hit[data-selected=\"true\"] { fill: var(--sg-selected); opacity: .35; }\n.sugoroku .sg-tray[data-target=\"true\"] { stroke: var(--sg-target); stroke-width: 4; fill: rgba(127, 227, 161, .18); }\n.sugoroku .sg-point[data-target=\"true\"], .sugoroku .sg-tray[data-target=\"true\"] { cursor: pointer; }\n\n.sugoroku-play {\n  --sgp-ink: #1f2320; --sgp-muted: #6b6f68; --sgp-rule: #ddd6c6; --sgp-surface: #fbf8f1; --sgp-accent: #b5452c; --sgp-good: #2f7a4f;\n  display: block; max-width: 100%; box-sizing: border-box; color: var(--sgp-ink); font-family: system-ui, -apple-system, \"Segoe UI\", sans-serif;\n  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;\n}\n@media (prefers-color-scheme: dark) {\n  :root:not([data-theme=\"light\"]) .sugoroku-play { --sgp-ink: #ece8dc; --sgp-muted: #a09d93; --sgp-rule: #3a3d38; --sgp-surface: #1d201e; --sgp-accent: #ff8a6b; --sgp-good: #6fcf97; }\n}\n:root[data-theme=\"dark\"] .sugoroku-play { --sgp-ink: #ece8dc; --sgp-muted: #a09d93; --sgp-rule: #3a3d38; --sgp-surface: #1d201e; --sgp-accent: #ff8a6b; --sgp-good: #6fcf97; }\n.sugoroku-play *, .sugoroku-play *::before, .sugoroku-play *::after { box-sizing: border-box; }\n.sugoroku-play .sgp-board { position: relative; width: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: default; }\n.sugoroku-play[data-drag=\"off\"] .sgp-board { touch-action: manipulation; }\n.sugoroku-play .sgp-board svg { display: block; width: 100%; height: 100%; }\n.sugoroku-play .sgp-score { margin: 0 0 8px; font-size: .8rem; color: var(--sgp-muted); min-height: 2.7em; font-variant-numeric: tabular-nums; }\n.sugoroku-play .sgp-status { margin: 10px 0 0; min-height: 2.9em; font-size: .92rem; font-weight: 600; line-height: 1.4; }\n.sugoroku-play[data-over=\"true\"] .sgp-status { color: var(--sgp-good); }\n.sugoroku-play .sgp-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }\n.sugoroku-play .sgp-controls[hidden], .sugoroku-play [hidden] { display: none !important; }\n.sugoroku-play button { font: inherit; color: inherit; user-select: none; -webkit-user-select: none; touch-action: manipulation; }\n.sugoroku-play .sgp-button { border: 1px solid var(--sgp-rule); background: var(--sgp-surface); color: var(--sgp-ink); border-radius: 999px; min-height: 48px; padding: 0 12px; font-size: .88rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; text-align: center; line-height: 1.2; cursor: pointer; }\n.sugoroku-play .sgp-button:hover:not(:disabled) { border-color: var(--sgp-ink); }\n.sugoroku-play .sgp-button:disabled { opacity: .34; cursor: default; }\n.sugoroku-play .sgp-button[data-primary=\"true\"]:not(:disabled) { background: var(--sgp-ink); color: var(--sgp-surface); border-color: var(--sgp-ink); }\n.sugoroku-play .sgp-button[data-attention=\"true\"]:not(:disabled) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--sgp-accent) 45%, transparent); }\n.sugoroku-play .sgp-ghost { position: fixed; z-index: 10; pointer-events: none; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .55); box-shadow: 0 4px 10px rgba(0, 0, 0, .4); left: 0; top: 0; }\n"

Examples

import { SUGOROKU_PLAY_STYLE } from "@johnmorrisdotca/sugoroku/play";
console.log(SUGOROKU_PLAY_STYLE.length);
7355

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/sugoroku 1.1.1.