.handbook {
  width: min(100%, 1370px);
  padding-inline: clamp(32px, 6vw, 96px);
}
.handbook::before {
  right: 1.4%;
  background-size: 102.8% 100%;
  mask-size: 102.8% 100%;
}
.game-controls {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 3px 7px;
}
#field .game-controls button {
  min-height: 40px; padding: 4px 10px; border: 1px solid transparent;
  border-radius: 5px; background: transparent; color: #392c1e;
  font: 600 clamp(14px,1.15vw,18px)/1.2 Georgia,serif;
}
#field .game-voice { justify-self:center; max-width:100%; padding: 0 4px; }
#status { background:transparent; color:#33291c; padding:4px 0; font:600 14px/1.4 Georgia,serif; }
#settings {
  box-sizing:border-box; width:min(390px,calc(100% - 32px)); max-height:85dvh; overflow:auto;
  padding:22px; border:1px solid #917d5f; border-radius:7px;
  background:#f8ead5; color:#352c1d; box-shadow:0 8px 34px #34281855;
  font:16px/1.45 Georgia,serif;
}
#settings::backdrop { background:#2a211b66; }
#settings form { display:flex; justify-content:space-between; align-items:center; gap:12px; }
#settings-title { font:italic bold 29px/1.1 Georgia,serif; letter-spacing:-.04em; }
#settings form button { width:44px; height:44px; font-size:26px; background:transparent; color:inherit; border:0; }
#settings .game-top { display:grid; grid-template-columns:1fr; gap:7px; justify-items:stretch; margin:14px 0; }
#settings .setting-label { font-weight:bold; }
#settings .select-wrap::after { display:none; }
#settings select,#settings .daily-pill { appearance:auto; background:#fff5e4; border:1px solid #927d5d; border-radius:5px; width:100%; min-height:44px; padding:8px; color:#3d3323; font:inherit; }
#settings .daily-pill { justify-content:center; }
#settings .daily-pill[aria-pressed=true] { background:#4c502c; color:white; }
.record-line { display:flex; justify-content:space-between; gap:10px; border-top:1px solid #bfaa88; padding:12px 0; }
.setting-note { font-size:15px; }
@media(hover:hover) and (pointer:fine) {
  #new:hover { background:linear-gradient(#80824b,#535b30); color:white; border-color:#f2e6c7; box-shadow:0 3px 8px #503e2855; }
  #field .game-controls button:not(:disabled):hover,#settings form button:hover,#settings .daily-pill:not([aria-pressed=true]):hover,#settings select:hover,#logic-reset:hover {
    background:#f6e7d0; color:#533b22; border-color:#a38d6c;
  }
  #settings .daily-pill[aria-pressed=true]:hover { background:#60663b; }
  .board[data-phase=won] .cell[data-state=covered]:hover,.board[data-phase=lost] .cell[data-state=covered]:hover { background:var(--covered); cursor:default; }
  .logic-grid button[aria-pressed=true]:hover { background:#ecd0a4; }
}
#new:active { background:#414725; box-shadow: inset 0 2px 4px #211c15; }
:where(button, select, summary, a):focus-visible { outline:3px solid #76501c; outline-offset:2px; }
.cell:focus-visible,.logic-grid button:focus-visible { outline:3px solid #6b4516; outline-offset:-3px; }
@media(max-width:760px) {
  .handbook { width:min(calc(100% - 28px),452px); padding-inline:clamp(18px,5vw,30px); }
  .handbook::before { right:0; background-size:203% 100%; mask-size:203% 100%; }
  #field .game-controls button { min-height:44px; padding:3px 5px; }
  #field .game-controls { gap:2px; }
}
#field #settings-open { border:1px solid #aa977b; background:#f8ebd8; }
@media(hover:hover) and (pointer:fine) {
  #field #settings-open:hover { border-color:#796348; background:#efddc1; }
}

#field #flag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
#flag .lever {
  box-sizing: border-box;
  flex: 0 0 44px;
  width: 44px;
  height: 24px;
  padding: 0;
  border: 1px solid #796a52;
  border-radius: 12px;
  background: #867963;
  box-shadow: inset 0 1px 2px #45392060;
}
#flag .lever::before {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
}
#flag[aria-pressed=true] .lever::before { transform: translateX(20px); }
#flag[aria-pressed=true] .lever::after {
  left: 4px;
  top: 2px;
  width: 15px;
  height: 18px;
  background: #ffd2a4;
  clip-path: polygon(12% 5%,25% 5%,25% 12%,95% 12%,73% 37%,95% 58%,25% 58%,25% 95%,12% 95%);
  content: "";
}
@media (max-width:760px) {
  .questions summary {
    position: relative;
    display: block;
    padding: 12px 30px 12px 0;
  }
  .questions summary::after {
    content: "";
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background:
      linear-gradient(currentColor,currentColor) center / 12px 2px no-repeat,
      linear-gradient(currentColor,currentColor) center / 2px 12px no-repeat;
  }
  .questions details[open] summary::after {
    content: "";
    background-size: 12px 2px, 0 0;
  }
}

/* Reserve the longest feedback at the actual font size and available width. */
.example-feedback {
  display:grid;
  max-width:39ch;
  margin-top:8px;
  font:700 clamp(12px,1vw,16px)/1.25 Georgia,serif;
}
.example-feedback > * { grid-area:1/1; }
.example-feedback > span { visibility:hidden; }
.logic .example-feedback #logic-response {
  position:static; clip-path:none; overflow:visible; width:auto; height:auto;
  max-width:none; margin:0; font:inherit;
}
@media(max-width:760px) {
  .example-feedback { font-size:14px; }
  .handbook .questions { padding-inline-end:12px; padding-bottom:34px; }
  .questions summary { padding:12px 0 12px 27px; }
  .questions summary::after { left:1px; right:auto; }
  .questions details p { margin-inline-start:27px; }
}

/* Leave room for the ascenders of the italic title at the torn edge. */
.logic { padding-block-start:clamp(18px,1.9cqw,30px); }
#logic-title { line-height:1.16; scroll-margin-block-start:24px; }
@media(max-width:760px) {
  .logic { padding-block-start:24px; }
  #how-title { position: relative; top: 6px; }
}

.scorebar > div { --counter-type: italic bold clamp(16px,2.4vw,38px)/1 monospace; }
.scorebar svg, .scorebar strong { font:var(--counter-type); }
.scorebar svg { width:1cap; height:1cap; flex:none; color:#ec4732; }
.scorebar div:last-child svg { color:#fff1d5; }
.scorebar .accessible::before { display:none; }
@media (max-width:760px) {
  .scorebar > div { --counter-type:bold 21px/1 monospace; }
}
