:root {
  --ink: #172033;
  --muted: #5f6b7c;
  --line: #dfe7f2;
  --purple: #6757f5;
  --purple-dark: #4b3ee3;
  --blue: #4078ff;
  --green: #28a967;
  --red: #e65f64;
  --soft-blue: #deecff;
  --soft-yellow: #fff1cb;
  --soft-green: #e4f9ee;
  --soft-mint: #ddfbef;
  --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;
}

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

.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);
}

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

.crossmath-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);
}
.crossmath-play-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 22px;
  align-items: start;
}
.crossmath-control-card,
.math-puzzle-shell {
  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);
}
.crossmath-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-yellow), #fffaf0);
  font-size: 1.85rem;
  box-shadow: 0 9px 18px rgba(34, 50, 84, 0.08);
}
.crossmath-control-card h2 {
  margin: 16px 0 14px;
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: -0.04em;
}
.puzzle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: #475569;
  font-size: 0.92rem;
}
.meta-pill {
  padding: 9px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: #435067;
  font-weight: 900;
}
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.control-actions { margin-top: 16px; }
.primary-btn, .secondary-btn {
  min-height: 44px;
  border-radius: 999px;
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.primary-btn:hover, .secondary-btn:hover { transform: translateY(-2px); }
.primary-btn {
  color: #fff;
  border: 0;
  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);
}
.ghost-btn { color: #435067; }
.how-to-card {
  margin-top: 20px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--soft-blue), #f7fbff);
  border: 1px solid rgba(124, 165, 255, 0.35);
}
.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; }

.crossmath-game-wrap { position: relative; }
.math-puzzle-shell {
  padding: 24px;
  background: linear-gradient(135deg, rgba(222, 236, 255, 0.82), rgba(255, 255, 255, 0.94));
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.section-heading h3 {
  margin: 2px 0 0;
  font-size: 1.6rem;
  line-height: 1.05;
  letter-spacing: -0.045em;
}
.small-label {
  margin: 0;
  color: var(--purple);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.game-instructions {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.6;
}
.board-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 22px 0 24px;
  overflow-x: auto;
  padding: 8px 0;
}
.crossmath-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 5), var(--cell-size, 72px));
  grid-auto-rows: var(--cell-size, 72px);
  gap: 10px;
  margin: 0 auto;
}
.cell,
.bank-number {
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  box-sizing: border-box;
}
.cell {
  font-size: 1.38rem;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid rgba(173, 186, 207, 0.82);
  color: #1e293b;
  box-shadow: 0 8px 16px rgba(34, 50, 84, 0.05);
}
.cell.empty {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.cell.operator,
.cell.equals {
  background: #eef3ff;
  color: #435067;
  border-color: #d7e1f0;
  font-size: 1.78rem;
}
.cell.blank {
  background: #ffffff;
  border: 2px dashed #98a8bf;
  cursor: pointer;
}
.cell.blank:hover {
  background: #f8fbff;
  border-color: var(--purple);
}
.cell.blank.selected {
  outline: 4px solid rgba(103, 87, 245, 0.18);
  outline-offset: 0;
  background: #f4f1ff;
  border-color: var(--purple);
}
.cell.blank.filled {
  background: #fffdf7;
  border-style: solid;
  border-color: #ffce73;
}
.cell.blank.correct {
  background: #ecfdf5;
  border-style: solid;
  border-color: #34d399;
}
.cell.blank.wrong {
  background: #fff1f2;
  border-style: solid;
  border-color: #fb7185;
}
.bank-card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(223, 231, 242, 0.92);
  border-radius: 24px;
  padding: 18px;
  margin-top: 8px;
}
.bank-title {
  margin: 0 0 12px;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
}
.number-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.bank-number {
  min-width: 62px;
  min-height: 62px;
  font-size: 1.35rem;
  background: linear-gradient(135deg, #fff, #f0f5ff);
  border: 2px solid #d5e0f2;
  color: #3730a3;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.bank-number:hover { transform: translateY(-2px); }
.bank-number.selected {
  border-color: var(--purple);
  background: #eee8ff;
}
.bank-number.used {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}
.game-actions { margin-top: 18px; }
.result-message {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  display: none;
  font-weight: 800;
}
.result-message.show { display: block; }
.result-message.success { background: #edf9ef; color: #1f6b2a; }
.result-message.error { background: #fff3f3; color: #9a2f2f; }
.result-message.info { background: #f3f8ff; color: #2556a3; }

.share-wrap {
  width: min(1120px, calc(100% - 44px));
  margin: 28px auto 40px;
  text-align: center;
}
.share-panel-icons {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.share-icon-btn,
.share-panel-icons button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #435067;
  font-weight: 900;
  cursor: pointer;
}
.share-feedback { color: var(--muted); min-height: 20px; }

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

@media (max-width: 980px) {
  .crossmath-play-grid { grid-template-columns: 1fr; }
  .crossmath-control-card { position: static; }
  .control-actions .primary-btn,
  .control-actions .secondary-btn { flex: 1; }
}

@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: 700px) {
  .container,
  .puzzle-subnav-card,
  .share-wrap { width: min(100% - 28px, 1120px); }
  .puzzle-header-inner { min-height: 74px; }
  .brand-badge { width: 40px; height: 40px; }
  .logo { font-size: 1.32rem; }
  .tagline { font-size: 0.58rem; }
  .puzzle-subnav-card { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
  .puzzle-subnav-card a { white-space: nowrap; }
  .crossmath-hero { padding: 42px 0 22px; }
  .crossmath-hero h1 { font-size: clamp(2.2rem, 12vw, 3.4rem); }
  .crossmath-play-section { padding: 22px 0 42px; }
  .crossmath-control-card,
  .math-puzzle-shell { padding: 18px; border-radius: 24px; }
  .section-heading h3 { font-size: 1.35rem; }
  .crossmath-grid { --cell-size: 58px; gap: 8px; }
  .cell { font-size: 1.1rem; border-radius: 15px; }
  .cell.operator,
  .cell.equals { font-size: 1.45rem; }
  .bank-number { min-width: 54px; min-height: 54px; font-size: 1.15rem; border-radius: 15px; }
  .action-row { display: grid; grid-template-columns: 1fr; }
  .primary-btn,
  .secondary-btn { width: 100%; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 390px) {
  .crossmath-grid { --cell-size: 52px; gap: 7px; }
  .cell { font-size: 1rem; }
  .cell.operator,
  .cell.equals { font-size: 1.3rem; }
}

/* Crossmath generator updates */
.difficulty-control {
  margin-top: 16px;
  display: grid;
  gap: 8px;
  font-weight: 900;
  color: #435067;
}

.difficulty-control select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(103, 87, 245, 0.18);
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.bank-card-hidden {
  display: none;
}

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

.hint-pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(40, 169, 103, 0.1);
  color: #1f7a4d;
  border: 1px solid rgba(40, 169, 103, 0.18);
  font-size: 0.75rem;
  font-weight: 900;
}

.bank-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

input.cell.blank {
  width: 100%;
  min-width: 0;
  text-align: center;
  appearance: textfield;
}

input.cell.blank:focus {
  outline: 4px solid rgba(103, 87, 245, 0.18);
  border-color: var(--purple);
  background: #f4f1ff;
}

/* Clearer Crossmath cell states */
.cell.given-number {
  background: linear-gradient(135deg, #eef6ff, #ffffff);
  border-color: #cfe0f7;
  color: #172033;
}

.cell.fillable-number {
  background: #ffffff;
  border: 3px dashed #7b92b8;
  color: #172033;
}

.cell.fillable-number::placeholder {
  color: #9fb0c9;
  opacity: 1;
}

.cell.not-needed {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  pointer-events: none;
}


/* 7x7 puzzle support */
.crossmath-grid {
  --cell-size: 72px;
}

.cell.empty.not-needed {
  visibility: hidden;
}

@media (max-width: 860px) {
  .crossmath-grid { --cell-size: 58px; }
}

@media (max-width: 520px) {
  .crossmath-grid { --cell-size: 48px; gap: 6px; }
  .cell { font-size: 0.95rem; border-radius: 13px; }
  .cell.operator,
  .cell.equals { font-size: 1.2rem; }
}
