:root {
  --paper: #f3ead8;
  --ink: #2a241c;
  --muted: #6d6458;
  --line: #1c1814;
  --btn: #fffaf2;
  --accent: #e24b3b;
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "SF Pro Rounded", "Nunito", ui-rounded, system-ui, sans-serif;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: calc(12px + var(--safe-t)) 16px calc(12px + var(--safe-b));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}

.top h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  flex: 1;
}

.ghost {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 8px 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.ghost {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 8px 4px;
}

.start {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
}

.lead {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.35;
  font-weight: 700;
}

.start-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 12px 18px;
  border-radius: 18px;
  border: 2px solid var(--ink);
  background: var(--btn);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: #b13228;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.build {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.mine {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.mine-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 8px 0 16px;
}

.mine-grid button {
  margin: 0;
  padding: 0;
  border: 0;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 1;
  box-shadow: 0 0 0 1px #d8d0c4;
  cursor: pointer;
}

.mine-grid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.empty {
  margin: 24px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 700;
}

.look {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: rgba(20, 16, 12, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.look img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.play {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  gap: 10px;
}

.stage {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#board {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: none;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 0 0 1px #d8d0c4;
}

#board.nope {
  animation: nope 0.32s ease;
}

@keyframes nope {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-7px);
  }
  75% {
    transform: translateX(7px);
  }
}

.play-hint {
  text-align: center;
  min-height: 1.4em;
}

.play-hint.bad {
  color: #c0392b;
  font-weight: 800;
}

.palette {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 16px;
  padding: 8px 12px 12px;
  max-width: 380px;
  margin: 0 auto;
  width: 100%;
}

.swatch {
  aspect-ratio: 1;
  width: 100%;
  max-width: 72px;
  justify-self: center;
  border-radius: 50%;
  border: 3px solid #fff;
  outline: 3px solid transparent;
  font: inherit;
  font-weight: 800;
  font-size: clamp(1rem, 4vw, 1.4rem);
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--ink);
}

.swatch.on {
  outline-color: var(--ink);
}

.busy {
  position: fixed;
  inset: 0;
  background: rgba(42, 36, 28, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.yay {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 8px 4px 4px;
  flex-shrink: 0;
}

.yay p {
  margin: 0;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
}

.busy[hidden],
.yay[hidden],
.start[hidden],
.play[hidden],
.mine[hidden],
.look[hidden],
.top-actions[hidden] {
  display: none;
}

.busy-card {
  background: #fffaf2;
  border: 3px solid var(--ink);
  border-radius: 20px;
  padding: 28px 24px;
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
}

.play.done .play-hint,
.play.done .palette {
  display: none;
}

@media (min-width: 720px) {
  .palette {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    max-width: 640px;
  }
}
