* {
  box-sizing: border-box;
}
:root {
  font-family: "Avenir Next", Avenir, "Trebuchet MS", system-ui, sans-serif;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  min-height: 100dvh;
}
main {
  width: min(100% - 32px, 1000px, max(720px, calc((100svh - 225px) * 1.5)));
  margin: 0 auto;
  padding: 18px 0 20px;
}
header {
  display: flex;
  gap: 18px;
  align-items: center;
  margin: 0 2px 14px;
}
.title {
  flex: 1;
}
.title p {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1px;
}
h1 {
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  letter-spacing: -0.045em;
  font-weight: 700;
  font-size: clamp(26px, 3.5vw, 44px);
  line-height: 1.1;
  margin: 0;
}
.home-link,
button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
header .home-link,
button.icon {
  border: 1px solid color-mix(in srgb, var(--ink) 24%, transparent);
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  flex-shrink: 0;
}
button.icon svg {
  width: 22px;
  height: 22px;
}
.board {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: var(--accent) center / 100% 100% no-repeat;
  border-radius: 16px;
  box-shadow:
    0 2px 2px #182a2117,
    0 10px 24px #182a2119;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.board svg#drawing {
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
}
.caption {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 16px 2px 11px;
}
#progress {
  font-weight: 800;
  font-size: 13px;
  color: var(--accent);
  white-space: nowrap;
}
#status {
  margin: 0;
  font-weight: 600;
  font-size: clamp(14px, 1.6vw, 17px);
  line-height: 1.35;
}
nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
button {
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  border-radius: 12px;
  padding: 10px 17px;
  min-height: 46px;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 92%, var(--ink));
  border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
}
button.primary,
nav button[aria-pressed="true"],
nav button[aria-expanded="true"] {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:active:enabled {
  transform: translateY(1px);
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.board:focus-visible {
  outline-offset: 1px;
}
svg text {
  font-family: "Avenir Next", Avenir, system-ui, sans-serif;
}
svg [data-pick] {
  cursor: pointer;
}
@media (max-width: 600px) {
  main {
    width: calc(100% - 18px);
    padding-top: 12px;
  }
  header {
    gap: 10px;
    margin-bottom: 12px;
  }
  .title p {
    font-size: 9px;
  }
  header .home-link,
  button.icon {
    width: 44px;
    height: 44px;
  }
  .board {
    border-radius: 12px;
  }
  .caption {
    display: grid;
    gap: 3px;
    margin: 12px 4px;
  }
  nav {
    gap: 7px;
  }
  button {
    font-size: 14px;
    padding: 10px 12px;
  }
}
@media (min-aspect-ratio: 7/4) and (max-height: 570px) {
  main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(190px, 31%);
    grid-template-rows: auto auto minmax(0, 1fr);
    align-content: start;
    column-gap: 12px;
    width: min(100% - 16px, calc((100dvh - 16px) * 2.22));
    height: 100dvh;
    padding: 8px 0;
  }
  header {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    gap: 5px;
    margin: 0 0 5px;
  }
  header .home-link,
  button.icon {
    width: 36px;
    height: 40px;
    min-height: 40px;
  }
  .title p {
    display: none;
  }
  h1 {
    font-size: clamp(18px, 2.7vw, 24px);
  }
  .playroom {
    display: contents;
  }
  .board {
    grid-column: 1;
    grid-row: 1/4;
    align-self: center;
    justify-self: center;
    width: min(100%, calc((100dvh - 16px) * 1.5));
  }
  .caption {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    gap: 2px 4px;
    margin: 3px 0 6px;
  }
  .caption #progress {
    white-space: normal;
    font-size: 12px;
  }
  .caption #status {
    grid-column: 1;
    font-size: 13px;
  }
  .caption .read-cue {
    grid-column: 2;
    grid-row: 1/3;
    align-self: center;
    width: 36px;
    height: 40px;
  }
  #controls {
    grid-column: 2;
    grid-row: 3;
    display: flex;
    align-content: flex-start;
    align-items: stretch;
    flex-wrap: wrap;
    align-self: stretch;
    gap: 5px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 3px 12px;
    scrollbar-width: thin;
  }
  #controls button {
    padding: 7px 10px;
    min-height: 44px;
    font-size: 14px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.caption .read-cue {
  width: 44px;
  height: 44px;
  margin-left: auto;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .caption {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
  }
  .caption .read-cue {
    grid-column: 2;
    grid-row: 1/3;
    align-self: center;
  }
}

#controls button[data-art]:not([data-art=""]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42em;
}
#controls button img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
#controls button svg {
  width: 23px;
  height: 23px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.board .gesture-guide { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; opacity:0; }
.gesture-guide.show { opacity:1; }
.board.handling .gesture-guide { visibility:hidden; }
.gesture-guide g { opacity:0; }
.gesture-guide.show g { animation: model-gesture 4.4s 1.2s 3 both; }
@keyframes model-gesture {
  0%, 16% { opacity:0; transform:translate(var(--x), var(--y)); }
  25% { opacity:.9; transform:translate(var(--x), var(--y)); }
  55%, 63% { opacity:.9; transform:translate(calc(var(--x) + var(--dx)),calc(var(--y) + var(--dy))); }
  71%,100% { opacity:0; transform:translate(calc(var(--x) + var(--dx)),calc(var(--y) + var(--dy))); }
}
@media (prefers-reduced-motion: reduce) {
  .gesture-guide.show g { animation:none !important; opacity:.84; transform:translate(var(--x), var(--y)); }
}
