:root {
  --pink: #ff4fa3;
  --purple: #6d4cff;
  --sky: #39bdf8;
  --mint: #32d49f;
  --yellow: #ffd84d;
  --coral: #ff744f;
  --ink: #2d2464;
  --muted: #665f82;
  --paper: #fffaf3;
  --shadow: 0 18px 36px rgba(68, 48, 120, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.seo-content,
.ad-slot-game-end {
  width: min(860px, 100%);
  margin: 22px auto 0;
}

.seo-content {
  padding: 20px;
  border: 3px solid rgba(255, 255, 255, 0.82);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 14px 28px rgba(42, 28, 92, 0.1);
}

.seo-content h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.35rem;
}

.seo-content p {
  margin: 0 0 16px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.seo-content p:last-child {
  margin-bottom: 0;
}

.seo-content ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.related-card {
  display: grid;
  gap: 5px;
  min-height: 118px;
  padding: 14px;
  border: 3px solid #ffffff;
  border-radius: 18px;
  background: linear-gradient(145deg, #ffffff, #fff0bd);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 7px 0 rgba(88, 42, 112, 0.12);
}

.related-card span {
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1;
}

.related-card strong,
.related-card small {
  display: block;
}

.related-card small {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.25;
}

.seo-content a,
.legal-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.5rem;
  color: var(--purple);
  font-weight: 900;
  text-decoration: none;
}

.seo-content a:hover,
.legal-footer a:hover {
  text-decoration: underline;
}

.ad-slot-game-end {
  min-height: 90px;
  border: 3px dashed rgba(109, 76, 255, 0.26);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.42);
}

.ad-slot {
  display: none;
}

body.ads-enabled .ad-slot {
  display: block;
}

.legal-footer {
  width: min(860px, 100%);
  margin: 22px auto 0;
  padding: 18px;
  border: 3px solid rgba(255, 255, 255, 0.82);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  text-align: center;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(42, 28, 92, 0.1);
}

.legal-footer strong {
  color: var(--ink);
}

.legal-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 14px;
  margin-top: 10px;
}

* {
  box-sizing: border-box;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

html {
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Arial, system-ui, sans-serif;
  color: var(--ink);
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    radial-gradient(circle at 16% 18%, rgba(255, 216, 77, 0.48) 0 9%, transparent 10%),
    radial-gradient(circle at 84% 16%, rgba(57, 189, 248, 0.34) 0 10%, transparent 11%),
    linear-gradient(135deg, #fff1a8 0%, #ffd5e9 42%, #bfeeff 100%);
  background-size: 34px 34px, 34px 34px, 100% 100%, 100% 100%, 100% 100%;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.app-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(14px, 3vw, 34px);
}

.start-screen,
.game-screen {
  width: 100%;
  border: 6px solid rgba(255, 255, 255, 0.9);
  border-radius: 30px;
  background: rgba(255, 250, 243, 0.92);
  box-shadow: var(--shadow);
}

.start-screen {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(22px, 5vw, 44px);
  text-align: center;
}

.game-screen {
  padding: clamp(16px, 3vw, 30px);
}

.magic-mark {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  margin: 0 auto 14px;
  border: 6px solid #ffffff;
  border-radius: 50%;
  background: conic-gradient(var(--pink), var(--yellow), var(--mint), var(--sky), var(--purple), var(--pink));
  color: #ffffff;
  font-size: 3rem;
  font-weight: 900;
  box-shadow: 0 12px 0 rgba(72, 45, 130, 0.16);
  animation: floatMark 3s ease-in-out infinite;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 8px;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--yellow);
  color: #704400;
  font-weight: 900;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 860px;
  margin: 0 auto 10px;
  color: transparent;
  background: linear-gradient(135deg, var(--ink), var(--purple) 38%, var(--pink) 72%, #f59e0b);
  -webkit-background-clip: text;
  background-clip: text;
  font-size: clamp(2.2rem, 7vw, 4.7rem);
  line-height: 0.98;
  overflow-wrap: anywhere;
  word-break: break-word;
}

h1 span {
  display: inline;
}

.subtitle {
  max-width: 760px;
  margin: 0 auto 10px;
  color: #3f3a68;
  font-size: clamp(1.1rem, 3vw, 1.45rem);
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.intro {
  max-width: 720px;
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: clamp(1rem, 2.5vw, 1.18rem);
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.player-field {
  display: grid;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto 16px;
  text-align: left;
}

.player-field span,
.difficulty-grid legend {
  color: var(--ink);
  font-weight: 900;
}

.player-field input {
  min-height: 56px;
  padding: 12px 16px;
  border: 3px solid #ffffff;
  border-radius: 18px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
  outline: none;
  box-shadow: 0 8px 18px rgba(68, 48, 120, 0.1);
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.difficulty-grid legend {
  grid-column: 1 / -1;
  text-align: left;
}

.difficulty-grid label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  min-height: 120px;
  align-items: center;
  padding: 14px;
  border: 3px solid #ffffff;
  border-radius: 20px;
  background: linear-gradient(145deg, #ffffff, #fff0bd);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(88, 42, 112, 0.13);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.difficulty-grid label:hover {
  transform: translateY(-2px);
}

.difficulty-grid label:has(input:checked) {
  border-color: var(--pink);
  box-shadow:
    0 8px 0 rgba(88, 42, 112, 0.13),
    0 0 0 5px rgba(255, 79, 163, 0.14);
}

.difficulty-grid input {
  width: 18px;
  height: 18px;
  accent-color: var(--pink);
}

.difficulty-grid strong,
.difficulty-grid small {
  display: block;
}

.difficulty-grid small {
  margin-top: 5px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.25;
}

.start-actions,
.header-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.primary-button,
.secondary-button,
.menu-button,
.subscribe-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  text-align: center;
  text-decoration: none;
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--mint), var(--sky), var(--purple));
  box-shadow: 0 8px 0 rgba(62, 67, 153, 0.28);
}

.secondary-button {
  background: linear-gradient(135deg, var(--coral), var(--pink));
  box-shadow: 0 8px 0 rgba(177, 49, 108, 0.25);
}

.menu-button {
  background: linear-gradient(135deg, var(--mint), var(--sky));
  box-shadow: 0 8px 0 rgba(39, 135, 217, 0.28);
}

.subscribe-button {
  position: relative;
  isolation: isolate;
  background: linear-gradient(135deg, #ff001f 0%, var(--pink) 48%, var(--purple) 100%);
  border: 4px solid #ffffff;
  overflow: hidden;
  box-shadow:
    0 9px 0 #b6004b,
    0 14px 28px rgba(255, 0, 80, 0.3);
}

.primary-button:hover,
.secondary-button:hover,
.menu-button:hover,
.subscribe-button:hover {
  transform: translateY(-3px);
  filter: saturate(1.08);
}

.compact {
  min-height: 46px;
  padding: 10px 14px;
  font-size: 0.95rem;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.game-header h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
}

.status-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.status-panel div {
  min-height: 76px;
  padding: 11px 12px;
  border: 3px solid #ffffff;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #fff0c2);
  text-align: center;
}

.status-panel span {
  display: block;
  margin-bottom: 5px;
  color: #766c8f;
  font-size: 0.88rem;
  font-weight: 900;
}

.status-panel strong {
  display: block;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
}

.message {
  min-height: 48px;
  margin: 0 auto 16px;
  padding: 12px 16px;
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 18px;
  background: #ffffff;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(68, 48, 120, 0.08);
}

.message.success {
  background: #e7fff5;
}

.message.warning {
  background: #fff0e8;
}

.play-area {
  display: grid;
  grid-template-columns: minmax(0, 590px) minmax(240px, 1fr);
  align-items: start;
  justify-content: center;
  gap: clamp(14px, 3vw, 24px);
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  width: min(100%, 590px);
  border: 4px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  background: var(--ink);
  box-shadow: var(--shadow);
}

.cell {
  display: grid;
  aspect-ratio: 1 / 1;
  place-items: center;
  border: 1px solid rgba(45, 36, 100, 0.28);
  background: #fffdf3;
  color: var(--ink);
  font-size: clamp(1.05rem, 3.4vw, 2rem);
  font-weight: 900;
}

.cell:nth-child(3n) {
  border-right-width: 3px;
}

.cell:nth-child(9n) {
  border-right-width: 1px;
}

.cell:nth-child(n + 19):nth-child(-n + 27),
.cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom-width: 3px;
}

.cell.fixed {
  background: linear-gradient(145deg, #fff3c4, #ffffff);
  color: #5b3b00;
}

.cell.selected {
  background: #dff6ff;
  box-shadow: inset 0 0 0 3px var(--sky);
}

.cell.related {
  background: #f1ecff;
}

.cell.same-number {
  background: #e7fff5;
}

.cell.error {
  background: #ffe5df;
  color: #b42318;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.number-button {
  min-height: 64px;
  border: 4px solid #ffffff;
  border-radius: 18px;
  background: linear-gradient(145deg, #ffffff, #fff0bd);
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 900;
  box-shadow: 0 7px 0 rgba(88, 42, 112, 0.16);
}

.number-button:hover {
  transform: translateY(-2px);
}

.game-actions {
  display: grid;
  gap: 10px;
}

.sudoku-actions {
  display: grid;
  gap: 10px;
}

.sudoku-actions-primary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sudoku-actions-secondary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(33, 27, 56, 0.66);
}

.modal-card {
  width: min(620px, 100%);
  max-height: min(88vh, 780px);
  overflow-y: auto;
  padding: clamp(22px, 5vw, 34px);
  border: 6px solid #ffffff;
  border-radius: 28px;
  background: linear-gradient(145deg, #ffffff, #fff1ce);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  animation: modalIn 240ms ease-out;
}

.modal-card h2 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 6vw, 3rem);
  line-height: 1.05;
}

.record-message {
  color: var(--muted);
  font-weight: 900;
}

.record-message.is-record {
  color: #8a5b00;
  text-shadow: 0 0 16px rgba(255, 216, 77, 0.6);
}

.podium-card {
  width: min(920px, 100%);
}

.podium-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
  text-align: left;
}

.podium-section {
  padding: 14px;
  border: 3px solid #ffffff;
  border-radius: 18px;
  background: #ffffff;
}

.podium-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style-position: inside;
}

.podium-list li {
  padding: 9px;
  border-radius: 12px;
  background: #fff6d8;
  font-weight: 900;
}

.podium-list span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
}

.podium-medal {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  margin-right: 6px;
  border-radius: 50%;
  background: #ffffff;
}

.empty-podium {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 5px solid rgba(255, 79, 163, 0.35);
  outline-offset: 3px;
}

@keyframes floatMark {
  50% {
    transform: translateY(-6px);
  }
}

@keyframes modalIn {
  from {
    transform: translateY(16px) scale(0.96);
    opacity: 0;
  }

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

@media (max-width: 920px) {
  .game-header {
    align-items: stretch;
    flex-direction: column;
    text-align: center;
  }

  .status-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .play-area {
    grid-template-columns: 1fr;
  }

  .sudoku-board {
    margin: 0 auto;
  }

  .side-panel {
    width: min(100%, 590px);
    max-width: 590px;
    margin: 0 auto;
  }

  .game-actions .secondary-button {
    min-height: 48px;
    padding: 10px 12px;
    line-height: 1.1;
  }

  .sudoku-actions-primary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sudoku-actions-secondary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .podium-grid,
  .difficulty-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    padding: 6px;
  }

  .start-screen,
  .game-screen {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 8px;
    border-width: 3px;
    border-radius: 22px;
  }

  .start-screen > *,
  .game-screen > *,
  .difficulty-grid,
  .start-actions,
  .header-actions,
  .play-area,
  .side-panel {
    min-width: 0;
    max-width: 100%;
  }

  h1 {
    max-width: 250px;
    margin-right: auto;
    margin-left: auto;
    font-size: clamp(1.04rem, 4.9vw, 1.22rem);
    line-height: 1.12;
    word-break: normal;
  }

  h1 span {
    display: block;
    font-size: 0.72em;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .subtitle,
  .intro {
    max-width: 250px;
    font-size: 0.92rem;
    word-break: break-word;
  }

  .start-actions,
  .header-actions,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .menu-button,
  .subscribe-button,
  .compact {
    width: 100%;
    max-width: 100%;
  }

  .status-panel {
    grid-template-columns: 1fr;
  }

  .sudoku-board {
    width: min(100%, calc(100vw - 20px));
    border-width: 3px;
    border-radius: 12px;
  }

  .cell {
    font-size: clamp(1rem, 6vw, 1.55rem);
  }

  .number-pad {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 5px;
  }

  .number-button {
    min-height: 44px;
    border-width: 2px;
    border-radius: 12px;
    font-size: 1rem;
  }

  .game-actions .secondary-button {
    width: 100%;
    font-size: 0.88rem;
  }
}

@media (max-width: 380px) {
  .sudoku-actions-primary,
  .sudoku-actions-secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
