From 4f50f2008f4d7c2a635f7f26861fcfc7f7504423 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Sun, 15 Nov 2026 13:45:21 +0100 Subject: Phase 3: web UI core loop (M3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Browser game UI on top of the Phase 2 protocol: server-driven, input-only clients with per-connection secret visibility. Web (Svelte 5): - Layout: TopBar (element buttons with use/imbue long-press, title, menu), MainList (character/monster/note rows), BottomBar (draw/next-round + level widget with T/H/X/C values). - CharacterRow with the secret initiative input: own value editable, server-masked values render as ??, revealed on draw. - Per-figure StatusMenu: health/max/xp/bless/curse/empower/enfeeble steppers, condition grid, turn-done — all server commands, player-gated. - Menu dialogs: select scenario, add section, add/remove character, set level/difficulty/solo/auto-level, add/remove monster, note row, action log with rollback, settings (style theme + language). - Player vs spectator UI gated on the live seat table; reconnecting banner, error toasts, connection status plumbing. - i18n: English ported, locale store with localStorage persistence. - Design tokens + the three style themes (frosthaven/gloomhaven/original). - Unit tests: level values, game logic (elements/conditions/art/stats), i18n, the reactive player store, the data client (sections keyed by scenario number), plus the existing connection/protocol/state tests. Server: - Serve the engine's data JSON at /data/ and artwork at /images/ so the client menus and rows read the same assets the engine loads. --- web/src/app.css | 746 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 742 insertions(+), 4 deletions(-) (limited to 'web/src/app.css') diff --git a/web/src/app.css b/web/src/app.css index 34530c9..90cc0c9 100644 --- a/web/src/app.css +++ b/web/src/app.css @@ -1,16 +1,754 @@ +/* X-Haven design tokens (Phase 3). + * + * Mirrors the reference app's look: a textured dark (or light) background, + * a 40px top bar with the six element buttons, character rows at 60px and + * monster rows at 96px, and a 40px bottom bar. Three style themes — + * frosthaven / gloomhaven / original — swap the background artwork and the + * display font (PLAN.md Phase 3: "the three style themes"). + */ + +@font-face { + font-family: 'GermaniaOne'; + src: url('/fonts/GermaniaOne-Regular.ttf') format('truetype'); + font-weight: 400; +} + +@font-face { + font-family: 'PirataOne'; + src: url('/fonts/PirataOne-Gloomhaven.ttf') format('truetype'); + font-weight: 400; +} + :root { + --font-display: 'PirataOne', 'Georgia', serif; + --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; + + /* Layout scale (the reference app multiplies every bar dimension by the + user's bar scaling; the web default is 1). */ + --bar-h: 40px; + --row-character-h: 60px; + --row-monster-h: 96px; + --list-w: 400px; + + /* Element colours (top_bar.dart). */ + --el-fire: #e2421e; + --el-ice: #55c8ef; + --el-air: #98b0b5; + --el-earth: #7ca82a; + --el-light: #eca60f; + --el-dark: #1f3283; + + /* Turn highlight (Colors.tealAccent). */ + --turn-current: #64ffda; + color-scheme: dark; - --bg: #15181d; - --fg: #e6e8ee; +} + +/* --- Style themes ------------------------------------------------------ */ + +/* Gloomhaven / Frosthaven: dark textured background. */ +:root[data-style='gloomhaven'], +:root[data-style='frosthaven'] { + --bg: #000; + --bg-image: url('/images/bg/bg.png'); + --bar-image: url('/images/psd/gloomhaven-bar.png'); + --bar-bg: #000; + --bar-opacity: 0.4; + --fg: #fff; + --shadow: #000; + --menu-bg: #101418; + --dialog-bg: #1a1f26; + --row-border: #000; +} + +:root[data-style='frosthaven'] { + --font-display: 'GermaniaOne', 'Georgia', serif; +} + +/* Original: light background (the reference default when style=original). */ +:root[data-style='original'] { + --bg: #808080; + --bg-image: url('/images/bg/frosthaven-bg.png'); + --bar-image: url('/images/psd/frosthaven-bar.png'); + --bar-bg: transparent; + --bar-opacity: 1; + --fg: #000; + --shadow: #00000099; + --menu-bg: #f4f1ea; + --dialog-bg: #fffdf7; + --row-border: #00000044; + color-scheme: light; } * { box-sizing: border-box; } +html, +body, +#app { + height: 100%; +} + body { margin: 0; - background: var(--bg); color: var(--fg); - font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; + font-family: var(--font-body); + background-color: var(--bg); + background-image: var(--bg-image); + background-size: cover; + background-position: center; +} + +button { + font-family: inherit; + color: inherit; + background: none; + border: none; + cursor: pointer; +} + +/* --- App frame ---------------------------------------------------------- */ + +.app { + display: flex; + flex-direction: column; + height: 100%; +} + +.app__list { + flex: 1; + overflow-y: auto; + display: flex; + justify-content: center; +} + +/* --- Top bar ------------------------------------------------------------ */ + +.topbar { + height: var(--bar-h); + display: flex; + align-items: stretch; + gap: 2px; + background-color: var(--bar-bg); + background-image: var(--bar-image); + background-size: auto 100%; + background-repeat: repeat-x; + color: #fff; + position: relative; + z-index: 2; +} + +.topbar__menu { + width: var(--bar-h); + display: grid; + place-items: center; + font-size: 20px; +} + +.topbar__title { + font-family: var(--font-display); + font-size: 22px; + line-height: 0.9; + text-shadow: 1px 1px 2px var(--shadow); + align-self: center; + margin-left: 4px; + user-select: none; +} + +.topbar__elements { + margin-left: auto; + display: flex; +} + +/* --- Element buttons ---------------------------------------------------- */ + +.elbtn { + position: relative; + width: 36px; + align-self: center; + margin-right: 4px; +} + +.elbtn__fill { + position: absolute; + bottom: 4px; + left: 2px; + width: 32px; + height: 0; + background: var(--el-color); + border-radius: 16px; + transition: height 0.35s cubic-bezier(0, 0, 0.2, 1); +} + +.elbtn__fill.half { + height: 14px; + border-radius: 0 0 16px 16px; +} + +.elbtn__fill.full { + height: 30px; + border-radius: 16px; +} + +.elbtn__icon { + position: relative; + width: 24px; + height: 24px; + margin: 4px auto 0; + display: block; + object-fit: contain; + pointer-events: none; +} + +/* --- Main list / rows --------------------------------------------------- */ + +.list { + width: var(--list-w); + padding-bottom: 50vh; +} + +.row { + position: relative; + width: 100%; + overflow: hidden; + box-shadow: 0 2px 8px #00000059; + margin-bottom: 2px; + user-select: none; +} + +.row--character { + height: var(--row-character-h); + display: flex; + align-items: center; +} + +.row--monster { + height: var(--row-monster-h); +} + +.row--note { + min-height: 34px; +} + +.row__bg { + position: absolute; + inset: 0; + z-index: 0; +} + +.row__inner { + position: relative; + z-index: 1; + display: flex; + align-items: center; + width: 100%; +} + +.row__art { + flex: 0 0 auto; + width: 56px; + height: 100%; + display: grid; + place-items: center; +} + +.row__art img { + max-width: 48px; + max-height: 52px; + object-fit: contain; + filter: drop-shadow(1px 1px 1px #000c); +} + +.row__name { + font-family: var(--font-display); + font-size: 17px; + text-shadow: 1px 1px 1px var(--shadow); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.row__hp { + font-size: 14px; + margin-left: 6px; + text-shadow: 1px 1px 1px var(--shadow); +} + +.row__xp, +.row__level { + position: absolute; + top: 6px; + right: 60px; + font-size: 13px; + text-shadow: 1px 1px 1px var(--shadow); +} + +.row__level { + top: auto; + bottom: 6px; +} + +.row__summon { + position: absolute; + top: 4px; + right: 4px; + font-size: 12px; + background: #0006; + border-radius: 4px; + padding: 1px 4px; +} + +/* Initiative */ +.init { + flex: 0 0 auto; + width: 34px; + text-align: center; + font-family: var(--font-display); + font-size: 26px; + line-height: 1; + text-shadow: 1px 1px 1px var(--shadow); + margin-left: 4px; +} + +.init__input { + width: 30px; + background: transparent; + border: none; + border-bottom: 2px solid #ffffff88; + color: #fff; + font-family: var(--font-display); + font-size: 24px; + text-align: center; + outline: none; + padding: 0; +} + +.init__secret { + opacity: 0.85; +} + +/* Turn state */ +.row--current .row__bg { + background: var(--turn-current); +} + +.row--done, +.row--dead { + filter: grayscale(1); + opacity: 0.75; +} + +/* Claim / ownership chip */ +.chip { + position: absolute; + left: 4px; + bottom: 2px; + font-size: 11px; + padding: 1px 5px; + border-radius: 8px; + background: #000a; + color: #fff; + z-index: 2; +} + +.chip--claim { + cursor: pointer; + background: #b58900; +} + +/* Conditions */ +.conds { + display: flex; + flex-wrap: wrap; + gap: 2px; + margin-left: 4px; + max-width: 200px; +} + +.cond { + font-size: 11px; + padding: 0 4px; + border-radius: 3px; + background: #00000066; + color: #fff; + line-height: 16px; +} + +.cond--chill { + background: #55c8efaa; +} + +.cond--plague { + background: #7ca82a99; +} + +/* Monster standee boxes */ +.monster__boxes { + display: flex; + flex-wrap: wrap; + gap: 2px; + padding: 2px 4px 4px; +} + +.monster__box { + width: 46px; + background: #00000055; + border-radius: 4px; + display: grid; + place-items: center; + position: relative; +} + +.monster__box img { + width: 34px; + height: 34px; + object-fit: contain; +} + +.monster__box--dead { + filter: grayscale(1); + opacity: 0.6; +} + +.monster__box-hp { + position: absolute; + bottom: 1px; + right: 2px; + font-size: 10px; + color: #fff; + text-shadow: 1px 1px 1px #000; +} + +/* Note row */ +.note__text { + padding: 4px 8px; + font-size: 13px; +} + +.note__edit { + text-align: left; + padding: 0; + font: inherit; +} + +/* --- Bottom bar --------------------------------------------------------- */ + +.bottombar { + height: var(--bar-h); + display: flex; + align-items: center; + justify-content: space-between; + background-color: var(--bar-bg); + background-image: var(--bar-image); + background-size: auto 100%; + background-repeat: repeat-x; + color: #fff; + position: relative; + z-index: 2; + box-shadow: 0 -4px 10px #00000040; +} + +.drawbtn { + position: relative; + height: 100%; + min-width: 110px; + font-family: var(--font-display); + font-size: 18px; + text-shadow: 1px 1px 2px var(--shadow); +} + +.drawbtn__round { + position: absolute; + bottom: 2px; + left: 44px; + font-size: 12px; + color: #ff0; + text-shadow: 1px 1px 1px var(--shadow); +} + +.drawbtn--locked { + opacity: 0.5; +} + +.levelwidget { + font-family: var(--font-display); + font-size: 15px; + text-align: center; + text-shadow: 1px 1px 2px var(--shadow); + padding: 0 8px; +} + +.levelwidget__scenario { + max-width: 200px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.levelwidget__stats { + font-size: 13px; +} + +/* --- Connection banner / toasts ---------------------------------------- */ + +.banner { + position: fixed; + top: var(--bar-h); + left: 50%; + transform: translateX(-50%); + background: #7a1f1f; + color: #fff; + padding: 4px 14px; + border-radius: 0 0 6px 6px; + font-size: 13px; + z-index: 50; +} + +.toast { + position: fixed; + bottom: calc(var(--bar-h) + 10px); + left: 50%; + transform: translateX(-50%); + background: #000c; + color: #fff; + padding: 8px 18px; + border-radius: 8px; + font-size: 16px; + max-width: 80vw; + z-index: 60; + text-align: center; + white-space: pre-line; +} + +/* --- Drawer menu -------------------------------------------------------- */ + +.drawer { + position: fixed; + top: 0; + left: 0; + bottom: 0; + width: 280px; + background: var(--menu-bg); + color: var(--fg); + z-index: 40; + overflow-y: auto; + box-shadow: 2px 0 12px #00000080; + transform: translateX(-100%); + transition: transform 0.2s ease; +} + +.drawer--open { + transform: translateX(0); +} + +.drawer__header { + height: 90px; + background: #1565c0; + background-image: url('/images/icon.png'); + background-size: cover; + position: relative; +} + +.drawer__item { + display: block; + width: 100%; + text-align: left; + padding: 10px 16px; + font-size: 15px; +} + +.drawer__item:hover:not(:disabled) { + background: #ffffff1a; +} + +.drawer__item:disabled { + opacity: 0.4; + cursor: default; +} + +.drawer__divider { + border: none; + border-top: 1px solid #ffffff22; + margin: 6px 0; +} + +/* --- Dialogs (menus) ---------------------------------------------------- */ + +.dialog__overlay { + position: fixed; + inset: 0; + background: #00000088; + display: grid; + place-items: center; + z-index: 45; +} + +.dialog__card { + background: var(--dialog-bg); + color: var(--fg); + border-radius: 8px; + max-width: 420px; + width: 92vw; + max-height: 80vh; + display: flex; + flex-direction: column; + box-shadow: 0 8px 30px #000c; +} + +.dialog__title { + font-family: var(--font-display); + font-size: 20px; + padding: 12px 16px 8px; + text-align: center; +} + +.dialog__body { + padding: 0 12px; + overflow-y: auto; + flex: 1; +} + +.dialog__footer { + display: flex; + justify-content: flex-end; + padding: 8px 12px; +} + +.dialog__close { + font-family: var(--font-display); + font-size: 18px; + padding: 4px 14px; +} + +/* --- Menu content bits -------------------------------------------------- */ + +.menulist { + list-style: none; + margin: 0; + padding: 0; +} + +.menulist__item { + display: block; + width: 100%; + text-align: left; + padding: 9px 8px; + font-size: 15px; + border-radius: 4px; +} + +.menulist__item:hover { + background: #ffffff1a; +} + +.menulist__item--added { + opacity: 0.5; +} + +.menulist__item img { + vertical-align: middle; + margin-right: 8px; + height: 32px; + width: 32px; + object-fit: contain; +} + +.search { + width: 100%; + padding: 8px; + font-size: 15px; + background: #00000022; + border: 1px solid #ffffff33; + border-radius: 4px; + color: inherit; + margin: 8px 0; +} + +.campaignbtns { + display: flex; + flex-wrap: wrap; + gap: 4px; + padding: 8px 4px; +} + +.campaignbtns button { + padding: 6px 10px; + border: 1px solid #ffffff44; + border-radius: 6px; + font-size: 14px; +} + +.campaignbtns button--active { + background: #1565c0; + border-color: #1565c0; + color: #fff; +} + +.statrow { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; + padding: 6px 4px; +} + +.statrow__label { + flex: 1; + font-size: 14px; +} + +.statrow__value { + font-family: var(--font-display); + font-size: 18px; + min-width: 44px; + text-align: center; +} + +.stepbtn { + width: 34px; + height: 34px; + border-radius: 50%; + border: 1px solid #ffffff55; + font-size: 18px; + line-height: 1; +} + +.stepbtn:disabled { + opacity: 0.3; +} + +.condgrid { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 4px; + padding: 8px 4px; +} + +.condgrid button { + padding: 8px 4px; + font-size: 12px; + border: 1px solid #ffffff33; + border-radius: 4px; +} + +.condgrid button.condgrid--on { + background: #1565c0; + color: #fff; +} + +.settingsrow { + display: flex; + align-items: center; + justify-content: space-between; + padding: 10px 4px; + gap: 12px; +} + +.settingsrow label { + font-size: 14px; +} + +select.search { + padding: 8px; } -- cgit v1.3.1