:root {
  --ink: #23364a;
  --paper: rgba(255, 253, 247, .94);
  --line: rgba(40, 64, 54, .15);
  --green: #4b7051;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #446658;
  font-synthesis: none;
}

.cloud-status { display: block; margin: 0; min-width: 0; max-width: 100%; padding: 5px 8px; border: 1px solid #a8bba7; border-radius: 8px; background: #fffdf7; color: #294333; font: 600 12px/1.4 system-ui, sans-serif; overflow-wrap: anywhere; opacity: 1; visibility: visible; transition: opacity .35s ease, visibility 0s; }
.cloud-status.is-faded { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .35s ease, visibility 0s linear .35s; }
.cloud-dialog { width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 22px; border: 0; border-radius: 18px; background: #fffdf7; color: var(--ink); }
.cloud-dialog::backdrop { background: #152e2466; backdrop-filter: blur(4px); }
.cloud-dialog > p { margin: 12px 0; font-size: 14px; line-height: 1.5; }
.cloud-choices { display: grid; gap: 8px; margin-top: 16px; }
.cloud-choices .button { white-space: normal; }
.cloud-choices .cloud-save-card { display: grid; justify-content: stretch; gap: 8px; width: 100%; padding: 12px; border: 2px solid #aab6ae; border-radius: 12px; background: var(--save-card-fill, #f5f6f2); color: #344c40; text-align: left; }
.cloud-save-card.has-less-progress { --save-card-fill: #fff1e6; border-color: #a5653d; color: #794624; }
.cloud-save-card.has-further-progress { --save-card-fill: #edf7e8; border-color: #448137; color: #2b6025; }
.cloud-choices .cloud-save-card:hover:not(:disabled) { background: var(--save-card-fill, #f5f6f2); box-shadow: inset 0 0 0 1px currentColor; }
.cloud-save-label { font-size: 13px; line-height: 1.45; }
.cloud-save-progress { justify-self: start; padding: 2px 8px; border: 1px solid currentColor; border-radius: 20px; font-size: 11px; font-weight: 750; line-height: 1.4; }
.cloud-save-summary { font-size: 12px; font-weight: 400; line-height: 1.5; }
.cloud-save-card[hidden], .cloud-save-progress[hidden] { display: none; }
.cloud-choices #cloud-stay-guest { margin-top: 4px; border-color: #b86256; background: #fff5f2; color: #913f35; }
.cloud-dialog .dialog-heading { align-items: flex-start; }
.cloud-dialog .close-dialog { flex-shrink: 0; }
.cloud-warning { padding: 10px; border: 1px solid #ad6544; border-radius: 8px; color: #723417; background: #fff1e5; font-size: 13px; }
.cloud-warning[hidden] { display: none; }

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
body { isolation: isolate; -webkit-font-smoothing: antialiased; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(17, 34, 35, .1);
  pointer-events: none;
  z-index: -1;
}
body.is-home::before { background: transparent; }
.round-background {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  user-select: none;
  z-index: -2;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible { outline: 3px solid #b7802e; outline-offset: 3px; }
h1, h2, p { margin: 0; }

.game-viewport {
  position: fixed;
  inset: 0;
  height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow: hidden;
}
.app {
  position: absolute;
  top: 20px;
  left: 50%;
  width: min(560px, calc(100% - 32px));
  margin: 0;
  transform: translateX(-50%) scale(var(--fit-scale, 1));
  transform-origin: top center;
}
.game-header {
  /* About 20% below the former 63px controls on a phone; cap both extremes. */
  --header-button-size: clamp(44px, min(13vw, 7svh), 56px);
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: calc(var(--header-button-size) * .16);
  margin-bottom: 12px;
}
.avatar-square { position: relative; display: grid; place-items: center; border: 1px solid var(--line); background: #e5ecdf; color: var(--green); text-decoration: none; }
.avatar-square svg { fill: currentColor; }
.avatar-square:hover { background: #edf1e8; }
.avatar-square:focus-visible { outline: 3px solid #b7802e; outline-offset: 3px; }
.avatar-square.is-signed-in { border-color: #4b7051; box-shadow: inset 0 0 0 2px #4b705133; }
.avatar-square.is-signed-in::after { content: ""; position: absolute; right: calc(var(--header-button-size) * -.07); bottom: calc(var(--header-button-size) * -.07); width: calc(var(--header-button-size) * .286); height: calc(var(--header-button-size) * .286); border: calc(var(--header-button-size) * .048) solid #e5ecdf; border-radius: 50%; background: #4b7051; }
.header-player { display: flex; flex: none; align-items: center; gap: calc(var(--header-button-size) * .11); }
.header-status { position: relative; display: flex; flex: 1; min-width: 0; align-self: stretch; align-items: center; justify-content: center; }
.header-status:has(.selection-text:not(:empty):not([hidden])) .cloud-status { visibility: hidden; }
.gem-balance { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 88px; height: 42px; padding: 4px 9px 4px 5px; border: 1px solid rgba(182, 199, 179, .5); border-radius: 9px; background: #fffdf7; box-shadow: 0 3px 12px #102a2226; color: #21392f; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gem-balance[hidden] { display: none; }
.gem-balance img { display: block; width: 32px; height: 32px; object-fit: contain; flex: none; filter: drop-shadow(0 1px 1px #234a3f80); }
.header-actions { display: flex; flex: none; align-items: center; gap: calc(var(--header-button-size) * .1); }
h1 { font-size: 25px; letter-spacing: -.8px; line-height: 1.2; font-weight: 650; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 17px;
  font-size: 13px;
  font-weight: 600;
  background: var(--paper);
  transition: background .15s;
}
.button:hover:not(:disabled) { background: #edf1e8; }
.game-header .header-icon-button { width: var(--header-button-size); height: var(--header-button-size); min-height: var(--header-button-size); flex: none; padding: 0; border-radius: calc(var(--header-button-size) * .2); }
.game-header .header-icon-button svg { width: calc(var(--header-button-size) * .62); height: calc(var(--header-button-size) * .62); }
.settings-button svg, .home-button svg, .hint-button svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.game-header .button.settings-button { border: 1px solid var(--line); background: #e5ecdf; color: var(--ink); }
.game-header .button.settings-button:hover:not(:disabled) { background: #edf1e8; color: var(--green); }
.settings-button svg { fill: currentColor; stroke: none; filter: drop-shadow(0 1px 2px #ffffffe6); }
.game-header .button.home-button { border: 1px solid var(--line); background: #e5ecdf; color: var(--ink); }
.game-header .button.home-button:hover:not(:disabled) { background: #edf1e8; color: var(--ink); }
.home-button svg { fill: currentColor; stroke: none; filter: drop-shadow(0 1px 2px #ffffffe6); }
.primary-button { background: var(--ink); color: #fffdf7; border-color: var(--ink); }
.primary-button:hover:not(:disabled) { background: #354e66; }
.home-screen { --home-tile-size: 240px; display: flex; flex-direction: column; align-items: center; gap: 30px; padding: 32px 24px; border: 0; background: transparent; text-align: center; }
.home-identity h1 { font-size: clamp(38px, 10vw, 56px); font-weight: 750; letter-spacing: -2.5px; line-height: 1.02; text-shadow: 0 1px 2px #fff, 0 3px 18px #ffffffe6; }
.home-identity h1 span { color: var(--green); }
.home-letter-grid { position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(5, 1fr); width: min(var(--home-tile-size), 100%); aspect-ratio: 1; padding: 10px; border: 1px solid #dfe5d8; border-radius: 20px; background: #f8f9f2; box-shadow: 0 9px 24px #28412b0b; }
.home-letter-grid::before, .home-letter-grid::after { content: ""; position: absolute; pointer-events: none; z-index: -1; border-radius: 24px; }
.home-letter-grid::before { left: 14px; right: 14px; top: 16px; height: calc((100% - 20px) / 5 - 10px); background: #d0dfbd; }
.home-letter-grid::after { left: 16px; top: calc(60% + 3px); height: calc((100% - 20px) / 5 - 10px); width: calc(80% - 23px); background: #f0dba5; }
.home-letter-grid span { display: grid; place-items: center; min-width: 0; font-size: 23px; font-weight: 650; color: #5e7352; }
.home-play-area { width: min(320px, 100%); }
.home-play { width: min(var(--home-tile-size), 100%); min-height: 54px; border-radius: 14px; box-shadow: 0 8px 24px #162a3c3d; font-size: 18px; letter-spacing: .1px; }
.home-difficulty { display: block; min-height: 44px; margin: 4px auto 0; padding: 8px 12px; border: 0; border-radius: 6px; background: transparent; color: #355c43; font-size: 13px; font-weight: 750; text-decoration: underline; text-shadow: 0 1px 2px #fff, 0 2px 8px #fffffff2; text-underline-offset: 3px; }
.home-difficulty:hover:not(:disabled) { color: var(--ink); }
.home-round { margin-top: 5px; color: #31463f; font-size: 12px; font-weight: 600; line-height: 1.6; text-shadow: 0 1px 2px #fff, 0 2px 8px #fffffff2; }
.game-layout { display: flex; flex-direction: column; gap: 12px; }
.word-panel {
  padding: 8px 14px;
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 14px;
  box-shadow: 0 4px 24px #122d2310;
}
.word-panel-heading { --title-font-size: clamp(14px, 4.5vw, 20px); position: relative; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 24px; margin: 0 0 3px; padding: 0 48px; }
.bonus-button { position: absolute; left: -5px; top: 50%; display: grid; place-items: center; padding: 5px; border: 0; border-radius: 9px; background: transparent; transform: translateY(-50%); font-size: var(--title-font-size); font-weight: 700; }
/* Double the title's capital height, compensating for the image's transparent padding. */
.bonus-words-indicator { display: block; width: 2.23cap; height: 2.23cap; object-fit: contain; }
.bonus-button:hover { background: #efe9d74d; }
.bonus-button.is-ready .bonus-words-indicator, .chest-button.is-ready img { filter: drop-shadow(0 0 7px #ffce54) drop-shadow(0 0 2px #ecbb47); animation: gift-glow 1.6s ease-in-out infinite alternate; }
.bonus-button.is-celebrating .bonus-words-indicator { animation: gift-bounce .8s ease-out; }
.hint-button svg { width: 28px; height: 28px; }
.word-panel h1 { min-width: 0; text-align: center; text-transform: uppercase; white-space: nowrap; font-size: var(--title-font-size); font-weight: 700; letter-spacing: -.2px; }
.progress-count { position: absolute; right: 0; top: 50%; font-size: 12px; font-weight: 650; color: var(--green); font-variant-numeric: tabular-nums; transform: translateY(-50%); }
.selection-text { position: absolute; left: 50%; top: 50%; width: max-content; max-width: 100%; padding: 4px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: 0 2px 12px #122d2314; transform: translate(-50%, -50%); text-align: center; font: 600 14px/20px ui-monospace, monospace; letter-spacing: 1.2px; color: var(--green); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.selection-text:empty { display: none; }
.selection-text.is-confirming { animation: selection-confirm var(--word-duration) var(--word-delay) both; }
.progress-track { height: 3px; background: #dce2d6; border-radius: 3px; overflow: hidden; margin-bottom: 3px; }
.progress-track > div { height: 100%; width: 0; background: #6c8b57; border-radius: 3px; transition: width .25s; }
.word-list { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 14px; list-style: none; padding: 0; margin: 0; }
.word-list li { flex: 0 0 auto; min-width: 0; min-height: 1.2em; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 16px; font-weight: 700; line-height: 1.1; letter-spacing: .4px; }
.word-label { min-width: 0; white-space: nowrap; }
.word-list li.is-found { color: #6a7860; }
.is-found .word-label { text-decoration: line-through; text-decoration-thickness: 1px; }
.word-list li.is-finding { animation: word-label-confirm var(--word-duration) var(--word-delay) both; }
.is-finding .word-label { position: relative; text-decoration: none; }
.is-finding .word-label::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: currentColor; transform-origin: left; animation: word-strike var(--word-duration) var(--word-delay) both; }
.word-panel.is-compact { padding: 6px 10px; }
.word-panel.is-compact .word-panel-heading { margin-bottom: 2px; }
.word-panel.is-compact .progress-track { margin-bottom: 2px; }
.word-panel.is-compact .word-list { gap: 0 8px; }
.word-panel.is-compact .word-list li { letter-spacing: .2px; }

.board-panel, .board-shell { width: 100%; }
.board-panel { display: flex; flex-direction: column; align-items: flex-start; align-self: center; }
.board-shell { position: relative; }
.board-controls { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.board-hint-button { width: 42px; height: 42px; min-height: 42px; padding: 5px; border-radius: 9px; background: var(--paper); color: #8b6b24; }
.board-hint-button:hover:not(:disabled) { background: #f5ead2; }
.board {
  position: relative;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 10px 40px #102a2220;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  isolation: isolate;
}
.letters { position: relative; width: 100%; aspect-ratio: var(--cols, 8) / var(--rows, 8); display: flex; flex-direction: column; }
.grid-row { display: grid; grid-template-columns: repeat(var(--cols, 8), minmax(0, 1fr)); flex: 1; min-height: 0; }
.cell {
  display: grid;
  place-items: center;
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(16px, 2.5vw, 25px);
  font-weight: 700;
  touch-action: none;
}
.board[data-cols="12"] .cell { font-size: clamp(16px, 2.2vw, 24px); }
.board.large-board .cell { font-size: clamp(14px, 2vw, 22px); }
.cell:focus-visible { outline: 2px solid #6e8660; outline-offset: -4px; }
.cell.found { font-weight: 750; }
/* A hint is a pulsing ring, so it never looks like a tapped first letter. */
.cell.hinted { box-shadow: inset 0 0 0 3px #b7802e; animation: hint-pulse 1s ease-in-out infinite alternate; }
.word-list li.is-hinted .word-label { padding: 0 5px; border-radius: 5px; background: #f6e3b0; box-shadow: 0 0 0 2px #b7802e; }
.board .miss-line { animation: miss-fade .6s ease-out forwards; }
.board .word-fill { animation: word-fill var(--word-duration) var(--word-delay) both; }
.board .word-ring { animation: word-ring var(--word-duration) var(--word-delay) both; }
.board .word-glow { filter: blur(7px); animation: word-glow var(--word-duration) var(--word-delay) both; }
.board .bonus-settle { animation: bonus-settle var(--word-duration) var(--word-delay) both; }
.board svg { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); overflow: visible; pointer-events: none; z-index: -1; }
.completion { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 20px; border-radius: 16px; background: rgba(255, 253, 247, .35); backdrop-filter: blur(2px); text-align: center; }
.completion:not([hidden]) { animation: completion-reveal .24s ease-out both; }
.completion-card { position: absolute; left: 50%; top: 50%; width: min(calc(100% - 40px), 300px); padding: 28px 22px; border: 1px solid var(--line); border-radius: 16px; background: #fffdf7; box-shadow: 0 12px 44px #23364a2b; transform: translate(-50%, -50%) scale(var(--completion-scale, 1)); }
.completion h2 { margin-bottom: 18px; font-size: clamp(24px, 5vw, 30px); font-weight: 700; letter-spacing: -.8px; }
.completion .button { width: 100%; min-height: 46px; font-size: 14px; }
.completion-emblem { display: grid; place-items: center; width: 40px; height: 40px; margin: 0 auto 12px; border-radius: 50%; background: #e0e9d6; color: var(--green); font-size: 24px; font-weight: 700; }
.gem-reward { display: flex; align-items: center; justify-content: center; gap: 6px; margin: -8px 0 16px; color: #3d6954; font-size: 16px; font-weight: 750; }
.gem-reward[hidden] { display: none; }
.gem-reward img { display: block; width: 28px; height: 28px; object-fit: contain; flex: none; }
.completion-actions { display: grid; gap: 8px; }
.quiet-button { background: transparent; border-color: transparent; color: #697760; }
.unlock-message { margin: -4px 0 18px; padding: 12px 10px; border: 1px solid #dfcd91; border-radius: 9px; background: #faf0d1; color: #796020; font-size: 13px; font-weight: 650; line-height: 1.5; }

dialog { width: min(610px, calc(100vw - 28px)); max-height: calc(100dvh - 32px); border: 1px solid #e1e4da; background: #fffdf7; color: var(--ink); border-radius: 16px; padding: 24px; box-shadow: 0 24px 100px #14243144; }
dialog::backdrop { background: #14243166; backdrop-filter: blur(4px); }
dialog h2 { font-size: 21px; font-weight: 650; letter-spacing: -.5px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; font-size: 23px; border: 1px solid var(--line); border-radius: 50%; background: transparent; }
.icon-button:hover { background: #edf1e8; }
.library-dialog { --dialog-pad-y: 24px; --dialog-pad-x: 24px; overscroll-behavior: contain; }
/* The title and difficulty tabs stay in view while the rounds scroll beneath them. */
.library-top { position: sticky; top: calc(-1 * var(--dialog-pad-y)); z-index: 1; margin: calc(-1 * var(--dialog-pad-y)) calc(-1 * var(--dialog-pad-x)) 16px; padding: var(--dialog-pad-y) var(--dialog-pad-x) 12px; border-bottom: 1px solid #ecefe6; background: #fffdf7; border-radius: 16px 16px 0 0; }
.selection-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: 12px; color: #626f58; }
.selection-gems { display: flex; align-items: center; gap: 5px; font-weight: 750; }
.selection-gems img { object-fit: contain; }
.difficulty-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; padding: 5px; border: 1px solid #dfe5d7; border-radius: 12px; background: #edf0e5; }
.difficulty-tabs button { min-width: 0; min-height: 42px; padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #626f58; font-size: 13px; font-weight: 700; }
.difficulty-tabs button[aria-selected="true"] { border-color: var(--green); background: var(--green); color: #fffdf7; box-shadow: 0 2px 6px #243a271a; }
.difficulty-tabs button:hover:not([aria-selected="true"]) { background: #e0e7d6; }
.settings-dialog { width: min(420px, calc(100vw - 28px)); }
.cloud-settings-button { width: 100%; min-height: 44px; margin-bottom: 10px; font-size: 14px; }
.delete-local-button { width: 100%; min-height: 44px; font-size: 14px; color: #943c30; border-color: #d9bcb3; background: #fff8f3; }
.delete-local-button:hover:not(:disabled) { color: #783024; background: #f8e9e0; }
.delete-local-dialog { width: min(440px, calc(100vw - 28px)); }
.delete-local-dialog .dialog-heading { margin-bottom: 14px; }
.delete-local-dialog p { margin: 12px 0; font-size: 14px; line-height: 1.55; }
#delete-local-message:empty { display: none; }
#delete-local-message { color: #943c30; }
.delete-local-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.delete-local-actions .button { flex: 1 1 130px; min-height: 44px; white-space: normal; }
.danger-button { background: #943c30; border-color: #943c30; color: #fff; }
.danger-button:hover:not(:disabled) { background: #783024; }
.library-list { display: grid; gap: 22px; min-width: 0; outline-offset: 4px; }
.selection-empty { padding: 14px 0; color: #6f7664; font-size: 13px; line-height: 1.6; }
.category-section { min-width: 0; scroll-margin-top: 180px; }
.category-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px 14px; margin-bottom: 10px; }
.category-heading h3 { margin: 0; font-size: 15px; font-weight: 750; letter-spacing: -.25px; }
.category-rounds { --round-width: clamp(104px, 28vw, 122px); display: flex; gap: 16px; overflow-x: auto; padding: 4px 3px 12px; scroll-snap-type: x proximity; scroll-padding-inline: 3px; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #b6c3a8 transparent; cursor: grab; }
.category-rounds::after { content: ''; flex: 0 0 max(0px, calc(100% - var(--round-width) - 16px)); }
.category-rounds.is-dragging { scroll-snap-type: none; cursor: grabbing; user-select: none; }
.category-rounds.is-settling { scroll-snap-type: none; }
.library-card { position: relative; display: flex; flex: 0 0 var(--round-width); flex-direction: column; align-items: center; gap: 5px; min-width: 0; padding: 8px 3px; text-align: center; border: 1px solid transparent; border-radius: 12px; background: transparent; scroll-snap-align: start; scroll-margin-top: 180px; color: #405838; }
.library-card::after { content: ''; position: absolute; top: 56px; left: calc(50% + 27px); width: calc(var(--round-width) - 38px); height: 3px; background: #ccd8c1; pointer-events: none; }
.library-card:last-child::after { display: none; }
.library-card:hover:not(:disabled) { background: #edf2e4; border-color: #b8c9a9; }
.library-card.current { border-color: #86a373; background: #edf2e4; }
.library-card.locked { opacity: .56; color: #646c5d; }
.round-marker { position: relative; display: grid; place-items: center; width: 52px; height: 52px; border: 2px solid #abc298; border-radius: 50%; background: #e5eedb; }
.library-card.locked .round-marker { border-color: #c4c5b6; background: #ecebe1; }
.lock-image { display: block; width: 38px; height: 38px; object-fit: contain; }
.card-round { font-size: 12px; line-height: 16px; font-weight: 750; color: inherit; }
.round-badges { position: absolute; right: -7px; bottom: -3px; display: flex; gap: 1px; }
.card-completed { display: grid; place-items: center; width: 19px; height: 19px; border: 1px solid #fffdf7; border-radius: 50%; background: #567943; color: #fffdf7; font-size: 13px; font-weight: 750; line-height: 1; }
.card-star { color: #bd8918; font-size: 22px; line-height: 1; text-shadow: 0 1px #fffdf7; }
.card-meta { font-size: 11px; color: inherit; line-height: 1.45; font-variant-numeric: tabular-nums; }
.category-purchase { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 64px; padding: 10px 14px; border: 1px solid #e0e0d5; border-radius: 12px; background: #eeeee5; color: #737768; text-align: left; }
.category-purchase:hover:not(:disabled) { background: #e5e7da; border-color: #c4cbb9; }
.category-purchase .lock-image { opacity: .64; }
.category-purchase .category-name { font-size: 15px; font-weight: 700; }
.locked-categories-heading { margin: 0 0 -10px; font-size: 12px; font-weight: 650; color: #78816e; }
.category-unlock-dialog { width: min(380px, calc(100vw - 28px)); }
.category-unlock-cost { display: flex; align-items: center; gap: 7px; font-weight: 750; }
.category-unlock-cost img { width: 30px; height: 30px; object-fit: contain; }
#category-unlock-message { margin: 12px 0; min-height: 20px; color: #737768; font-size: 14px; }
.category-unlock-actions { display: flex; gap: 10px; margin-top: 16px; }
.category-unlock-actions .button { flex: 1; min-height: 44px; }
.bonus-dialog { width: min(420px, calc(100vw - 28px)); }
.bonus-dialog .dialog-heading { margin-bottom: 12px; }
.bonus-chest-row { display: flex; align-items: center; gap: 10px; }
.bonus-meter { flex: 1; min-width: 0; }
.bonus-meter-label { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 10px; color: #6f7664; font-size: 11px; }
#bonus-points { color: var(--green); font-weight: 750; font-variant-numeric: tabular-nums; }
.bonus-progress { height: 12px; overflow: hidden; border-radius: 12px; background: #e3e8d9; box-shadow: inset 0 1px 2px #4052370d; }
#bonus-progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7b9a57, #bacd80); transition: width .35s ease; }
.chest-button { position: relative; display: grid; place-items: center; flex: 0 0 88px; width: 88px; height: 96px; padding: 0; border: 0; border-radius: 14px; background: transparent; }
.chest-button img { display: block; width: 100%; height: 100%; object-fit: contain; }
.chest-button:disabled { opacity: .72; }
.chest-button:not(:disabled):hover { background: #f7edd3; }
.chest-button.is-opening img { animation: chest-open .9s ease-in-out; }
.chest-status { min-height: 34px; margin: 5px 0 18px; color: #707664; font-size: 12px; line-height: 1.5; }
.bonus-discoveries { padding-top: 20px; border-top: 1px solid var(--line); }
.bonus-found-label { color: #6e7564; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.4px; }
#bonus-map-title { margin: 6px 0 16px; color: var(--green); font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.bonus-found-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.bonus-found-list li { padding: 8px 12px; border: 1px solid #e4d7ac; border-radius: 8px; background: #f7efd7; color: #8a6c28; font-size: 13px; font-weight: 700; letter-spacing: .7px; }
.bonus-empty { padding: 12px 0; color: #6f7666; font-size: 13px; line-height: 1.6; }
.bonus-feedback { position: fixed; z-index: 20; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); padding: 13px 21px; border: 1px solid #e0c775; border-radius: 40px; background: #fffae8; box-shadow: 0 5px 28px #332b2229; color: #846523; font-size: 14px; font-weight: 700; text-align: center; opacity: 0; transform: translate(-50%, 10px); transition: opacity .2s, transform .2s; pointer-events: none; }
.bonus-feedback.is-visible { opacity: 1; transform: translate(-50%, 0); }
.bonus-feedback.beside-gems { left: var(--beside-left); top: var(--beside-top); bottom: auto; max-width: var(--beside-width); padding: 9px 16px; white-space: nowrap; transform: translate(0, -40%); }
.bonus-feedback.over-board { left: var(--board-center); top: var(--board-top); bottom: auto; width: max-content; max-width: var(--board-width); transform: translate(-50%, -6px); }
.bonus-feedback.over-board.is-visible { transform: translate(-50%, 0); }
.bonus-feedback.beside-gems.is-visible { transform: translate(0, -50%); }
.celebration-layer { position: fixed; inset: 0; z-index: 1000; overflow: hidden; pointer-events: none; user-select: none; }
.confetti-particle { position: absolute; display: block; width: 7px; height: 12px; border-radius: 2px; opacity: 0; will-change: transform, opacity; }
.error-banner { background: #fff2e9; color: #82452e; border: 1px solid #ddb99f; border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.error-banner p { font-size: 12px; line-height: 1.6; margin-bottom: 10px; }
.save-notice { margin: 0 0 12px; padding: 10px 14px; border: 1px solid #e0c775; border-radius: 10px; background: #fff6dc; color: #6a4f12; font-size: 12px; font-weight: 650; line-height: 1.5; text-align: center; }
.save-notice:empty { margin: 0; padding: 0; border: 0; }
dialog .save-notice:not(:empty) { margin: -8px 0 16px; }
.toast { position: fixed; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; opacity: 0; pointer-events: none; }
@keyframes hint-pulse { to { box-shadow: inset 0 0 0 3px #b7802e, 0 0 0 5px #f2cb7699; } }
@keyframes miss-fade { 0%, 45% { opacity: .7; } 100% { opacity: 0; } }
/* Preserve the selected yellow, bloom at the confetti burst, then settle into
   the saved word's own color. Negative delays survive highlight redraws. */
@keyframes word-fill {
  0%, 18% { stroke: #eeca7e; stroke-width: 70; opacity: 1; }
  34% { stroke: #f8dfa1; stroke-width: 73; opacity: 1; }
  86%, 100% { stroke: var(--rest-stroke); stroke-width: var(--rest-width); opacity: var(--rest-opacity); }
}
@keyframes word-ring {
  0%, 12% { stroke: #9c6b16; stroke-width: 80; opacity: 1; }
  34% { stroke: #dbac4e; stroke-width: 84; opacity: .65; }
  86%, 100% { stroke: var(--rest-stroke); stroke-width: var(--rest-width); opacity: var(--rest-opacity); }
}
@keyframes word-glow {
  0% { stroke: #eeca7e; stroke-width: 80; opacity: 0; }
  18% { stroke: #eeca7e; stroke-width: 98; opacity: .72; }
  45% { stroke: var(--found-color); stroke-width: 100; opacity: .48; }
  100% { stroke: var(--found-color); stroke-width: 82; opacity: 0; }
}
@keyframes bonus-settle { 0%, 34% { opacity: 1; } 86%, 100% { opacity: .72; } }
@keyframes word-label-confirm {
  0% { color: var(--ink); transform: scale(1); }
  18%, 34% { color: #9c6b16; transform: scale(1.07); }
  86%, 100% { color: #6a7860; transform: scale(1); }
}
@keyframes word-strike { 0%, 34% { transform: scaleX(0); } 70%, 100% { transform: scaleX(1); } }
@keyframes selection-confirm {
  0% { opacity: 1; box-shadow: 0 2px 12px #122d2314; }
  18%, 34% { opacity: 1; box-shadow: 0 0 16px #eeca7e99; border-color: #d8b561; }
  65% { opacity: 1; box-shadow: 0 0 12px var(--found-color); }
  100% { opacity: 0; box-shadow: 0 0 0 transparent; }
}
@keyframes completion-reveal { from { opacity: 0; } to { opacity: 1; } }
@keyframes gift-glow { to { filter: drop-shadow(0 0 12px #ffc741) drop-shadow(0 0 3px #ffde7b); } }
@keyframes gift-bounce { 0%, 100% { transform: scale(1) rotate(0); } 20% { transform: scale(1.22) rotate(-10deg); } 42% { transform: scale(1.16) rotate(9deg); } 65% { transform: scale(1.1) rotate(-4deg); } }
@keyframes chest-open { 0% { transform: scale(1) rotate(0); } 20% { transform: scale(.9) rotate(-7deg); } 38% { transform: scale(.95) rotate(7deg); } 60% { transform: translateY(-10px) scale(1.25); filter: drop-shadow(0 0 14px #ffcc49); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 600px) {
  .game-viewport { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .game-header { margin-bottom: 10px; }
  .game-layout { gap: 10px; }
  .home-screen { --home-tile-size: 210px; gap: 26px; padding: 30px 20px; border-radius: 20px; }
  .home-letter-grid span { font-size: 21px; }
  .word-panel { padding: 6px 12px; }
  .word-panel-heading { margin-bottom: 2px; }
  .word-list { column-gap: 10px; }
  .word-list li { font-size: 14px; letter-spacing: .25px; }
  .board-controls { margin-top: 6px; }
  .board, .letters, .board svg { --board-inset: 9px; }
  .board { padding: var(--board-inset); border-radius: 14px; }
  .board svg { inset: var(--board-inset); }
  .board svg { width: calc(100% - 18px); height: calc(100% - 18px); }
  .cell { font-size: clamp(16px, 4.7vw, 25px); }
  .board[data-cols="12"] .cell { font-size: clamp(15px, 4vw, 23px); }
  .board.large-board .cell { font-size: clamp(14px, 3.8vw, 22px); }
  dialog { padding: 20px 16px; }
  .library-dialog { --dialog-pad-y: 20px; --dialog-pad-x: 16px; }
}
@media (max-height: 680px) {
  .home-screen { --home-tile-size: 175px; gap: 20px; padding-block: 22px; }
  .home-letter-grid span { font-size: 18px; }
  .home-identity h1 { font-size: 40px; }
}

.replacement-notice { position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 100; max-width: 38rem; margin: auto; padding: 1rem; border-radius: 1rem; background: #fff; color: #24344b; box-shadow: 0 4px 24px #0006; }
.replacement-notice[hidden] { display: none; }
