/*
 * Feels Like — v1.1 styling.
 *
 * Same cluster-C frame as v0 (off-white field, italic serif wordmark, white space as
 * material, no chrome). v1.1 keeps v1's share controls and adds:
 *   - .rules-meta (a quiet sub-line on the intro telling Priya it's a 90-second daily)
 *   - .share-controls / .share-toggle / .share-preview (the new share-format chooser
 *     and live preview pane — Priya needs to SEE the words are absent before pasting)
 *   - .pulsing (a soft Next-button pulse during the 1.6s auto-advance)
 *   - .quick-picks / .quick-pick (one-tap starter colors before the full picker)
 */

:root {
  --bg: #f7f3ec;
  --ink: #161514;
  --muted: #6c655c;
  --accent: #4a3a25;
  --line: #e8e2d6;
  --radius: var(--radius-md, 8px);
  --cursor-radius: var(--radius-md, 6px);
  --game-focus: var(--border-focus, var(--accent));
  --serif: var(--font-serif, ui-serif, 'Iowan Old Style', 'Apple Garamond', Baskerville, 'Times New Roman', serif);
  --sans: var(--font-sans, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  --mono: var(--font-mono, ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110d;
    --ink: #f1ece1;
    --muted: #8b8275;
    --accent: #c5a572;
    --line: #2a2520;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 2.5rem 1rem 0.5rem;
}

.wordmark {
  font-family: var(--serif);
  font-size: 3.25rem;
  margin: 0 0 0.2rem;
  letter-spacing: -0.02em;
  font-weight: 500;
  font-style: italic;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-family: var(--serif);
  font-style: italic;
}

main {
  flex: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
}

footer {
  text-align: center;
  padding: 1.25rem 1rem 1.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

footer .brand {
  font-family: var(--serif);
  font-style: italic;
}

.screen { display: none; }
.screen.active { display: block; animation: fadein 0.25s ease; }

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

.puzzle-no {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
  text-align: center;
  letter-spacing: 0.02em;
}

.rules {
  font-size: 1.05rem;
  text-align: center;
  margin: 0 0 0.5rem;
  color: var(--ink);
  max-width: 36ch;
  margin-left: auto;
  margin-right: auto;
}

.rules-meta {
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 auto 1.5rem;
  max-width: 36ch;
}

.primary {
  display: block;
  margin: 1.75rem auto 0;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 0.9rem 2.25rem;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, box-shadow 0.2s;
  min-width: 12rem;
}
.primary:hover { background: var(--accent); }
.primary:active { transform: translateY(1px); }
.primary:focus-visible {
  outline: 2px solid var(--game-focus);
  outline-offset: 3px;
}

/* v1: subtle pulse on the Next button during auto-advance. Hints "this is moving on,
   tap if you want it sooner" without alarm. */
.primary.pulsing {
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 58, 37, 0.0); }
  50%      { box-shadow: 0 0 0 6px rgba(74, 58, 37, 0.18); }
}
@media (prefers-reduced-motion: reduce) {
  .primary.pulsing { animation: none; }
  .screen.active { animation: none; }
}

.round-header {
  text-align: center;
  margin-bottom: 0.5rem;
}

.round-counter {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--muted);
}

.prompt-word {
  font-family: var(--serif);
  font-size: 2.4rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
  font-weight: 500;
  text-align: center;
  margin: 1.25rem 0 1.75rem;
  color: var(--ink);
  max-width: 18ch;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 480px) {
  .prompt-word { font-size: 2.8rem; }
}

.big-swatch {
  width: 100%;
  aspect-ratio: 1.6 / 1;
  border-radius: var(--radius);
  background: var(--line);
  transition: background 0.15s ease;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

.quick-pick-label {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
  margin: 0.85rem auto 0.65rem;
}

.quick-picks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 0 0 0.9rem;
}

.quick-pick {
  min-height: 3.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--chip-color);
  color: #15110d;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  padding: 0.35rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.34), 0 1px 0 rgba(0,0,0,0.04);
  transition: transform 0.05s ease, box-shadow 0.15s ease;
}

.quick-pick span {
  display: inline-block;
  padding: 0.14rem 0.36rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.72);
}

.quick-pick:hover {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.52), 0 2px 8px rgba(0,0,0,0.12);
}

.quick-pick:active { transform: translateY(1px); }

.quick-pick:focus-visible {
  outline: 2px solid var(--game-focus);
  outline-offset: 2px;
}

.quick-pick.selected {
  box-shadow: inset 0 0 0 3px var(--ink), 0 0 0 2px var(--bg), 0 2px 8px rgba(0,0,0,0.15);
}

.phase { display: none; }
.phase.visible { display: block; animation: fadein 0.2s ease; }

/* ---------- picker ---------- */

.picker {
  margin: 1rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  touch-action: none;
}

.picker-field {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04), inset 0 0 0 1px rgba(0,0,0,0.06);
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

.picker-bar {
  position: relative;
  width: 100%;
  height: 44px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04), inset 0 0 0 1px rgba(0,0,0,0.06);
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
}

.picker-field canvas,
.picker-bar canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.picker-cursor {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.85), 0 1px 3px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: transparent;
  top: 0;
  left: 0;
}

.picker-cursor--bar {
  width: 26px;
  height: 40px;
  border-radius: var(--cursor-radius);
}

.picker-field:focus-visible,
.picker-bar:focus-visible {
  outline: 2px solid var(--game-focus);
  outline-offset: 2px;
}

/* ---------- reveal ---------- */

.reveal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
}

.reveal-cell {
  text-align: center;
}

.reveal-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  background: var(--line);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04), inset 0 0 0 1px rgba(0,0,0,0.06);
}

/* v1: faster animate-in (250ms vs v0's 450ms). The structural anti-sycophancy beat is
   still legible; the wait is shorter. */
.reveal-swatch--judge {
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.reveal-swatch--judge.animate-in {
  opacity: 1;
  transform: scale(1);
}

.reveal-label {
  font-family: var(--serif);
  font-style: italic;
  margin: 0.5rem 0 0.1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.verdict {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.45;
  text-align: center;
  margin: 1rem auto 0.5rem;
  max-width: 32ch;
  color: var(--ink);
}

.round-score {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
}

.round-score span {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--ink);
}

/* ---------- finale ---------- */

#finale h2, #already h2 {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 500;
  font-style: italic;
  text-align: center;
  margin: 0.5rem 0 1.25rem;
}

#finale h2 span,
.already-score-line span {
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.already-score-line {
  text-align: center;
  margin: 0 0 1rem;
  color: var(--ink);
  font-size: 1.05rem;
}

.band-result {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 1rem auto 1rem;
  max-width: 28ch;
}

.band-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-family: var(--serif);
  font-size: 1.05rem;
}

.band-emoji {
  font-size: 1.4rem;
  line-height: 1;
  flex: 0 0 1.6em;
}

.band-word {
  color: var(--ink);
}

.finale-help {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.25rem auto 1.5rem;
  font-family: var(--serif);
  font-style: italic;
  max-width: 34ch;
}

.finale-help em {
  font-style: normal;
  color: var(--ink);
}

/* ---------- v1: share controls ---------- */

.share-controls {
  margin: 1.25rem 0 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.share-controls-label {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  text-align: center;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.share-toggle {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 36ch;
  margin: 0 auto;
}

.share-toggle-opt {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: start;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.share-toggle-opt:hover { background: var(--line); }

.share-toggle-opt input[type="radio"] {
  margin-top: 0.3rem;
  accent-color: var(--ink);
}

.share-toggle-opt:has(input:checked) {
  border-color: var(--line);
  background: var(--line);
}

.share-toggle-text {
  display: block;
  font-family: var(--serif);
  line-height: 1.35;
}

.share-toggle-text strong {
  display: block;
  font-style: normal;
  font-weight: 500;
  color: var(--ink);
  font-size: 0.98rem;
}

.share-toggle-text em {
  display: block;
  font-style: italic;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.1rem;
}

.verdict-pick {
  margin: 1rem 0 0.5rem;
}

.verdict-pick[hidden] { display: none; }

.verdict-pick-label {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  text-align: center;
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}

.verdict-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 36ch;
  margin: 0 auto;
}

.verdict-opt {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.verdict-opt:hover { background: var(--line); }

.verdict-opt input[type="radio"] {
  margin-top: 0.3rem;
  accent-color: var(--ink);
}

.verdict-opt-word {
  display: block;
  grid-column: 2;
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.1rem;
}

.verdict-opt-text {
  display: block;
  grid-column: 2;
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--ink);
}

/* v1: live preview of the exact share string. Priya needs to SEE the words are gone. */
.share-preview {
  margin: 1.25rem auto 0.25rem;
  max-width: 36ch;
  padding: 0.85rem 1rem;
  background: var(--line);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--ink);
  user-select: all;
  -webkit-user-select: all;
}

.share-status {
  text-align: center;
  color: var(--muted);
  min-height: 1.4em;
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.next-puzzle {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  margin-top: 1.75rem;
  font-family: var(--serif);
  font-style: italic;
}

@media (max-width: 420px) {
  .wordmark { font-size: 2.6rem; }
  main { padding: 1.25rem 1rem 2rem; }
  .prompt-word { font-size: 2.1rem; }
  .share-preview { font-size: 0.8rem; }
}
