:root {
  --ink: #172033;
  --muted: #5f6b7c;
  --line: #dfe7f2;
  --purple: #6757f5;
  --purple-dark: #4b3ee3;
  --blue: #4078ff;
  --soft-blue: #deecff;
  --soft-yellow: #fff1cb;
  --soft-green: #e4f9ee;
  --soft-pink: #ffe1ee;
  --soft-purple: #eee8ff;
  --shadow: 0 18px 45px rgba(34, 50, 84, 0.11);
  --shadow-soft: 0 10px 25px rgba(34, 50, 84, 0.08);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(255, 191, 77, 0.22), transparent 28%),
    radial-gradient(circle at 88% 14%, rgba(103, 87, 245, 0.14), transparent 30%),
    linear-gradient(180deg, #fbfdff 0%, #f4f8ff 45%, #fff9f1 100%);
  min-height: 100vh;
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
.container { width: min(1120px, calc(100% - 44px)); margin: 0 auto; }
.hidden { display: none !important; }

/* Header */
.puzzle-site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(223, 231, 242, 0.9);
}
.puzzle-header-inner {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: fit-content; }
.brand-badge {
  width: 44px; height: 44px; border-radius: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.92rem; font-weight: 900;
  background: linear-gradient(135deg, #4078ff, #6757f5);
  box-shadow: 0 12px 22px rgba(64, 120, 255, 0.22);
}
.logo { display: block; font-size: 1.55rem; font-weight: 900; letter-spacing: -0.04em; line-height: 1; color: var(--ink); }
.tagline { display: block; margin-top: 7px; color: #718096; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.18em; }
.site-nav { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.site-nav a {
  padding: 8px 12px; border-radius: 999px; color: #435067;
  font-size: 0.87rem; font-weight: 800; border: 1px solid transparent;
}
.site-nav a:hover, .site-nav a.active { color: #fff; background: var(--purple); }
.menu-toggle {
  display: none; width: 42px; height: 42px; border: 1px solid var(--line);
  border-radius: 14px; background: #fff; cursor: pointer; font-size: 1.2rem;
}

.puzzle-subnav-card {
  width: min(1120px, calc(100% - 44px));
  margin: 14px auto 0;
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(223, 231, 242, 0.9);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
}
.puzzle-subnav-card a {
  padding: 10px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: #435067;
  font-weight: 900;
  font-size: 0.9rem;
}
.puzzle-subnav-card a:hover, .puzzle-subnav-card a.active {
  color: #fff;
  background: var(--purple);
  border-color: var(--purple);
}

/* Hero */
.word-hero {
  padding: 68px 0 28px;
  text-align: center;
}
.word-hero-inner { max-width: 850px; }
.eyebrow {
  display: inline-flex;
  width: fit-content;
  color: var(--purple);
  background: rgba(103, 87, 245, 0.08);
  border: 1px solid rgba(103, 87, 245, 0.12);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.word-hero h1 {
  margin: 18px 0 12px;
  font-size: clamp(2.25rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: -0.07em;
}
.word-hero p:not(.eyebrow) {
  max-width: 690px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.05rem;
}

/* Main game layout */
.word-play-section {
  padding: 28px 0 54px;
  border-top: 1px solid rgba(223, 231, 242, 0.75);
  border-bottom: 1px solid rgba(223, 231, 242, 0.75);
  background: rgba(255, 255, 255, 0.42);
}
.word-play-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 22px;
  align-items: start;
}
.word-control-card,
.word-capture-card,
.grid-card,
.word-search-sidebar {
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
}
.word-control-card {
  padding: 24px;
  position: sticky;
  top: 116px;
}
.control-icon {
  width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 19px;
  background: linear-gradient(135deg, var(--soft-blue), #f7fbff);
  font-size: 1.85rem;
  box-shadow: 0 9px 18px rgba(34, 50, 84, 0.08);
}
.word-control-card h2 {
  margin: 16px 0 10px;
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: -0.04em;
}
.control-copy {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
}
.word-input-panel {
  display: grid;
  gap: 9px;
}
.word-input-label {
  color: #435067;
  font-size: 0.86rem;
  font-weight: 900;
}
.word-input {
  width: 100%;
  min-height: 122px;
  resize: vertical;
  border-radius: 20px;
  border: 1px solid var(--line);
  padding: 14px;
  outline: none;
  background: #fff;
  color: var(--ink);
}
.word-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(103, 87, 245, 0.12);
}
.primary-btn, .secondary-btn {
  min-height: 44px;
  border-radius: 999px;
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
  border: 0;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.primary-btn:hover, .secondary-btn:hover { transform: translateY(-2px); }
.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  box-shadow: 0 13px 24px rgba(64, 120, 255, 0.2);
}
.secondary-btn {
  color: var(--purple-dark);
  background: #fff;
  border: 1px solid var(--line);
}
.how-to-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--soft-yellow), #fffaf1);
  border: 1px solid rgba(255, 194, 90, 0.22);
}
.how-to-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  letter-spacing: -0.02em;
}
.how-to-card ul {
  margin: 0;
  padding-left: 18px;
  color: #5f5a4e;
  font-size: 0.92rem;
}
.how-to-card li + li { margin-top: 6px; }

.word-game-column { min-width: 0; }
.word-capture-card {
  padding: 24px;
  overflow: hidden;
}
.share-title-wrap {
  text-align: center;
  margin-bottom: 20px;
}
.share-card-title {
  margin: 0 0 5px;
  font-size: 1.8rem;
  line-height: 1.1;
  letter-spacing: -0.045em;
}
.share-card-subtitle {
  margin: 0;
  color: #718096;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.word-search-layout {
  display: grid;
  grid-template-columns: minmax(390px, 1fr) minmax(180px, 220px);
  gap: 14px;
  align-items: start;
}
.grid-card {
  border-radius: 26px;
  padding: 18px;
  background: rgba(255,255,255,0.9);
}
.word-search-grid {
  display: grid;
  grid-template-columns: repeat(11, minmax(28px, 48px));
  justify-content: center;
  gap: 8px;
  user-select: none;
  touch-action: none;
}
.word-cell {
  border: 1px solid #d5deec;
  background: linear-gradient(180deg, #ffffff, #f5f8ff);
  color: var(--ink);
  border-radius: 12px;
  min-height: 42px;
  aspect-ratio: 1 / 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.word-cell:hover { transform: translateY(-1px); }
.word-cell.selected {
  background: #fff4c7;
  border-color: #f5c84c;
  color: #7a4b00;
}
.word-cell.found {
  background: linear-gradient(135deg, #48c579, #33a862);
  border-color: #2d9b58;
  color: #fff;
  box-shadow: 0 9px 18px rgba(45, 157, 88, 0.18);
}
.word-cell.answer:not(.found) {
  background: #fff4c7;
  border-color: #f5c84c;
  color: #7a4b00;
  box-shadow: inset 0 0 0 2px rgba(245, 200, 76, 0.35);
}
.word-search-sidebar {
  padding: 16px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(248,251,255,0.92));
}
.word-search-sidebar h2 {
  margin: 0 0 14px;
  font-size: 1.12rem;
  letter-spacing: -0.03em;
}
.word-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 8px;
}
.word-list li {
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  color: #435067;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}
.word-list li.found {
  color: #16834e;
  background: #e9f9ef;
  border-color: #a7ebc2;
  text-decoration: line-through;
}
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.action-row button { flex: 1; min-width: 120px; }
.result-message {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 0.92rem;
  display: none;
}
.result-message.show { display: block; }
.result-message.info { background: #edf5ff; color: #2556a3; }
.result-message.success { background: #edf9ef; color: #1f6b2a; }
.result-message.error { background: #fff3f3; color: #9a2f2f; }

/* Share controls */
.share-wrap {
  margin: 30px auto 48px;
  text-align: center;
  width: min(1120px, calc(100% - 44px));
}
.share-panel-icons {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.share-icon-btn,
.share-panel-icons button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  text-decoration: none;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.share-feedback {
  margin-top: 12px;
  font-size: 14px;
  color: #5b6475;
  min-height: 20px;
}

/* Footer */
.site-footer {
  padding: 34px 0;
  background: rgba(255,255,255,0.58);
  border-top: 1px solid rgba(223, 231, 242, 0.9);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.site-footer h3 { margin: 0 0 6px; font-size: 1rem; font-weight: 900; }
.site-footer p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-nav a { color: #435067; font-weight: 800; font-size: 0.9rem; }
.footer-nav a:hover { color: var(--purple); }

@media (max-width: 1020px) {
  .word-play-grid,
  .word-search-layout {
    grid-template-columns: 1fr;
  }
  .word-control-card {
    position: static;
  }
  .word-search-sidebar {
    order: 2;
  }
}

@media (max-width: 820px) {
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .site-nav {
    position: absolute;
    top: calc(100% + 10px);
    left: 22px;
    right: 22px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    border-radius: 22px;
    background: rgba(255,255,255,0.97);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-soft);
  }
  .site-nav.open { display: flex; }
  .site-nav a { text-align: center; }
}

@media (max-width: 680px) {
  .container,
  .puzzle-subnav-card,
  .share-wrap {
    width: min(100% - 28px, 1120px);
  }
  .puzzle-header-inner { min-height: 76px; }
  .brand-badge { width: 40px; height: 40px; }
  .logo { font-size: 1.32rem; }
  .tagline { font-size: 0.58rem; }
  .word-hero { padding: 44px 0 22px; }
  .word-hero h1 { font-size: clamp(2.18rem, 13vw, 3.35rem); }
  .word-capture-card,
  .word-control-card { padding: 18px; }
  .grid-card { padding: 12px; border-radius: 22px; overflow-x: auto; }
  .word-search-grid {
    grid-template-columns: repeat(11, minmax(24px, 32px));
    gap: 5px;
    min-width: max-content;
  }
  .word-cell {
    min-height: 32px;
    border-radius: 9px;
    font-size: 0.84rem;
  }
  .action-row { flex-direction: column; }
  .action-row button { width: 100%; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
}

@media print {
  @page { size: letter portrait; margin: 0.5in; }
  body { background: #fff; color: #000; }
  .puzzle-site-header,
  .puzzle-subnav-card,
  .word-hero,
  .word-control-card,
  .share-wrap,
  .site-footer {
    display: none !important;
  }
  .word-play-section { padding: 0; border: 0; background: #fff; }
  .word-play-grid { display: block; }
  .word-capture-card {
    box-shadow: none;
    border: 0;
    padding: 0;
  }
}


/* Wider puzzle grid + narrower word list panel */
.word-search-layout {
  grid-template-columns: minmax(390px, 1fr) minmax(180px, 220px);
  gap: 14px;
}
.word-search-sidebar {
  padding: 16px;
}
.word-search-sidebar h2 {
  font-size: 1.12rem;
}
.word-list {
  gap: 7px;
}
.word-list li {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 0.86rem;
}
.word-search-sidebar .action-row {
  gap: 8px;
}
.word-search-sidebar .action-row button {
  min-width: 0;
  padding: 0 12px;
  font-size: 0.86rem;
}
@media (max-width: 1020px) {
  .word-search-layout {
    grid-template-columns: 1fr;
  }
}
