:root {
  --bg: #0d0e16;
  --bg-elev: #181a26;
  --bg-elev-2: #222536;
  --bg-soft: #14151f;
  --fg: #f5f6fb;
  --fg-dim: #a4a9bd;
  --fg-faint: #61667a;

  /* The Puzzly palette — playful but disciplined */
  --accent: #ffd166;          /* warm yellow — primary brand */
  --accent-2: #ff7eb6;         /* pink */
  --accent-3: #6ee7ff;         /* cyan */
  --accent-4: #a78bfa;         /* purple */
  --accent-soft: rgba(255, 209, 102, 0.14);

  --green: #4ec77b;
  --yellow: #f4c542;
  --blue: #5aa3ff;
  --purple: #b07bff;
  --pink: #ff7eb6;
  --red: #ff6b6b;

  --border: #2a2e40;
  --border-soft: #1f2231;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 16px 40px rgba(0, 0, 0, 0.45);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(167, 139, 250, 0.12), transparent 60%),
    radial-gradient(900px 500px at 95% 8%, rgba(110, 231, 255, 0.10), transparent 60%),
    radial-gradient(1200px 600px at 50% -200px, rgba(255, 209, 102, 0.08), transparent 60%),
    var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 20px 96px;
}

/* ---------- Site header ---------- */
header.site {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

header.site h1 {
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 800;
}
header.site h1 a { color: var(--fg); }
header.site h1 a:hover { text-decoration: none; opacity: 0.92; }

/* The Puzzly wordmark */
.wordmark { display: inline-flex; align-items: baseline; gap: 4px; }
.wordmark-the {
  font-weight: 500;
  font-size: 0.72em;
  color: var(--fg-dim);
  letter-spacing: 0;
  text-transform: lowercase;
  font-style: italic;
}
.wordmark-name {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 55%, var(--accent-4) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}
.wordmark-dot {
  color: var(--accent-3);
  font-weight: 800;
  margin-left: -2px;
}

header.site .tag {
  color: var(--fg-dim);
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}

h2 {
  font-size: 22px;
  margin: 20px 0 6px;
  letter-spacing: -0.01em;
  font-weight: 700;
}
h3 {
  font-size: 12px;
  margin: 0 0 12px;
  font-weight: 700;
  color: var(--fg-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
p { line-height: 1.55; color: var(--fg-dim); margin: 0 0 12px; }

/* ---------- Index: game cards ---------- */
.game-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}
@media (min-width: 560px) {
  .game-grid { grid-template-columns: 1fr 1fr; }
}

.game-card {
  position: relative;
  display: block;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 20px 22px;
  color: var(--fg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
/* Tier-colored left rail — playful but consistent */
.game-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--card-rail, var(--accent));
  opacity: 0.85;
}
.game-card.c-yellow { --card-rail: var(--accent); }
.game-card.c-pink   { --card-rail: var(--accent-2); }
.game-card.c-cyan   { --card-rail: var(--accent-3); }
.game-card.c-purple { --card-rail: var(--accent-4); }
.game-card.c-blue   { --card-rail: var(--blue); }
.game-card.c-green  { --card-rail: var(--green); }

.game-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  border-color: var(--card-rail, var(--accent));
  background: var(--bg-elev-2);
  box-shadow: var(--shadow-hover);
}
.game-card .name {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.015em;
  margin-bottom: 6px;
}
.game-card .pitch {
  color: var(--fg-dim);
  font-size: 13.5px;
  line-height: 1.55;
}

.lede {
  font-size: 15.5px;
  color: var(--fg-dim);
  line-height: 1.6;
  margin: 0 0 18px;
}
.lede strong { color: var(--fg); font-weight: 700; }

/* ---------- Game page chrome ---------- */
.back-link {
  display: inline-block;
  font-size: 12.5px;
  color: var(--fg-dim);
  margin-bottom: 6px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

.game-hero {
  margin: 8px 0 14px;
}
.game-hero .eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 4px;
}
.game-hero h2 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.game-hero .rule {
  color: var(--fg-dim);
  font-size: 14px;
  line-height: 1.55;
}
.game-hero .rule .pill {
  display: inline-block;
  background: linear-gradient(90deg, var(--accent-soft), rgba(255, 126, 182, 0.16));
  color: var(--accent);
  border: 1px solid rgba(255, 209, 102, 0.25);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 6px;
  vertical-align: 1px;
}

/* ---------- Stat bar (guess counter + status) ---------- */
.statbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--fg-dim);
}
.statbar .left,
.statbar .right { display: flex; align-items: center; gap: 10px; }
.statbar .label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.statbar .value {
  font-weight: 700;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.statbar .nudge {
  color: var(--yellow);
  font-weight: 700;
  font-size: 12px;
}

/* ---------- Buttons / inputs ---------- */
button, .btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  background: var(--bg-elev-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 18px;
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.06s ease, box-shadow 0.12s ease;
}
button:hover:not(:disabled), .btn:hover {
  border-color: var(--accent);
  background: var(--bg-elev);
}
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #ffb84d 100%);
  color: #1a1305;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(255, 209, 102, 0.25);
}
button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #ffdc8a 0%, #ffc566 100%);
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(255, 209, 102, 0.35);
}

input[type="text"] {
  font-family: var(--sans);
  font-size: 16px;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  width: 100%;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elev-2);
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.18);
}
input[type="text"]::placeholder { color: var(--fg-faint); }

.controls {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.controls input { flex: 1; }

/* ---------- Result / share ---------- */
.result-panel {
  margin-top: 22px;
  padding: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  animation: fade-up 0.32s ease both;
  position: relative;
  overflow: hidden;
}
.result-panel::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: var(--radius);
  padding: 1px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2), var(--accent-4));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0.55;
  pointer-events: none;
}
.result-panel h2 { margin-top: 0; }
.result-panel .detail { color: var(--fg-dim); font-size: 14px; line-height: 1.55; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.share-grid {
  font-family: var(--mono);
  white-space: pre;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 14px;
  user-select: all;
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg);
}

/* ---------- Attempt pips ---------- */
.attempts {
  display: flex;
  gap: 6px;
}
.attempts .pip {
  width: 22px;
  height: 10px;
  border-radius: 4px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.attempts .pip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.attempts .pip.wrong {
  background: var(--red);
  border-color: var(--red);
}
.attempts .pip.right {
  background: var(--green);
  border-color: var(--green);
  transform: scale(1.08);
}

/* ---------- How to play ---------- */
.howto {
  margin-top: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  overflow: hidden;
}
.howto summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--fg-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: color 0.12s ease, background 0.12s ease;
}
.howto summary:hover { color: var(--fg); background: rgba(255, 255, 255, 0.02); }
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after {
  content: "+";
  font-family: var(--mono);
  color: var(--fg-faint);
  font-size: 16px;
  transition: transform 0.18s ease, color 0.12s ease;
}
.howto[open] summary::after { content: "−"; color: var(--accent); }
.howto .body {
  padding: 0 14px 14px;
  font-size: 13px;
  color: var(--fg-dim);
  line-height: 1.6;
}
.howto .body ol { margin: 0; padding-left: 18px; }
.howto .body li { margin-bottom: 4px; }

/* ---------- Misc ---------- */
.muted { color: var(--fg-dim); }
.faint { color: var(--fg-faint); }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.spacer { height: 16px; }
.hidden { display: none !important; }

footer.site {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--fg-faint);
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
