/* /play/ — daily web puzzle. Builds on the site tokens in /styles.css. */

.play-page {
  --play-edge: rgba(46, 30, 22, 0.82);
  --play-line: rgba(46, 30, 22, 0.16);
  --play-mark: rgba(46, 30, 22, 0.62);
}

.play-shell {
  width: min(var(--page), calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 88px;
}

.play-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  align-items: start;
  gap: 56px;
}

.play-intro {
  position: sticky;
  top: 112px;
}

.play-intro h1 {
  margin-bottom: 18px;
  color: var(--accent);
  font-size: clamp(40px, 5vw, 62px);
  font-weight: 950;
  line-height: 1.02;
}

.play-lead {
  max-width: 460px;
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 650;
  line-height: 1.6;
}

.play-game {
  max-width: 600px;
  padding: 20px;
  border: 1px solid var(--outline);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.play-tabs,
.play-mode {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-muted);
}

.play-tabs {
  width: 100%;
}

.play-tabs button,
.play-mode button {
  flex: 1;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 15px;
  font-weight: 850;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.play-tabs small {
  font-weight: 650;
  opacity: 0.8;
}

.play-tabs button[aria-selected="true"],
.play-mode button[aria-checked="true"] {
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 2px var(--accent), var(--shadow-soft);
}

.play-tabs button:focus-visible,
.play-mode button:focus-visible,
.play-button:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

.play-tabs button:hover,
.play-mode button:hover {
  color: var(--text);
}

.play-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 4px 12px;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 700;
}

.play-status b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.play-board {
  --size: 6;
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(var(--size), minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--play-edge);
  border-radius: 14px;
  overflow: hidden;
  background: var(--play-edge);
}

.play-game[data-play-state="loading"] .play-board,
.play-game[data-play-state="error"] .play-board {
  background: var(--surface-muted);
  border-color: var(--outline);
}

.play-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--play-line);
  border-radius: 0;
  background: var(--region);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.play-cell.edge-top { border-top: 2px solid var(--play-edge); }
.play-cell.edge-right { border-right: 2px solid var(--play-edge); }
.play-cell.edge-bottom { border-bottom: 2px solid var(--play-edge); }
.play-cell.edge-left { border-left: 2px solid var(--play-edge); }

.play-cell:hover {
  filter: brightness(1.07);
}

.play-cell:focus-visible {
  z-index: 2;
  outline: 3px solid var(--orange);
  outline-offset: -3px;
}

.play-cell:disabled {
  cursor: default;
  opacity: 1;
}

.play-cell.is-marked::after {
  content: "\00d7";
  color: var(--play-mark);
  font-size: calc(100cqi / var(--size) * 0.56);
  font-weight: 900;
  line-height: 1;
}

.play-cell.is-cat::after {
  content: "";
  width: 86%;
  height: 86%;
  background: url("/assets/icons/cat-piece-96.webp") center / contain no-repeat;
  background-image: image-set(url("/assets/icons/cat-piece-96.webp") 1x, url("/assets/icons/cat-piece-192.webp") 2x);
  filter: drop-shadow(0 2px 3px rgba(46, 30, 22, 0.3));
  animation: play-pop 360ms cubic-bezier(0.16, 1.55, 0.45, 1);
}

.play-cell.is-wrong {
  animation: play-shake 380ms ease;
}

.play-cell.is-hint {
  z-index: 2;
  outline: 4px solid var(--orange);
  outline-offset: -4px;
  animation: play-pulse 800ms ease-in-out 2;
}

.play-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.play-mode {
  margin-right: auto;
}

.play-mode button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mode-cat {
  width: 18px;
  height: 18px;
  background: url("/assets/icons/cat-piece-96.webp") center / contain no-repeat;
}

.play-button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 850;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease;
}

.play-button small {
  color: var(--text-muted);
  font-weight: 700;
}

.play-button:hover {
  background: var(--surface-muted);
}

.play-button:active {
  transform: translateY(1px);
}

.play-button-strong {
  border-color: transparent;
  background: var(--orange);
  color: #3b2414;
}

.play-button-strong:hover {
  background: #ffa733;
}

.play-help {
  margin: 14px 4px 0;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.play-message {
  min-height: 1.5em;
  margin: 8px 4px 0;
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 800;
}

.play-result {
  margin-top: 16px;
  padding: 22px;
  border-radius: 20px;
  background: var(--header);
}

.play-result h2 {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 32px;
  font-weight: 950;
}

.play-result h2:focus {
  outline: none;
}

.play-result > p {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.play-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 20px;
}

.play-app {
  padding-top: 18px;
  border-top: 1px solid var(--outline);
}

.play-app p {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.55;
}

.play-app .store-row,
.play-guide .store-row {
  margin-top: 12px;
}

.play-guide {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 56px;
  margin-top: 88px;
  padding-top: 56px;
  border-top: 1px solid var(--outline);
}

.play-guide h2 {
  margin-bottom: 18px;
  color: var(--accent);
  font-size: 36px;
  font-weight: 950;
  line-height: 1.1;
}

.play-guide h3 {
  margin: 22px 0 6px;
  color: var(--text);
  font-size: 19px;
  font-weight: 900;
}

.play-guide p,
.play-rules li {
  color: var(--text-muted);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.6;
}

.play-guide a:not(.store-button) {
  color: var(--accent-text);
  font-weight: 850;
}

.play-rules {
  margin: 0 0 18px;
  padding-left: 22px;
}

.play-rules strong {
  color: var(--text);
}

@keyframes play-pop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes play-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@keyframes play-pulse {
  50% { outline-color: var(--accent); }
}

@media (max-width: 900px) {
  .play-hero,
  .play-guide {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .play-intro {
    position: static;
  }

  .play-game {
    max-width: none;
  }
}

@media (max-width: 520px) {
  .play-shell {
    width: calc(100% - 24px);
    padding-top: 28px;
  }

  .play-intro h1 {
    font-size: 38px;
  }

  .play-lead {
    font-size: 16px;
  }

  .play-game {
    padding: 12px;
    border-radius: 22px;
  }

  .play-tabs button {
    padding: 0 6px;
    font-size: 14px;
  }

  .play-tabs small {
    display: block;
    font-size: 11px;
  }

  .play-controls {
    gap: 6px;
  }

  .play-mode {
    width: 100%;
    margin-right: 0;
  }

  .play-mode button {
    flex: 1;
    justify-content: center;
  }

  .play-button {
    flex: 1;
    padding: 0 10px;
  }

  .play-guide h2 {
    font-size: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .play-cell.is-cat::after,
  .play-cell.is-wrong,
  .play-cell.is-hint {
    animation: none;
  }
}
