From 68c9b7560642c802ca3bfe6d7e0f7a8c54412c40 Mon Sep 17 00:00:00 2001 From: Zhineng Li Date: Thu, 30 Apr 2026 10:33:23 +0800 Subject: keyboard & touch navigation, configurable settings, and refactor - keyboard support: arrow keys or `hjkl` to move cursor, Space to start selection, Enter to confirm, Escape to cancel - configurable settings: word placement directions, grid size, cell size, colors, fonts, debug mode, and more via `GameSettings` - modernize CSS (logical properties, grid layout) and HTML semantics - refactor JavaScript code around single-responsibility principles --- css/style.css | 163 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 132 insertions(+), 31 deletions(-) (limited to 'css/style.css') diff --git a/css/style.css b/css/style.css index 51304ed..73e9a77 100644 --- a/css/style.css +++ b/css/style.css @@ -1,58 +1,159 @@ -/* CSS reset */ +*, *::before, *::after { + box-sizing: border-box; +} + +:root { + --stone-50: oklch(98.5% 0.001 106.423); + --stone-100: oklch(97% 0.001 106.424); + --stone-200: oklch(92.3% 0.003 48.717); + --stone-500: oklch(55.3% 0.013 58.071); + --stone-700: oklch(37.4% 0.01 67.558); + --stone-800: oklch(26.8% 0.007 34.298); +} -body, h1 { +body, h1, h2, p, ul { margin: 0; padding: 0; } -h1 { - text-transform: uppercase; +ul { + list-style-type: none; } body { - color: #333; + font-family: system-ui, -apple-system, sans-serif; + color: var(--stone-800); + background-color: var(--stone-100); + min-height: 100vh; } -/* Common */ +.page { + position: relative; + display: grid; + grid-template-areas: + "title title title" + "board . words" + "status status status"; + grid-template-columns: auto 2.5rem auto; + justify-content: center; + margin-inline: auto; + width: min(62rem, calc(100% - 2rem)); +} -.fix { - *zoom: 1; +.page__header { + margin-block: 2rem; + grid-area: title; + text-align: center; } -.fix:after { - display: table; - clear: both; - content: ''; +.page__board { + grid-area: board; + display: flex; + justify-content: center; } -/* Home */ +.page__words { + grid-area: words; +} -.wrap { - width: 960px; - margin: 0 auto; - padding: 40px 0; +.page__footer { + margin-block: 2rem; + grid-area: status; text-align: center; - position:relative; } -.logo, #gameArea { - margin-bottom: 40px; +.page__title { + font-weight: 700; + font-size: clamp(1.25rem, 4vw, 2rem); + letter-spacing: 0.04em; + text-transform: uppercase; + color: var(--stone-800); +} + +.page__status { + font-size: 0.85rem; + letter-spacing: 0.02em; + color: var(--stone-500); +} + +.word-list { + display: flex; + flex-direction: column; + gap: 0.5rem; +} + +.word-list__item { + font-weight: 500; + font-size: 0.875rem; + letter-spacing: 0.03em; + color: var(--stone-800); + transition: opacity 0.2s, color 0.2s; } -.ws-area, .ws-words { - display: inline-block; - vertical-align: top; +.word-list__item--found { + text-decoration: line-through; + opacity: 0.4; } -.ws-words { - margin-left: 20px; - text-align: left; +@media (max-width: 860px) { + .page { + grid-template-columns: auto; + grid-template-areas: + "title" + "board" + "words" + "status"; + } + + .page__header { + margin-block: 1rem; + } + + .word-list { + margin-block-start: 1rem; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + gap: 0.75rem 1.25rem; + } + + .page__footer { + margin-block: 2rem 1rem; + } } -.ws-word { - margin-bottom: 4px; +.complete { + position: absolute; + background-color: color-mix(in srgb, var(--stone-50) 92%, transparent); + width: 100%; + height: 100%; + left: 0; + top: 0; } -.ws-words ::first-letter{ - text-transform : capitalize; -} \ No newline at end of file +.complete__inner { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; +} + +.complete__content { + padding: 1.5rem; + text-align: center; +} + +.complete__title { + font-weight: 700; + font-size: 1.75rem; + letter-spacing: 0.06em; + text-transform: uppercase; + color: var(--stone-800); +} + +.complete__message { + margin-block-start: 0.5rem; + font-size: 1rem; + color: var(--stone-700); +} -- cgit v1.2.3