:root {
  color-scheme: light;
  font: 16px/1.4 system-ui, sans-serif;
  color: #2d1a0e;
  background: #264a20;
}
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-underline-offset: .16em; }
:focus-visible { outline: 3px solid #fff8c6; outline-offset: 3px; box-shadow: 0 0 0 6px #204021; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.scene {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  overflow: clip;
  background: linear-gradient(#179deb 0%, #6cc5f7 35%, #5e8b29 66%, #315b13);
}
.landscape {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 8%;
  z-index: -1;
}

.wood {
  --wood-top: #f8c678;
  --wood-middle: #eda750;
  --wood-bottom: #b26126;
  background:
    repeating-linear-gradient(2deg, transparent 0 4px, #6f351720 5px, transparent 7px 10px),
    linear-gradient(155deg, var(--wood-top), var(--wood-middle) 55%, var(--wood-bottom));
  border: 2px solid #633515;
  box-shadow: inset 0 2px #fff0a879, inset 0 -4px #6b321562, 0 5px 0 #533217, 0 8px 12px #26320c73;
  text-shadow: 0 1px #ffe5a97a;
}

.masthead { position: absolute; z-index: 1; top: 14px; left: clamp(9px, 2.4vw, 35px); }
.rammy {
  display: grid;
  place-items: center;
  position: relative;
  width: clamp(88px, 11.1vw, 179px);
  aspect-ratio: 1.25;
  padding: 7% 12%;
  transform: rotate(-8deg);
  background: url("rammy-wood.webp") center / contain no-repeat;
  filter: drop-shadow(0 4px 2px #2b180c72);
  text-align: center;
  text-decoration: none;
  color: #281608;
  font-size: clamp(.82rem, 1.85vw, 1.43rem);
  font-weight: 900;
  line-height: 1.02;
  text-shadow: 0 1px #f7d6a5ae;
}
.rammy::before, .rammy::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 28px;
  bottom: calc(100% - 10px);
  background: repeating-linear-gradient(#5f3f25 0 3px, #b17c3e 3px 5px, #3d2d20 5px 7px);
  border-radius: 4px;
}
.rammy::before { left: 18%; }
.rammy::after { right: 18%; }

.game-layout {
  --ball: clamp(48px, min(8vw, calc((100svh - 448px) / 6)), 96px);
  --board-width: calc(var(--ball) * 5 + 26px);
  --sign-width: clamp(158px, 17vw, 235px);
  --board-gap: clamp(25px, 4vw, 54px);
  width: min(100% - 32px, var(--board-width) + var(--sign-width) + var(--board-gap));
  margin-inline: auto;
  padding-block: 5px 7px;
}
.intro {
  position: relative;
  width: calc(var(--board-width) + 40px);
  margin: 0 auto 7px -20px;
  text-align: center;
}
.logo-art {
  display: block;
  width: 100%;
  height: clamp(104px, 15svh, 196px);
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 5px 4px #21180159);
}
.tagline {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: -5px auto 0;
  border-radius: 16% 14% 15% 17% / 36% 35% 43% 40%;
  padding: 3px 15px 5px;
  color: #301704;
  font-size: clamp(.92rem, 2.3vw, 1.45rem);
  font-weight: 950;
  line-height: 1.1;
}
.play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sign-width);
  grid-template-areas:
    "heading menu"
    "board menu"
    "help menu"
    "bottom bottom";
  column-gap: var(--board-gap);
  row-gap: 5px;
  align-items: center;
}
.puzzle-header, .status, .legend, .reaction {
  color: #fff8e5;
  background: #24260de8;
  border-radius: 8px;
  box-shadow: 0 2px 6px #18200955;
}
.puzzle-header {
  grid-area: heading;
  display: flex;
  align-items: baseline;
  justify-self: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 9px;
  padding: 3px 11px;
}
.puzzle-header h2 { font-size: 1rem; font-weight: 850; }
#puzzle-label { font-size: .76rem; font-weight: 700; }
.board-help {
  grid-area: help;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.status {
  width: fit-content;
  max-width: 100%;
  justify-self: center;
  text-align: center;
  font-size: .82rem;
  padding: 4px 10px;
}
.status[data-error="true"] { background: #692316; font-weight: 750; }
.board-help:has(.status[data-error="true"]) .legend { display: none; }
.board {
  grid-area: board;
  justify-self: center;
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 5px;
  border-radius: 11px;
  background: linear-gradient(140deg, #483318b8, #282b0e88);
  box-shadow: 0 7px 15px #14220c72;
  list-style: none;
}
.board li { display: grid; grid-template-columns: repeat(5, var(--ball)); gap: 4px; }
.tile {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 50%;
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  font-weight: 750;
  font-size: clamp(1.125rem, calc(var(--ball) * .49), 2.75rem);
  line-height: 1;
  color: #583019;
  text-shadow: 0 1px #fff4d8;
}
.tile::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background: url("wool.webp") center / contain no-repeat;
  filter: var(--wool-filter, brightness(.86));
}
li[data-current="true"] .tile::before { --wool-filter: brightness(1.07) drop-shadow(0 0 2px #fff9b7); }
.tile[data-mark] {
  color: #fff2d3;
  text-shadow: 0 1px #55371e, 0 2px 2px #2e1b0ece, 1px 0 #3c2919b3, -1px 0 #3c2919b3;
  padding-bottom: 3px;
}
.tile[data-mark="elsewhere"] {
  color: #482608;
  text-shadow: 0 1px #fff1af;
}
.tile[data-mark="exact"]::before { --wool-filter: brightness(.72) sepia(1) saturate(4.5) hue-rotate(43deg); }
.tile[data-mark="elsewhere"]::before { --wool-filter: brightness(.85) sepia(1) saturate(7) hue-rotate(5deg); }
.tile[data-mark="absent"]::before { --wool-filter: grayscale(1) brightness(.5); }
.tile small {
  position: absolute;
  right: 5%;
  bottom: 5%;
  min-width: 15px;
  height: 15px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 900 .65rem/1 system-ui, sans-serif;
  color: #fffbea;
  text-shadow: none;
  background: #292216;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px 10px;
  margin: 0;
  padding: 3px 9px;
  font-size: .73rem;
  font-weight: 650;
}
.legend li, .rule-list li { display: flex; align-items: center; gap: 4px; }
.dot { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font: 900 .7rem/1 system-ui, sans-serif; flex: none; }
.dot.exact { background: #396a17; color: #fffbea; }
.dot.elsewhere { background: #f2bc26; color: #2d1a07; }
.dot.absent { background: #615c60; color: #fffbea; }

.keyboard {
  grid-area: bottom;
  width: min(100%, 630px);
  justify-self: start;
  display: grid;
  gap: 5px;
  margin: 3px 0 4px;
  margin-inline-start: clamp(-42px, -2.7vw, -18px);
}
.key-row { display: flex; justify-content: center; gap: 4px; }
.key {
  flex: 1 1 0;
  min-width: 0;
  max-width: 55px;
  min-height: clamp(38px, 4.8svh, 42px);
  padding: 0 1px 3px;
  border: 1px solid #825735;
  border-radius: 10px;
  color: #2d1a0e;
  background: linear-gradient(145deg, #fffaf0, #f4dbb1 70%, #d2a26e);
  box-shadow: inset 0 2px #fffefe99, inset 0 -4px #94633c44, 0 4px #603a1c, 0 5px 5px #1c230d88;
  font-size: clamp(.81rem, 2.4vw, 1.22rem);
  font-weight: 950;
  touch-action: manipulation;
}
.key[data-key="Enter"], .key[data-key="Backspace"] {
  flex-grow: 1.55;
  max-width: 78px;
  font-size: 1.2rem;
  color: #fff7e5;
  text-shadow: 0 1px #3a1e0d;
  background: repeating-linear-gradient(3deg, transparent 0 4px, #75341830 5px, transparent 6px 9px), linear-gradient(#ca792e, #864119);
  border-color: #552601;
}
.key[data-mark="exact"] { color: #fffbe9; background: linear-gradient(#61991c, #315b0f); border-color: #32560d; }
.key[data-mark="elsewhere"] { color: #2d1a0e; background: linear-gradient(#ffdf5e, #e4a221); }
.key[data-mark="absent"] { color: #fffbe9; background: linear-gradient(#726a6f, #514b50); border-color: #514b50; }
.key:hover, .sign:not(:disabled):hover { filter: brightness(1.1); }
.key:active, .sign:not(:disabled):active { translate: 0 2px; }

.signpost {
  grid-area: menu;
  position: relative;
  isolation: isolate;
  display: grid;
  gap: 11px;
  align-self: center;
  margin-top: 12px;
}
.signpost::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -10px;
  bottom: 8px;
  left: 47%;
  width: 22px;
  border-radius: 7px;
  background: linear-gradient(90deg, #683a21, #ae7136 31%, #895627 61%, #482512);
  box-shadow: 4px 4px 5px #11260980;
}
.sign {
  display: block;
  width: 100%;
  min-height: 44px;
  border-radius: 12px 7px 11px 8px;
  font-size: clamp(.95rem, 2.3vw, 1.29rem);
  font-weight: 950;
  text-align: center;
  color: #2c180b;
  padding: 5px 7px 7px;
  transform: rotate(-2.5deg);
}
.sign:nth-child(even) { transform: rotate(1.5deg); }
.sign span[aria-hidden] { margin-right: .37em; }
.sign-play {
  --wood-top: #77a426;
  --wood-middle: #558117;
  --wood-bottom: #345513;
  color: #fffbea;
  text-shadow: 0 2px 2px #1a300a;
}
.sign:disabled { filter: saturate(.7); }
.mode-button, .text-button {
  min-height: 38px;
  border: 1px solid #714423;
  border-radius: 8px;
  padding: 4px 9px;
  background: #ffebbf;
  color: #40260f;
  font-size: .86rem;
  font-weight: 800;
}
.mode-button { justify-self: center; min-width: 88px; }
.reaction { justify-self: center; padding: 4px 8px; font-size: .78rem; font-weight: 680; text-align: center; }
.noscript { grid-column: 1 / -1; color: #fff8e6; text-align: center; }

.finish {
  grid-area: bottom;
  width: min(100%, 630px);
  justify-self: center;
  background: #fff0cf;
  border: 1px solid #704625;
  border-radius: 10px;
  box-shadow: 0 3px 9px #1e200f77;
  margin-top: 4px;
  padding: 9px 12px;
}
.finish h3, .flock h3 { margin: 0 0 4px; font-size: 1.19rem; }
.finish p, .flock p { margin: 0 0 7px; font-size: .88rem; }
.finish a { display: inline-block; margin: 0 8px 5px 0; font-size: .875rem; font-weight: 700; }

dialog { width: min(430px, calc(100vw - 28px)); border: 2px solid #9e682e; border-radius: 13px; padding: 24px; color: #342511; background: #fff2d2; }
dialog::backdrop { background: #1c230fba; }
dialog p { margin: 12px 0; }
.close { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; color: #372611; border: 1px solid #a9773e; border-radius: 7px; background: #eed39d; font-size: 1.2rem; }
.rule-list { list-style: none; margin: 8px 0; padding: 0; }
.rule-list li { margin: 8px 0; gap: 9px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stats-grid div, .flock { background: #f1dfb7; border-radius: 8px; padding: 10px; }
.stats-grid dt, .flock small { font-size: .75rem; color: #58401e; }
.stats-grid dd { margin: 0; font-size: 1.35rem; font-weight: 800; }
.flock h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.flock p { margin: 0; }
#share-text {
  display: block;
  width: 100%;
  margin: 12px 0;
  border: 1px solid #bc8c58;
  border-radius: 7px;
  padding: 9px;
  background: #fff9ea;
  color: #342511;
  font-size: .88rem;
  resize: vertical;
}
.copy-result { min-height: 40px; border-radius: 8px; color: #40260f; padding: 4px 12px; font-weight: 850; }
.copy-status { min-height: 1.4em; font-size: .84rem; }

@media (min-width: 691px) and (min-height: 850px) {
  .game-layout { --ball: clamp(48px, min(8vw, calc((100svh - 428px) / 6)), 96px); }
}

@media (max-width: 690px) {
  .landscape { object-fit: cover; object-position: 78% top; }
  .game-layout {
    --ball: clamp(38px, min(13.4vw, calc((100svh - 464px) / 6)), 58px);
    width: min(100% - 22px, 445px);
    padding-block: 6px 7px;
  }
  .rammy { width: clamp(63px, 17.7vw, 88px); font-size: clamp(.63rem, 2.8vw, .79rem); }
  .rammy::before, .rammy::after { width: 3px; bottom: calc(100% - 6px); }
  .intro { width: min(76%, 265px); margin: 0 auto 7px; }
  .logo-art { height: clamp(54px, 10.5svh, 88px); }
  .tagline { padding-inline: 8px; max-width: 100%; font-size: clamp(.69rem, 3.35vw, .86rem); }
  .play {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "menu" "heading" "board" "help" "bottom";
    row-gap: 5px;
  }
  .board { padding: 4px; }
  .status { padding-inline: 6px; font-size: .75rem; }
  .legend { gap: 3px 6px; padding-inline: 6px; font-size: .69rem; }
  .keyboard { width: 100%; margin-inline-start: 0; }
  .key { min-height: 39px; max-width: none; border-radius: 7px; }
  .key[data-key="Enter"], .key[data-key="Backspace"] { max-width: 70px; }
  .signpost {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: min(100%, 360px);
    justify-self: center;
    margin: 2px 0 5px;
  }
  .signpost::before { display: none; }
  .sign, .sign:nth-child(even) { transform: none; min-height: 40px; font-size: clamp(.69rem, 3.25vw, .8rem); padding: 3px 2px 5px; }
  .mode-button { min-height: 40px; min-width: 0; width: 100%; padding-inline: 3px; font-size: clamp(.69rem, 3.25vw, .8rem); }
  .sign span[aria-hidden], .sign-play { display: none; }
  .reaction { display: none; }
  .finish { margin-top: 2px; padding: 7px 9px; }
}

@media (max-width: 690px) and (max-height: 620px) {
  .game-layout { --ball: clamp(32px, calc((100svh - 372px) / 6), 38px); }
  .logo-art { height: clamp(43px, 9svh, 55px); }
  .play { row-gap: 4px; }
  .key { min-height: 34px; }
  .finish { margin-top: 1px; }
  .finish h3 { margin-bottom: 2px; font-size: 1.05rem; }
  .finish p, .finish a, .finish .text-button { font-size: .75rem; }
  .finish p { margin-bottom: 4px; }
  .finish a { margin-right: 4px; }
  .finish .text-button { min-height: 34px; padding-inline: 6px; }
}


