:root {
  color-scheme: light;
  --ink: #233b34;
  --muted: #647166;
  --green: #205b46;
  --paper: #f7f7f0;
  --line: #dce1d6;
  --accent: #cced9c;
  --board: min(100%,490px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next",Avenir,"Segoe UI",sans-serif;
  background-image: radial-gradient(ellipse at 0 0,#e5ecd96b,transparent 50%),radial-gradient(ellipse at 100% 100%,#eee8d880,transparent 50%);
  min-height: 100vh;
}

button,select {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button: disabled {
  cursor: default;
  opacity: .4;
}

button,select {
  touch-action: manipulation;
}

button: focus-visible,select:focus-visible {
  outline: 3px solid #7ba85b;
  outline-offset: 3px;
}

button {
  transition: background .18s,transform .18s,color .18s;
}

button: active:not(:disabled) {
  transform: translateY(1px);
}

.app {
  max-width: 1040px;
  margin: auto;
  padding: 32px 40px 20px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  gap: 13px;
  align-items: center;
}

.brand-mark {
  font-size: 44px;
  color: var(--green);
  line-height: 1;
}

.brand h1 {
  font-family: Georgia,serif;
  font-size: 39px;
  letter-spacing: -2px;
  font-weight: 400;
  margin: 0;
  line-height: 1;
}

.brand h1 span {
  color: #82a359;
}

.brand p {
  font-size: 8px;
  letter-spacing: 2px;
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.icon-button {
  /* Keep the portal's maximize control clear of the help button. */
  margin-right: 28px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-family: Georgia,serif;
  font-size: 18px;
}

.icon-button:hover {
  background: #e5ecde;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0,1.5fr) minmax(240px,1fr);
  gap: 38px;
  align-items: center;
}

.board-section {
  min-width: 0;
}

.board-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 11px;
}

.level-badge {
  color: var(--green);
  background: #e5ecdc;
  border-radius: 5px;
  padding: 5px 8px;
  font-weight: 750;
  font-size: 9px;
  letter-spacing: 1.2px;
}

.puzzle-kind {
  color: var(--muted);
  font-size: 10px;
}

.timer {
  margin-left: auto;
  background: none;
  border: 0;
  display: flex;
  gap: 12px;
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  align-items: center;
  padding: 4px;
}

.timer>span:last-child {
  color: #829077;
  font-size: 14px;
}

.board-wrap {
  position: relative;
}

#board {
  display: grid;
  grid-template-columns: repeat(9,1fr);
  aspect-ratio: 1;
  border: 2px solid #5e7766;
  border-radius: 9px;
  overflow: hidden;
  background: #fffef8;
  box-shadow: 0 12px 40px #3444310b;
  isolation: isolate;
}

#board [role=row] {
  display: contents;
}

.cell {
  position: relative;
  padding: 0;
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  font-size: clamp(18px,3vw,30px);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .16s,color .16s;
  outline-offset: -4px!important;
}

.cell:nth-child(3n) {
  border-right: 2px solid #83947c;
}

.cell:nth-child(9) {
  border-right: 0;
}

#board [role=row]:nth-child(3n) .cell {
  border-bottom: 2px solid #83947c;
}

#board [role=row]:last-child .cell {
  border-bottom: 0;
}

.cell.peer {
  background: #f0f3e9;
}

.cell.match {
  background: #e0edce;
  color: #1f583e;
}

.cell.user {
  color: #42754a;
  font-weight: 650;
}

.cell.selected {
  background: #d3e7b9;
  box-shadow: inset 0 0 0 2px #719956;
  z-index: 1;
}

.cell.wrong {
  color: #b04444;
  background: #fae4df;
}

.cell.selected.wrong {
  box-shadow: inset 0 0 0 2px #c5746d;
}

.cell.pop .value {
  animation: ink .22s ease-out;
}

.cell.celebrate {
  animation: ripple .65s ease both;
  animation-delay: var(--delay,0ms);
}

.cell .pencil {
  position: absolute;
  inset: 3px;
  display: grid;
  grid-template-columns: repeat(3,1fr);
  grid-template-rows: repeat(3,1fr);
  font-size: clamp(8px,1.15vw,11px);
  font-weight: 500;
  color: #677d5e;
}

.pencil span {
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  color: var(--muted);
  margin-top: 15px;
}

.board-footer>span:first-child {
  display: flex;
  align-items: center;
  gap: 4px;
}

.board-footer i {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #749d50;
  margin-right: 3px;
}

.progress-track {
  height: 3px;
  background: #e3e8dc;
  margin-top: 10px;
  border-radius: 9px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0;
  background: #8aaf60;
  transition: width .4s ease;
}

.intro .eyebrow {
  font-size: 8px;
  letter-spacing: 1.6px;
}

.eyebrow {
  display: block;
  font-size: 10px;
  letter-spacing: 2px;
  color: #7d8d70;
  font-weight: 650;
}

.intro h2 {
  font-family: Georgia,serif;
  font-size: 34px;
  letter-spacing: -1.2px;
  font-weight: 400;
  margin: 12px 0 9px;
}

.intro p {
  font-size: 11px;
  line-height: 1.8;
  color: var(--muted);
  margin: 0 0 25px;
}

.difficulty-control label {
  font-size: 8px;
  letter-spacing: 1.6px;
  font-weight: 700;
  display: block;
  margin-bottom: 8px;
  color: #7b8776;
}

select {
  width: 100%;
  padding: 10px 26px 10px 11px;
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 11px;
}

.tools {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 5px;
  margin: 13px 0;
}

.tools button {
  position: relative;
  background: none;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-radius: 7px;
  color: #647462;
  font-size: 9px;
}

.tools button>span {
  font-size: 23px;
  line-height: 25px;
}

.tools small {
  position: absolute;
  top: 0;
  right: 1px;
  font-size: 7px;
  background: #e9eedd;
  padding: 2px 3px;
  border-radius: 3px;
  line-height: 1.2;
}

.tools button[aria-pressed=true] {
  background: #e3edda;
  color: var(--green);
  border-color: #bacfa3;
}

.tools button:hover:not(:disabled) {
  background: #e5ecde;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(9,1fr);
  gap: 4px;
}

.keypad button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid #dce3d3;
  border-radius: 5px;
  height: 47px;
  background: #edf1e4;
  color: var(--green);
  font-size: 19px;
  font-weight: 500;
  padding: 0;
}

.keypad button:hover {
  background: #dce9cb;
}

.keypad button.complete {
  background: #e2e9da;
  color: #526947;
}

.keypad small {
  min-width: 18px;
  padding: 0 3px;
  border-radius: 4px;
  background: #d9e6cc;
  color: #2f5739;
  font-size: 12px;
  font-weight: 650;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
}

.keypad-help {
  grid-column: 1/-1;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 15px;
  text-align: center;
}

.message {
  min-height: 34px;
  line-height: 1.5;
  font-size: 10px;
  text-align: center;
  color: #74836b;
  margin: 11px 0 8px;
}

.primary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  padding: 13px 16px;
  width: 100%;
  border-radius: 6px;
  background: #24533f;
  color: #f4f7ed;
  font-size: 12px;
  font-weight: 500;
}

.primary:hover {
  background: #153e2e;
}

.primary>span {
  font-size: 18px;
  color: #bad68c;
}

.daily {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 10px;
  padding: 12px 13px;
  border: 1px solid #dce3d2;
  border-radius: 6px;
  background: transparent;
  width: 100%;
  text-align: left;
  color: var(--ink);
  font-size: 11px;
}

.daily:hover {
  background: #edf1e3;
}

.daily>span:first-child {
  font-size: 22px;
  color: #809963;
}

.daily small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  margin-top: 4px;
}

.daily-arrow {
  margin-left: auto;
  color: #809963;
}

.page-footer {
  border-top: 1px solid var(--line);
  margin-top: 26px;
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #8c9487;
  font-size: 9px;
}

.page-footer button {
  background: none;
  border: 0;
  font-size: 9px;
  padding: 0;
  color: #7a8673;
}

.page-footer b {
  font-size: 8px;
  color: #567543;
  margin-left: 4px;
}

dialog {
  border: 1px solid #d4deca;
  border-radius: 18px;
  padding: 0;
  width: min(390px,calc(100vw - 32px));
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 25px 100px #14281e44;
}

dialog: :backdrop {
  background: #1d332765;
  backdrop-filter: blur(7px);
}

.modal-content {
  padding: 30px;
  text-align: center;
}

.modal-symbol {
  font-size: 48px;
  color: #7c9f51;
  display: block;
  margin-bottom: 16px;
}

.modal-content h2 {
  font: normal 32px Georgia,serif;
  letter-spacing: -1px;
  margin: 12px 0;
}

.modal-content p {
  font-size: 13px;
  line-height: 1.8;
  color: #76836e;
}

.modal-content ul {
  padding-left: 20px;
  text-align: left;
  font-size: 12px;
  line-height: 1.9;
  color: #76836e;
}

.modal-content .primary {
  justify-content: center;
  margin-top: 12px;
}

.secondary {
  background: none;
  border: 0;
  padding: 13px;
  color: #6c7962;
  font-size: 12px;
}

.win-stats {
  display: flex;
  justify-content: center;
  gap: 25px;
  margin: 22px 0;
}

.win-stats b {
  display: block;
  font-size: 23px;
  font-weight: 500;
  margin-bottom: 5px;
}

.win-stats span {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #7d8874;
}

.particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 7px;
  height: 12px;
  background: var(--color);
  left: var(--left);
  top: -20px;
  animation: fall 2.5s var(--delay) ease-in forwards;
}

.app.enter #board {
  animation: arrive .45s ease-out;
}

body.modal-open #board {
  filter: blur(7px);
}

@keyframes ink {
  from {
    opacity: 0;
    transform: scale(.65);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes ripple {
  40% {
    background: #bdda97;
  }
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fall {
  to {
    transform: translate(var(--drift),550px) rotate(500deg);
    opacity: 0;
  }
}

@media(min-width:850px) and (min-height:700px) {
  .app {
    padding-top: 45px;
  }
  .header {
    margin-bottom: 38px;
  }
  .game-layout {
    gap: 48px;
  }
  .intro h2 {
    font-size: 40px;
  }
  .intro p {
    font-size: 13px;
  }
  .keypad button {
    height: 53px;
  }
  .tools {
    margin: 22px 0;
  }
  .page-footer {
    margin-top: 35px;
  }
}

@media(max-width:620px) {
  .app {
    padding: 20px 20px 16px;
    max-width: 480px;
  }
  .header {
    margin-bottom: 20px;
  }
  .brand h1 {
    font-size: 34px;
  }
  .brand-mark {
    font-size: 36px;
  }
  .game-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .intro {
    display: none;
  }
  .board-meta {
    margin-bottom: 11px;
  }
  .cell {
    font-size: clamp(21px,6vw,29px);
  }
  .cell .pencil {
    font-size: clamp(8px,2.3vw,11px);
  }
  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 10px;
  }
  .difficulty-control {
    grid-column: 1/-1;
  }
  .difficulty-control label {
    display: none;
  }
  select {
    font-size: 12px;
    padding: 11px;
  }
  .tools {
    grid-column: 1/-1;
    margin: 8px 0;
  }
  .tools button {
    font-size: 10px;
  }
  .tools small {
    right: 15px;
  }
  .keypad {
    grid-column: 1/-1;
    gap: 5px;
  }
  .keypad button {
    height: 48px;
    font-size: 22px;
  }
  .message {
    grid-column: 1/-1;
    min-height: 29px;
    font-size: 11px;
    margin: 5px 0;
  }
  .daily {
    margin: 0;
    padding: 9px;
    font-size: 10px;
  }
  .primary {
    font-size: 11px;
    padding: 12px;
  }
  .daily small {
    font-size: 8px;
  }
  .page-footer {
    margin-top: 20px;
    font-size: 8px;
  }
  .page-footer button {
    font-size: 8px;
  }
}

@media(max-width:350px) {
  .app {
    padding: 15px 12px;
  }
  .puzzle-kind {
    font-size: 9px;
  }
  .page-footer>span {
    max-width: 145px;
  }
  .keypad {
    gap: 3px;
  }
}

@media(prefers-reduced-motion:reduce) {
  *,*::before,*::after {
    animation: none!important;
    transition: none!important;
    scroll-behavior: auto!important;
  }
}
