/* WordTwiq web game. Palette and type follow the original game; layout is responsive. */
@import url('/brand.css');
:root {
  color-scheme: light;
  --ink: var(--brand-ink); --bg: var(--brand-bg); --white: #fff; --purple: var(--brand-purple); --purple-dark: var(--brand-purple-dark); --coral: #ff826d;
  /* Right place: a softer lime inspired by the logo, with dark letters and a subtle one-pixel edge. */
  --exact: #b1df8a; --exact-ink: #25213d; --exact-soft: #e6f4dc; --exact-dark: #91be6f; --exact-indicator: #5c903b; --present-indicator: #c65a46; --absent-indicator: #8a839c;
  --edge: #dcd9e6; --muted: #676477; --gold: #f8cc64; --absent: #d9dde3; --lavender: #f0ebff; --soft: #f6f5f9;
  --radius: var(--brand-radius); --shadow: 0 3px 0 #cfc9db;
  --display: Fredoka, Gabarito, ui-rounded, system-ui, sans-serif;
  --sans: Gabarito, ui-rounded, system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { background-image: radial-gradient(#e7e3ed .8px, transparent .8px); background-size: 28px 28px; }
#app.screen-game { background: var(--bg); }
button, .button { font: 700 16px/1.15 var(--sans); color: var(--ink); background: var(--white); border: 0; border-radius: var(--radius); padding: 12px 18px; min-height: 44px;
  cursor: pointer; box-shadow: var(--shadow); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; touch-action: manipulation; transition: transform .08s, background .15s; }
@media (hover: hover) { button:hover:not(:disabled):not(.key), .button:hover { background: #fbfaff; } }
button:active:not(:disabled) { transform: translateY(1px) scale(.98); }
button:disabled { opacity: .45; cursor: default; }
button.primary, .button.primary { background: var(--purple); color: var(--white); box-shadow: 0 4px 0 var(--purple-dark); }
button.primary:hover:not(:disabled), .button.primary:hover { background: #7f5bef; }
button.small { min-height: 40px; padding: 8px 14px; font-size: 15px; }
button.block, .button.block { display: flex; width: 100%; margin: 12px 0 0; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { font-weight: 700; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--purple); margin: 0 0 6px; }
.display, h1 { font-family: var(--display); font-weight: 700; letter-spacing: -.01em; }
.small { font-size: 14px; color: var(--muted); }
.center { text-align: center; }
.accent { color: var(--purple); }
.strong { font-weight: 700; }
.wide-only { display: inline; }
.narrow-only { display: none; }

/* ----- Header ----- */
/* Short pages fill the viewport; long content and enlarged text can still scroll. */
body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
#app { flex: 1 0 auto; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px max(16px, calc((100vw - 1240px) / 2 + 40px)) 8px; background: rgba(245, 243, 238, .92); }
@supports (backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px)) { .topbar { background: rgba(245, 243, 238, .82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); } }
.brand { background: transparent; box-shadow: none; padding: 4px 6px; gap: 12px; min-height: 0; }
.brand:hover { background: transparent !important; }
.logo { border-radius: 12px; display: block; }
.wordmark { font-family: var(--display); font-size: clamp(30px, 3vw, 42px); font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.top-actions button { font-size: 16px; }
.menu-trigger { position: relative; }
.update-ready .menu-trigger::after { content: ''; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--purple); }
/* A quiet switch: solid purple is reserved for the main action. */
.music-toggle { background: #e9e6ef; color: var(--muted); box-shadow: none; }
.music-toggle.on { background: #eee8fc; color: var(--purple); }

/* ----- Pages ----- */
.page { width: min(980px, 100%); margin: 0 auto; padding: 16px clamp(16px, 4vw, 32px) 40px; text-align: center; position: relative; flex: 1; }
.page h1 { font-size: clamp(40px, 6vw, 62px); line-height: 1.05; margin: 6px 0 18px; }
.lede { font-size: clamp(18px, 2vw, 22px); color: var(--muted); margin: 18px auto; max-width: 720px; }
.note { color: var(--muted); font-size: 17px; line-height: 1.5; max-width: 720px; margin: 14px auto; }
.stack { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 22px auto 0; width: min(520px, 100%); }
.stack > button, .pair-buttons { width: 100%; }
.pair-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.big { font-size: 22px; min-height: 64px; }
.clock { color: var(--muted); font-size: 15px; margin-top: 18px; }
.steps { text-align: left; display: inline-block; font-weight: 700; font-size: clamp(18px, 2vw, 22px); line-height: 1.6; margin: 22px auto 0; padding-left: 1.4em; }
.examples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin: 20px 0; }
.example { background: var(--white); border-radius: 20px; padding: 18px 12px 12px; margin: 0; box-shadow: 0 3px 0 #e5e1ec; }
.example figcaption { color: var(--muted); font-weight: 700; margin-top: 10px; font-size: 17px; }
.pair { display: grid; gap: 6px; justify-content: center; }
.pair-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.pair-tile { display: grid; place-items: center; aspect-ratio: 1; min-width: 34px; border-radius: 10px; background: #f0edf6; font: 700 clamp(20px, 2.6vw, 28px) var(--sans); }
.pair-tile.twin { background: var(--exact); color: var(--exact-ink); box-shadow: inset 0 0 0 1px var(--exact-dark); }


/* ----- Home ----- */
/* Today is the primary composition; the twin illustration supports it. */
.home { width: min(1180px, 100%); display: flex; flex-direction: column; justify-content: center; gap: 20px; padding-block: 18px 24px; }
.home-stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 36px; align-items: center; text-align: left; }
.home-copy { min-width: 0; }
.home h1:focus { outline: none; }
.home h1 { font-size: clamp(40px, 4.5vw, 62px); margin: 6px 0 12px; }
.home .lede { font-size: 18px; line-height: 1.4; margin: 0 0 18px; }
.today-panel { padding: 16px 20px; border: 1px solid var(--edge); border-radius: 20px; background: var(--white); }
.today-panel h2 { margin: 0 0 6px; font-size: 14px; color: var(--purple); }
.today-date { margin: 0 0 6px; font: 700 22px/1.2 var(--display); }
.today-status { margin: 0 0 12px; font-size: 16px; }
.today-panel .big { width: 100%; min-height: 52px; }
.today-panel .clock { margin: 12px 0 0; font-size: 14px; text-align: center; }
.home-play { margin-top: 12px; }
.home-links { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 10px; gap: 0 6px; }
.home-links button { font-size: 15px; padding: 8px; }
.home-recovery { font-size: 14px; line-height: 1.4; }
.more-from-dfj { width: min(480px, 100%); margin: 8px auto 0; padding-top: 16px; border-top: 1px solid var(--edge); text-align: left; }
.more-from-dfj h2 { margin: 0 0 8px; font: 700 .875rem/1.4 var(--sans); color: var(--muted); }
.sibling-game { display: flex; align-items: center; gap: 16px; padding: 12px 14px; border: 1px solid var(--edge); border-radius: 16px; color: var(--ink); text-decoration: none; background: var(--soft); }
.sibling-game-copy { display: grid; gap: 3px; min-width: 0; font-size: 1rem; line-height: 1.4; }
.sibling-game-copy strong { font: 600 1.25rem/1.3 var(--display); }
.sibling-game-copy > span { color: var(--muted); }
.sibling-game-copy .sibling-game-destination { font-size: .75rem; overflow-wrap: anywhere; }
.sibling-game-arrow { flex: 0 0 auto; margin-left: auto; color: var(--purple-dark); font-size: 1.25rem; }
.sibling-game:hover strong, .sibling-game:focus-visible strong { text-decoration: underline; text-underline-offset: 3px; }

/* Living board: the pair types itself in, the four matches settle, the changing letter turns green. */
.showcase { position: relative; isolation: isolate; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: clamp(18px, 3vh, 36px) 12px; --t: clamp(48px, 12vw, 64px); }
.orb { position: absolute; z-index: -1; border-radius: 50%; pointer-events: none; filter: blur(30px); opacity: .7; animation: orb 16s ease-in-out infinite alternate; }
.orb-a { width: 62%; aspect-ratio: 1; left: 2%; top: 0; background: radial-gradient(circle, #ded2ff 0%, rgba(222, 210, 255, 0) 70%); }
.orb-b { width: 54%; aspect-ratio: 1; right: 0; bottom: -4%; background: radial-gradient(circle, #dcf1c8 0%, rgba(220, 241, 200, 0) 70%); animation-delay: -8s; }
@keyframes orb { to { transform: translate(7%, -6%) scale(1.1); } }
.show-label { margin: 0 0 18px; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.show-board { display: grid; gap: calc(var(--t) * .22); perspective: 600px; }
.show-row { display: grid; grid-template-columns: repeat(5, var(--t)); gap: calc(var(--t) * .14); }
.show-tile { width: var(--t); aspect-ratio: 1; display: grid; place-items: center; border-radius: calc(var(--t) * .24); background: rgba(255, 255, 255, .5); box-shadow: inset 0 0 0 2px #e4dfec;
  font: 700 calc(var(--t) * .6) var(--display); color: var(--ink); transition: background .35s, box-shadow .35s, transform .4s, opacity .4s; }
.show-tile.typed { background: var(--white); box-shadow: 0 calc(var(--t) * .1) 0 #dcd8e6; animation: show-type .3s cubic-bezier(.2, 1.4, .4, 1); }
.show-tile.match { box-shadow: 0 calc(var(--t) * .1) 0 #d6cfe6, inset 0 0 0 2px #d9cffa; }
.show-row:first-child { --tilt: -7deg; }
.show-row:last-child { --tilt: 7deg; }
.show-tile.twin-slot { background: var(--exact-soft); box-shadow: inset 0 0 0 2px #c7e3ae; }
.show-tile.twin { background: var(--exact); color: var(--exact-ink); box-shadow: 0 calc(var(--t) * .1) 0 var(--exact-dark); }
@keyframes show-type { from { transform: scale(.7) translateY(6px); opacity: .2; } }
/* Once the matches settle, the green pair lifts and tilts apart: the one change, made visible. */
.showcase.revealed .show-tile.twin { transform: translateY(-5px) rotate(var(--tilt)); transition: transform .45s cubic-bezier(.2, 1.4, .4, 1), background .35s, box-shadow .35s; }
.showcase.revealed .show-row:last-child .show-tile.twin { transition-delay: .08s; }
.showcase.leaving .show-tile { transform: translateY(10px) scale(.88); opacity: 0; }
.show-caption { min-height: 1.4em; margin: 22px 0 12px; font-size: 16px; font-weight: 700; color: var(--muted); }
.game-modal .showcase * { animation-play-state: paused; }
@media (min-width: 901px) { .showcase { --t: clamp(50px, 4.8vw, 72px); min-height: 340px; } }
@media (max-width: 900px) and (min-height: 651px) {
  .home-stage { display: flex; flex-direction: column; gap: 0; text-align: center; }
  .home-copy { display: contents; }
  .home .eyebrow { order: 0; margin: 0 0 4px; }
  .home h1 { order: 1; }
  .home .lede { order: 2; }
  .home .showcase { order: 3; padding: 4px 0; --t: 44px; }
  .home .show-label { display: none; }
  .home .show-caption { margin: 10px 0 12px; font-size: 14px; }
  .today-panel { order: 4; width: min(480px, 100%); }
  .home-play { order: 5; width: min(480px, 100%); }
  .home-links { order: 6; }
  .home-recovery { order: 7; }
}
@media (max-width: 600px) {
  .phone .home { padding: 4px 16px 16px; gap: 12px; justify-content: flex-start; }
  .phone .home-stage { display: flex; flex-direction: column; gap: 0; text-align: center; }
  .phone .home-copy { display: contents; }
  .phone .home .eyebrow { display: none; }
  .phone .home h1 { order: 1; font-size: 30px; margin: 4px 0 6px; }
  .phone .home .lede { order: 2; font-size: 15px; margin: 0; max-width: 300px; }
  .phone .home .showcase { order: 3; padding: 10px 0 2px; --t: min(54px, calc((100vw - 96px) / 5)); min-height: 0; }
  .phone .home .show-label { display: none; }
  .phone .home .show-caption { margin: 10px 0; font-size: 13px; }
  .phone .today-panel { order: 4; width: 100%; padding: 12px; }
  .phone .today-date { font-size: 20px; }
  .phone .today-panel .big { min-height: 48px; font-size: 20px; }
  .phone .today-panel .clock { margin-top: 10px; }
  .phone .home-play { order: 5; width: 100%; gap: 10px; }
  .phone .home-play button { font-size: 16px; padding: 10px 6px; }
  .phone .home-links { order: 6; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .phone .home-recovery { order: 7; }
}
@media (max-width: 600px) and (max-height: 700px) {
  .phone .home .showcase { --t: min(46px, calc((100vw - 96px) / 5)); }
}
@media (max-width: 600px) and (min-height: 780px) {
  .phone .home .showcase { --t: min(62px, calc((100vw - 90px) / 5)); }
}
@media (min-width: 601px) and (max-height: 650px) {
  .home { padding-block: 4px 12px; }
  .home-stage { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; }
  .home .eyebrow, .home .show-label { display: none; }
  .home h1 { font-size: 28px; margin: 0 0 4px; }
  .home .lede { margin: 0 0 8px; font-size: 15px; }
  .today-panel { padding: 10px 12px; }
  .today-date { font-size: 18px; }
  .today-status { margin-bottom: 8px; }
  .today-panel .clock { margin-top: 8px; }
  .showcase { --t: 36px; min-height: 0; padding: 10px 0; }
}

/* ----- Puzzle (desktop) ----- */
.game { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 4px clamp(12px, 3vw, 40px) 18px; }
.game-nav { width: min(1120px, 100%); display: grid; grid-template-columns: 120px 1fr 120px; align-items: center; gap: 12px; }
.game-nav > :last-child { justify-self: end; }
.game-title { text-align: center; }
.game-title .eyebrow { font-size: 15px; }
.connection { margin: 0; font-weight: 700; font-size: clamp(18px, 1.8vw, 24px); }
.game-body { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; width: min(1120px, 100%); margin-top: 14px; }
.legend { justify-self: end; color: var(--muted); font-size: 16px; }
.legend p, .legend-row { display: flex; align-items: center; gap: 12px; margin: 0 0 22px; }
.swatch { width: 24px; height: 24px; border-radius: 7px; display: inline-block; flex: none; }
.swatch.exact { background: var(--exact); } .swatch.present { background: var(--coral); } .swatch.absent { background: var(--absent); }
.tips { color: var(--muted); font-size: 17px; max-width: 240px; }
.tips-title { color: var(--purple); font-weight: 700; font-size: 19px; text-transform: uppercase; }
.boards { display: flex; gap: 10px; align-items: flex-start; }
.board h2 { margin: 0; text-align: center; color: var(--purple); font-size: 16px; text-transform: uppercase; letter-spacing: .06em; }
.word-status { margin: 0 0 8px; text-align: center; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.word-status.found { color: var(--purple); font-weight: 700; }
.grid { display: grid; gap: 6px; }
.board .grid { margin-top: var(--board-label-space, 0px); }
.row { display: grid; grid-template-columns: repeat(5, var(--tile, 49px)); gap: 6px; }
.row-numbers { list-style: none; margin: var(--board-label-height, 43px) 0 0; padding: 0; display: grid; gap: 6px; color: var(--muted); font-weight: 700; font-size: 14px; }
.row-numbers li { height: var(--tile, 49px); display: grid; place-items: center; width: 24px; }
.tile { width: var(--tile, 49px); height: var(--tile, 49px); display: grid; place-items: center; border-radius: 11px; background: var(--white); border: 2px solid var(--edge);
  font: 700 calc(var(--tile, 49px) * .52) var(--sans); color: var(--ink); text-transform: uppercase; user-select: none; }
.tile.active { border-color: #cec7dd; background: var(--white); }
.tile.active.entry-next { position: relative; }
.tile.active.entry-next::after { content: ''; position: absolute; width: 14px; height: 3px; bottom: 5px; border-radius: 2px; background: var(--purple-dark); }
/* The entry group keeps keyboard focus without boxing in all five letters. */
.row[data-focus-key="guess-entry"]:focus-visible { outline: none; }
.row[data-focus-key="guess-entry"]:focus-visible .tile { border-bottom-color: var(--purple-dark); }
.tile.active.filled { background: var(--white); }
.tile.exact { background: var(--exact); border: 1px solid var(--exact-dark); color: var(--exact-ink); }
.tile.present { background: var(--coral); border-color: var(--coral); }
.tile.absent { background: var(--absent); border-color: var(--absent); color: #59616f; }
.tile.active.kept { background: var(--exact-soft); border-color: #c5deb6; }
.tile.flip { animation: flip .32s ease-out; }
.tile.pop { animation: pop .16s ease-out; }
.shake { animation: shake .24s linear; }
@keyframes flip { 0% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes pop { 50% { transform: scale(1.075); } }
.found-accent { animation: found-accent .3s var(--accent-delay, 0ms) ease-out; }
@keyframes found-accent { 45% { transform: translateY(-4px) scale(1.04); } }
.card-arrive { animation: card-arrive .2s ease-out; }
@keyframes card-arrive { from { opacity: .6; transform: translateY(8px); } }
@keyframes shake { 20% { translate: -4px; } 40% { translate: 4px; } 60% { translate: -3px; } 80% { translate: 2px; } }
.counter { margin: 14px 0 0; color: var(--muted); font-weight: 700; font-size: 15px; letter-spacing: .04em; text-transform: uppercase; }
.status { margin: 6px 0 0; min-height: 1.5em; color: var(--muted); font-size: 17px; text-align: center; }
.actions { display: flex; gap: 16px; margin: 10px 0 12px; }
.actions button { min-width: 190px; }
.desktop-feedback { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; width: min(740px, 100%); margin: 10px 0 8px; }
.desktop-feedback > div { min-width: 0; }
.desktop-feedback .counter { margin: 0; font-size: 13px; }
.desktop-feedback .status { margin-top: 4px; font-size: 15px; }
.desktop-feedback .actions { margin: 0; gap: 8px; flex-shrink: 0; }
.desktop-feedback .actions button { min-width: 0; padding: 10px 14px; }

/* ----- Keyboard ----- */
.keyboard { width: min(740px, 100%); display: grid; gap: 8px; margin-top: 4px; }
.key-row { display: flex; gap: 6px; justify-content: center; }
.key { flex: 1 1 0; max-width: 68px; min-height: 48px; padding: 0 0 6px; position: relative; flex-direction: column; font-size: 20px; box-shadow: 0 3px 0 #cfc9db; }
.key.wide { flex: 1.5 1 0; max-width: 104px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; padding-bottom: 0; }
.key.enter { background: var(--purple); color: var(--white); box-shadow: 0 3px 0 var(--purple-dark); }
.key .bars { position: absolute; left: 7px; right: 7px; bottom: 5px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.key .bars i { height: 5px; border-radius: 3px; background: var(--edge); }
.key .bars i:not(.exact):not(.present):not(.absent) { visibility: hidden; }
.key .bars i.exact { background: var(--exact-indicator); } .key .bars i.present { background: var(--present-indicator); } .key .bars i.absent { background: var(--absent-indicator); }
.key.has-exact { background: var(--exact-soft); color: #3b6a1f; }
.key.has-present { background: #ffe7db; }
.key.ruled-out { background: #dcdce3; color: #5d5d6a; }
.key.ruled-out .key-letter { text-decoration: line-through; text-decoration-thickness: 2px; }

/* ----- Phone ----- */
.phone .wide-only { display: none; }
.phone .narrow-only { display: inline; }
.phone .topbar { padding: max(8px, env(safe-area-inset-top)) 12px 4px; gap: 8px; }
.phone .brand { padding: 4px 0; gap: 8px; flex-shrink: 1; }
.phone .logo { width: 32px; height: 32px; border-radius: 9px; }
.phone .wordmark { font-size: clamp(19px, 5.9vw, 24px); }
.phone .top-actions { flex-wrap: wrap; flex-shrink: 1; gap: 6px; }
.phone .top-actions button { min-height: 44px; padding: 8px 10px; font-size: 14px; }
.phone .page { padding: 8px 20px calc(28px + env(safe-area-inset-bottom)); }
.phone .page h1 { font-size: 36px; }
.phone .examples { grid-template-columns: 1fr; }
.phone .examples .example:not(:first-child) { display: none; }
.phone .steps { font-size: 18px; line-height: 1.35; } .phone .steps li { margin-bottom: 10px; }
.phone .pair-buttons { grid-template-columns: 1fr 1fr; gap: 10px; }
.compact-game .screen-game { height: calc(100dvh - var(--update-height, 0px)); overflow: visible; }
html.compact-game #app.screen-game { background: #f7f5f1; }
.compact-game .game { padding: 0; min-height: 0; align-items: stretch; }
.toolbar { display: flex; flex: 0 0 auto; gap: 7px; padding: 8px 12px 10px; }
.screen-game .top-actions button:not(.music-toggle), .game-nav > button { box-shadow: none; background: rgba(255,255,255,.7); border: 1px solid #e5e1eb; min-height: 44px; }
.compact-game .toolbar button { min-width: 0; padding: 8px 10px; border: 1px solid #e5e1eb; background: rgba(255,255,255,.8); box-shadow: none; font-size: clamp(12px, 3.5vw, 15px); white-space: normal; }
.compact-game .toolbar .grow { background: transparent; border-color: transparent; color: var(--ink); }
.toolbar .grow { flex: 1; }
.history-area { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.history-window { position: relative; display: flex; flex: 1; min-height: 0; }
.compact-game .history-area:has(.phone-clue-guide:not([hidden])) .history { padding-block: 4px; }
.history { flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
/* Guesses read top to bottom, with spare height before a short trail. */
.history-jump { position: absolute; right: 22px; bottom: 12px; min-height: 44px; padding: 10px 16px; border: 1px solid #d7cee8; border-radius: 24px; background: var(--white); color: var(--purple-dark); font-size: 14px; box-shadow: 0 3px 12px rgba(36,33,59,.14); z-index: 1; }
.compact-game .history .card { flex: 0 0 auto; }
.card { background: var(--white); border: 1px solid #e8e4ef; border-radius: 20px; padding: 11px 12px 14px; box-shadow: 0 3px 0 #e1ddea, 0 10px 22px rgba(36,33,59,.045); --tile: min(46px, calc((100vw - 110px) / 5)); }
.card-title { margin: 0 0 7px; font-size: 12px; font-weight: 700; color: #5e596c; text-transform: uppercase; letter-spacing: .09em; }
.card-row { display: grid; grid-template-columns: 40px repeat(5, var(--tile)); gap: 5px; align-items: center; justify-content: center; margin-top: 6px; }
.compact-game .card .tile { border-radius: 12px; }
.card-label { font-size: 11px; font-weight: 700; color: #6551ab; letter-spacing: .06em; text-transform: uppercase; text-align: center; }
.card.empty .note { font-size: 16px; margin: 10px 0 2px; }
.entry-panel { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0 14px 8px; padding: 10px 12px 8px; border: 1px solid #e8e4ef; border-radius: 20px; background: var(--white); box-shadow: 0 3px 0 #e1ddea; }
.entry-panel .counter { margin: 0; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.entry-panel .status { min-height: 1.35em; margin: 0; font-size: 14px; }
.entry-panel .input-row { margin: 5px 0 0; }
.entry-panel .result-button { width: min(360px, 100%); margin: 4px 0; }
.dock { border: 1px solid #e7e2ed; border-bottom: 0; border-radius: 20px 20px 0 0; box-shadow: 0 -9px 24px rgba(36,33,59,.05); padding: 10px 6px calc(10px + env(safe-area-inset-bottom)); background: #fff; display: flex; flex-direction: column; align-items: center; }
.counter .found-count { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.dock .counter { margin: 0; font-size: 13px; color: var(--ink); text-transform: none; letter-spacing: 0; }
.input-row { --tile: 44px; margin: 7px 0 3px; }
.dock .result-button { width: calc(100% - 40px); margin-top: 6px; }
.dock .status { font-size: 14px; margin: 4px 0 6px; }
.compact-game .keyboard { width: 100%; gap: 6px; }
.compact-game .key-row { gap: 4px; }
.compact-game .key { min-height: 50px; font-size: 22px; max-width: none; border: 1px solid #e6e2ed; border-radius: 11px; background: #f9f8fc; box-shadow: 0 3px 0 #d7d2e0; }
.compact-game .key.has-exact { background: var(--exact-soft); border-color: #cfe5c2; }
.compact-game .key.has-present { background: #ffebe3; border-color: #f6d2c7; }
.compact-game .key.ruled-out { background: #e8e8ed; border-color: #e8e8ed; }
.compact-game .key.enter { background: var(--purple); color: var(--white); border-color: var(--purple); box-shadow: 0 3px 0 var(--purple-dark); }
.compact-game .key.wide { font-size: 13px; }
.compact-game .toolbar button { min-height: 44px; }
.phone-clue-guide { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; width: 100%; padding: 4px 6px 7px; color: #555364; font-size: 12px; font-weight: 700; line-height: 1.25; }
.phone-clue-guide .clue-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.phone-clue-guide .swatch { width: 12px; height: 12px; border-radius: 4px; }
.phone-clue-guide .bar-hint { color: var(--muted); font-weight: 400; }
.phone-clue-guide .guide-dismiss { min-height: 44px; padding: 8px 12px; background: transparent; color: var(--purple-dark); box-shadow: none; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
@media (max-height: 620px) { .compact-game .key { min-height: 44px; } .card { --tile: min(38px, calc((100vw - 110px) / 5)); } }
/* On short phones the empty preview keeps both word rows visible. The same rule
   is explained by the welcome screen and the clue guide after the first guess. */
@media (max-width: 600px) and (max-height: 620px) { .compact-game .card.empty .note { display: none; } }
/* ----- Dialogs ----- */
dialog#game-dialog { border: 0; padding: 0; border-radius: 26px; width: min(720px, calc(100% - 32px)); max-height: min(860px, calc(100dvh - 32px)); color: var(--ink); background: var(--white); display: none; flex-direction: column; overflow: hidden; }
dialog#game-dialog[open] { display: flex; animation: sheet-in .18s cubic-bezier(.2,.8,.2,1); }
@keyframes sheet-in { from { transform: translateY(14px); } to { transform: none; } }
dialog#game-dialog.dialog-menu, dialog#game-dialog.dialog-credits, dialog#game-dialog.dialog-settings { width: min(560px, calc(100% - 32px)); }
dialog#game-dialog.dialog-archive { width: min(600px, calc(100% - 32px)); }
dialog#game-dialog::backdrop { background: rgba(36, 28, 59, .56); }
.dialog-head { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 12px 28px; border-bottom: 1px solid var(--edge); }
.dialog-head h2 { margin: 0; font: 700 28px var(--display); }
#game-dialog-title:focus { outline: none; }
.dialog-head .close { font-size: 26px; min-width: 44px; padding: 0; box-shadow: none; background: var(--soft); }
.dialog-body { min-height: 0; overflow-y: auto; padding: 18px 28px 26px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.dialog-body p { font-size: 17px; line-height: 1.5; margin: 0 0 12px; }
.dialog-body p.small { font-size: 15px; }
.dialog-body .display { font-size: 32px; margin: 4px 0 12px; line-height: 1.1; }
.dialog-body h4 { margin: 18px 0 6px; font-size: 18px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two > button { margin-top: 12px; }
.two + p { margin-top: 14px; }
.dialog-body .examples { gap: 10px; }
.dialog-body .example { padding: 12px 8px 8px; }
.dialog-body .pair-tile { font-size: 20px; min-width: 0; }
.dialog-help .pair-tile { background: var(--soft); }
.dialog-help .pair-tile.twin { background: var(--exact); box-shadow: inset 0 0 0 1px var(--exact-dark); }
.menu-section { margin-bottom: 20px; }
.menu-section:last-child { margin-bottom: 0; }
.menu-section h3 { margin: 0 0 8px; font-size: 17px; }
.menu-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.menu-grid button { background: var(--soft); box-shadow: inset 0 0 0 1px var(--edge); min-height: 48px; }
.version-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--soft); border: 1px solid var(--edge); border-radius: 16px; padding: 14px; margin: 0 0 20px; }
.version-panel strong { font-size: 15px; }
.version-panel p.small { font-size: 13px; line-height: 1.35; margin: 4px 0 0; }
.version-panel button { min-height: 44px; font-size: 13px; padding: 10px 12px; box-shadow: inset 0 0 0 1px var(--edge); }
.version-panel.ready { border-color: var(--purple); background: var(--lavender); }
.version-panel.ready button { box-shadow: 0 3px 0 var(--purple-dark); }
.dialog-leaderboard .segmented button.primary { background: var(--lavender); color: var(--purple-dark); box-shadow: inset 0 0 0 2px var(--purple); }
.dialog-leaderboard .segmented button.primary:hover:not(:disabled) { background: #e5dcff; }
.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 10px 0 20px; }
.stat { background: #f5f1ff; border-radius: 16px; padding: 12px 6px; text-align: center; }
.stat strong { display: block; font: 700 34px var(--display); }
.stat span { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.distribution { list-style: none; padding: 0; margin: 6px 0 14px; display: grid; gap: 6px; }
.distribution li { display: flex; align-items: center; gap: 10px; }
.distribution .n { width: 16px; color: var(--muted); font-weight: 700; }
.distribution .bar { height: 18px; border-radius: 6px; background: var(--edge); max-width: calc(100% - 80px); }
.distribution .bar.filled { background: var(--purple); }
.distribution .count { color: var(--muted); font-size: 15px; }
.dialog-body .stars { text-align: center; font-size: 40px; line-height: 1; letter-spacing: 12px; margin: 4px 0 12px; color: #e3def0; }
.stars .on { color: var(--purple); }
.dialog-result .stars .on { display: inline-block; animation: star-arrive .32s .1s cubic-bezier(.2,.8,.2,1) both; }
.dialog-result .stars .on:nth-child(2) { animation-delay: .18s; }
.dialog-result .stars .on:nth-child(3) { animation-delay: .26s; }
@keyframes star-arrive { from { opacity: 0; transform: scale(.72) translateY(4px); } to { opacity: 1; transform: none; } }
.result-pair { margin: 8px auto 14px; }
.result-pair .pair-tile { width: 52px; font-size: 28px; background: #edeaf4; }
.result-pair .pair-tile.twin { background: var(--exact); }
.volume { display: grid; grid-template-columns: 1fr auto; align-items: center; margin: 18px 0 8px; }
.volume output { font: 700 22px var(--sans); color: var(--purple); }
.volume input { grid-column: 1 / -1; width: 100%; accent-color: var(--purple); height: 36px; }
.themes { display: grid; gap: 10px; margin: 10px 0 14px; }
.theme { justify-content: flex-start; display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; text-align: left; background: #f8f6fc; box-shadow: inset 0 0 0 1.5px #dcd5e9; padding: 10px 14px; }
.theme.selected { background: #eee7ff; box-shadow: inset 0 0 0 2px var(--purple); }
.theme input { accent-color: var(--purple); width: 22px; height: 22px; grid-row: 1 / 3; }
.theme .badge { grid-row: 1 / 3; color: var(--muted); font-size: 16px; }
.theme.selected .badge { color: var(--purple); }
.theme strong { font-size: 19px; } .theme small { font-size: 14px; color: var(--muted); font-weight: 400; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--edge); }
.setting strong { display: block; font-size: 18px; } .setting small { color: var(--muted); font-size: 15px; }
.setting .toggle { min-width: 86px; }
.score-rules { color: var(--muted); text-align: center; font-size: 14px; margin: 10px 0; }
.score-rules summary { cursor: pointer; padding: 8px; }
.score-rules p { margin: 8px auto; max-width: 440px; }
.letter-list { font-size: 22px !important; font-weight: 700; letter-spacing: .08em; }
.letter-list.out { background: #e5e5eb; color: #5d5d6a; border-radius: 12px; padding: 10px 14px; }
.letter-list.in { color: var(--purple); }
.clue-list { margin: 0 0 8px; padding-left: 1.4em; line-height: 1.6; }
.credits-head { display: flex; gap: 18px; align-items: center; margin-bottom: 12px; }
.credits-head img { border-radius: 16px; }
.credits-head p.wordmark { font-size: 30px; margin: 0; line-height: 1.15; }
.credits-head p:not(.wordmark) { font-size: 15px; margin: 4px 0 0; color: var(--muted); }
.dialog-body .producer-name { font: 700 clamp(20px, 4vw, 26px)/1.2 var(--display); margin-bottom: 22px; overflow-wrap: anywhere; }
.credit-note { border-left: 4px solid #ddd3fc; padding-left: 14px; margin: 14px 0; }
.licence-text p { white-space: pre-wrap; font-size: 15px !important; }
.ticks { list-style: none; padding: 0; font-weight: 700; font-size: 18px; line-height: 1.7; }
.ticks li::before { content: '✓  '; color: var(--purple); }
.field { display: block; margin: 12px 0 4px; }
.field input { display: block; width: 100%; margin-top: 6px; font: 700 20px var(--sans); color: var(--ink); background: var(--lavender); border: 2px solid transparent; border-radius: 14px; padding: 12px 14px; }
.field input:focus { border-color: var(--purple); outline: none; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin-bottom: 10px; }
.ranks { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.ranks .group { font-weight: 700; color: var(--purple); text-transform: uppercase; font-size: 14px; letter-spacing: .06em; margin-top: 8px; }
.rank-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; background: var(--soft); border-radius: 14px; padding: 10px 12px; }
.rank-row.mine { background: var(--lavender); }
.rank-row .rank { font: 700 22px var(--display); color: var(--muted); text-align: center; }
.rank-row.mine .rank { color: var(--purple); }
.rank-row .who, .rank-row .score { display: grid; min-width: 0; }
.rank-row .who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.rank-row small { color: var(--muted); font-size: 13px; }
.rank-row .score { text-align: right; } .rank-row .score strong { color: var(--purple); font-size: 18px; }
.phone dialog#game-dialog, dialog#game-dialog.phone-sheet { width: 100%; max-width: 480px; max-height: calc(100dvh - 12px - env(safe-area-inset-top)); margin: auto auto 0; border-radius: 22px 22px 0 0; }
.phone .dialog-body { padding: 14px 20px calc(24px + env(safe-area-inset-bottom)); }
.phone .dialog-head h2 { font-size: 24px; }
.phone .dialog-head { padding: 12px 16px 12px 20px; }
.phone dialog#game-dialog.dialog-menu, .phone dialog#game-dialog.dialog-credits { width: 100%; }
@media (max-width: 360px) { .version-panel { grid-template-columns: 1fr; gap: 10px; } .version-panel button { width: 100%; } }
.phone .stat-tiles { grid-template-columns: 1fr 1fr; }
.phone .dialog-body .display { font-size: 27px; }

/* ----- Celebration and intro ----- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate3d(0, 110dvh, 0) rotate(540deg); } }
.intro { position: fixed; inset: 0; margin: 0; border: 0; padding: 24px; width: 100%; height: 100dvh; max-width: none; max-height: none; color: var(--ink); background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.intro-lockup { display: flex; align-items: center; gap: 20px; }
.intro-lockup img { border-radius: 26px; animation: arrive .7s cubic-bezier(.2, 1.6, .4, 1) both; }
.intro-lockup .wordmark { font-size: clamp(48px, 9vw, 96px); animation: fadeUp .5s .9s both; }
.intro-tagline { color: var(--purple); font-weight: 700; font-size: clamp(22px, 3vw, 34px); margin: 0; animation: fadeUp .45s 1.7s both; }
.intro-producer { color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin: 0; animation: fadeUp .45s 2.1s both; }
.intro button { position: absolute; bottom: calc(32px + env(safe-area-inset-bottom)); }
.phone .intro-lockup { flex-direction: column; gap: 16px; }
.phone .intro-lockup img { width: 96px; height: 96px; }
.phone .intro-lockup .wordmark { font-size: clamp(42px, 12vw, 64px); }
@media (max-height: 500px) {
  .phone .intro { padding-bottom: 76px; }
  .phone .intro-lockup { flex-direction: row; gap: 14px; }
  .phone .intro-lockup img { width: 64px; height: 64px; }
  .phone .intro-lockup .wordmark { font-size: 42px; }
  .phone .intro-producer { font-size: 13px; }
}
@keyframes arrive { from { transform: scale(.18) rotate(-24deg); opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } }

/* ----- Narrower desktop and tablets ----- */
@media (max-width: 1100px) { .game-body { grid-template-columns: auto; justify-content: center; } .legend, .tips { display: none; } .top-actions button { padding: 10px 12px; font-size: 15px; } }
@media (max-width: 860px) and (min-width: 601px) { .top-actions > .wide-only { display: none; } .examples { gap: 10px; } }
@media (min-width: 901px) and (max-height: 800px) {
  .screen-game .topbar { padding-top: 6px; padding-bottom: 4px; }
  .screen-game .logo { width: 36px; height: 36px; }
  .screen-game .wordmark { font-size: 30px; }
  .game-body { margin-top: 4px; }
  .game { padding-bottom: 8px; }
  .game .key { min-height: 44px; }
  .desktop-feedback { margin-block: 6px; }
  .game .connection { font-size: 18px; }
}
@media (min-width: 901px) {
  dialog#game-dialog.dialog-menu { width: min(740px, calc(100% - 48px)); }
  .dialog-menu .dialog-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 20px 24px; }
  .dialog-menu .menu-section { min-width: 0; margin: 0; }
  .dialog-menu .version-panel { grid-column: 1 / -1; }
}
@media (max-width: 700px) { .desktop-feedback { flex-wrap: wrap; justify-content: center; } }
.dialog-body button.block + p, .dialog-body .button.block + p { margin-top: 14px; }
/* Solid clue surfaces stay legible; only navigation uses translucent material. */
@media (prefers-reduced-transparency: reduce) { .topbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; } }
@media (pointer: coarse) {
  .phone .topbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .compact-game .game { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

/* Directory cards live in a secondary sheet, leaving the puzzle and its toolbar untouched. */
.production-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 8px; }
.production-links button.small { min-height: 44px; }
.dialog-listings .dialog-body { padding-top: 16px; }
.dialog-listings .listings-intro { margin: 0 0 16px; color: var(--muted); font-size: 16px; line-height: 1.4; }
.dialog-listings .dgi-feature { display: grid; grid-template-columns: 200px minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 16px; margin: 0 0 22px; border: 1px solid #d4c8f1; border-radius: 18px; background: linear-gradient(120deg, var(--lavender), #f3f7ef); color: var(--ink); text-decoration: none; }
.dialog-listings .dgi-feature img { display: block; width: 200px; max-width: 100%; height: auto; }
.featured-copy { display: grid; gap: 5px; min-width: 0; }
.featured-copy > span { font-size: 13px; color: var(--purple-dark); }
.featured-copy > strong { font: 700 24px/1.1 var(--display); }
.listings-section { margin: 0 0 20px; }
.listings-section > h3 { font-size: 20px; margin: 0 0 14px; }
.listing-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.listing-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 76px; padding: 14px; border: 1px solid var(--edge); border-radius: 14px; background: var(--soft); color: var(--ink); text-decoration: none; }
.listing-copy { display: grid; gap: 5px; min-width: 0; }
.listing-copy strong { font-size: 18px; line-height: 1.2; overflow-wrap: anywhere; }
.listing-copy > span { color: var(--muted); font-size: 14px; line-height: 1.35; }
.external-arrow { color: var(--purple-dark); font-size: 22px; flex: 0 0 auto; }
.listings-note { color: var(--muted); font-size: 14px; line-height: 1.5; }
@media (hover: hover) { .listing-card:hover, .dialog-listings .dgi-feature:hover { background: var(--lavender); border-color: #b8a6e9; } }
@media (max-width: 520px) {
  .listing-grid { grid-template-columns: 1fr; }
  .dialog-listings .dgi-feature { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; margin-bottom: 18px; }
  .dialog-listings .dgi-feature img { grid-column: 1 / -1; justify-self: center; }
  .featured-copy > strong { font-size: 22px; }
  .listing-card { min-height: 72px; padding: 12px 14px; }
  .production-links { column-gap: 0; }
}

/* Tile entry and compact history share one available-height layout. */
.topbar { flex-wrap: wrap; }
.top-actions, .brand { min-width: 0; }
.game-heading { font: 700 15px var(--sans); }
.play-area { display: flex; flex: 1; flex-direction: column; min-height: 0; width: min(600px, 100%); align-self: center; margin-block: 0; }
.entry-area { flex: 0 0 auto; min-width: 0; }
.compact-game .game { width: 100%; flex: 1; min-height: 0; padding: 0; align-items: stretch; }
.compact-game .history-area { flex: 1; min-height: 110px; }
.compact-game .history .card { flex-shrink: 0; --tile: min(46px, calc((100cqw - 74px) / 5)); }
/* The empty illustration leaves room for the tutorial action on short phones. */
@media (max-width: 600px) and (max-height: 620px) {
  .compact-game .history .card.empty { padding-block: 8px; --tile: min(34px, calc((100cqw - 74px) / 5)); }
  /* Keep both first-guess rows readable while the one-time key is open. The
     full key-bar explanation remains in Clue guide at the top of the game. */
  .compact-game .history-area:has(.phone-clue-guide:not([hidden])) .history { padding-block: 4px; }
  .compact-game .history-area:has(.phone-clue-guide:not([hidden])) .history-window { min-height: 100px; }
  .compact-game .history-area:has(.phone-clue-guide:not([hidden])) .card { --tile: 28px; padding: 5px 10px; }
  .compact-game .history-area:has(.phone-clue-guide:not([hidden])) .card-title { margin-bottom: 3px; font-size: 11px; }
  .compact-game .history-area:has(.phone-clue-guide:not([hidden])) .card-row { margin-top: 3px; }
  .compact-game .history-area:has(.phone-clue-guide:not([hidden])) .card .tile { font-size: 22px; border-radius: 8px; }
  .compact-game .phone-clue-guide { display: grid; grid-template-columns: max-content auto; justify-content: center; column-gap: 18px; row-gap: 0; padding: 2px 8px; }
  .compact-game .phone-clue-guide .clue-item { grid-column: 1; }
  .compact-game .phone-clue-guide .bar-hint { display: none; }
  .compact-game .phone-clue-guide .guide-dismiss { grid-column: 2; grid-row: 1 / 4; }
}
.compact-game .history { flex: 1; container-type: inline-size; }
/* Auto margin yields to overflow, keeping the first card reachable in a long trail. */
.compact-game .history > :first-child { margin-top: auto; }
.compact-game .entry-panel { padding: 5px 10px; gap: 2px; margin-bottom: 5px; }
.compact-game .dock { margin: 0 8px max(8px, var(--game-safe-bottom, env(safe-area-inset-bottom))); padding: 8px; border-bottom: 1px solid var(--edge); border-radius: 20px; box-shadow: 0 3px 0 #e1ddea; }
.compact-game .keyboard { margin-top: 0; gap: 8px; }
.compact-game .key.wide { padding-inline: 4px; }
.compact-game .key-row { gap: 4px; }
.compact-game .toolbar { flex-wrap: wrap; }
.key-row { flex-wrap: wrap; }
.key { min-width: 1.05em; }
.key.wide { min-width: max-content; padding-inline: 6px; }
.themes { border: 0; padding: 0; margin-inline: 0; }
.themes legend { font-weight: 700; padding: 0 0 8px; }
.theme { cursor: pointer; border-radius: var(--radius); }
.theme:focus-within { outline: 3px solid var(--purple-dark); outline-offset: 2px; }
@media (min-width: 601px) and (max-height: 650px) {
  .compact-game .play-area { display: grid; flex: 1; width: min(1080px, 100%); margin-block: 0; grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr); grid-template-rows: minmax(0, 1fr); gap: 6px; }
  .compact-game .topbar { padding: 4px 12px; }
  .compact-game .top-actions > .wide-only { display: none; }
  .compact-game .toolbar { padding: 3px 12px; }
  .compact-game .history { flex: 1; padding: 5px 8px 8px; }
  .compact-game .history-area { flex: 1; min-height: 110px; }
  /* Oversized text starts at the column top and scrolls; normal keys end at the bottom. */
  .compact-game .entry-area { align-self: safe end; }
  .compact-game .entry-panel { margin: 0 6px 4px; padding-block: 4px; }
  .compact-game .key { min-height: 44px; }
  .compact-game .key-row { gap: 4px; }
  .compact-game .keyboard { gap: 6px; }
  .compact-game .phone-clue-guide { padding: 2px 4px; }
  .compact-game .dock { padding: 8px; }
}
/* Short landscape keeps the tray frame without sacrificing key touch height. */
@media (min-width: 601px) and (max-height: 390px) {
  .compact-game .topbar { padding-block: 0; }
  .compact-game .toolbar { padding-block: 2px; }
  .compact-game .entry-panel { gap: 0; padding-block: 2px; margin-bottom: 0; }
  .compact-game .entry-panel .input-row { --tile: 38px; margin-top: 0; }
}
@media (forced-colors: active) {
  :focus-visible { outline-color: Highlight; }
  .row[data-focus-key="guess-entry"]:focus-visible { outline: 2px solid Highlight; }
  .tile.active.entry-next::after { background: Highlight; forced-color-adjust: none; }
  .tile.exact { border: 3px solid CanvasText; }
  .tile.present { border: 3px dashed CanvasText; }
  .tile.absent { border: 1px dotted CanvasText; }
  .theme.selected, button[aria-pressed=true] { outline: 2px solid Highlight; }
}
html.clue-symbols .tile { position: relative; }
html.clue-symbols .tile.exact::after, html.clue-symbols .tile.present::after, html.clue-symbols .tile.absent::after { position: absolute; bottom: 0; right: 2px; font: 700 11px var(--sans); }
html.clue-symbols .tile.exact::after { content: '✓'; }
html.clue-symbols .tile.present::after { content: '~'; }
html.clue-symbols .tile.absent::after { content: '×'; }
.history-attempt{padding:1rem 0;border-bottom:1px solid var(--line,#ddd)}
.attempt-id{overflow-wrap:anywhere}
.worked-examples{margin:1rem 0}.worked-examples summary{cursor:pointer;font-weight:700}
.example .pair-tile.twin{outline:2px solid currentColor;outline-offset:2px}



/* At exceptional heights the page scrolls, retaining readable 44px keys. */
@media (max-height: 340px) { .compact-game .screen-game { height: auto; min-height: calc(100dvh - var(--update-height, 0px)); } .compact-game .play-area { min-height: 240px; } }

/* Calendar-first Archive: one scrolling body, bounded dates, disclosed tools. */
dialog#game-dialog.dialog-archive { width: min(600px, calc(100% - 16px)); }
.dialog-archive .dialog-head { padding: 12px 12px 12px 16px; }
.dialog-archive .dialog-head h2 { font-size: 25px; }
.dialog-archive .dialog-body { padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); }
.archive-content { max-width: 460px; margin: 0 auto; }
.archive-toolbar { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 8px; align-items: center; }
.archive-toolbar > button { min-width: 0; padding: 8px 0; min-height: 44px; box-shadow: none; background: var(--soft); }
.archive-toolbar .archive-month-trigger { font-size: 18px; background: transparent; }
.dialog-body .archive-summary { margin: 4px 0 8px; text-align: center; font-size: 15px; line-height: 1.35; }
.dialog-body .archive-recovery, .dialog-body .archive-message, .dialog-body .archive-empty { font-size: 15px; line-height: 1.4; margin: 8px 0; }
.dialog-archive .calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dialog-archive .dow { min-width: 0; text-decoration: none; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.dialog-archive .day { position: relative; min-width: 0; min-height: 50px; padding: 4px 0 14px; font-size: 18px; border-radius: 10px; background: var(--soft); box-shadow: inset 0 0 0 1px var(--edge); }
.dialog-archive .day:disabled { opacity: 1; color: #73717e; background: transparent; box-shadow: none; }
.dialog-archive .day:hover:not(:disabled) { background: var(--lavender); }
.dialog-archive .day.today { box-shadow: inset 0 0 0 2px var(--purple); }
.dialog-archive .day i { position: absolute; bottom: 1px; left: 0; right: 0; font-size: 14px; line-height: 14px; font-weight: 800; font-style: normal; }
.archive-key { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 12px; margin: 10px 0 12px; font-size: 14px; color: var(--muted); }
.archive-key span { display: inline-flex; gap: 4px; align-items: center; }
.archive-key i { font-style: normal; font-weight: 800; }
.dialog-archive i.done { color: #356524; }
.dialog-archive i.started { color: #806000; }
.dialog-archive i.unsolved { color: #575463; }
.dialog-archive i.unavailable { color: var(--purple-dark); }
.archive-shortcuts { display: flex; flex-direction: column; gap: 8px; }
.archive-shortcuts button { width: 100%; box-shadow: none; background: var(--soft); }
.archive-shortcuts button.primary { background: var(--purple); color: var(--white); }
.archive-secondary { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 8px; margin: 8px 0 4px; }
.archive-secondary button { background: transparent; box-shadow: none; padding: 8px 12px; color: var(--purple-dark); }
.dialog-body .archive-note { font-size: 14px; line-height: 1.4; text-align: center; color: var(--muted); margin: 4px 0 0; }
.archive-tool { margin: 8px 0 12px; padding: 12px; border-radius: 14px; background: var(--soft); }
.archive-tool label { display: block; font-size: 16px; }
.archive-tool input, .archive-tool select { display: block; width: 100%; min-width: 0; min-height: 44px; margin-top: 4px; padding: 8px; border: 1px solid var(--edge); border-radius: 8px; background: var(--white); color: var(--ink); font: 400 16px var(--sans); }
.archive-month-fields { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 8px; }
.archive-tool-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.archive-tool-actions button { flex: 1 1 auto; min-width: 0; }
.dialog-body .archive-date-help, .dialog-body .archive-error { font-size: 15px; margin: 8px 0; line-height: 1.4; overflow-wrap: anywhere; }
.dialog-body .archive-error { color: #8b283d; }
.archive-error:empty { display: none; }
@media (max-width: 600px) {
  .dialog-archive .day { min-height: 44px; font-size: 16px; }
  .dialog-archive .dialog-head h2 { font-size: 24px; }
}
@media (forced-colors: active) {
  .dialog-archive .day:not(:disabled) { border: 1px solid ButtonText; }
  .dialog-archive .day.today { border: 2px solid Highlight; }
}

/* Explicit shared roles: opt in; game keys, Archive and legacy screens retain their contracts. */
button.role-primary { background: var(--purple); color: white; box-shadow: 0 4px 0 var(--purple-dark); }
button.role-secondary { background: var(--soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge); }
button.role-quiet { background: transparent; color: var(--purple-dark); box-shadow: none; }
button.role-selected, button.role-switch[aria-checked=true] { background: var(--lavender); color: var(--purple-dark); box-shadow: inset 0 0 0 2px var(--purple); }
button.role-switch { background: var(--soft); box-shadow: inset 0 0 0 1px var(--edge); }
.role-disclosure { margin-block: 16px; }
.role-disclosure > summary { padding-block: 10px; cursor: pointer; font-weight: 700; }
.role-status { color: var(--muted); }
.role-warning { padding: 10px 12px; border: 1px solid var(--purple); border-radius: 12px; background: var(--lavender); color: var(--ink); }
button.role-destructive { color: #8b283d; background: #fff2f4; box-shadow: inset 0 0 0 1px #c67889; }
.top-actions > .role-quiet { padding-inline: 10px; }
.single-example { grid-template-columns: minmax(0, 320px); justify-content: center; }
.welcome .public-disclosure { margin-block: 16px; font-size: 15px; }
.help-steps { padding-left: 0; list-style-position: inside; line-height: 1.5; }
.help-steps li { margin-bottom: 10px; }
.dialog-help .help-steps { padding-left: 1.5em; list-style-position: outside; }
.dialog-help .help-steps li { padding-left: 6px; margin-bottom: 16px; }
.dialog-help .help-steps li::marker { color: var(--purple-dark); font-weight: 700; }
.dialog-help .help-steps strong { display: block; }
.dialog-help .help-section-title { font: 700 22px/1.25 var(--display); margin: 24px 0 12px; }
.dialog-help .example { padding: 16px 12px; background: var(--soft); box-shadow: none; }
.dialog-help .example .pair { width: min(280px, 100%); margin-inline: auto; justify-content: stretch; gap: 8px; }
.dialog-help .example .pair-tile { font-size: clamp(22px, 6vw, 30px); background: var(--white); }
.dialog-help .example .pair-tile.twin { background: var(--exact); }
.dialog-help .example figcaption { text-align: center; font-size: 16px; line-height: 1.4; }
.worked-boards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 16px; margin-block: 12px 20px; }
.worked-board { min-width: 0; }
.dialog-help .worked-board p { font-size: 15px; margin-bottom: 8px; }
.worked-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; width: min(280px, 100%); }
.worked-tile { display: grid; place-items: center; min-height: 40px; aspect-ratio: 1; border: 1px solid var(--edge); border-radius: 8px; font: 700 24px/1 var(--sans); position: relative; padding-bottom: 6px; }
.worked-tile.exact { background: var(--exact); color: var(--exact-ink); }
.worked-tile.present { background: var(--coral); color: var(--ink); }
.worked-tile.absent { background: var(--absent); color: var(--ink); }
.worked-tile small { position: absolute; bottom: 2px; right: 4px; font: 700 11px/1 var(--sans); }
.compact-colour-key .legend-row { margin-bottom: 10px; }
.menu-grid button.role-quiet { min-width: 0; overflow-wrap: anywhere; text-align: left; justify-content: flex-start; background: var(--soft); }
.dialog-menu .version-panel { margin: 8px 0 0; border-radius: 12px; padding: 10px; background: transparent; }
.version-panel.needs-action { background: var(--lavender); border-color: var(--purple); }
.mode-label { font-size: 15px; font-weight: 700; text-align: center; }
.tutorial-action { font-size: 14px; padding: 4px 12px; min-height: 44px; }
.result-actions { margin-top: 20px; }
.result-actions button:not(.primary) { background: var(--soft); box-shadow: inset 0 0 0 1px var(--edge); }
.result-persistence { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--edge); }
.result-persistence h3 { font-size: 17px; margin: 0 0 12px; }
@media (max-width: 360px) { .welcome h1 { font-size: 34px; } .welcome .lede { font-size: 17px; } }

.entry-guidance { display: contents; }
.tutorial-guidance { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; width: 100%; }
.tutorial-guidance .status { text-align: left; }
.tutorial-guidance .tutorial-action { max-width: 118px; }

.tutorial-counter { flex: 0 0 auto; margin: 0; font-size: 13px; text-align: center; }
@media (min-width: 601px) and (max-height: 650px) {
  .compact-game .tutorial-entry { padding-block: 0; }
  .tutorial-entry .input-row { margin-top: 0; }
}

/* Supporting sheets share the Menu hierarchy and explicit action roles. */
.support-section { margin: 0 0 22px; min-width: 0; }
.support-section + .support-section { padding-top: 18px; border-top: 1px solid var(--edge); }
.support-section > h3 { font: 700 19px/1.3 var(--sans); margin: 0 0 10px; }
.support-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-block: 12px; }
.support-actions > button { flex: 1 1 160px; min-width: 0; }
.support-section .setting { padding-top: 8px; }
.support-section .setting > div { min-width: 0; }
.support-section .setting .toggle { flex: 0 0 auto; min-width: 68px; }
.support-section .setting small { display: block; margin-top: 4px; line-height: 1.4; }
.support-section .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
.support-section .stat span { overflow-wrap: anywhere; }
.dialog-music .themes { min-width: 0; border: 0; padding: 0; margin-top: 18px; }
.dialog-music .themes legend { font-weight: 700; margin-bottom: 10px; }
.dialog-music .theme { min-width: 0; grid-template-columns: 28px minmax(0, 1fr); border-radius: 12px; }
.dialog-music .theme strong, .dialog-music .theme small { overflow-wrap: anywhere; }
.dialog-music .volume { gap: 6px; font-weight: 700; }
.dialog-music .volume input { margin: 0; }
.selectable { user-select: text; -webkit-user-select: text; overflow-wrap: anywhere; }
.dialog-body .support-address { font-size: 21px; font-weight: 700; }
.dialog-body .button.role-secondary { background: var(--soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge); }
.dialog-body .button.role-quiet { background: transparent; color: var(--purple-dark); box-shadow: none; }
.dialog-account .selected-owner { margin-bottom: 20px; }
.dialog-account .selected-owner h3 { font-size: 26px; overflow-wrap: anywhere; }
.dialog-account .role-warning { margin-block: 12px; }
.dialog-profile .field { margin-top: 0; }
.dialog-profile .field > span { font-size: 19px; font-weight: 700; }
.dialog-profile .field input { min-width: 0; }
.dialog-profile .support-section { margin-top: 22px; }
.dialog-leaderboard .ranking-filter { min-width: 0; border: 0; padding: 0; margin: 0 0 12px; }
.dialog-leaderboard .ranking-filter legend { margin-bottom: 8px; font-weight: 700; }
.dialog-leaderboard .segmented { grid-auto-columns: minmax(0, 1fr); }
.dialog-leaderboard .segmented button { min-width: 0; padding-inline: 8px; overflow-wrap: anywhere; }
.dialog-leaderboard .board-status { margin-block: 14px; }
.dialog-leaderboard .rank-row { grid-template-columns: 32px minmax(0, 1fr) minmax(64px, auto); }
.dialog-leaderboard .rank-row .who strong { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; line-height: 1.35; }
.dialog-leaderboard .rank-id { margin-top: 5px; color: var(--muted); font-size: 12px; }
.dialog-leaderboard .rank-id summary { cursor: pointer; padding-block: 5px; overflow-wrap: anywhere; }
.dialog-leaderboard .rank-id small { display: block; font-size: 12px; }
.dialog-credits .version-panel { margin: 24px 0 0; }
.production { padding-bottom: 0; }
.production-links > button.small { background: transparent; box-shadow: none; color: var(--purple-dark); }
@media (max-width: 360px) {
  .dialog-music .setting, .dialog-settings .setting { gap: 8px; }
  .dialog-leaderboard .rank-row { gap: 6px; padding: 10px 8px; grid-template-columns: 26px minmax(0, 1fr); }
  .dialog-leaderboard .rank-row .score { grid-column: 2; text-align: left; overflow-wrap: anywhere; }
  .dialog-leaderboard .rank-row .score strong { font-size: 15px; }
}
