:root {
  --bg-top: #efe1c9;
  --bg-bottom: #d6e3f0;
  --surface: rgba(251, 247, 240, 0.86);
  --surface-strong: #fffdf7;
  --ink: #1f2a37;
  --muted: #5c6877;
  --line: rgba(31, 42, 55, 0.12);
  --line-strong: rgba(31, 42, 55, 0.22);
  --brand: #0d6e6e;
  --brand-strong: #084f4f;
  --brand-soft: rgba(13, 110, 110, 0.14);
  --warning: #b45309;
  --error: #b42318;
  --success: #157347;
  --shadow: 0 22px 60px rgba(31, 42, 55, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.65), transparent 38%),
    radial-gradient(circle at bottom right, rgba(13, 110, 110, 0.18), transparent 28%),
    linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='280' height='220' viewBox='0 0 280 220'%3E%3Cg fill='none' stroke='rgba(31,42,55,0.055)' stroke-width='0' font-family='Trebuchet MS, Segoe UI, sans-serif' font-size='15'%3E%3Ctext x='26' y='44' fill='rgba(31,42,55,0.05)'%3E3 + 4 = 7%3C/text%3E%3Ctext x='154' y='86' fill='rgba(31,42,55,0.04)'%3E8 - 5 = 3%3C/text%3E%3Ctext x='34' y='146' fill='rgba(31,42,55,0.045)'%3E6 %C3%97 2 = 12%3C/text%3E%3Ctext x='146' y='186' fill='rgba(31,42,55,0.05)'%3E9 %C3%B7 3 = 3%3C/text%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 280px 220px;
}

button {
  font: inherit;
}

.page-shell {
  position: relative;
  z-index: 1;
  padding: 32px 18px 40px;
}

.page-topbar {
  max-width: 1180px;
  margin: 0 auto 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.site-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(13, 110, 110, 0.96), rgba(8, 79, 79, 0.88)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent);
  color: #fff;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 12px 26px rgba(13, 110, 110, 0.24);
}

.site-logo-copy {
  display: grid;
  gap: 2px;
}

.site-logo-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  line-height: 0.92;
  letter-spacing: -0.03em;
}

.site-logo-subtitle {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.size-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.size-tab {
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(31, 42, 55, 0.12);
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  font-weight: 700;
}

.size-tab--aux {
  background: rgba(13, 110, 110, 0.08);
  border-color: rgba(13, 110, 110, 0.18);
  color: var(--brand-strong);
}

.size-tab.is-current {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(13, 110, 110, 0.24);
}

.hero-card {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 700px);
  gap: 28px;
  align-items: start;
}

.hero-copy {
  padding: 12px 8px;
}

.hero-meta-strip {
  margin-top: 22px;
}

.hero-copy .meta-card {
  background: rgba(255, 255, 255, 0.62);
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.74rem;
  color: var(--brand-strong);
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.5rem, 5vw, 4.8rem);
  line-height: 0.94;
  max-width: 9ch;
}

.subtitle {
  max-width: 34ch;
  margin: 18px 0 0;
  line-height: 1.6;
  color: var(--muted);
  font-size: 1.05rem;
}

.game-panel {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 28px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.seo-stack {
  max-width: 1180px;
  margin: 26px auto 0;
  display: grid;
  gap: 18px;
}

.puzzle-link-stack {
  margin-top: 18px;
}

.puzzle-links h2 {
  font-size: clamp(1.35rem, 1.9vw, 1.8rem);
}

.puzzle-links .seo-link-card strong {
  font-size: 1rem;
}

.site-footer {
  max-width: 1180px;
  margin: 22px auto 0;
  padding: 0 2px 8px;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: center;
  align-items: center;
}

.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.site-footer__nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  border-bottom: 1px solid transparent;
  transition:
    border-color 160ms ease,
    color 160ms ease;
}

.site-footer__nav a:hover,
.site-footer__nav a:focus-visible {
  color: var(--ink);
  border-bottom-color: currentColor;
  outline: none;
}

.site-footer__credit {
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--muted);
  opacity: 0.82;
  text-align: center;
}

.site-footer__credit a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition:
    border-color 160ms ease,
    opacity 160ms ease,
    color 160ms ease;
}

.site-footer__credit a:hover,
.site-footer__credit a:focus-visible {
  border-bottom-color: currentColor;
  opacity: 1;
  color: var(--ink);
  outline: none;
}

.seo-card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 24px;
  padding: 24px 24px 22px;
  box-shadow: var(--shadow);
}

.seo-card h2 {
  margin-bottom: 14px;
  font-size: clamp(1.6rem, 2.2vw, 2.2rem);
  line-height: 1.02;
}

.seo-card h3 {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.seo-card p {
  margin: 0 0 12px;
  max-width: 75ch;
  color: var(--muted);
  line-height: 1.72;
}

.seo-card p:last-child,
.seo-card ul:last-child,
.seo-card div:last-child {
  margin-bottom: 0;
}

.seo-list {
  margin: 0 0 14px;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.7;
}

.seo-list li + li {
  margin-top: 8px;
}

.seo-link-grid,
.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.seo-link-grid {
  margin: 14px 0;
}

.seo-link-card,
.faq-item {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  padding: 16px 16px 14px;
}

.seo-link-card {
  display: grid;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.seo-link-card:hover {
  transform: translateY(-1px);
  border-color: rgba(13, 110, 110, 0.24);
  box-shadow: 0 12px 24px rgba(13, 110, 110, 0.08);
}

.seo-link-card strong {
  font-size: 1.06rem;
}

.seo-link-card span,
.faq-item p {
  color: var(--muted);
  line-height: 1.6;
}

.faq-grid {
  margin-top: 10px;
}

.article-page .page-shell {
  padding-bottom: 28px;
}

.article-shell,
.article-hero {
  max-width: 1040px;
  margin: 0 auto;
}

.article-hero {
  padding: 10px 6px 0;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.breadcrumbs a {
  color: var(--brand-strong);
  text-decoration: none;
  border-bottom: 1px solid rgba(13, 110, 110, 0.22);
  transition:
    border-color 160ms ease,
    color 160ms ease;
}

.breadcrumbs a:hover,
.breadcrumbs a:focus-visible {
  color: var(--brand);
  border-bottom-color: currentColor;
  outline: none;
}

.breadcrumbs span[aria-current="page"] {
  color: var(--ink);
}

.article-hero h1 {
  max-width: 13ch;
  font-size: clamp(3.4rem, 7vw, 5.8rem);
}

.article-hero .subtitle {
  max-width: 42ch;
}

.article-context-links {
  max-width: 46ch;
  margin: 14px 0 0;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--muted);
}

.article-context-links a {
  color: var(--brand-strong);
  text-decoration: none;
  border-bottom: 1px solid rgba(13, 110, 110, 0.22);
  transition:
    border-color 160ms ease,
    color 160ms ease;
}

.article-context-links a:hover,
.article-context-links a:focus-visible {
  color: var(--brand);
  border-bottom-color: currentColor;
  outline: none;
}

.article-body {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.article-body .seo-card p {
  max-width: 84ch;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.article-card {
  min-height: 156px;
}

.article-related {
  margin-top: 4px;
}

.article-cta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.article-cta-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 20px;
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.article-cta-card:hover,
.article-cta-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(13, 110, 110, 0.24);
  box-shadow: 0 14px 28px rgba(13, 110, 110, 0.1);
  outline: none;
}

.article-cta-card strong {
  font-size: 1.05rem;
}

.article-cta-card span {
  color: var(--muted);
  line-height: 1.6;
}

.size-tab:hover,
.site-logo:hover {
  transform: translateY(-1px);
}

.site-logo:hover .site-logo-mark {
  box-shadow: 0 16px 30px rgba(13, 110, 110, 0.3);
}

.panel-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.difficulty-switch {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.difficulty-switch button,
.controls button,
.ghost-button,
.completion-actions button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.difficulty-switch button {
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  min-width: 92px;
}

.difficulty-switch button[aria-pressed="true"] {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(13, 110, 110, 0.24);
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-top .meta-strip {
  margin-left: auto;
  justify-content: flex-end;
}

.meta-card {
  min-width: 132px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.74);
  border-radius: 18px;
  border: 1px solid var(--line);
}

.meta-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.board-frame {
  margin-top: 22px;
  padding: clamp(12px, 3vw, 24px);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.8), rgba(255, 251, 243, 0.62)),
    repeating-linear-gradient(
      135deg,
      rgba(13, 110, 110, 0.035) 0 18px,
      rgba(13, 110, 110, 0.06) 18px 36px
    );
  border: 1px solid var(--line);
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  grid-template-rows: repeat(11, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.board:empty::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(255, 251, 243, 0.68)),
    repeating-linear-gradient(
      90deg,
      rgba(13, 110, 110, 0.05) 0 calc((100% - 60px) / 11),
      rgba(255, 255, 255, 0.22) calc((100% - 60px) / 11) calc((100% - 60px) / 11 + 4px)
    );
  opacity: 0.5;
}

.board-cell {
  aspect-ratio: 1 / 1;
  min-height: 34px;
  border-radius: 14px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  font-weight: 800;
  user-select: none;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.board-cell[data-type="inactive"] {
  pointer-events: none;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(214, 227, 240, 0.04));
  color: transparent;
  border-color: transparent;
  opacity: 0.18;
}

.board-cell[data-type="operator"],
.board-cell[data-type="equals"],
.board-cell[data-type="number"] {
  pointer-events: none;
  background: rgba(13, 110, 110, 0.12);
  border-color: rgba(13, 110, 110, 0.18);
  color: var(--brand-strong);
}

.board-cell[data-type="number"] {
  background:
    linear-gradient(145deg, rgba(13, 110, 110, 0.24), rgba(13, 110, 110, 0.16));
  border-color: rgba(13, 110, 110, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.board-cell[data-type="empty"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 251, 244, 0.96));
  border-color: rgba(31, 42, 55, 0.18);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.board-cell[data-type="empty"]:hover {
  transform: translateY(-1px);
  background: #ffffff;
  border-color: rgba(13, 110, 110, 0.22);
  box-shadow: 0 10px 24px rgba(13, 110, 110, 0.08);
}

.controls button:hover,
.ghost-button:hover,
.completion-actions button:hover,
.difficulty-switch button:hover {
  transform: translateY(-1px);
}

.board-cell.is-selected {
  border-color: var(--brand);
  outline: 3px solid rgba(13, 110, 110, 0.22);
  outline-offset: 1px;
  box-shadow:
    0 0 0 1px rgba(13, 110, 110, 0.24),
    0 0 24px rgba(13, 110, 110, 0.18);
}

.board-cell.is-filled {
  background:
    linear-gradient(145deg, rgba(13, 110, 110, 0.16), rgba(13, 110, 110, 0.1));
}

.board-cell.is-placeholder {
  color: rgba(31, 42, 55, 0.34);
  font-weight: 700;
}

.board-cell.is-value-match {
  box-shadow: inset 0 0 0 2px rgba(13, 110, 110, 0.18);
}

.board-cell.is-hinted {
  background: rgba(180, 83, 9, 0.14);
  border-color: rgba(180, 83, 9, 0.24);
}

.board-cell.is-error {
  background: rgba(180, 35, 24, 0.12);
  border-color: rgba(180, 35, 24, 0.24);
  color: var(--error);
}

.board-cell.is-solved {
  background: rgba(21, 115, 71, 0.14);
  border-color: rgba(21, 115, 71, 0.24);
  color: var(--success);
}

.board-cell.is-placed {
  animation: cell-place 180ms ease-out;
}

.board-cell.is-shaking {
  animation: cell-shake 280ms ease-in-out;
}

.status-line {
  min-height: 1.5em;
  margin: 14px 2px 0;
  font-size: 0.98rem;
  color: var(--muted);
}

.status-line[data-tone="error"] {
  color: var(--error);
}

.status-line[data-tone="success"] {
  color: var(--success);
}

.status-line[data-tone="warning"] {
  color: var(--warning);
}

.tray-panel {
  margin-top: 16px;
}

.tray-heading-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.tray-heading-row h2 {
  font-size: 1.3rem;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  border: 1px solid var(--line);
}

.tray {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  gap: 12px;
  margin-top: 14px;
  min-height: 92px;
}

.tray-button {
  position: relative;
  min-height: 68px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease,
    opacity 160ms ease;
}

.tray-button:hover {
  transform: translateY(-1px);
  border-color: rgba(13, 110, 110, 0.22);
  box-shadow: 0 10px 24px rgba(13, 110, 110, 0.08);
}

.tray-button.is-selected {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  box-shadow: 0 12px 26px rgba(13, 110, 110, 0.24);
}

.tray-button.is-value-match {
  box-shadow: 0 0 0 2px rgba(13, 110, 110, 0.12);
}

.tray-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.tray-count {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 0.74rem;
  font-weight: 700;
  opacity: 0.82;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.controls button,
.completion-actions button {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
}

.controls .accent-button,
.completion-actions .accent-button {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.completion-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(14px);
  z-index: 40;
  animation: completion-overlay-in 180ms ease-out;
}

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

.completion-dialog {
  width: min(100%, 380px);
  padding: 28px;
  border-radius: 28px;
  background: #fffdf8;
  border: 1px solid rgba(31, 42, 55, 0.08);
  box-shadow: 0 20px 48px rgba(31, 42, 55, 0.18);
  animation: completion-dialog-in 220ms ease-out;
  overflow: hidden;
  position: relative;
}

.completion-dialog::after {
  content: "";
  position: absolute;
  inset: -30% auto auto -10%;
  width: 140px;
  height: 140px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(13, 110, 110, 0.16), transparent 70%);
  pointer-events: none;
}

.completion-summary {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.completion-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.print-page {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.52), transparent 34%),
    linear-gradient(180deg, #f4efe5, #e5edf5);
}

.print-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 18px 40px;
}

.print-card {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(31, 42, 55, 0.08);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.print-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.print-header p {
  margin: 10px 0 0;
  color: var(--muted);
}

.print-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.print-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 24px;
  margin-top: 24px;
  align-items: start;
}

.print-board .board-cell {
  border-radius: 10px;
  min-height: 38px;
}

.print-board .board-cell[data-type="empty-print"] {
  background: #ffffff;
  border-color: rgba(31, 42, 55, 0.22);
  box-shadow: none;
}

.print-side {
  display: grid;
  gap: 12px;
}

.print-side h2 {
  font-size: 1.2rem;
}

.print-link {
  color: var(--brand-strong);
  word-break: break-word;
}

.print-qr {
  width: 180px;
  height: 180px;
  padding: 10px;
  background: white;
  border-radius: 18px;
  border: 1px solid rgba(31, 42, 55, 0.1);
  box-shadow: 0 12px 24px rgba(31, 42, 55, 0.1);
}

@page {
  size: A4 portrait;
  margin: 10mm;
}

@keyframes completion-dialog-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes completion-overlay-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes cell-place {
  0% {
    transform: scale(0.9);
  }

  60% {
    transform: scale(1.07);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes cell-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-4px);
  }

  40% {
    transform: translateX(4px);
  }

  60% {
    transform: translateX(-3px);
  }

  80% {
    transform: translateX(3px);
  }
}

@media (max-width: 980px) {
  .hero-card {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: none;
  }

  .print-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding-top: 12px;
    padding-inline: 10px;
    padding-bottom: calc(132px + env(safe-area-inset-bottom));
  }

  .page-topbar {
    position: sticky;
    top: 0;
    z-index: 18;
    gap: 10px;
    margin-bottom: 10px;
    padding: 8px 0 10px;
    background: linear-gradient(180deg, rgba(239, 225, 201, 0.94), rgba(239, 225, 201, 0.66));
    backdrop-filter: blur(14px);
  }

  .site-logo {
    gap: 10px;
  }

  .site-logo-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 0.84rem;
  }

  .site-logo-title {
    font-size: 1.34rem;
  }

  .site-logo-subtitle {
    display: none;
  }

  .size-tabs {
    width: 100%;
    gap: 8px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .size-tab {
    padding: 10px 8px;
    text-align: center;
    font-size: 0.92rem;
  }

  .game-panel {
    padding: 14px 14px 12px;
    border-radius: 22px;
  }

  .difficulty-switch {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 4px;
  }

  .hero-card {
    gap: 10px;
  }

  .hero-copy {
    padding: 2px 2px 0;
  }

  .seo-stack {
    margin-top: 14px;
    gap: 12px;
  }

  .seo-card {
    padding: 18px 16px 16px;
    border-radius: 20px;
  }

  .seo-card h2 {
    font-size: 1.45rem;
  }

  .seo-link-grid,
  .faq-grid {
    grid-template-columns: 1fr;
  }

  .article-grid,
  .article-cta-grid {
    grid-template-columns: 1fr;
  }

  .site-footer {
    margin-top: 16px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .site-footer__credit {
    font-size: 0.84rem;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: clamp(1.9rem, 10vw, 2.5rem);
    line-height: 0.98;
  }

  .subtitle {
    max-width: none;
    margin-top: 6px;
    font-size: 0.9rem;
    line-height: 1.35;
  }

  .difficulty-switch button {
    min-width: 0;
    min-height: 52px;
    padding: 10px 8px;
    font-size: 0.95rem;
  }

  .panel-top {
    gap: 10px;
  }

  .meta-strip {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .meta-card {
    min-width: 0;
    padding: 10px 10px 9px;
    border-radius: 16px;
  }

  .meta-card strong {
    display: block;
    font-size: 0.95rem;
  }

  .meta-label {
    margin-bottom: 4px;
    font-size: 0.66rem;
  }

  .controls,
  .completion-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .tray {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
  }

  .tray-panel {
    position: sticky;
    bottom: 0;
    z-index: 12;
    margin-top: 10px;
    margin-inline: -14px;
    margin-bottom: calc(-12px - env(safe-area-inset-bottom));
    padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
    background:
      linear-gradient(180deg, rgba(239, 225, 201, 0.02), rgba(255, 253, 248, 0.98) 20%),
      rgba(255, 253, 248, 0.98);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(31, 42, 55, 0.1);
    box-shadow: 0 -18px 36px rgba(31, 42, 55, 0.12);
  }

  .board-cell {
    min-height: 32px;
    border-radius: 11px;
    font-size: clamp(0.82rem, 2.6vw, 1rem);
  }

  .tray-button,
  .controls button,
  .difficulty-switch button,
  .ghost-button,
  .completion-actions button {
    min-height: 58px;
  }

  .board-frame {
    margin-top: 12px;
    padding: 8px;
    border-radius: 18px;
  }

  .board {
    gap: 4px;
  }

  .status-line {
    min-height: 1.3em;
    margin-top: 8px;
    font-size: 0.92rem;
  }

  .tray-heading-row {
    gap: 10px;
  }

  .tray-heading-row h2 {
    font-size: 1.05rem;
  }

  .ghost-button {
    padding-inline: 12px;
    font-size: 0.92rem;
  }

  .tray-button {
    min-height: 64px;
    border-radius: 16px;
    font-size: 1.08rem;
  }

  .tray-count {
    top: 6px;
    right: 8px;
    font-size: 0.68rem;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
  }

  .controls .accent-button {
    grid-column: 1 / -1;
    min-height: 62px;
    font-size: 1rem;
    box-shadow: 0 14px 28px rgba(13, 110, 110, 0.22);
  }

  #check-button {
    background: rgba(13, 110, 110, 0.12);
    border-color: rgba(13, 110, 110, 0.2);
    color: var(--brand-strong);
  }

  .board-cell[data-type="inactive"] {
    opacity: 0.12;
  }

  .board-cell[data-type="operator"],
  .board-cell[data-type="equals"] {
    background: rgba(13, 110, 110, 0.16);
  }

  .board-cell[data-type="number"] {
    background:
      linear-gradient(145deg, rgba(13, 110, 110, 0.28), rgba(13, 110, 110, 0.2));
  }

  .board-cell[data-type="empty"] {
    border-color: rgba(31, 42, 55, 0.14);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.92),
      0 3px 8px rgba(31, 42, 55, 0.04);
  }

  .completion-dialog {
    width: min(100%, 360px);
    padding: 24px 20px calc(22px + env(safe-area-inset-bottom));
    border-radius: 24px;
    box-shadow: 0 24px 54px rgba(31, 42, 55, 0.24);
  }

  .completion-overlay {
    padding: 16px;
    background: rgba(15, 23, 42, 0.44);
    backdrop-filter: blur(16px);
  }

  .completion-summary {
    line-height: 1.45;
  }

  .completion-actions {
    margin-top: 18px;
    gap: 10px;
  }
}

@media print {
  body::before {
    display: none;
  }

  html,
  body {
    background: white;
  }

  html,
  body,
  .print-page {
    width: 100%;
    min-height: auto;
  }

  .page-topbar,
  .difficulty-switch,
  .status-line,
  .tray-panel,
  .controls,
  .tool-actions,
  .seo-stack,
  .site-footer,
  .completion-overlay,
  .print-actions {
    display: none !important;
  }

  .page-shell,
  .print-shell {
    padding: 0;
  }

  .hero-card {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .hero-copy {
    padding: 0 0 12px;
  }

  .game-panel,
  .print-card {
    box-shadow: none;
    border: 0;
    background: white;
    padding: 0;
  }

  .print-shell {
    max-width: none;
  }

  .print-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4mm;
    margin-bottom: 6mm;
  }

  .print-page h1 {
    max-width: none;
    font-size: 27pt;
    line-height: 0.96;
  }

  .print-header .eyebrow {
    margin-bottom: 2mm;
    font-size: 8pt;
  }

  .print-header p {
    margin-top: 2mm;
    font-size: 10pt;
    line-height: 1.3;
  }

  .print-body {
    grid-template-columns: minmax(0, 1fr) 40mm;
    gap: 6mm;
    margin-top: 0;
    align-items: start;
  }

  .board-frame {
    padding: 0;
    border: 0;
    background: white;
    margin-top: 0;
  }

  .board,
  .print-board {
    gap: 2mm;
  }

  .print-board {
    width: 100%;
    max-width: 144mm;
  }

  .print-board .board-cell {
    min-height: 0;
    border-radius: 3mm;
    font-size: 12pt;
    box-shadow: none;
  }

  .print-side {
    gap: 4mm;
    align-content: start;
  }

  .print-side .eyebrow {
    margin-bottom: 1mm;
  }

  .print-side h2 {
    font-size: 15pt;
  }

  .print-link {
    font-size: 9pt;
    line-height: 1.25;
  }

  .print-qr {
    width: 36mm;
    height: 36mm;
    padding: 2mm;
    border-radius: 3mm;
    box-shadow: none;
  }
}
