Moonchess: vanishing tic-tac-toe, online and practice modes
Online play over WebSockets with any-string game codes, seats and spectators, and a 1-second heartbeat. Practice mode against Columbina, backed by a full solver, with an accuracy slider, spoilers, undo and piece freshness. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
c52f30dc59
18 files changed
+1743
No files matched your search
@@ -0,0 +1,181 @@
|
||||
:root {
|
||||
--bg: #f6f5f1;
|
||||
--surface: #ffffff;
|
||||
--border: #dedbd2;
|
||||
--text: #1d1c1a;
|
||||
--muted: #6f6c64;
|
||||
--x: #d0543a;
|
||||
--o: #2f6fb5;
|
||||
--win: #e9c46a;
|
||||
--error: #b3261e;
|
||||
--radius: 14px;
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--bg: #15161a;
|
||||
--surface: #1f2026;
|
||||
--border: #33353d;
|
||||
--text: #ecebe6;
|
||||
--muted: #9a988f;
|
||||
--x: #f07a5f;
|
||||
--o: #6aa6ea;
|
||||
--win: #c9a64a;
|
||||
--error: #ff8a80;
|
||||
color-scheme: dark;
|
||||
}
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
main {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
padding: 48px 16px;
|
||||
}
|
||||
|
||||
h1 { font-size: 2.2rem; margin: 0 0 8px; letter-spacing: -0.02em; }
|
||||
.lede { color: var(--muted); margin: 0 0 32px; }
|
||||
|
||||
button {
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
padding: 12px 18px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
}
|
||||
button:hover { border-color: var(--muted); }
|
||||
button.primary { background: var(--text); color: var(--bg); border-color: var(--text); width: 100%; }
|
||||
button.primary:hover { opacity: 0.9; }
|
||||
button.small { padding: 6px 12px; font-size: 0.875rem; }
|
||||
button.ghost { background: transparent; }
|
||||
|
||||
.divider {
|
||||
display: flex; align-items: center; gap: 12px;
|
||||
color: var(--muted); font-size: 0.875rem; margin: 28px 0 16px;
|
||||
}
|
||||
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
|
||||
|
||||
#join-form { display: flex; gap: 8px; }
|
||||
#join-code {
|
||||
flex: 1; min-width: 0;
|
||||
font: 600 1.25rem/1 ui-monospace, "SF Mono", Menlo, monospace;
|
||||
letter-spacing: 0.05em; text-transform: uppercase;
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px; border: 1px solid var(--border);
|
||||
background: var(--surface); color: var(--text);
|
||||
}
|
||||
#join-code::placeholder { text-transform: none; letter-spacing: 0; font-family: system-ui, sans-serif; font-weight: 400; font-size: 1rem; }
|
||||
#join-code:focus { outline: 2px solid var(--o); outline-offset: -1px; }
|
||||
|
||||
.error { color: var(--error); min-height: 1.5em; margin: 12px 0 0; }
|
||||
|
||||
.bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
|
||||
.code-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
|
||||
.label { color: var(--muted); font-size: 0.875rem; }
|
||||
.code {
|
||||
font: 700 1.3rem ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.1em;
|
||||
min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
.code-wrap button, .bar > button { flex-shrink: 0; }
|
||||
|
||||
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 24px 0 8px; }
|
||||
.player {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
padding: 10px 12px; border-radius: 10px;
|
||||
border: 1px solid var(--border); background: var(--surface);
|
||||
font-size: 0.9rem; color: var(--muted);
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
.player.active { border-color: var(--text); color: var(--text); }
|
||||
.player.empty { border-style: dashed; }
|
||||
.player.gone { border-style: dashed; }
|
||||
.player.gone .who { color: var(--error); }
|
||||
.player .mark { font-weight: 800; font-size: 1.1rem; }
|
||||
.mark.x { color: var(--x); }
|
||||
.mark.o { color: var(--o); }
|
||||
|
||||
button.player {
|
||||
font: inherit; font-size: 0.9rem; font-weight: 400;
|
||||
text-align: left; width: 100%; cursor: pointer;
|
||||
}
|
||||
button.player[aria-pressed="true"] .who { font-weight: 600; }
|
||||
.page-title { font-size: 1.4rem; margin: 0; }
|
||||
.hint { color: var(--muted); font-size: 0.85rem; margin: 6px 0 0; }
|
||||
|
||||
.difficulty { margin-top: 24px; }
|
||||
.difficulty label { display: flex; justify-content: space-between; font-weight: 600; }
|
||||
.difficulty output { font-variant-numeric: tabular-nums; }
|
||||
.difficulty input { width: 100%; margin: 10px 0 0; accent-color: var(--text); }
|
||||
|
||||
.spoiler {
|
||||
margin-top: 20px; padding: 10px 12px;
|
||||
border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
|
||||
}
|
||||
.spoiler summary { cursor: pointer; font-weight: 600; }
|
||||
.spoiler p { margin: 8px 0 0; color: var(--muted); }
|
||||
.spoiler strong { color: var(--text); }
|
||||
|
||||
.toggle { display: flex; align-items: center; gap: 8px; margin-top: 12px; cursor: pointer; user-select: none; }
|
||||
.toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--text); cursor: pointer; }
|
||||
|
||||
.status { font-size: 1.15rem; font-weight: 600; text-align: center; margin: 20px 0 16px; min-height: 1.5em; }
|
||||
|
||||
.board {
|
||||
/* minmax(0, 1fr) and absolutely positioned marks keep cell sizes independent of content */
|
||||
display: grid; gap: 8px;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
grid-template-rows: repeat(3, minmax(0, 1fr));
|
||||
aspect-ratio: 1; width: min(100%, 60vh); margin: 0 auto;
|
||||
}
|
||||
.cell {
|
||||
position: relative;
|
||||
padding: 0; border-radius: var(--radius);
|
||||
border: 1px solid var(--border); background: var(--surface);
|
||||
display: grid; place-items: center;
|
||||
cursor: default;
|
||||
}
|
||||
.cell.playable { cursor: pointer; }
|
||||
.cell.playable:hover { border-color: var(--muted); }
|
||||
.cell.win { background: color-mix(in srgb, var(--win) 30%, var(--surface)); border-color: var(--win); }
|
||||
.cell svg { position: absolute; inset: 21%; width: 58%; height: 58%; overflow: visible; }
|
||||
.cell svg * { fill: none; stroke-width: 12; stroke-linecap: round; }
|
||||
.cell .x-mark * { stroke: var(--x); }
|
||||
.cell .o-mark * { stroke: var(--o); }
|
||||
/* Freshness view: newest piece solid, older ones fading toward the doomed look */
|
||||
.board.freshness .cell[data-age="1"] svg { opacity: 0.65; }
|
||||
.board.freshness .cell[data-age="2"] svg { opacity: 0.3; }
|
||||
.cell.doomed svg { opacity: 0.3; animation: fade 1.6s ease-in-out infinite; }
|
||||
.cell.placed svg { animation: pop 0.18s ease-out; }
|
||||
|
||||
@keyframes fade { 50% { opacity: 0.12; } }
|
||||
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.cell.doomed svg, .cell.placed svg { animation: none; }
|
||||
}
|
||||
|
||||
#game.offline .board,
|
||||
#game.offline .players { opacity: 0.4; pointer-events: none; }
|
||||
#game.offline .status { color: var(--error); }
|
||||
|
||||
.footer { margin-top: 20px; }
|
||||
.actions { display: flex; gap: 8px; }
|
||||
.actions > button { flex: 1; }
|
||||
.actions > button.primary { flex: 2; }
|
||||
.actions > button:disabled { opacity: 0.45; cursor: default; border-color: var(--border); }
|
||||
.meta { color: var(--muted); font-size: 0.875rem; text-align: center; margin: 12px 0 0; min-height: 1.5em; }
|
||||
Reference in new issue
Block a user