:root {
  color-scheme: light;
  --page: #f9e6c6;
  --ink: #351e30;
  --oxblood: #802c40;
  --pink: #f9bbc4;
  --bone: #fff1d2;
  --metal: #b66c36;
  --leather: #593329;
  --serif: Georgia, "Times New Roman", serif;
  --gutter: clamp(10px, 3.2vw, 42px);
  --width: min(81vw, 1530px);
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 system-ui, sans-serif;
}

* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0; min-height: 100dvh; padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom) }
a { color: var(--oxblood); text-underline-offset: .22em; text-decoration-thickness: .075em }
button { font: 750 .92rem/1.18 system-ui, sans-serif; color: inherit; min-height: 44px; min-width: 44px; cursor: pointer; touch-action: manipulation; border: 1px solid #783e3c; border-radius: 4px; background: var(--bone); padding: 6px 12px; box-shadow: 0 2px 0 #633427; }
button:active { transform: translateY(2px); box-shadow: none }
button:disabled { cursor: default }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #7f2942; outline-offset: 3px }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap }

.mast {
  width: var(--width);
  margin: 0 auto;
  min-height: 74px;
  padding: calc(8px + env(safe-area-inset-top)) 1px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.mast h1, .mast .brand { display: flex; align-items: center; gap: .28em; margin: 0; font: 900 clamp(2.35rem, 3.9vw, 4.2rem)/.97 var(--serif); letter-spacing: -.075em; color: var(--ink); text-decoration: none }
.mast img { width: .79em; height: .79em; flex: none }
.mast nav { display: flex; align-items: center; flex: none }
.mast nav a { display: grid; place-items: center; min-height: 44px; padding-inline: 8px; font-size: .92rem; font-weight: 760 }

#game {
  --pad: clamp(7px, 1.15vw, 17px);
  --field-gap: clamp(3px, .58vw, 10px);
  --rail: clamp(4px, 2.4vw, 44px);
  width: var(--width);
  height: clamp(520px, calc(100dvh - 106px), 1000px);
  margin: 0 auto;
  padding: var(--pad);
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) 58px;
  gap: var(--pad);
  border: 1px solid #542f2c;
  border-radius: 9px;
  background: repeating-linear-gradient(3deg, #fee5a805 0 1px, #2b132211 2px, transparent 4px 8px),
    linear-gradient(110deg, #a15630, #c67d40 20%, #ca8040 70%, #a6502b);
  box-shadow: inset 0 0 0 1px #e6a360, inset 0 -7px 0 #6d382833, 0 5px 0 #683929, 0 10px 24px #6d341e2b;
}

.readouts {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 52px;
  gap: 0;
  align-items: center;
  min-width: 0;
  border: 1px solid #43242b;
  border-radius: 5px;
  background: linear-gradient(170deg, #503140, #362232 66%);
  box-shadow: inset 0 1px 0 #8e6269;
  color: var(--bone);
}
.meter { display: flex; align-items: center; justify-content: center; gap: .55em; height: 100%; padding: 0 .4em; font-weight: 670; font-size: .91rem; line-height: 1.1; text-align: center; color: #ffe3b5; border-right: 1px solid #e8b99a39; }
.meter strong { font: bold clamp(1.34rem, 2.25vw, 2rem)/1.05 var(--serif); font-variant-numeric: tabular-nums; color: #fff3da; }
.time-meter { position: relative; overflow: hidden }
.time-meter i { position: absolute; inset: auto 0 0; height: 3px; transform-origin: left; transform: scaleX(var(--time, 1)); background: #eab279; }
.time-meter.urgent strong { color: #ffd0d8 }
.time-meter.urgent i { background: #f198ab }
.pause-button { display: grid; place-items: center; justify-self: center; padding: 0; color: #ffebc9; background: #684052; border-color: #9c6576; box-shadow: none }
.pause-button:focus-visible { outline-color: #fff1d2; outline-offset: 1px }
.pause-icon { width: 15px; height: 17px; border-inline: 4px solid currentColor; border-radius: 1px }

.rack {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) var(--rail);
  min-height: 0;
  position: relative;
  padding: var(--field-gap) 0;
  background: repeating-linear-gradient(0deg,#311e2015 0 1px, transparent 1px 4px),
    radial-gradient(ellipse at 42% 34%, #704335 15%, #502d2b 82%);
  border: 1px solid #5b332c;
  border-radius: 4px;
  box-shadow: inset 0 3px 6px #382026af, 0 1px #dc9a56;
}
.rail { display: grid; grid-template-rows: repeat(7,minmax(0,1fr)); gap: var(--field-gap); align-items: center; justify-items: center; }
.rail i { width: 42%; max-width: 16px; height: 2px; background: #d09567; box-shadow: 0 1px #291726 }
.rail i:nth-child(2) { width: 70%; background: #f4ba90 }
.rail i.forecast { width: 85%; background: #fff3cc; box-shadow: 0 0 5px #ffe4ae }
.rail i.cleared { background: #ffbdc7; box-shadow: 0 0 7px #ff8e9f }

#board {
  min-width: 0;
  display: grid;
  grid-template: repeat(7,minmax(0,1fr))/repeat(7,minmax(0,1fr));
  gap: var(--field-gap);
  position: relative;
  outline: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#board:focus-visible::after { content: ""; position: absolute; pointer-events: none; inset: -2px; border: 1px solid #ffe6af; border-radius: 4px; }
.tile {
  display: grid;
  place-items: center;
  color: #40272d;
  min-width: 0;
  min-height: 0;
  position: relative;
  border: 1px solid #523127;
  border-radius: 4px;
  background:
    repeating-linear-gradient(100deg, #82512a0d 0 1px, transparent 2px 7px),
    linear-gradient(104deg, #f8d18b, #ffe2a5 45%, #edb56b);
  box-shadow: inset 0 1px #fff3c8, inset 0 -5px #91613a56, 0 2px 2px #351c23b3;
  text-shadow: 0 1px #fff2c4;
  font: 800 clamp(1.65rem, min(5.1vw, 6.7dvh), 4.65rem)/.94 var(--serif);
}
.tile span { position: relative; z-index: 2; padding-bottom: .07em; pointer-events: none; transition: translate .105s ease-out; }
.tile::after { content: ""; position: absolute; width: 23%; max-width: 23px; bottom: 11%; height: 1px; background: #9461378a; }
.tile:nth-of-type(3n + 1) { background-position: 0 0, 7px 0 }
.tile:nth-of-type(4n + 1) { background-position: 3px 0, -8px 0 }
.tile.falling { z-index: 2; }
.tile.empty { pointer-events: none; background: #39232b48; border-color: #ce947339; box-shadow: inset 0 1px 2px #291e2566; }
.tile.empty::after { display: none }
.tile.empty.cleared { border-color: #e8ab962f; box-shadow: inset 0 0 12px #291b2345; }
.tile.empty.cleared::after { display: block; bottom: 50%; width: 72%; max-width: none; background: #e7a8953c; }
.tile.selected {
  color: #4a193a;
  text-shadow: 0 1px #ffe2dd;
  border-color: #8d3453;
  background: linear-gradient(135deg, #ffdbd3, #ee9aae);
  box-shadow: inset 0 2px #fff0e2, inset 0 -4px #a44f6855, 0 2px 3px #381925ae;
}
.tile.selected span { translate: 0 -.055em }
.tile.tip::before, .tile.cursor::before { content: ""; position: absolute; z-index: 2; inset: 5px; border: 2px dashed #7e345d; border-radius: 3px; pointer-events: none; }
.tile.tip::before { border-color: #994567; border-style: dotted }
.tile.tip-start::before { border-style: solid }
#ink { display: block; position: absolute; z-index: 3; width: 100%; height: 100%; inset: 0; pointer-events: none; }

.controls {
  min-width: 0;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: clamp(4px, 1vw, 14px);
  padding: 4px;
  background: #743d34;
  border: 1px solid #60332b;
  border-radius: 5px;
  box-shadow: inset 0 1px 2px #42252c80, 0 1px #e79a56;
}
.controls button { min-width: 64px }
.controls [data-act="lift"] { font-variant-numeric: tabular-nums; min-width: 72px; }
.controls [data-act="lift"][aria-pressed="true"] { background: #852f44; color: #fff2d6; }
.tray.forecast #hint { color: #ffe0a2; }
.controls button:focus-visible { outline-offset: 1px; outline-color: #ffefd5 }
.controls button:disabled { opacity: .73 }
.tray { display: grid; place-content: center; text-align: center; overflow: hidden; line-height: 1.14; color: #ffecd0; background: #4c292e; border-radius: 3px; box-shadow: inset 0 1px 4px #301a224d; padding: 2px 5px; }
#word { font: bold clamp(1.01rem, 2.3vw, 1.6rem)/1 var(--serif); color: #ffe2bc; letter-spacing: .105em; overflow-wrap: anywhere; }
#hint { margin: 0; font-size: .87rem; font-weight: 625; overflow-wrap: anywhere; }
#word:not(:empty) + #hint { margin-top: 2px }

.panel {
  position: absolute;
  z-index: 4;
  text-align: center;
  inset: 50% auto auto 50%;
  width: min(calc(100% - 32px), 424px);
  transform: translate(-50%,-50%) rotate(-.65deg);
  color: var(--ink);
  background: repeating-linear-gradient(2deg, #753e3610 0 1px, transparent 2px 5px), #ffe0aa;
  padding: 19px clamp(13px, 3vw, 30px) 20px;
  border: 1px solid #5a3133;
  border-radius: 4px;
  box-shadow: 0 0 0 3px #ffe1af, 0 0 0 4px #783c46, 3px 8px 0 4px #42212687, 0 11px 22px 4px #28142894;
}
.panel::before, .panel::after { content: ""; position: absolute; background: #983d4d; width: 7px; height: 7px; transform: rotate(45deg); top: 10px; }
.panel::before { left: 10px }
.panel::after { right: 10px }
.panel h2 { font: 900 clamp(1.75rem, 4.6vw, 2.82rem)/1.02 var(--serif); letter-spacing: -.05em; margin: 0 0 .25em; }
.panel p { font-size: .94rem; font-weight: 635; margin: 0 0 13px; line-height: 1.36; }
.panel-actions { display: flex; gap: 8px; justify-content: center; }
.panel-actions button { min-width: 88px; }
.panel-actions .primary, .button-link { background: #852f44; color: #fff2d6; border-color: #5e2437; box-shadow: 0 2px #5d2739; min-width: 124px; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 16px; padding-top: 13px; border-top: 1px solid #a36956; }
.options button { padding: 4px 6px; background: #fff0d3; }
.options button[aria-pressed="true"] { background: #6b3b4a; color: #fff1d4; }
.options button[aria-pressed="true"]::before { content: "✓ "; }
#game[data-mode="won"] .panel { background-color: #ffc7c6; inset-block-start: 64%; }
#game[data-mode="playing"] .panel, #game[data-mode="tutorial"] .panel { pointer-events: none }
#game.hand-off .rack { animation: impression .19s ease-out both }
#game.finish .rack { animation: celebration .38s ease-out both }
.tray.bad { animation: impression .18s ease-out both }
#game:not([data-reduced]) .panel:not([hidden]) { animation: slip .17s ease-out both }
@keyframes impression { 30% { translate: 2px 1px } 65% { translate: -1px 0 } }
@keyframes celebration { 28% { translate: 0 -4px; filter: brightness(1.19) } 60% { translate: 0 2px } }
@keyframes slip { from { opacity: .7; translate: 0 6px } to { opacity: 1; translate: 0 0 } }
[data-reduced] *, [data-reduced] *::before, [data-reduced] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

.editorial {
  width: min(calc(100% - 2 * var(--gutter)), 760px);
  margin: clamp(38px, 6vw, 78px) auto;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.68;
}
.editorial .intro { font: normal clamp(1.2rem, 2.2vw, 1.52rem)/1.48 var(--serif); margin-top: 0; }
.editorial h2 { margin: 1.38em 0 .24em; font: 800 clamp(1.52rem, 3.6vw, 2.15rem)/1.12 var(--serif); letter-spacing: -.035em; }
.editorial p { margin: 0 0 .92em }
.tips { padding-inline-start: 1.4em }
.tips li { margin-bottom: .43em; padding-inline-start: .22em }
.tips li::marker { color: var(--oxblood); font-weight: 800; }
.questions { border-top: 2px solid #b47555; margin: 2em 0 1.4em; }
details { border-bottom: 1px solid #bc876a; }
summary { cursor: pointer; padding: .56em 0; font-weight: 760; }
details > p { padding-inline-start: 1.05em; }
.fineprint { font-size: .95rem }
.site-footer {
  width: var(--width);
  margin: 20px auto 0;
  padding: 14px 0 19px;
  border-top: 2px solid #a96750;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  column-gap: 18px;
}
.site-footer a { display: inline-flex; min-height: 44px; align-items: center; }
.site-footer .footer-brand { color: var(--ink); font: bold 1.45rem var(--serif); text-decoration: none; letter-spacing: -.045em; }
.site-footer nav { display: flex; gap: 17px; flex-wrap: wrap; font-size: .93rem; font-weight: 650; }
.subpage { min-height: 65dvh; padding-top: .5px }
.subpage h1 { margin: 0 0 .3em; font: 900 clamp(2.45rem, 8vw, 4.4rem)/1.02 var(--serif); letter-spacing: -.068em; }
.worked-board { display: block; width: 100%; height: auto; margin: .5em 0 1em; }
.button-link { display: inline-grid; place-items: center; min-height: 44px; border-radius: 4px; padding: 0 14px; text-decoration: none; font-weight: 765; font-size: .95rem; }
.guide-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; width: min(100%, 360px); margin: 12px 0 14px; background: #693e35; padding: 5px; border-radius: 4px; }
.guide-row span { display: grid; place-items: center; min-height: 45px; font: bold 1.7rem var(--serif); background: #ffd99c; border: 1px solid #945c47; border-radius: 3px; box-shadow: inset 0 -3px #b37449; }
.guide-row span:first-child, .guide-row span:nth-child(2), .guide-row span:nth-child(3) { background: #f4a8ba; box-shadow: inset 0 -3px #b85b78; }

@media (max-width: 850px) {
  :root { --width: calc(100% - 16px) }
  .mast { min-height: 58px }
  #game { --rail: clamp(3px, 1.2vw, 10px); height: clamp(470px, calc(100dvh - 80px), 890px); }
  .meter { flex-direction: column; gap: 1px; }
  .tile { font-size: clamp(1.6rem, 7.7vw, 3.6rem); }
}
@media (max-width: 450px) {
  .mast h1, .mast .brand { white-space: nowrap; font-size: clamp(1.7rem, 9vw, 2.35rem); }
  #game { --pad: 6px; --field-gap: 3px; --rail: 1px; grid-template-rows: 52px minmax(0, 1fr) 60px; }
  .readouts { grid-template-columns: repeat(3, minmax(0,1fr)) 49px; }
  .meter { padding-inline: 2px; }
  .row-meter > span { font-size: .77rem; }
  .tile { font-size: clamp(1.45rem, 7.3vw, 2.2rem); }
  .controls button { min-width: 48px; padding-inline: 6px; font-size: .87rem; }
  .controls [data-act="lift"] { min-width: 57px; padding-inline: 5px; }
  .panel { padding-block: 15px; }
}
@media (orientation: landscape) and (max-height: 535px) {
  .mast { min-height: 43px; padding-block: env(safe-area-inset-top) 0; }
  .mast h1, .mast .brand { font-size: 2.05rem; }
  #game { height: max(288px, calc(100dvh - 52px)); --pad: 5px; --rail: 6px; grid-template-columns: 113px minmax(0, 1fr) 96px; grid-template-rows: minmax(0, 1fr); }
  .rack { padding-block: 2px; }
  .rail, #board { row-gap: 2px; }
  .readouts { grid-template: repeat(4, minmax(0,1fr))/1fr; }
  .meter { flex-direction: column; border-right: 0; border-bottom: 1px solid #e8b99a39; }
  .controls { grid-template: 44px 44px minmax(0,1fr) 44px/1fr; gap: 6px; }
  .controls button { padding-inline: 3px; }
  .tile { font-size: clamp(1.3rem, 7dvh, 2rem); }
  .panel { padding-block: 12px; }
  .panel h2 { font-size: 1.8rem; }
  .panel p { margin-bottom: 7px; }
  .options { margin-top: 10px; padding-top: 6px; }
}
@media (orientation: portrait) and (max-height: 700px) {
  #game { height: max(462px, calc(100dvh - 75px)); }
}
@media (max-width: 320px) {
  .mast { gap: 2px }
  .mast nav a { padding-inline: 4px; }
}
