: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 { font: inherit; }
.container { width: min(1120px, calc(100% - 44px)); margin: 0 auto; }
.hidden { display: none !important; }

/* Header: same feel as Puzzle Games page */
.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);
}

/* Page hero */
.cryptogram-hero {
  padding: 68px 0 28px;
  text-align: center;
}
.cryptogram-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;
}
.cryptogram-hero h1 {
  margin: 18px 0 12px;
  font-size: clamp(2.25rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: -0.07em;
}
.cryptogram-hero p:not(.eyebrow) {
  max-width: 690px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.05rem;
}

/* Main game layout */
.cryptogram-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);
}
.cryptogram-play-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 22px;
  align-items: start;
}
.cryptogram-control-card,
.cryptogram-card,
.empty-game-card {
  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);
}
.cryptogram-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-purple), #fbf9ff);
  font-size: 1.85rem;
  box-shadow: 0 9px 18px rgba(34, 50, 84, 0.08);
}
.mode-section h2 {
  margin: 16px 0 14px;
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: -0.04em;
}
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: #eef3ff;
  margin-bottom: 16px;
}
.mode-tab {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #536176;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 900;
}
.mode-tab.active {
  color: #fff;
  background: var(--purple);
  box-shadow: 0 10px 20px rgba(103, 87, 245, 0.22);
}
.mode-panel { display: none; }
.mode-panel.active { display: block; }
.mode-description { margin: 0 0 14px; color: var(--muted); font-size: 0.94rem; }
.custom-form { display: grid; gap: 10px; }
.phrase-input {
  width: 100%;
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0 15px;
  outline: none;
  background: #fff;
}
.phrase-input:focus, .cryptogram-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 rgba(103, 87, 245, 0.18);
}
.how-to-card {
  margin-top: 20px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--soft-yellow), #fffaf0);
  border: 1px solid rgba(255, 210, 119, 0.45);
}
.how-to-card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.how-to-card ul { margin: 0; padding-left: 18px; color: #5b6372; font-size: 0.92rem; }
.how-to-card li + li { margin-top: 5px; }

.cryptogram-game-wrap { position: relative; min-height: 430px; }
.empty-game-card {
  min-height: 430px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 28px;
  background: linear-gradient(135deg, var(--soft-blue), #f7fbff);
}
.empty-game-card span { font-size: 3rem; }
.empty-game-card h3 { margin: 10px 0 5px; font-size: 1.55rem; letter-spacing: -0.04em; }
.empty-game-card p { margin: 0; color: var(--muted); }
.share-capture-area:has(.cryptogram-card:not(.hidden)) + .empty-game-card { display: none; }

.cryptogram-card {
  padding: 26px;
  background: linear-gradient(135deg, #fff, #f7fbff);
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.small-label {
  margin: 0 0 5px;
  color: var(--purple);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.section-heading h3 {
  margin: 0;
  font-size: 1.65rem;
  line-height: 1;
  letter-spacing: -0.05em;
}
.legend-card {
  margin: 0 0 18px;
  padding: 13px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--soft-purple), #fbf9ff);
  border: 1px solid rgba(103, 87, 245, 0.12);
  color: #44506a;
  font-weight: 800;
}
.cryptogram-board {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px;
  margin-bottom: 20px;
  border-radius: 24px;
  background: linear-gradient(135deg, #f0f6ff, #fff7ea);
  border: 1px solid rgba(34, 50, 84, 0.08);
}
.cryptogram-cell {
  width: 58px;
  padding: 8px;
  display: grid;
  gap: 7px;
  justify-items: center;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(34, 50, 84, 0.07);
}
.cryptogram-cipher {
  color: #56637a;
  font-size: 0.9rem;
  font-weight: 900;
}
.cryptogram-input {
  width: 40px;
  height: 40px;
  border: 2px solid var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 900;
  text-transform: uppercase;
  outline: none;
}
.cryptogram-space { width: 22px; }
.cryptogram-board.solved .cryptogram-cell {
  background: #e4f9ee;
  border: 1px solid rgba(68, 180, 84, 0.25);
}
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.result-message {
  min-height: 28px;
  margin-top: 14px;
  text-align: center;
  color: var(--muted);
  font-weight: 900;
}
.result-message.success { color: #15945e; }
.result-message.error { color: #d9534f; }
.result-message.info { color: var(--purple-dark); }

/* Share + footer */
.share-wrap { max-width: 1120px; margin: 26px auto 34px; padding: 0 22px; text-align: center; }
.share-panel-icons { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.share-icon-btn, .share-panel-icons button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 0 14px;
  color: #435067;
  font-weight: 900;
  cursor: pointer;
}
.share-icon-btn:hover, .share-panel-icons button:hover { color: #fff; background: var(--purple); border-color: var(--purple); }
.share-feedback { min-height: 22px; margin-top: 10px; color: var(--muted); }
.puzzle-site-footer { padding: 32px 0; border-top: 1px solid var(--line); background: rgba(255, 255, 255, 0.62); }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.site-footer h3 { margin: 0; font-size: 1rem; font-weight: 900; }
.site-footer p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-nav a { color: #435067; font-size: 0.9rem; font-weight: 800; }
.footer-nav a:hover { color: var(--purple); }

@media (max-width: 980px) {
  .cryptogram-play-grid { grid-template-columns: 1fr; }
  .cryptogram-control-card { position: static; }
}
@media (max-width: 820px) {
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .site-nav {
    position: absolute;
    left: 22px;
    right: 22px;
    top: 76px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow);
  }
  .site-nav.open { display: flex; }
  .site-nav a { text-align: center; }
}
@media (max-width: 680px) {
  .container, .puzzle-subnav-card { width: min(100% - 28px, 1120px); }
  .puzzle-header-inner { min-height: 74px; }
  .brand-badge { width: 40px; height: 40px; }
  .logo { font-size: 1.28rem; }
  .tagline { font-size: 0.58rem; }
  .puzzle-subnav-card { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .puzzle-subnav-card a { width: 100%; text-align: center; }
  .cryptogram-hero { padding: 44px 0 24px; }
  .cryptogram-hero h1 { font-size: clamp(2.25rem, 13vw, 3.5rem); }
  .mode-tabs, .action-row { grid-template-columns: 1fr; display: grid; }
  .cryptogram-card, .cryptogram-control-card { padding: 20px; border-radius: 24px; }
  .cryptogram-board { gap: 8px; padding: 12px; justify-content: center; }
  .cryptogram-cell { width: 50px; }
  .cryptogram-input { width: 36px; height: 36px; }
  .section-heading { justify-content: center; text-align: center; }
  .section-heading .secondary-btn { width: 100%; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
}
