feat(wasm): playable browser game at /play
Add `SolitaireGame` WASM binding to `solitaire_wasm` exposing draw(), move_cards(), undo(), auto_complete_step(), and state() — all backed by the real solitaire_core rules engine. Add /play route to solitaire_server serving a full vanilla-JS interactive Klondike game (game.html / game.css / game.js). Features: drag-and-drop card moves (mouse + touch via PointerEvents), click stock to draw, double-click card to auto-move to foundation, undo, draw-1/3 toggle, new game, auto-complete animation, win overlay, seed display. Rebuild solitaire_wasm.js + solitaire_wasm_bg.wasm. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,239 @@
|
||||
/* Solitaire Quest — interactive game page.
|
||||
Palette and card styles mirror replay.css; adds drag, selection,
|
||||
HUD, and win-overlay layers. */
|
||||
|
||||
:root {
|
||||
--bg: #0f0a1f;
|
||||
--felt: #0f4c30;
|
||||
--panel: #1a0f2e;
|
||||
--panel-hi: #2d1b69;
|
||||
--text: #f5f0ff;
|
||||
--text-muted: #b5a8d5;
|
||||
--accent: #ffd23f;
|
||||
--red: #cc3344;
|
||||
--black: #1a0f2e;
|
||||
--card-bg: #ffffff;
|
||||
--card-border: #ccc;
|
||||
--card-w: 80px;
|
||||
--card-h: 112px;
|
||||
--gap: 12px;
|
||||
--fan: 28px;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* ── Header / HUD ────────────────────────────────────────────────────── */
|
||||
|
||||
header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 20px;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.07);
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.hud-left { display: flex; align-items: center; gap: 12px; }
|
||||
.hud-center { display: flex; gap: 20px; font-size: 14px; font-weight: 600; }
|
||||
.hud-right { display: flex; align-items: center; gap: 10px; }
|
||||
|
||||
.logo { font-size: 16px; font-weight: 700; }
|
||||
.muted { color: var(--text-muted); font-size: 12px; }
|
||||
|
||||
button {
|
||||
background: var(--panel-hi);
|
||||
color: var(--text);
|
||||
border: 1px solid rgba(255,255,255,0.12);
|
||||
border-radius: 6px;
|
||||
padding: 6px 14px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
transition: background 120ms;
|
||||
}
|
||||
button:hover { background: var(--accent); color: var(--black); }
|
||||
button:disabled { opacity: 0.4; cursor: default; }
|
||||
|
||||
.toggle-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.toggle-label:hover { color: var(--text); }
|
||||
|
||||
/* ── Board ───────────────────────────────────────────────────────────── */
|
||||
|
||||
main {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#board {
|
||||
position: relative;
|
||||
background: var(--felt);
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
/* 7 columns wide */
|
||||
width: calc(7 * var(--card-w) + 6 * var(--gap) + 40px);
|
||||
/* top row + generous fan budget for a 13-card column */
|
||||
height: calc(var(--card-h) + 28px + var(--card-h) + 12 * var(--fan) + 40px);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* Empty-pile slot markers */
|
||||
.slot {
|
||||
position: absolute;
|
||||
width: var(--card-w);
|
||||
height: var(--card-h);
|
||||
border: 2px dashed rgba(255,255,255,0.15);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.slot.drop-active {
|
||||
border-color: var(--accent);
|
||||
background: rgba(255, 210, 63, 0.08);
|
||||
}
|
||||
|
||||
/* ── Cards ───────────────────────────────────────────────────────────── */
|
||||
|
||||
.card {
|
||||
position: absolute;
|
||||
top: 0; left: 0;
|
||||
width: var(--card-w);
|
||||
height: var(--card-h);
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--card-border);
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.35);
|
||||
padding: 4px 6px;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
cursor: grab;
|
||||
transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
|
||||
opacity 200ms ease,
|
||||
box-shadow 120ms ease;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.card:active { cursor: grabbing; }
|
||||
|
||||
.card.face-down {
|
||||
background:
|
||||
repeating-linear-gradient(
|
||||
45deg,
|
||||
#482f97 0, #482f97 6px,
|
||||
#2d1b69 6px, #2d1b69 12px
|
||||
);
|
||||
color: transparent;
|
||||
border-color: #4a3a8a;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.card .corner {
|
||||
position: absolute;
|
||||
font-size: 14px;
|
||||
line-height: 1.1;
|
||||
text-align: center;
|
||||
}
|
||||
.card .corner.top { top: 4px; left: 6px; }
|
||||
.card .corner.bottom { bottom: 4px; right: 6px; transform: rotate(180deg); }
|
||||
|
||||
.card.red { color: var(--red); }
|
||||
.card.black { color: var(--black); }
|
||||
|
||||
.card .center {
|
||||
position: absolute;
|
||||
top: 50%; left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
/* Stock pile: pointer cursor since it's a click target, not draggable */
|
||||
.card.stock-card { cursor: pointer; }
|
||||
|
||||
/* Selected / being-dragged state */
|
||||
.card.selected {
|
||||
box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(0,0,0,0.5);
|
||||
z-index: 200;
|
||||
transition: none; /* snap instantly while dragging */
|
||||
}
|
||||
|
||||
/* Drop-target highlight on cards (top of a tableau column) */
|
||||
.card.drop-target {
|
||||
box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
/* Recycle indicator on empty stock */
|
||||
.recycle-label {
|
||||
position: absolute;
|
||||
top: 50%; left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
font-size: 26px;
|
||||
color: rgba(255,255,255,0.3);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* ── Win overlay ─────────────────────────────────────────────────────── */
|
||||
|
||||
#win-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(10, 5, 20, 0.75);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#win-overlay.hidden { display: none; }
|
||||
|
||||
.win-card {
|
||||
background: var(--panel);
|
||||
border: 1px solid rgba(255,255,255,0.12);
|
||||
border-radius: 16px;
|
||||
padding: 40px 48px;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
box-shadow: 0 20px 60px rgba(0,0,0,0.6);
|
||||
}
|
||||
|
||||
.win-title {
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.win-score {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.win-detail {
|
||||
font-size: 14px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
#btn-win-new {
|
||||
margin-top: 8px;
|
||||
padding: 12px 32px;
|
||||
font-size: 16px;
|
||||
}
|
||||
Reference in New Issue
Block a user