:root {
  color-scheme: light;
  --ink: #303f32;
  --green: #305b4b;
  --paper: #fff8e7;
  --line: #ba9d75;
  --accent: #965031;
  font-family: ui-rounded, 'Trebuchet MS', system-ui, sans-serif;
  color: var(--ink);
  background: #f9f2df;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
a {
  font: inherit;
  touch-action: manipulation;
}
button {
  color: inherit;
  cursor: pointer;
}
a {
  color: var(--green);
}
:focus-visible {
  outline: 4px solid #006f78;
  outline-offset: 2px;
}
.player {
  margin: auto;
  max-width: 920px;
  padding: 12px clamp(10px, 4vw, 36px) 25px;
}
.player nav,
.tools,
.feedback {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.player nav a,
.tools button,
dialog a {
  font-weight: 700;
  font-size: 0.95rem;
  text-underline-offset: 4px;
  padding: 8px 0;
}
.game-head {
  display: flex;
  align-items: center;
  gap: 17px;
  margin: 9px 0;
}
.game-head img {
  width: 78px;
  height: 81px;
  object-fit: contain;
}
.game-head h1 {
  font:
    700 clamp(1.65rem, 4vw, 2.7rem)/1.08 Georgia,
    serif;
  margin: 0;
  color: #3e4935;
}
.game-head p {
  margin: 6px 0 0;
  max-width: 65ch;
  line-height: 1.4;
}
.tabletop {
  border: 2px solid #977b57;
  border-radius: 20px;
  overflow: hidden;
  background: #e6c79c url(art/table.webp) center/cover;
  box-shadow: 0 4px 0 #b9a17c;
}
#area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: clamp(7px, 2vw, 17px);
  min-height: 320px;
}
#area:has(canvas) {
  padding: 0;
  min-height: 0;
}
canvas.field {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(65vh, 490px);
  aspect-ratio: 3/2;
  object-fit: fill;
  touch-action: none;
}
.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: 4px;
  width: min(
    100%,
    calc(var(--cols) * 100px),
    calc(var(--cols) / var(--rows) * min(53vh, 420px))
  );
  aspect-ratio: var(--cols) / var(--rows);
}
.choice,
.tools button,
dialog button {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  box-shadow: 0 2px 0 #ac926c;
  font-weight: 700;
  padding: 5px 10px;
}
.choice:hover:enabled,
.tools button:hover {
  background: #ffefbd;
}
.choice[aria-pressed='true'],
.next-stitch {
  outline: 3px solid #367e72;
  outline-offset: -3px;
  background: #d9ece0;
}
.tile {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 4px;
  background: #fff7dff0;
}
.tile:disabled {
  opacity: 1;
  cursor: default;
}
.tile img {
  width: 88%;
  height: 88%;
  object-fit: contain;
  pointer-events: none;
}
.tile-text {
  font-size: clamp(0.65rem, 2.5vw, 1.3rem);
}
.tile:has(img) .tile-text,
.puzzle-picture .tile-text {
  position: absolute;
  right: 2px;
  bottom: 2px;
  background: #fff8db;
  border-radius: 4px;
  padding: 0 3px;
  color: #43432c;
}
.vacant,
.board .tile.vacant:disabled {
  background: #eadab879;
  border-color: #c5ab8280;
  box-shadow: none;
}
.blocked,
.wall {
  background: repeating-linear-gradient(
    45deg,
    #cfad88,
    #cfad88 6px,
    #b5936c 7px,
    #b5936c 9px
  );
}
.blocked img {
  opacity: 0.55;
}
.target,
.legal,
.marked,
.wet {
  background: #bddac3;
}
.patch0 {
  background: #e8c1ad;
}
.patch1 {
  background: #bddac4;
}
.patch2 {
  background: #f0dc9d;
}
.patch3 {
  background: #cbd6e5;
}
.peg {
  flex-direction: column;
  min-height: 115px;
  justify-content: flex-end;
}
.peg img {
  height: 30%;
  max-height: 62px;
}
.peg:empty {
  border-bottom: 7px solid #9a6d46;
}
.towers {
  aspect-ratio: 3/1;
}
.ticket,
.pattern,
.legend,
.stitches {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #fff5da;
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: bold;
}
.ticket img,
.stitches img {
  width: clamp(24px, 6vw, 48px);
  height: 45px;
  object-fit: contain;
}
.handled {
  opacity: 0.32;
}
.pattern {
  font-size: clamp(1rem, 3vw, 1.55rem);
}
#controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 10px 0 3px;
}
#controls:empty {
  display: none;
}
#controls button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
#controls img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}
.feedback {
  min-height: 35px;
  font-size: 0.96rem;
}
.feedback output {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tools {
  justify-content: flex-end;
  border-top: 1px solid #d5c6a9;
  padding-top: 8px;
}
.tools button {
  padding: 7px 15px;
}
.pipe,
.hub {
  position: absolute;
  background: #657f68;
  pointer-events: none;
}
.wet .pipe,
.wet .hub {
  background: #38828c;
}
.arm0,
.arm2 {
  width: 19%;
  height: 51%;
  left: 40%;
}
.arm0 {
  top: 0;
}
.arm2 {
  bottom: 0;
}
.arm1,
.arm3 {
  height: 19%;
  width: 51%;
  top: 40%;
}
.arm1 {
  right: 0;
}
.arm3 {
  left: 0;
}
.hub {
  inset: 36%;
  border-radius: 50%;
}
.ringboard img {
  transform: rotate(var(--tilt));
}
.ribbons {
  row-gap: 65px;
}
.threads {
  position: absolute;
  width: 100%;
  height: 65px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.threads path {
  fill: none;
  stroke-width: 6;
}
.water-channel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 60%;
  background: linear-gradient(
    to right,
    #73b8b2 var(--water),
    #ede1b9 var(--water)
  );
  border-radius: 16px;
}
.water-channel img {
  height: 44px;
}
.paper-doll {
  position: relative;
  height: min(45vh, 335px);
  aspect-ratio: 0.72;
}
.doll-base {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.accessory {
  position: absolute;
  object-fit: contain;
}
.a0 {
  width: 41%;
  top: 0;
  left: 34%;
}
.a1 {
  width: 36%;
  top: 48%;
  left: 34%;
}
.a2 {
  width: 33%;
  top: 63%;
  left: 64%;
}
.postcards {
  display: grid;
  width: 100%;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}
.postcard {
  position: relative;
  aspect-ratio: 1.27;
  background: url(art/lake.webp) center/cover;
  border: 4px solid #fffae9;
  border-radius: 6px;
}
.spot {
  position: absolute;
  width: 23%;
  height: 25%;
  transform: translate(-50%, -50%);
  border: none;
  box-shadow: none;
  background: transparent;
}
.spot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.spot:disabled {
  border: 3px dashed var(--green);
  border-radius: 50%;
}
.endgame {
  gap: 1px;
}
.endgame .tile {
  padding: 0;
  border-radius: 2px;
}
.endgame .river {
  border-bottom: 4px solid #74b6bb;
}
.legend {
  font-size: 0.76rem;
}
dialog {
  border: 2px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  padding: 24px;
  text-align: center;
  max-width: 90vw;
}
dialog::backdrop {
  background: #263b32a1;
}
dialog img {
  width: 95px;
  height: 106px;
  object-fit: contain;
}
dialog h2 {
  font-family: Georgia, serif;
}
dialog button,
dialog a {
  display: block;
  margin: 10px auto;
}
dialog button {
  background: var(--green);
  color: white;
  padding: 10px 20px;
}
@media (max-width: 570px) {
  .player {
    padding: 6px 9px 14px;
  }
  .game-head {
    gap: 9px;
  }
  .game-head img {
    width: 54px;
    height: 65px;
  }
  .game-head p {
    font-size: 0.91rem;
  }
  #area {
    min-height: 275px;
  }
  .board {
    gap: 3px;
  }
  .tile {
    border-radius: 7px;
  }
  .postcards {
    grid-template-columns: 1fr;
    width: min(95%, 330px);
  }
  .postcard {
    aspect-ratio: 1.8;
  }
  .legend {
    font-size: 0.7rem;
  }
  .feedback {
    font-size: 0.83rem;
  }
}
.cut-table {
  width: min(100%, 520px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8%;
}
.cut-table svg {
  width: 26%;
  background: #fbefd2;
  border-radius: 6px;
}
.cut-sheet {
  position: relative;
  width: 58%;
  aspect-ratio: 1;
  background: repeating-linear-gradient(45deg, #f8eab9 0 8px, #f5e5ad 9px 10px);
  border: 3px solid #a68c5f;
  box-shadow: 0 6px 6px #74582935;
}
.cut-sheet button {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  padding: 0;
  width: clamp(22px, 6vw, 33px);
  aspect-ratio: 1;
}
.beds .tile {
  border-bottom: 7px solid #a1754c;
  background: #f5dcad;
}
.beds .tile-text {
  font-size: 0.77rem;
}
.tile img.boat-ticket {
  position: absolute;
  width: 37%;
  height: 37%;
  top: 3%;
  left: 3%;
  background: #fff8df;
  border-radius: 50%;
}
.stitches .next-stitch {
  border-radius: 8px;
}
.sudoku .tile:nth-child(4n + 2) {
  border-right: 4px solid #806c4f;
}
.sudoku .tile:nth-child(n + 5):nth-child(-n + 8) {
  border-bottom: 4px solid #806c4f;
}
canvas.field {
  width: min(100%, calc(min(65svh, 490px) * 1.5));
  height: auto;
  max-height: none;
}
