:root { color-scheme: light; font-family: Inter, ui-sans-serif, system-ui, sans-serif; color: #1d1b17; background: #f3ead8; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: radial-gradient(circle at 8% 5%, #fff9 0 5%, transparent 18%), #f3ead8; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
main { width: min(1220px, 100%); min-height: 100vh; margin: auto; padding: clamp(12px, 2.2vw, 28px); }
header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 48px; margin-bottom: clamp(18px, 3vw, 36px); }
.home, .text-button { color: #5e584f; font-weight: 850; font-size: .76rem; letter-spacing: .09em; text-transform: uppercase; text-decoration: none; }
.brand { display: flex; align-items: baseline; gap: 5px; text-transform: uppercase; letter-spacing: -.04em; }
.brand span { font: italic 600 1rem Georgia, serif; text-transform: none; }
.brand strong { font-size: 1.12rem; }
.text-button { justify-self: end; border: 0; padding: 8px; background: none; cursor: pointer; }
.eyebrow { margin: 0 0 6px; color: #d45136; font-size: .7rem; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; line-height: .95; letter-spacing: -.045em; }
h1 { font-size: clamp(2.5rem, 7vw, 5.6rem); }
.library-intro { width: min(650px, 100%); margin-bottom: 30px; }
.library-intro > p:last-child { color: #686057; font-family: Georgia, serif; font-size: 1.05rem; line-height: 1.55; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 13px; padding-bottom: 30px; }
.book-card { position: relative; min-height: 190px; padding: 18px; overflow: hidden; text-align: left; border: 2px solid #1d1b17; border-radius: 13px; color: #1d1b17; background: var(--paper, #fffaf0); cursor: pointer; box-shadow: 4px 5px 0 #1d1b17; transition: transform .15s, box-shadow .15s; }
.book-card:hover { transform: translate(-2px,-2px); box-shadow: 6px 7px 0 #1d1b17; }
.book-card h2 { position: relative; z-index: 1; max-width: 80%; font-size: 1.9rem; }
.book-card p { position: absolute; z-index: 1; bottom: 12px; left: 18px; margin: 0; font-size: .7rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.book-card img { position: absolute; right: -9px; bottom: -15px; width: 105px; height: 105px; opacity: .82; transform: rotate(-5deg); }
.hidden { display: none !important; }
.game-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.game-heading h1 { font-size: clamp(2rem, 5vw, 4rem); }
.read-button, .primary-button, .score-row button, .bonus-button { border: 2px solid #1d1b17; border-radius: 99px; padding: 9px 15px; color: #fff; background: #1d1b17; font-weight: 850; font-size: .75rem; cursor: pointer; }
.heading-actions { display: flex; gap: 7px; }
.next-button { color: #1d1b17; background: #f5c84c; }
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: clamp(14px, 2.5vw, 28px); align-items: start; }
.board-wrap { position: relative; width: min(100%, calc(100vh - 190px)); width: min(100%, calc(100dvh - 190px)); aspect-ratio: 1; margin: auto; }
.board { display: grid; width: 100%; height: 100%; padding: clamp(5px, 1vw, 10px); border: 3px solid #1d1b17; border-radius: 14px; background: #fffaf0; box-shadow: 7px 8px 0 #1d1b1720; touch-action: none; user-select: none; }
.cell { position: relative; display: grid; place-items: center; min-width: 0; border-radius: 50%; font-size: clamp(.8rem, 2.25vw, 1.45rem); font-weight: 800; line-height: 1; }
.cell.selected::before, .cell.found::before, .cell.bonus-found::before, .cell.hinted::before { content: ""; position: absolute; inset: 8%; z-index: 0; border-radius: 50%; background: #f5c84c99; }
.cell.found::before { background: #88c9a499; }
.cell.bonus-found::before { background: #ba9be8a8; }
.cell.hinted::before { border: 3px solid #e44f37; background: transparent; animation: hint-pulse .7s ease-in-out infinite alternate; }
.cell span { position: relative; z-index: 1; pointer-events: none; }
.selection-word { position: absolute; left: 50%; bottom: 9px; z-index: 3; min-width: 70px; padding: 5px 10px; border-radius: 99px; color: white; background: #1d1b17e8; text-align: center; font-size: .72rem; font-weight: 850; letter-spacing: .1em; transform: translateX(-50%); opacity: 0; }
.selection-word.visible { opacity: 1; }
.word-panel { min-width: 0; }
.score-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 13px; border-bottom: 2px solid #1d1b17; }
.score-row > div { display: flex; align-items: baseline; gap: 5px; font-size: .7rem; font-weight: 850; text-transform: uppercase; }
.score-number { font: 700 2rem Georgia, serif; }
.score-row button:disabled { opacity: .38; cursor: default; }
.bonus-button { width: 100%; margin-top: 12px; color: #1d1b17; background: #f5c84c; }
.bonus-button:disabled { opacity: .38; cursor: default; }
.hint-copy { color: #71695e; font-size: .72rem; line-height: 1.4; }
.word-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 15px 0 0; padding: 0; list-style: none; }
.word-list li { font-size: clamp(.72rem, 1.3vw, .9rem); font-weight: 850; letter-spacing: .06em; overflow-wrap: anywhere; text-transform: uppercase; }
.word-list li.found { color: #8a8379; text-decoration: line-through 2px #d45136; }
dialog { width: min(720px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: clamp(18px, 4vw, 38px); border: 3px solid #1d1b17; border-radius: 15px; background: #fffaf0; box-shadow: 9px 10px 0 #1d1b17; }
dialog::backdrop { background: #1d1b17aa; backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 15px; margin-bottom: 24px; }
.dialog-head h2, .complete-dialog h2 { font-size: clamp(2rem, 6vw, 3.7rem); }
.icon-button { border: 0; background: none; font-size: 2rem; line-height: 1; cursor: pointer; }
#reader article { color: #37332d; font: 1.05rem/1.7 Georgia, serif; }
#reader article p { white-space: pre-wrap; }
.complete-dialog { width: min(440px, calc(100% - 24px)); text-align: center; }
.complete-dialog img { width: 100px; height: 100px; margin: -12px auto 8px; }
.complete-dialog > p:not(.eyebrow) { color: #686057; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: center; gap: 8px; }
@keyframes hint-pulse { to { transform: scale(1.15); border-color: #f19e38; } }

@media (max-width: 720px) {
  main { padding: 9px; }
  header { min-height: 39px; margin-bottom: 8px; }
  .brand strong { font-size: .94rem; }
  .brand span { display: none; }
  .library { padding: 12px 5px; }
  .book-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .book-card { min-height: 155px; padding: 14px; box-shadow: 3px 4px 0 #1d1b17; }
  .book-card h2 { font-size: clamp(1.3rem, 6vw, 1.75rem); }
  .book-card p { left: 14px; }
  .book-card img { width: 80px; height: 80px; }
  .game-heading { align-items: center; margin: 3px 3px 9px; }
  .game-heading h1 { max-width: 65vw; overflow: hidden; font-size: 1.5rem; text-overflow: ellipsis; white-space: nowrap; }
  .read-button { padding: 7px 10px; }
  .heading-actions { gap: 4px; }
  .next-button { position: fixed; right: 12px; bottom: 12px; z-index: 8; padding: 11px 16px; box-shadow: 3px 4px 0 #1d1b17; }
  .play-layout { display: flex; flex-direction: column; gap: 10px; }
  .board-wrap { width: min(100%, calc(100dvh - 285px)); min-width: min(100%, 290px); }
  .cell { font-size: clamp(.82rem, 4.4vw, 1.2rem); }
  .word-panel { width: 100%; }
  .score-row { padding: 0 2px 6px; }
  .score-number { font-size: 1.5rem; }
  .hint-copy { display: none; }
  .bonus-button { width: auto; margin: 7px 3px 0; padding: 6px 10px; font-size: .65rem; }
  .word-list { grid-template-columns: repeat(4, 1fr); gap: 5px 8px; margin: 8px 4px 0; }
  .word-list li { font-size: clamp(.57rem, 2.6vw, .72rem); }
}

@media (max-width: 380px) { .word-list { grid-template-columns: repeat(3, 1fr); } }
