/* ==========================================================================
   Page-specific styles. Shared tokens and components live in app.css.
   ========================================================================== */

/* ---------- Home ---------- */

.hero {
  padding: 18px 0 8px;
  text-align: center;
}

.hero-eyebrow {
  font-family: var(--font-display);
  font-size: clamp(14px, 2.4vw, 22px);
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hero h1 {
  margin-top: 6px;
  font-size: clamp(48px, 10vw, 92px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.hero-sub {
  margin-top: 16px;
  font-size: clamp(16px, 2.6vw, 22px);
  color: var(--text-muted);
}

.cta-play {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(16px, 4vw, 34px);
  margin: clamp(26px, 5vw, 44px) auto 0;
  padding: clamp(20px, 3.6vw, 30px) clamp(22px, 5vw, 44px) clamp(20px, 3.6vw, 30px) clamp(24px, 6vw, 72px);
  border-radius: var(--radius-xl);
  background: var(--gradient);
  color: #fff;
  box-shadow: var(--shadow-primary);
  overflow: hidden;
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}

.cta-play::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.22), transparent 55%);
  opacity: 0;
  transition: opacity 0.25s;
}

.cta-play:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 48px rgba(92, 64, 240, 0.5);
}

.cta-play:hover::before {
  opacity: 1;
}

.cta-play:active {
  transform: translateY(-1px) scale(0.99);
}

.cta-play .play-icon {
  flex: none;
  font-size: clamp(36px, 7vw, 58px);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.18));
}

.cta-play .cta-text {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.cta-play strong {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(22px, 4.4vw, 36px);
  font-weight: 700;
  line-height: 1.15;
}

.cta-play span {
  display: block;
  margin-top: 4px;
  font-size: clamp(14px, 2.4vw, 20px);
  opacity: 0.85;
}

.cta-play .cta-arrow {
  flex: none;
  font-size: clamp(22px, 3.6vw, 32px);
  transition: transform 0.25s var(--ease);
}

.cta-play:hover .cta-arrow {
  transform: translateX(6px);
}

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: clamp(28px, 5vw, 48px) 0;
}

.feature {
  padding: 4px clamp(6px, 2vw, 20px);
  text-align: center;
  border-left: 1px solid var(--border-strong);
}

.feature:first-child {
  border-left: 0;
}

.feature i {
  font-size: clamp(24px, 4vw, 34px);
  color: var(--text);
  transition: transform 0.25s var(--ease), color 0.2s;
}

.feature:hover i {
  transform: translateY(-3px) scale(1.06);
  color: var(--primary-text);
}

.feature strong {
  display: block;
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: clamp(15px, 2.6vw, 22px);
  font-weight: 700;
}

.feature span {
  display: block;
  margin-top: 2px;
  font-size: clamp(12.5px, 2vw, 17px);
  color: var(--text-muted);
  line-height: 1.35;
}

.banner-stack {
  display: grid;
  gap: 14px;
}

.banner-stack .banner {
  padding-top: 22px;
  padding-bottom: 22px;
}

@media (min-width: 900px) {
  .home .main-inner {
    padding-top: clamp(0px, 4vh, 60px);
  }
}

/* ---------- Play ---------- */

.play-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.play-header {
  text-align: center;
}

.play-header h1 {
  min-height: 1.15em;
  font-size: clamp(28px, 6.2vw, 50px);
  font-weight: 800;
  word-break: break-word;
}

.creator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  margin-top: 6px;
  font-size: clamp(15px, 2.4vw, 19px);
  font-weight: 600;
  color: var(--text-muted);
}

.creator .fa-circle-check {
  color: var(--text);
}

.play-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: clamp(12px, 2.4vh, 22px) 0 clamp(14px, 2.6vh, 26px);
  font-size: clamp(16px, 2.6vw, 21px);
  font-weight: 600;
  color: var(--text-muted);
}

.play-stats > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 clamp(18px, 4.4vw, 34px);
}

.play-stats > div + div {
  border-left: 1px solid var(--border-strong);
}

.play-stats i {
  font-size: 0.95em;
}

.play-stats .bump {
  animation: bump 0.25s var(--ease);
}

@keyframes bump {
  50% {
    transform: scale(1.18);
    color: var(--text);
  }
}

.board-wrap {
  position: relative;
  width: min(100%, 520px);
  width: min(100%, 560px, max(290px, 100svh - 360px));
  margin: 0 auto;
}

@media (min-width: 900px) {
  .board-wrap {
    width: min(100%, 580px, max(340px, 100svh - 330px));
  }
}

.board {
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  gap: clamp(5px, 1.6cqi, 12px);
  padding: 18px;
  padding: clamp(10px, 5.4cqi, 34px);
  border-radius: var(--radius-xl);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02), var(--shadow);
  aspect-ratio: 1;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

:root[data-theme="light"] .board {
  background: var(--surface);
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: clamp(6px, 1.8cqi, 12px);
  background: var(--tile);
  color: var(--tile-text);
  font-family: var(--font);
  font-size: 26px;
  font-size: clamp(18px, 7.2cqi, 40px);
  font-weight: 800;
  line-height: 1;
  transition: background 0.18s, transform 0.14s var(--ease), box-shadow 0.18s, color 0.18s;
}

button.tile {
  cursor: pointer;
}

.tile.is-clue {
  background: var(--tile-clue);
  color: var(--tile-clue-text);
  cursor: default;
}

@media (hover: hover) {
  button.tile:not(.correct):not(:disabled):hover {
    background: var(--tile-hover);
    transform: translateY(-2px);
  }

  button.tile.almost-correct:not(:disabled):hover {
    background: #ffa233;
  }
}

.tile.almost-correct {
  background: var(--orange);
  color: #fff;
}

.tile.correct {
  background: var(--green);
  color: #fff;
  cursor: default;
}

.tile.selected,
.tile.selected:hover {
  transform: translateY(-4px) scale(1.07);
  box-shadow: 0 0 0 3px var(--bg-elev), 0 0 0 6px var(--primary-text), 0 12px 24px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

:root[data-theme="light"] .tile.selected {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--primary), 0 12px 24px rgba(20, 22, 60, 0.25);
}

.tile.swapped {
  animation: swap-pop 0.24s var(--ease);
}

@keyframes swap-pop {
  0% {
    transform: scale(0.86);
  }
  60% {
    transform: scale(1.06);
  }
}

.tile.just-solved {
  animation: solve-flip 0.5s var(--ease) both;
  animation-delay: calc(var(--col) * 55ms);
}

@keyframes solve-flip {
  0% {
    transform: rotateX(0);
  }
  45% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0);
  }
}

.tile:disabled {
  opacity: 1;
}

.board.is-complete {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 50%, transparent), 0 20px 60px rgba(34, 197, 94, 0.18);
}

.board.is-loading .tile {
  background: var(--surface-2);
}

.board.is-loading .tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  animation: shimmer 1.4s infinite;
  transform: translateX(-100%);
}

.board-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  border-radius: var(--radius-xl);
  text-align: center;
  background: rgba(10, 11, 38, 0.75);
  background: color-mix(in srgb, var(--bg-elev) 70%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade-in 0.2s ease;
}

.board-overlay[hidden] {
  display: none;
}

.board-overlay strong {
  font-family: var(--font-display);
  font-size: 24px;
}

.play-actions {
  display: grid;
  gap: 10px;
  width: min(100%, 500px);
  margin: clamp(16px, 3vh, 30px) auto 0;
}

.play-actions .btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.keyboard-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

@media (hover: none) {
  .keyboard-hint {
    display: none;
  }
}

/* Leaderboard */

.lb-head {
  text-align: center;
}

.lb-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 800;
}

.lb-head h2 i {
  color: var(--yellow);
  font-size: 0.95em;
}

.lb-head p {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 16px;
}

.lb-counts {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 16px 0 22px;
  font-size: 20px;
  font-weight: 800;
}

.lb-counts .plays {
  color: var(--yellow);
}

.lb-counts .solved {
  color: var(--green-text);
}

.lb-counts .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
}

.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 88px;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform 0.18s var(--ease);
}

.lb-row:hover {
  transform: translateX(-3px);
}

.lb-row.is-new {
  animation: feed-in 0.4s var(--ease);
}

.lb-rank {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-3);
  font-size: 22px;
  font-weight: 900;
}

.lb-info {
  min-width: 0;
}

.lb-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
}

.lb-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-name .flag {
  width: 26px;
  height: 19px;
}

.lb-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-muted);
}

.lb-meta .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.lb-row.rank-1 {
  background: var(--gold-bg);
  border-color: transparent;
  color: var(--gold-text);
  box-shadow: 0 10px 28px rgba(245, 198, 60, 0.22);
}

.lb-row.rank-1 .lb-rank {
  background: rgba(255, 255, 255, 0.75);
  color: var(--gold-text);
}

.lb-row.rank-1 .lb-meta {
  color: rgba(42, 29, 0, 0.78);
}

.lb-row.rank-2 {
  background: var(--silver-bg);
}

.lb-row.rank-2 .lb-rank {
  background: radial-gradient(circle at 35% 30%, #dfe2f0, var(--silver-ring));
  color: #24263f;
}

.lb-row.rank-3 {
  background: var(--bronze-bg);
  border-color: color-mix(in srgb, var(--bronze-ring) 50%, transparent);
}

.lb-row.rank-3 .lb-rank {
  background: radial-gradient(circle at 35% 30%, #f1b47f, var(--bronze-ring));
  color: #3a1f0b;
}

.lb-row.skeleton-row {
  background: var(--surface);
}

.lb-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.lb-empty i {
  display: block;
  margin-bottom: 10px;
  font-size: 26px;
  color: var(--yellow);
}

@media (max-width: 899px) {
  .play .aside {
    margin-top: 36px;
  }

  .lb-row {
    min-height: 74px;
    padding: 12px 16px;
  }

  .lb-rank {
    width: 40px;
    height: 40px;
    font-size: 19px;
  }

  .lb-name {
    font-size: 18px;
  }

  .lb-meta {
    font-size: 15px;
  }
}

/* Results modal */

.results {
  text-align: center;
}

.results-emoji {
  font-size: 46px;
  line-height: 1;
}

.results h2 {
  margin-top: 10px;
  font-size: 30px;
  font-weight: 800;
}

.results-sub {
  margin-top: 4px;
  color: var(--text-muted);
}

.results-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 0 14px;
}

.results-stats div {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.results-stats strong {
  display: block;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
}

.results-stats span {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--orange) 16%, transparent);
  color: var(--orange);
  font-weight: 800;
}

.streak-chip[hidden] {
  display: none;
}

.results-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: left;
}

.results-section h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 10px;
}

.share-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.share-btn {
  display: grid;
  place-items: center;
  height: 50px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 20px;
  transition: background 0.15s, transform 0.12s, color 0.15s;
}

.share-btn:hover {
  background: var(--surface-3);
  transform: translateY(-2px);
}

.share-btn.native {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  font-size: 16px;
  font-weight: 800;
  background: var(--primary-soft);
  color: var(--primary-text);
  border-color: transparent;
}

.name-form {
  display: flex;
  gap: 8px;
}

.name-form .input {
  flex: 1;
  min-width: 0;
}

.name-form .btn {
  flex: none;
  min-height: 50px;
}

.saved-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--green) 12%, transparent);
  color: var(--green-text);
  font-weight: 800;
}

.saved-name[hidden],
.name-form[hidden] {
  display: none;
}

.results-actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.upsell {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: left;
  font-size: 14.5px;
  transition: background 0.15s;
}

.upsell:hover {
  background: var(--surface-2);
}

.upsell i {
  color: var(--primary-text);
  font-size: 20px;
}

.upsell span {
  flex: 1;
}

/* ---------- Browse ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.tabs {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.tabs button {
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 15px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

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

.tabs button[aria-selected="true"] {
  background: var(--primary);
  color: #fff;
}

.search {
  position: relative;
  flex: 1 1 220px;
}

.search i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

.search .input {
  padding-left: 44px;
  height: 48px;
}

.select {
  height: 48px;
  padding: 0 40px 0 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%238a8fb5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  font-weight: 700;
  appearance: none;
  cursor: pointer;
}

.select:focus {
  outline: none;
  border-color: var(--primary);
}

.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.puzzle-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 118px;
  padding: 18px 18px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.18s var(--ease), border-color 0.18s, background 0.18s;
}

.puzzle-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
  background: var(--surface-2);
}

.puzzle-card .pc-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
}

.puzzle-card .pc-name .arrow {
  color: var(--primary-text);
  margin: 0 4px;
}

.puzzle-card .pc-creator {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14.5px;
  font-weight: 600;
}

.puzzle-card .pc-meta {
  display: flex;
  gap: 14px;
  margin-top: auto;
  padding-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-faint);
}

.puzzle-card .pc-play {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.18s, transform 0.18s var(--ease);
}

.puzzle-card:hover .pc-play,
.puzzle-card:focus-visible .pc-play {
  opacity: 1;
  transform: none;
}

@media (hover: none) {
  .puzzle-card .pc-play {
    opacity: 1;
    transform: none;
    background: var(--surface-3);
    color: var(--text);
  }
}

.puzzle-card.skeleton-card {
  pointer-events: none;
}

.load-more {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

.empty-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty-state i {
  display: block;
  margin-bottom: 12px;
  font-size: 28px;
  color: var(--text-faint);
}

/* ---------- Create ---------- */

.create-layout {
  display: grid;
  gap: 18px;
}

/* Side-by-side only when the content column itself is wide enough */
.create .main-inner {
  container-type: inline-size;
}

@container (min-width: 640px) {
  .create-layout {
    grid-template-columns: minmax(0, 1fr) 250px;
    align-items: start;
  }

  .create-preview {
    position: sticky;
    top: 36px;
  }
}

.create-card {
  padding: clamp(18px, 3vw, 28px);
}

.word-rows {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.word-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.word-row label {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-muted);
}

.word-row.is-clue label {
  color: var(--primary-text);
}

.word-input {
  height: 52px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.word-row.is-clue .word-input {
  background: color-mix(in srgb, var(--tile-clue) 60%, var(--surface-2));
}

.word-count {
  width: 42px;
  text-align: right;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-faint);
}

.word-row.is-complete .word-count {
  color: var(--green-text);
}

@media (max-width: 520px) {
  .word-row {
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
  }

  .word-row label {
    grid-column: 1 / -1;
  }

  .word-input {
    font-size: 20px;
    letter-spacing: 0.3em;
  }
}

.create-preview .board {
  padding: 14px;
  gap: 6px;
}

.create-preview .tile {
  font-size: clamp(14px, 6.4cqi, 26px);
}

.create-preview .tile.is-empty {
  background: transparent;
  border: 1.5px dashed var(--border-strong);
}

.create-preview h3 {
  margin-bottom: 12px;
  font-size: 17px;
}

.create-preview p {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.notice {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 14px;
  color: var(--text-muted);
}

.notice i {
  margin-top: 3px;
  color: var(--primary-text);
}

.publish-success {
  text-align: center;
  padding: clamp(24px, 4vw, 40px);
}

.publish-success .big-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--green) 16%, transparent);
  color: var(--green-text);
  font-size: 32px;
}

.copy-field {
  display: flex;
  gap: 8px;
  margin: 20px auto;
  max-width: 520px;
}

.copy-field .input {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 15px;
}

.tips {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 16px;
}

.tips li {
  display: flex;
  gap: 14px;
}

.tips .num {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 900;
  font-size: 14px;
}

.tips strong {
  display: block;
}

.tips span {
  color: var(--text-muted);
  font-size: 14.5px;
}

.example-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.example-chain span {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--tile);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.example-chain span.is-clue {
  background: var(--tile-clue);
  color: var(--tile-clue-text);
}

/* ---------- Stats ---------- */

.stats .main-inner {
  container-type: inline-size;
}

/* Recent quests */
.history {
  padding: 20px;
  margin-bottom: 30px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.history-head .section-title {
  font-size: 20px;
}

.history-count {
  color: var(--text-faint);
  font-size: 13.5px;
  font-weight: 700;
}

.history-list {
  list-style: none;
  margin: 0 -8px;
  padding: 0;
}

.history-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
}

.history-item:first-child {
  border-top: 0;
}

.history-item.is-new {
  animation: feed-in 0.45s var(--ease);
}

.history-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-faint);
  font-size: 15px;
}

.is-solved .history-icon {
  background: color-mix(in srgb, var(--green) 16%, transparent);
  color: var(--green-text);
}

.is-solving .history-icon {
  background: color-mix(in srgb, var(--orange) 16%, transparent);
  color: var(--orange);
}

.history-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.history-main .skeleton-line {
  height: 12px;
}

.history-who {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.history-who b {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 800;
}

.history-who b.is-anon {
  color: var(--text-muted);
  font-weight: 700;
}

.history-chip {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.is-solved .history-chip {
  background: color-mix(in srgb, var(--green) 14%, transparent);
  color: var(--green-text);
}

.is-solving .history-chip {
  background: color-mix(in srgb, var(--orange) 14%, transparent);
  color: var(--orange);
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 6px 12px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}

.history-meta a {
  color: var(--primary-text);
  font-weight: 800;
}

.history-meta a:hover {
  text-decoration: underline;
}

.history-place {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.history-place span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta time {
  flex: none;
  color: var(--text-faint);
}

.history-result {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.history-result strong {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.is-solving .history-result strong {
  color: var(--orange);
}

.history-result span {
  color: var(--text-faint);
  font-size: 12.5px;
  font-weight: 700;
}

.history-empty {
  padding: 28px 8px;
  text-align: center;
  color: var(--text-muted);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.pager-label {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.stats-subtitle {
  margin-bottom: 14px;
  font-size: 20px;
}

/* Narrow screens: tighter rows, icon-only pager buttons */
@container (max-width: 480px) {
  .history {
    padding: 16px 14px;
  }

  .history-item {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 10px;
  }

  .history-icon {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  .history-meta {
    font-size: 12.5px;
    gap: 8px;
  }

  .pager .btn span {
    display: none;
  }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@container (min-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}

.stat-card .label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-muted);
}

.stat-card .label i {
  color: var(--primary-text);
}

.stat-card .value {
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: clamp(24px, 3.4vw, 34px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-card .value .skeleton {
  display: block;
  width: 70%;
  height: 30px;
}

.stat-lists {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

@container (min-width: 640px) {
  .stat-lists {
    grid-template-columns: 1fr 1fr;
  }
}

.rank-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.rank-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-weight: 700;
}

.rank-list li:first-child {
  border-top: 0;
}

.rank-list .n {
  width: 22px;
  color: var(--text-faint);
  font-weight: 900;
}

.rank-list .place {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rank-list .count {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Tutorial ---------- */

.tutorial-grid {
  display: grid;
  gap: 20px;
}

/* ---------- Legal pages ---------- */

.prose {
  max-width: 720px;
  padding: clamp(20px, 4vw, 40px);
  color: var(--text-muted);
  font-size: 16.5px;
  line-height: 1.7;
}

.prose h1 {
  color: var(--text);
  font-size: clamp(30px, 5vw, 40px);
  font-weight: 800;
}

.prose .updated {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-faint);
}

.prose h2 {
  margin: 30px 0 8px;
  color: var(--text);
  font-size: 21px;
  font-weight: 700;
}

.prose p + p {
  margin-top: 12px;
}

.prose ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.prose li + li {
  margin-top: 6px;
}

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

.prose a {
  color: var(--primary-text);
  font-weight: 700;
}

.prose a:hover {
  text-decoration: underline;
}

/* ---------- 404 ---------- */

.not-found {
  display: grid;
  place-items: center;
  min-height: 60vh;
  text-align: center;
}

.not-found .code {
  font-family: var(--font-display);
  font-size: clamp(80px, 16vw, 140px);
  font-weight: 800;
  line-height: 1;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.not-found p {
  margin: 10px 0 24px;
  color: var(--text-muted);
}

@media (max-width: 520px) {
  .puzzle-card {
    min-height: 100px;
    padding: 14px 16px;
  }

  .puzzle-card .pc-name {
    font-size: 17.5px;
  }
}
