:root {
  --ink: #101b2b;
  --ink-soft: #172740;
  --ink-raised: #203552;
  --paper: #f4ecdc;
  --paper-deep: #dfd1b6;
  --tile: #fff9ec;
  --tile-edge: #d8c6a5;
  --amber: #f6bd62;
  --amber-deep: #d98c32;
  --teal: #6bc2b5;
  --coral: #ef776d;
  --sky: #89aee4;
  --text: #f7f1e5;
  --muted: #9dacbf;
  --shadow: 0 24px 64px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; min-height: 100%; background: var(--ink); }

body {
  color: var(--text);
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

#app {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% 4%, rgba(107, 194, 181, .12), transparent 28rem),
    radial-gradient(circle at 88% 20%, rgba(137, 174, 228, .10), transparent 32rem),
    linear-gradient(155deg, #122038 0%, #0c1625 72%);
  overflow: hidden;
}

.app-header {
  position: relative;
  z-index: 20;
  width: min(1120px, 100%);
  margin: auto;
  padding: max(14px, env(safe-area-inset-top)) 18px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  border: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  font-weight: 790;
  font-size: 17px;
  cursor: pointer;
}

.brand i { color: var(--amber); font-family: Georgia, serif; font-weight: 400; }

.brand-tile {
  position: relative;
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: linear-gradient(#fff9eb, #decaa5);
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 9px;
  box-shadow: 0 3px 0 #a98e66, 0 8px 18px rgba(0, 0, 0, .22);
  transform: rotate(-5deg);
  font-size: 21px;
  font-weight: 850;
}

.brand-tile small { position: absolute; right: 3px; bottom: 1px; font-size: 7px; }
.header-actions { display: flex; gap: 8px; }

.icon-button, .language-pill {
  min-width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px;
  background: rgba(255, 255, 255, .06);
  cursor: pointer;
}

.language-pill { font-size: 12px; font-weight: 850; letter-spacing: .08em; }
.icon-button { font-size: 18px; }

main { position: relative; min-height: calc(100dvh - 66px); }
.screen { display: none; width: min(1060px, 100%); margin: auto; padding: 36px 20px max(36px, env(safe-area-inset-bottom)); }
.screen.active { display: block; animation: screen-in .35s ease both; }

@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } }

.home-screen { max-width: 880px; }
.hero { position: relative; max-width: 690px; margin: 4vh auto 34px; text-align: center; }
.eyebrow { margin: 0 0 8px; color: var(--amber); font-size: 12px; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: -.04em; text-wrap: balance; }
h1 { font-size: clamp(42px, 9vw, 74px); line-height: .98; }
h2 { font-size: clamp(30px, 6vw, 46px); line-height: 1.03; }
.hero-copy, .section-heading > p:last-child { max-width: 560px; margin: 18px auto 0; color: var(--muted); line-height: 1.6; }

.constellation { position: absolute; inset: -44px 0 auto; height: 180px; pointer-events: none; opacity: .6; }
.constellation i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 14px var(--amber); animation: twinkle 3s ease-in-out infinite; }
.constellation i:nth-child(1) { left: 8%; top: 25%; }
.constellation i:nth-child(2) { left: 22%; top: 4%; animation-delay: -1s; }
.constellation i:nth-child(3) { right: 18%; top: 18%; animation-delay: -2s; }
.constellation i:nth-child(4) { right: 3%; top: 55%; animation-delay: -.6s; }
.constellation i:nth-child(5) { left: 2%; top: 77%; animation-delay: -1.7s; }
@keyframes twinkle { 50% { opacity: .22; transform: scale(.6); } }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mode-card, .continue-card {
  position: relative;
  border: 1px solid rgba(255, 255, 255, .1);
  background: linear-gradient(145deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .045));
  box-shadow: 0 18px 44px rgba(0, 0, 0, .18);
  cursor: pointer;
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.mode-card:hover, .continue-card:hover { transform: translateY(-3px); border-color: rgba(246, 189, 98, .42); }
.mode-card:active, .continue-card:active { transform: translateY(0) scale(.985); }
.mode-card { min-height: 224px; padding: 24px; border-radius: 26px; text-align: left; display: flex; flex-direction: column; justify-content: flex-end; }
.mode-card::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 85% 12%, rgba(246, 189, 98, .14), transparent 45%); }
.challenge-card::after { background: radial-gradient(circle at 85% 12%, rgba(107, 194, 181, .16), transparent 48%); }
.mode-copy { position: relative; z-index: 2; display: flex; flex-direction: column; max-width: 80%; }
.mode-copy small { color: var(--amber); font-size: 11px; font-weight: 820; letter-spacing: .12em; text-transform: uppercase; }
.challenge-card .mode-copy small { color: var(--teal); }
.mode-copy strong { margin: 4px 0 8px; font-size: 29px; letter-spacing: -.03em; }
.mode-copy em { color: var(--muted); font-size: 13px; line-height: 1.45; font-style: normal; }
.mode-arrow { position: absolute; z-index: 2; right: 22px; bottom: 22px; font-size: 30px; color: var(--amber); }
.mode-art { position: absolute; z-index: 1; right: 24px; top: 22px; width: 110px; height: 100px; }
.moon { position: absolute; right: 4px; top: 4px; width: 66px; height: 66px; border-radius: 50%; background: linear-gradient(145deg, #ffd77e, #dc8c38); box-shadow: 0 0 38px rgba(246, 189, 98, .27); }
.orbit { position: absolute; right: -13px; top: 28px; width: 102px; height: 38px; border: 2px solid rgba(255, 255, 255, .3); border-radius: 50%; transform: rotate(-18deg); }
.orbit-art .star { position: absolute; right: 74px; top: 46px; color: white; font-style: normal; animation: float 2.8s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px) rotate(8deg); } }
.trail-art i { position: absolute; width: 32px; height: 32px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 8px rgba(107, 194, 181, .1); }
.trail-art i:nth-child(1) { right: 8px; top: 5px; }
.trail-art i:nth-child(2) { right: 58px; top: 36px; width: 24px; height: 24px; opacity: .75; }
.trail-art i:nth-child(3) { right: 22px; top: 75px; width: 18px; height: 18px; opacity: .5; }
.trail-art::before { content: ""; position: absolute; right: 27px; top: 18px; width: 62px; height: 72px; border: 3px dashed rgba(107, 194, 181, .35); border-left: 0; border-bottom: 0; transform: rotate(24deg); border-radius: 50%; }

.continue-card { width: 100%; padding: 14px 18px; margin: 0 0 16px; border-radius: 20px; display: flex; align-items: center; text-align: left; gap: 14px; }
.continue-card.hidden { display: none; }
.continue-icon { width: 44px; height: 44px; display: grid; place-items: center; background: var(--amber); color: var(--ink); border-radius: 14px; font-size: 22px; font-weight: 900; }
.continue-card span:nth-child(2) { display: flex; flex-direction: column; flex: 1; }
.continue-card small { color: var(--muted); }
.continue-card strong { margin-top: 2px; }
.continue-card b { font-size: 26px; color: var(--amber); }

.home-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.home-stat { padding: 14px 16px; border: 1px solid rgba(255, 255, 255, .07); border-radius: 17px; background: rgba(0, 0, 0, .1); text-align: center; }
.home-stat strong { display: block; color: var(--amber); font-size: 21px; }
.home-stat small { color: var(--muted); font-size: 11px; }

.back-link, .text-button { border: 0; background: none; color: var(--muted); cursor: pointer; }
.back-link { padding: 8px 0; margin-bottom: 24px; }
.back-link:hover, .text-button:hover { color: var(--text); }
.section-heading { text-align: center; margin: 2vh auto 30px; }
.section-heading.compact { margin-bottom: 18px; }
.difficulty-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 860px; margin: 0 auto 24px; }
.difficulty-card { position: relative; padding: 22px; min-height: 210px; border: 2px solid transparent; border-radius: 24px; background: rgba(255,255,255,.06); text-align: left; cursor: pointer; }
.difficulty-card.selected { border-color: var(--amber); background: rgba(246,189,98,.1); }
.difficulty-card .portrait { width: 62px; height: 62px; margin-bottom: 24px; display: grid; place-items: center; border-radius: 22px; background: linear-gradient(145deg, var(--ink-raised), #0d1828); font-size: 32px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.difficulty-card strong { display: block; font-size: 21px; }
.difficulty-card p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.difficulty-card i { position: absolute; right: 16px; top: 16px; width: 24px; height: 24px; border: 2px solid rgba(255,255,255,.2); border-radius: 50%; font-style: normal; }
.difficulty-card.selected i::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--amber); }

.primary-button, .secondary-button {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 15px;
  font-weight: 780;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, opacity .15s ease;
}
.primary-button { border: 0; color: #382306; background: linear-gradient(180deg, #ffd47c, var(--amber)); box-shadow: 0 4px 0 #bd792c, 0 10px 22px rgba(0,0,0,.18); }
.secondary-button { border: 1px solid rgba(255,255,255,.11); background: rgba(255,255,255,.065); }
.primary-button:active, .secondary-button:active { transform: translateY(2px); }
.primary-button:disabled, .secondary-button:disabled { opacity: .38; cursor: default; filter: grayscale(.4); box-shadow: none; }
.wide { display: block; width: min(380px, 100%); margin: 12px auto 0; }

.chapter-progress { max-width: 620px; margin: 0 auto 12px; text-align: center; color: var(--muted); font-size: 13px; }
.chapter-progress .progress-track { margin-top: 8px; }
.challenge-path { position: relative; width: min(620px, 100%); margin: auto; padding: 18px 0 60px; }
.challenge-path::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 30px; width: 4px; border-radius: 4px; background: linear-gradient(var(--teal), rgba(107,194,181,.08)); transform: translateX(-50%); }
.challenge-node { position: relative; width: 48%; min-height: 112px; margin: 0 0 16px; padding: 17px 18px; border: 1px solid rgba(255,255,255,.09); border-radius: 20px; background: var(--ink-soft); text-align: left; cursor: pointer; }
.challenge-node:nth-child(even) { margin-left: 52%; }
.challenge-node::after { content: ""; position: absolute; top: 46px; right: -9.3%; width: 14px; height: 14px; border: 4px solid var(--ink); border-radius: 50%; background: var(--teal); box-shadow: 0 0 20px rgba(107,194,181,.5); }
.challenge-node:nth-child(even)::after { right: auto; left: -9.3%; }
.challenge-node.locked { opacity: .45; cursor: default; }
.challenge-node.locked::after { background: #586579; box-shadow: none; }
.challenge-node small { color: var(--teal); text-transform: uppercase; letter-spacing: .1em; font-weight: 800; }
.challenge-node strong { display: block; margin: 5px 0; font-size: 18px; }
.challenge-node span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.node-medals { position: absolute; right: 13px; top: 12px; color: var(--amber); font-size: 11px; letter-spacing: 2px; }

.game-screen { width: min(1180px, 100%); padding-top: 8px; }
.game-topbar { width: min(720px, 100%); margin: 0 auto 10px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.score-card { padding: 6px 12px; min-width: 78px; border-radius: 14px; background: rgba(255,255,255,.055); text-align: center; }
.score-card small { display: block; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.score-card strong { display: block; font-size: 23px; line-height: 1; font-variant-numeric: tabular-nums; }
.player-score { grid-column: 1; }
.rival-score, .target-score { grid-column: 3; }
.turn-orb { grid-column: 2; min-width: 82px; text-align: center; }
.turn-orb span { display: block; color: var(--amber); animation: turn-pulse 2s ease-in-out infinite; }
.turn-orb small { color: var(--muted); font-size: 10px; }
@keyframes turn-pulse { 50% { opacity: .45; transform: scale(.8) rotate(25deg); } }

.game-layout { display: grid; grid-template-columns: minmax(0, 680px) minmax(260px, 340px); gap: 22px; align-items: center; justify-content: center; }
.board-column { min-width: 0; }
.board-wrap { position: relative; width: min(100%, 680px); aspect-ratio: 1; margin: auto; padding: 8px; border-radius: 20px; background: linear-gradient(145deg, #f8f0df, #cdbb9c); box-shadow: 0 7px 0 #8f7957, 0 28px 60px rgba(0,0,0,.3); container-type: inline-size; }
.board { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(15, 1fr); grid-template-rows: repeat(15, 1fr); overflow: hidden; border: 2px solid #948469; border-radius: 12px; background: #d7cdb9; touch-action: none; }
.board-cell { position: relative; display: grid; place-items: center; min-width: 0; padding: 0; border: 0; border-right: 1px solid rgba(55,47,34,.17); border-bottom: 1px solid rgba(55,47,34,.17); background: #e7ddc9; cursor: pointer; }
.board-cell:nth-child(15n) { border-right: 0; }
.board-cell::before { content: attr(data-label); color: #273649; font-size: clamp(6px, 1.9cqw, 12px); font-weight: 950; line-height: 1; letter-spacing: -.04em; white-space: nowrap; text-align: center; text-shadow: 0 1px rgba(255,255,255,.42); }
.board-cell[data-premium="dl"] { background: #c6e1dc; box-shadow: inset 0 0 0 1px rgba(28,105,100,.18); }
.board-cell[data-premium="tl"] { background: #83beb6; box-shadow: inset 0 0 0 1px rgba(18,82,80,.26); }
.board-cell[data-premium="dw"] { background: #f0d29a; box-shadow: inset 0 0 0 1px rgba(136,86,24,.18); }
.board-cell[data-premium="tw"] { background: #e28e70; box-shadow: inset 0 0 0 1px rgba(116,48,34,.24); }
.board-cell[data-premium="center"] { background: #f0c36c; }
.board-cell[data-premium="center"]::before { content: "✦"; font-size: clamp(8px, 1.5cqw, 14px); }
.board-cell[data-tile-state="draft"]::before, .board-cell[data-tile-state="committed"]::before { display: none; }
.board-cell.drop-target { box-shadow: inset 0 0 0 3px var(--teal); z-index: 2; }
.board-cell.word-highlight { box-shadow: inset 0 0 0 2px rgba(246,189,98,.95); z-index: 1; }
.board-cell.invalid { animation: cell-warn .34s ease; box-shadow: inset 0 0 0 3px var(--coral); z-index: 3; }
@keyframes cell-warn { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.tile {
  position: relative;
  width: 88%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(111,85,50,.28);
  border-radius: 18%;
  color: #172238;
  background: linear-gradient(150deg, #fffdf5, #eadabd);
  box-shadow: 0 2px 0 #bca278, 0 4px 8px rgba(36,24,11,.22);
  font-size: clamp(12px, 3.1cqw, 27px);
  font-weight: 850;
  line-height: 1;
  cursor: grab;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}
.tile small { position: absolute; right: 8%; bottom: 5%; font-size: 31%; font-weight: 900; }
.tile.blank::after { content: "✦"; position: absolute; left: 7%; top: 4%; color: var(--amber-deep); font-size: 28%; }
.tile.draft { background: linear-gradient(150deg, #fff9e7, #f4c974); animation: tile-in .2s cubic-bezier(.2,1.5,.4,1); }
.tile.recent { animation: recent-tile .55s ease both; }
.tile.selected { outline: 3px solid var(--amber); transform: translateY(-5px); }
.tile.dragging { opacity: .35; }
@keyframes tile-in { from { opacity: .25; transform: scale(.45) rotate(-8deg); } }
@keyframes recent-tile { 0% { transform: scale(.72); filter: brightness(1.5); } 55% { transform: scale(1.08); } }

.rack-wrap { width: min(560px, calc(100% - 34px)); min-height: 72px; margin: 16px auto 0; position: relative; padding: 8px 10px; border-radius: 15px 15px 20px 20px; background: linear-gradient(#8e6d45, #60452e); box-shadow: inset 0 3px 0 rgba(255,255,255,.18), 0 6px 0 #3e2b20, 0 15px 26px rgba(0,0,0,.25); }
.rack { min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 5px; }
.rack .tile { width: min(12.5%, 59px); flex: 0 0 min(12.5%, 59px); font-size: clamp(21px, 5cqw, 34px); }
.rack-shuffle { position: absolute; right: -38px; top: 14px; width: 32px; height: 38px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 22px; cursor: pointer; }

.game-panel { display: flex; flex-direction: column; gap: 12px; }
.objective-card, .word-preview, .definition-card { padding: 16px; border: 1px solid rgba(255,255,255,.09); border-radius: 18px; background: rgba(255,255,255,.05); }
.objective-card > small { color: var(--teal); font-size: 10px; font-weight: 820; letter-spacing: .12em; text-transform: uppercase; }
.objective-card > strong { display: block; margin: 5px 0 10px; }
.objective-card > span { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }
.progress-track { height: 7px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.08); }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--amber)); transition: width .45s ease; }
.word-preview { min-height: 82px; }
.word-preview > div { display: flex; justify-content: space-between; gap: 10px; }
#preview-words { font-weight: 750; overflow-wrap: anywhere; }
#preview-score { color: var(--amber); font-size: 22px; }
#move-message { min-height: 20px; margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
#move-message.error { color: #ff9a8f; }
.word-lookup-trigger { display: block; width: 100%; margin: 0; padding: 10px 12px; border: 1px solid rgba(107,194,181,.45); border-radius: 12px; color: var(--teal); background: rgba(107,194,181,.12); box-shadow: 0 4px 14px rgba(0,0,0,.12); font-size: 12px; font-weight: 850; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.definition-card > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.definition-card strong { color: var(--amber); }
.definition-card small { color: var(--muted); text-transform: uppercase; }
.definition-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.action-grid .secondary-button { min-width: 0; padding-inline: 8px; font-size: 12px; }
.play-button { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 10px; }
.play-button b { font-size: 12px; }

.score-burst { position: absolute; z-index: 8; left: 50%; top: 45%; color: var(--amber); font-size: 48px; font-weight: 900; text-shadow: 0 4px 20px rgba(0,0,0,.55); pointer-events: none; opacity: 0; }
.score-burst.show { animation: score-up .9s cubic-bezier(.2,.8,.25,1) both; }
@keyframes score-up { 0% { opacity: 0; transform: translate(-50%, 20px) scale(.7); } 25% { opacity: 1; transform: translate(-50%, 0) scale(1.12); } 100% { opacity: 0; transform: translate(-50%, -65px) scale(.9); } }

.modal-layer { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 18px; }
.modal-layer.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5,10,18,.74); backdrop-filter: blur(10px); animation: fade-in .18s ease; }
.modal { position: relative; z-index: 1; display: none; width: min(460px, 100%); max-height: min(760px, calc(100dvh - 36px)); overflow-y: auto; padding: 28px; border: 1px solid rgba(255,255,255,.12); border-radius: 28px; background: linear-gradient(155deg, #203552, #111d30); box-shadow: var(--shadow); animation: modal-in .28s cubic-bezier(.2,1.2,.3,1); }
.modal.active { display: block; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(24px) scale(.94); } }
.modal-close { position: absolute; top: 14px; right: 14px; width: 42px; height: 42px; border: 0; border-radius: 50%; background: rgba(255,255,255,.07); font-size: 25px; cursor: pointer; }
.modal h2 { margin-bottom: 20px; }
.modal-note { color: var(--muted); font-size: 12px; line-height: 1.5; }
.game-menu-actions { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.game-menu-actions h3, .settings-title { margin: 0 0 10px; font-size: 16px; }
.settings-list { display: grid; gap: 4px; margin: 8px 0 18px; }
.settings-list label { min-height: 62px; display: flex; align-items: center; gap: 14px; cursor: pointer; }
.settings-list label > span { flex: 1; }
.settings-list strong, .settings-list small { display: block; }
.settings-list small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.settings-list input { position: absolute; opacity: 0; }
.settings-list i { position: relative; width: 48px; height: 28px; border-radius: 99px; background: #536075; transition: background .2s ease; }
.settings-list i::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: transform .2s ease; }
.settings-list input:checked + i { background: var(--teal); }
.settings-list input:checked + i::after { transform: translateX(20px); }
.text-button { display: block; padding: 9px 0; }
.language-options { display: grid; gap: 10px; }
.language-options button { display: flex; align-items: center; gap: 14px; padding: 15px; border: 2px solid transparent; border-radius: 18px; background: rgba(255,255,255,.06); text-align: left; cursor: pointer; }
.language-options button.selected { border-color: var(--amber); background: rgba(246,189,98,.1); }
.language-options b { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; color: var(--ink); background: var(--paper); }
.language-options span { flex: 1; }
.language-options strong, .language-options small { display: block; }
.language-options small { margin-top: 3px; color: var(--muted); }
.language-options i { opacity: 0; color: var(--amber); }
.language-options .selected i { opacity: 1; }
.exchange-rack { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 66px; }
.exchange-rack .tile { width: 54px; font-size: 28px; }
.letter-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.letter-grid button { aspect-ratio: 1; border: 1px solid rgba(255,255,255,.1); border-radius: 10px; background: rgba(255,255,255,.07); font-weight: 800; cursor: pointer; }
.onboarding-modal { width: min(520px, 100%); }
.onboarding-steps { display: grid; gap: 10px; margin: 4px 0 22px; }
.onboarding-steps article { display: flex; align-items: flex-start; gap: 12px; padding: 13px; border-radius: 16px; background: rgba(255,255,255,.055); }
.onboarding-steps article > b { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border-radius: 10px; color: var(--ink); background: var(--amber); }
.onboarding-steps strong, .onboarding-steps small { display: block; }
.onboarding-steps small { margin-top: 4px; color: var(--muted); line-height: 1.4; }
.lookup-modal { width: min(540px, 100%); }
.lookup-modal h2 { margin: 8px 0 4px; color: var(--amber); font-size: 34px; letter-spacing: .02em; }
.lookup-alternatives { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; }
.lookup-alternatives button { padding: 5px 9px; border: 1px solid rgba(255,255,255,.11); border-radius: 99px; background: rgba(255,255,255,.06); font-size: 11px; font-weight: 800; cursor: pointer; }
.lookup-alternatives button.selected { border-color: var(--teal); color: var(--teal); background: rgba(107,194,181,.1); }
.lookup-form { min-height: 20px; margin: 0 0 16px; color: var(--teal); font-size: 12px; font-weight: 750; }
.lookup-meanings { display: grid; gap: 9px; }
.lookup-meaning { display: grid; grid-template-columns: 24px 1fr; gap: 8px; padding: 11px 12px; border-radius: 14px; background: rgba(255,255,255,.055); line-height: 1.48; }
.lookup-meaning b { color: var(--amber); }
.lookup-source { margin: 16px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.lookup-source a { color: var(--teal); text-decoration: underline; text-underline-offset: 2px; }
.lookup-source a:hover, .lookup-source a:focus-visible { color: var(--amber); }
.result-modal { text-align: center; overflow: hidden; }
.result-stars { margin: 10px 0 16px; color: var(--amber); font-size: 30px; letter-spacing: 8px; }
.result-copy { color: var(--muted); line-height: 1.55; }
.result-scores { display: flex; justify-content: center; gap: 12px; margin: 22px 0; }
.result-score { min-width: 108px; padding: 13px; border-radius: 17px; background: rgba(255,255,255,.06); }
.result-score strong, .result-score small { display: block; }
.result-score strong { color: var(--amber); font-size: 27px; }
.result-score small { color: var(--muted); }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 15px; border-radius: 3px; animation: confetti 1.8s ease-in forwards; }
@keyframes confetti { to { transform: translate(var(--drift), 600px) rotate(720deg); opacity: 0; } }
.prose-modal { width: min(620px, 100%); }
.prose-modal h3 { margin: 22px 0 5px; color: var(--amber); }
.prose-modal p, .prose-modal li { color: var(--muted); line-height: 1.55; font-size: 14px; }
.hidden { display: none !important; }

.drag-ghost { position: fixed; z-index: 200; width: 50px; pointer-events: none; transform: translate(-50%, -70%); font-size: 27px; }
.thinking .turn-orb span { animation-duration: .55s; }
.thinking .board { pointer-events: none; }
.thinking .rack { opacity: .65; }

.high-contrast .board-cell { border-color: rgba(0,0,0,.38); }
.high-contrast .tile { border: 2px solid #3b2b1a; box-shadow: 0 2px 0 #765b37; }

@media (max-width: 820px) {
  .screen { padding-top: 18px; }
  .game-screen { padding: 0 8px max(18px, env(safe-area-inset-bottom)); }
  .game-layout { display: flex; flex-direction: column; gap: 12px; }
  .board-column { width: min(680px, 100%); }
  .board-wrap { max-width: min(calc(100vw - 16px), calc(100dvh - 260px), 680px); }
  .game-panel { width: min(680px, 100%); gap: 8px; }
  .objective-card { display: none; }
  .objective-card.challenge-objective { display: block; margin: 0; padding: 9px 12px; border-radius: 14px; }
  .objective-card.challenge-objective > strong { margin: 3px 0 5px; font-size: 14px; }
  .objective-card.challenge-objective > span { margin-top: 4px; font-size: 10px; }
  .objective-card.challenge-objective .progress-track { height: 5px; }
  .definition-card { display: none !important; }
  .word-preview { min-height: 54px; padding: 9px 13px; }
  #move-message { margin-top: 3px; min-height: 16px; }
  .action-grid { grid-template-columns: repeat(3, 1fr); }
  .action-grid .secondary-button { min-height: 43px; }
  .play-button { min-height: 50px; }
  .rack-wrap { margin-top: 12px; }
}

@media (max-width: 620px) {
  .app-header { padding-inline: 12px; }
  .brand > span:last-child { display: none; }
  .screen { padding-inline: 13px; }
  .hero { margin-top: 3vh; }
  .hero-copy { font-size: 14px; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: 168px; }
  .mode-copy em { max-width: 88%; }
  .home-stats { grid-template-columns: repeat(3, 1fr); }
  .home-stat { padding: 10px 5px; }
  .difficulty-grid { grid-template-columns: 1fr; }
  .difficulty-card { min-height: 132px; padding: 18px 18px 14px 96px; }
  .difficulty-card .portrait { position: absolute; left: 18px; top: 21px; margin: 0; }
  .difficulty-card p { margin-bottom: 0; }
  .challenge-node { width: 82%; }
  .challenge-node:nth-child(even) { margin-left: 18%; }
  .challenge-path::before { left: 11%; }
  .challenge-node::after, .challenge-node:nth-child(even)::after { left: -10.4%; right: auto; }
  .score-card { min-width: 0; padding-inline: 6px; }
  .turn-orb { min-width: 58px; }
  .rack-wrap { width: calc(100% - 28px); padding-inline: 5px; }
  .rack { gap: 3px; }
  .rack .tile { width: 13.3%; flex-basis: 13.3%; }
  .rack-shuffle { right: -32px; }
  .modal { padding: 25px 20px; border-radius: 24px; }
}

@media (max-height: 730px) and (max-width: 820px) {
  .app-header { padding-top: max(7px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .brand-tile { width: 30px; height: 30px; }
  .icon-button, .language-pill { height: 36px; min-width: 38px; }
  .game-topbar { margin-bottom: 5px; }
  .score-card strong { font-size: 19px; }
  .board-wrap { max-width: min(calc(100vw - 16px), calc(100dvh - 238px)); padding: 6px; border-radius: 16px; }
  .rack-wrap { min-height: 60px; margin-top: 8px; padding-block: 5px; }
  .rack { min-height: 48px; }
  .word-preview { display: none; }
  .action-grid .secondary-button { min-height: 38px; padding-block: 8px; }
  .play-button { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
