:root {
  --grid-size: 4;
  --grid-max-width: min(100vw - 40px, 960px);
  --divider-thickness: clamp(3px, 0.8vw, 4px);
  --arrow-size: var(--divider-thickness);
  --frame-thickness: clamp(4px, 0.9vw, 7px);
  --grid-padding: clamp(16px, 4vw, 28px);
  --cell-min-size: 48px;
  --cell-max-size: 180px;
  --page-side-padding: 20px;
  font-family: 'Roboto', sans-serif;
}

@media (min-width: 769px) {
  :root {
    --grid-max-width: min(100vw - 40px, 720px);
    --divider-thickness: clamp(2.25px, 0.6vw, 3px);
    --grid-padding: clamp(12px, 3vw, 21px);
    --cell-min-size: 36px;
    --cell-max-size: 135px;
  }

  .cell-value {
    font-size: clamp(2.1rem, 5.25vw, 3.75rem);
  }

  .arrow-symbol {
    font-size: clamp(15.75px, calc(var(--cell-size) * 0.525), 45px);
    width: clamp(27px, calc(var(--cell-size) * 0.675), 81px);
    height: clamp(27px, calc(var(--cell-size) * 0.675), 81px);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #111111;
  color: #1a1a1a;
  touch-action: manipulation;
}

.page {
  max-width: 960px;
  margin: 40px auto;
  padding: 0 var(--page-side-padding) 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.logo {
  display: flex;
  justify-content: center;
}

.logo img {
  width: min(343px, 68vw);
  height: auto;
}

.puzzle-selector {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: #111113;
  border: 1px solid #2a2a2d;
  width: 100%;
  color: #f3f3f5;
}

.puzzle-selector--daily {
  flex-direction: column;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
}

.daily-puzzle-banner {
  font-size: clamp(0.9rem, 2.4vw, 1.05rem);
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.06em;
  line-height: 1.25;
}

.puzzle-selector--daily .daily-puzzle-banner {
  min-width: 0;
}

.puzzle-message {
  padding: 32px 20px;
  text-align: center;
  font-size: 1.05rem;
  color: #f3f3f5;
  background: #111113;
  border: 1px solid #2a2a2d;
  border-radius: 12px;
  max-width: min(520px, 90%);
  margin: 0 auto;
}

.puzzle-set-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.puzzle-set-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: #a7a7ab;
}

.puzzle-set-select {
  padding: 10px 14px;
  border-radius: 0;
  border: 1px solid #333333;
  background: #151517;
  font-size: 0.95rem;
  color: #f3f3f5;
  min-width: 180px;
}

.puzzle-set-select:focus-visible {
  outline: 2px solid #b7b7bd;
  outline-offset: 2px;
}

.puzzle-nav-button {
  padding: 10px 18px;
  border-radius: 0;
  border: 1px solid #333333;
  background: #151517;
  color: #f3f3f5;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.puzzle-nav-button--next,
.puzzle-nav-button--previous {
  font-size: 0;
  line-height: 0;
  padding: clamp(8px, 1.5vw, 12px);
}

.puzzle-nav-icon {
  width: clamp(18px, 2.8vw, 28px);
  height: auto;
}

.puzzle-nav-icon--previous {
  transform: scaleX(-1);
  transform-origin: center;
}

.puzzle-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  color: #a7a7ab;
  border-color: #2a2a2d;
}

.puzzle-nav-button:focus-visible {
  outline: 2px solid #b7b7bd;
  outline-offset: 2px;
}

.puzzle-nav-button:not(:disabled):hover {
  background: #111113;
  border-color: #2a2a2d;
}

.puzzle-title {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-width: 140px;
  text-align: center;
  color: #a7a7ab;
}

.puzzle-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.how-to-play {
  width: 100%;
  background: #111113;
  border: 1px solid #2a2a2d;
  padding: clamp(28px, 6vw, 48px);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 3vw, 18px);
  color: #f3f3f5;
}

.how-to-play__intro {
  display: grid;
  gap: 12px;
  text-align: center;
}

.how-to-play__title {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #f5f5f7;
}

.how-to-play__intro p {
  margin: 0;
  color: #a7a7ab;
  line-height: 1.6;
}

.how-to-play__basics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: clamp(18px, 4vw, 28px);
}

.how-to-play__card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01));
  border: 1px solid #2a2a2d;
  padding: 22px;
  display: grid;
  gap: clamp(12px, 2.6vw, 18px);
}

.how-to-play__card-title {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ededf1;
}

.how-to-play__card p {
  margin: 0;
  color: #a7a7ab;
  line-height: 1.6;
}

.how-to-play__rules {
  display: grid;
  gap: clamp(24px, 5vw, 36px);
}

.how-to-play__divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0));
  border: none;
}

.rule-group {
  display: grid;
  gap: 16px;
}

.rule-group--hidden {
  display: none;
}

.how-to-play__section-title {
  margin: 0;
  font-size: clamp(1.3rem, 3.5vw, 1.8rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ededf1;
  text-align: center;
}

.rule-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: clamp(18px, 4vw, 28px);
}

.rule-card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01));
  border: 1px solid #2a2a2d;
  display: grid;
  gap: clamp(12px, 2.6vw, 18px);
  padding: 22px;
}

.rule-card__header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
}

.rule-card__symbol {
  color: #b7b7bd;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 50%;
  width: 64px;
  height: 64px;
}

.rule-card__title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ffffff;
}

.rule-card__content {
  display: grid;
  gap: 8px;
}

.rule-card__heading-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.rule-card__heading-row .rule-card__title {
  margin: 0;
}

.rule-card__demo-button {
  appearance: none;
  border: 1px solid #333333;
  background: #151517;
  color: #f3f3f5;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 0;
  padding: 6px 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.rule-card__demo-button:hover {
  background: #111113;
  border-color: #2a2a2d;
  color: #ffffff;
}

.rule-card__demo-button:focus-visible {
  outline: 2px solid #b7b7bd;
  outline-offset: 2px;
  background: #1c1c21;
  border-color: #b7b7bd;
  color: #ffffff;
}

.rule-card__demo-button:active {
  background: #0c0c0f;
  border-color: #2a2a2d;
}

.rule-card__description {
  margin: 0;
  color: #a7a7ab;
  line-height: 1.6;
}

.rule-card__example {
  display: grid;
  gap: 12px;
}

.example-grid {
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
  align-items: center;
  justify-content: start;
  font-size: 0.95rem;
}

.example-grid--notes {
  grid-template-columns: repeat(3, minmax(60px, 1fr));
  justify-items: center;
}

.example-grid--inline {
  grid-auto-columns: minmax(40px, auto);
}

.example-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 4px;
  background: #151517;
  border: 1px solid #333333;
  color: #f6f6f8;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.example-cell--candidates {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  min-width: 60px;
  min-height: 60px;
  font-size: 0.75rem;
}

.example-cell--candidates span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  padding: 2px 4px;
}

.example-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: #b7b7bd;
}

.example-symbol__svg {
  width: 100%;
  height: auto;
  display: block;
}

.example-cell[data-digit="1"],
.example-cell--candidates span[data-digit="1"] {
  color: #f1c43f;
}

.example-cell[data-digit="2"],
.example-cell--candidates span[data-digit="2"] {
  color: #37ae60;
}

.example-cell[data-digit="3"],
.example-cell--candidates span[data-digit="3"] {
  color: #4498db;
}

.example-cell[data-digit="4"],
.example-cell--candidates span[data-digit="4"] {
  color: #9b69b6;
}

.example-cell[data-digit="5"],
.example-cell--candidates span[data-digit="5"] {
  color: #e74c5c;
}

.example-cell[data-digit="6"],
.example-cell--candidates span[data-digit="6"] {
  color: #f39c12;
}

.example-cell[data-digit="7"],
.example-cell--candidates span[data-digit="7"] {
  color: #1abc9c;
}

.example-cell[data-digit="8"],
.example-cell--candidates span[data-digit="8"] {
  color: #ff7aa2;
}

.example-cell[data-digit="9"],
.example-cell--candidates span[data-digit="9"] {
  color: #5f66ff;
}

@media (max-width: 640px) {
  .example-grid {
    justify-content: center;
  }

  .rule-card__header {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .rule-card__symbol {
    margin: 0 auto;
  }
}

.puzzle-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  gap: 32px;
}

.puzzle-layout > * {
  flex-shrink: 0;
}

.grid-wrapper {
  --grid-available-width: min(
    var(--grid-max-width),
    calc(100vw - 2 * var(--page-side-padding))
  );
  --cell-size: clamp(
    var(--cell-min-size),
    calc(
      (
          var(--grid-available-width) -
          (var(--grid-size) - 1) * var(--arrow-size) -
          2 * var(--grid-padding)
        ) / var(--grid-size)
    ),
    var(--cell-max-size)
  );
  box-sizing: border-box;
  display: grid;
  position: relative;
  border: 1px solid #2a2a2d;
  overflow: hidden;
  background: #151517;
  padding: var(--grid-padding);
  justify-content: center;
  align-content: center;
  width: min(
    100%,
    calc(
      var(--grid-size) * var(--cell-size) +
      (var(--grid-size) - 1) * var(--arrow-size) +
      2 * var(--grid-padding)
    )
  );
  max-width: var(--grid-max-width);
}

.hint-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 40;
}

.hint-overlay--visible {
  display: flex;
}

.hint-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 12, 16, 0.78);
}

.hint-overlay__dialog {
  position: relative;
  z-index: 1;
  width: min(760px, 90vw);
  max-height: min(90vh, 720px);
  background: #111113;
  border: 1px solid #2a2a2d;
  border-radius: 0;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hint-overlay__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px 8px;
}

.hint-overlay__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #f3f3f5;
}

.hint-overlay__close {
  border: none;
  background: none;
  color: #9a9aa1;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 0;
  transition: background 0.2s ease, color 0.2s ease;
}

.hint-overlay__close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.hint-overlay__body {
  padding: 12px 26px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: #d6d6dd;
  overflow-y: auto;
}

.hint-overlay__message {
  font-size: 0.95rem;
  color: #9a9aa1;
  display: none;
}

.hint-overlay__message.visible {
  display: block;
}

.hint-overlay__grid-wrapper {
  background: #151517;
  padding: 14px;
  display: flex;
  justify-content: center;
  border-radius: 0;
}

.hint-overlay__grid-wrapper--hidden {
  display: none;
}

.hint-overlay__step-indicator {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f3f3f5;
}

.hint-overlay__description {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #c1c1cb;
  min-height: calc(1.5em * 3);
}

.rule-demo-overlay .hint-overlay__dialog {
  max-width: min(720px, 92vw);
}


.rule-demo-overlay .hint-grid {
  --hint-cell-size: clamp(58px, calc(420px / var(--grid-size)), 96px);
  --hint-divider-thickness: 1px;
  --hint-arrow-size: var(--hint-divider-thickness);
}

.rule-demo-overlay .hint-grid__arrow {
  overflow: visible;
}

.rule-demo-overlay .hint-grid__connector {
  background: #151517;
}

.rule-demo-overlay .hint-grid__connector::before,
.rule-demo-overlay .hint-grid__connector::after {
  content: none;
}

.rule-demo-overlay .hint-grid .arrow-symbol {
  font-size: clamp(18px, calc(var(--hint-cell-size) * 0.52), 44px);
  width: clamp(32px, calc(var(--hint-cell-size) * 0.68), 72px);
  height: clamp(32px, calc(var(--hint-cell-size) * 0.68), 72px);
}

.rule-demo-overlay .hint-overlay__description {
  display: block;
}

.rule-demo-overlay .hint-overlay__description p {
  margin: 0;
}

.hint-overlay__controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px 24px;
  border-top: 1px solid #1f1f23;
  background: rgba(17, 17, 19, 0.95);
}

.hint-overlay__nav-group {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.hint-overlay__nav {
  border: none;
  border-radius: 0;
  background: #2f2f37;
  color: #f3f3f5;
  padding: 8px 18px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.hint-overlay__nav:disabled {
  opacity: 0.45;
  cursor: default;
}

.hint-overlay__nav:not(:disabled):hover {
  background: #3d3d46;
}

.hint-overlay__slider {
  flex: 1 1 auto;
  min-width: 0;
  accent-color: #3498db;
  height: 4px;
}

.hint-grid {
  --hint-cell-size: clamp(36px, calc(260px / var(--grid-size)), 56px);
  --hint-gap-size: clamp(2px, calc(var(--hint-cell-size) * 0.08), 6px);
  --hint-arrow-size: var(--hint-gap-size);
  --hint-divider-thickness: clamp(1.5px, calc(var(--hint-cell-size) * 0.05), 3px);
  display: grid;
  gap: 0;
}

@media (min-width: 769px) {
  .hint-grid {
    --hint-cell-size: clamp(45px, calc(325px / var(--grid-size)), 70px);
  }
}

.hint-grid__connector {
  position: relative;
  background: transparent;
  pointer-events: none;
  --divider-thickness: var(--hint-divider-thickness);
}

.hint-grid__connector::before,
.hint-grid__connector::after {
  content: '';
  position: absolute;
  background: #151517;
}

.hint-grid__connector::before {
  width: var(--hint-divider-thickness);
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.hint-grid__connector::after {
  height: var(--hint-divider-thickness);
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.hint-grid__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  --divider-thickness: var(--hint-divider-thickness);
}

.hint-grid .arrow-symbol {
  font-size: clamp(16px, calc(var(--hint-cell-size) * 0.45), 42px);
  width: clamp(24px, calc(var(--hint-cell-size) * 0.7), 60px);
  height: clamp(24px, calc(var(--hint-cell-size) * 0.7), 60px);
  color: #a6a6b2;
}

.hint-cell {
  position: relative;
  min-width: var(--hint-cell-size);
  min-height: var(--hint-cell-size);
  background: #202028;
  border-radius: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.hint-cell--given {
  background: #19191f;
}

.hint-cell--filled {
  background: #26262f;
}

.hint-cell--target {
  box-shadow: inset 0 0 0 3px rgba(52, 152, 219, 0.8);
}

.hint-cell--reference {
  box-shadow: inset 0 0 0 3px rgba(241, 196, 15, 0.75);
}

.hint-cell--solved {
  box-shadow: inset 0 0 0 3px rgba(55, 174, 96, 0.85);
}

.hint-cell__value {
  display: none;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.6rem, calc(var(--hint-cell-size) * 0.7), 2.4rem);
  font-weight: 600;
  color: #f4f4f7;
  width: 100%;
  height: 100%;
  place-self: center;
}

.hint-cell__value.visible {
  display: flex;
}

.hint-cell__candidates {
  display: grid;
  grid-template-columns: repeat(var(--grid-size), 1fr);
  grid-template-rows: repeat(var(--grid-size), 1fr);
  gap: 4px;
  width: 100%;
  height: 100%;
  padding: 6px;
  box-sizing: border-box;
  align-self: stretch;
  justify-self: stretch;
}

.hint-cell__candidate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: clamp(0.7rem, calc(var(--hint-cell-size) * 0.28), 1rem);
  color: #5f616b;
  border-radius: 0;
  transition: color 0.15s ease;
  opacity: 1;
}

.hint-cell__candidate.active {
  color: #f5f5f8;
  font-weight: 600;
}

.hint-cell__candidate.removed {
  color: #ff9aa2;
  background: rgba(231, 76, 60, 0.28);
}

.hint-cell--inactive .hint-cell__candidate {
  opacity: 0.45;
}

@media (max-width: 720px) {
  .hint-overlay {
    padding: 12px;
  }

  .hint-overlay__controls {
    flex-direction: column;
    align-items: stretch;
  }

  .hint-overlay__nav-group {
    margin-left: 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
  }

  .hint-overlay__nav {
    width: 100%;
    text-align: center;
  }

  .hint-overlay__slider {
    width: 100%;
  }
}

.grid-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  border: var(--frame-thickness) solid #151517;
  pointer-events: none;
}

.grid-wrapper.puzzle-solved {
  border-color: #37ae60;
  box-shadow: 0 0 0 2px rgba(55, 174, 96, 0.3);
}

.grid-wrapper.puzzle-invalid {
  border-color: #e74c5c;
  box-shadow: 0 0 0 2px rgba(231, 76, 92, 0.3);
}

.puzzle-status-message {
  position: absolute;
  top: 11px;
  left: 0px;
  right: auto;
  transform: none;
  display: none;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  pointer-events: auto;
  white-space: nowrap;
  text-align: left;
  flex-wrap: nowrap;
  max-width: calc(100% - 2 * var(--grid-padding));
  z-index: 5;
}

.puzzle-status-message.visible {
  display: flex;
}

.puzzle-status-message__label {
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #37ae60;
}

.puzzle-status-message--error .puzzle-status-message__label {
  color: #e74c5c;
}

.puzzle-status-action {
  border: 1px solid #333333;
  background: #111113;
  color: #f3f3f5;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

.puzzle-status-action:hover,
.puzzle-status-action:focus-visible {
  background: #1f1f22;
  border-color: #2a2a2d;
  outline: none;
}

.puzzle-status-action:focus-visible {
  outline: 2px solid #b7b7bd;
  outline-offset: 2px;
}

.grid-wrapper > * {
  position: relative;
}

.cell {
  background: #222222;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  border-radius: 0;
}

.cell.cell--incorrect {
  background: #5b1616;
}

.cell:focus {
  outline: none;
}

.cell.selected {
  box-shadow: inset 0 0 0 8px #3A3A3A;
}

.cell.given {
  background: #1b1b1b;
}

.candidate-grid {
  position: absolute;
  inset: clamp(6px, 1.4vw, 12px);
  display: grid;
  grid-template-columns: repeat(var(--grid-size), 1fr);
  grid-template-rows: repeat(var(--grid-size), 1fr);
  gap: clamp(2px, 0.6vw, 6px);
  align-items: stretch;
  justify-items: stretch;
}

.candidate-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.75rem, 1.8vw, 1rem);
  color: #60636b; /*#60636b*/
  border-radius: 2px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.candidate-slot.active {
  background: #1A1A1A;
  color: #e8e8ea;
  font-weight: 600;
}

.cell-value {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: clamp(2.8rem, 7vw, 5rem);
  font-family: 'Roboto', sans-serif;
  font-weight: 300;
  color: #E74C3C;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.08);
}

.cell-value.visible {
  display: flex;
}

.cell.given .cell-value {
  display: flex;
  color: #E74C3C;
  /*-webkit-text-stroke: 2px black;*/
}

.arrow {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  overflow: visible;
  z-index: 2;
}

.arrow.hidden {
  color: transparent;
}

.arrow-symbol {
  --arrow-symbol-rotation: 0deg;
  font-family: 'Roboto', sans-serif;
  font-size: clamp(21px, calc(var(--cell-size) * 0.525), 60px);
  font-weight: 400;
  line-height: 1;
  color: #999999;
  pointer-events: none;
  white-space: nowrap;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: clamp(36px, calc(var(--cell-size) * 0.675), 108px);
  height: clamp(36px, calc(var(--cell-size) * 0.675), 108px);
  transform: rotate(var(--arrow-symbol-rotation));
}

.arrow-symbol svg {
  width: 100%;
  height: 100%;
}

.arrow.horizontal::before,
.arrow.vertical::before {
  content: '';
  position: absolute;
  background: #151517;
}

.arrow.horizontal::before {
  height: var(--divider-thickness);
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.arrow.vertical::before {
  width: var(--divider-thickness);
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.arrow.horizontal .arrow-symbol,
.arrow.vertical .arrow-symbol {
  z-index: 1;
}

.connector {
  position: relative;
  background: transparent;
  z-index: 1;
}

.connector::before,
.connector::after {
  content: '';
  position: absolute;
  background: #151517;
}

.connector::before {
  width: var(--divider-thickness);
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.connector::after {
  height: var(--divider-thickness);
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.control-panel-stack {
  width: min(100%, clamp(220px, 32vw, 360px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border: 1px solid #333333;
  border-radius: 0;
  background: #151517;
  box-shadow: none;
  max-width: 100%;
  color: #f3f3f5;
}

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  background: #111113;
  border-radius: 0;
  border: 1px solid #333333;
}

.mode-button {
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-size: 0.95rem;
  cursor: pointer;
  color: #a7a7ab;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease;
}

.mode-button:hover {
  background: #181818;
}

.mode-button.active {
  background: #333333;
  color: #f3f3f5;
  box-shadow: none;
}

.mode-button:focus-visible {
  outline: 2px solid #b7b7bd;
  outline-offset: 2px;
}


.number-input-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  background: #111113;
  border: 1px solid #333333;
  padding: 16px;
  --number-button-font-size: clamp(0.95rem, 2.2vw, 1.1rem);
  --number-button-padding-block: 14px;
  --number-button-min-height: 48px;
}

.number-input-container.mode-normal {
  --number-button-font-size: clamp(1.9rem, 6vw, 2.7rem);
  --number-button-padding-block: max(
    0px,
    calc((var(--number-button-min-height) - 1em) / 2)
  );
}

.number-input-container.mode-normal .number-button {
  font-weight: 100;
}

.number-input-container.mode-candidate {
  --number-button-font-size: clamp(0.95rem, 2.2vw, 1.1rem);
}

.number-input-container .number-pad {
  width: 100%;
}

.number-pad {
  display: grid;
  /*grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));*/
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.number-button {
  border: 1px solid #333333;
  border-radius: 0;
  background: #111113;
  padding: var(--number-button-padding-block) 0;
  font-size: var(--number-button-font-size);
  font-family: 'Roboto', sans-serif;
  font-weight: 700;
  color: #f3f3f5;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  min-height: var(--number-button-min-height);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.number-button.used {
  background: #1c1c1f;
  color: #55555a;
  border-color: #1c1c1f;
}

.number-button:hover:not(:disabled) {
  background: #1f1f22;
  border-color: #2a2a2d;
}

.number-button:focus-visible {
  outline: 2px solid #b7b7bd;
  outline-offset: 2px;
}

.number-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.clear-all-button {
  width: 100%;
  text-align: center;
  align-self: stretch;
}

.control-panel-footer {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.control-panel-footer .control-button {
  width: 100%;
}

.control-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.control-button {
  border: 1px solid #333333;
  border-radius: 0;
  padding: 12px;
  background: #111113;
  font-size: 0.95rem;
  font-weight: 600;
  color: #f3f3f5;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.control-button:hover:not(:disabled) {
  background: #1f1f22;
  border-color: #2a2a2d;
}

.control-button:focus-visible {
  outline: 2px solid #b7b7bd;
  outline-offset: 2px;
}

.control-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.control-button.danger {
  color: #ff8080;
  background: #1e1a1a;
  border-color: #4a2d2d;
}

.control-button.danger:hover:not(:disabled) {
  background: #2a1f1f;
  border-color: #5c3939;
}

.instructions {
  max-width: 560px;
  text-align: center;
  color: #a7a7ab;
  line-height: 1.6;
}

@media (max-width: 768px) {
  :root {
    --grid-max-width: min(100vw - 24px, 640px);
    --grid-padding: clamp(12px, 3vw, 24px);
    --cell-min-size: 36px;
    --cell-max-size: 160px;
    --page-side-padding: 12px;
  }

  .page {
    padding: 0 var(--page-side-padding) 32px;
  }
}

@media (max-width: 640px) {
  :root {
    --grid-max-width: min(100vw - 24px, 520px);
    --grid-padding: clamp(10px, 3.5vw, 20px);
    --cell-min-size: 24px;
    --cell-max-size: 140px;
  }

  .puzzle-layout {
    flex-direction: column;
    align-items: center;
    width: min(100%, var(--grid-max-width));
    margin: 0 auto;
    gap: 20px;
  }

  .grid-wrapper {
    width: 100%;
  }

  .control-panel-stack {
    width: 100%;
  }

  .control-panel {
    padding: 16px;
  }

  .mode-toggle {
    max-width: 420px;
    margin: 0 auto;
  }

  .number-pad {
    grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
    gap: 8px;
  }

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

  .cell-value {
    font-size: clamp(2rem, 8vw, 3.2rem);
  }

  .candidate-grid {
    inset: clamp(6px, 2.8vw, 10px);
  }

  .arrow-symbol {
    font-size: clamp(1.4rem, 5.2vw, 2.4rem);
  }
}

.solve-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  width: 100vw;
  height: 100vh;
}

.solve-popup--visible {
  opacity: 1;
  pointer-events: auto;
}

.solve-popup__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.solve-popup--visible .solve-popup__backdrop {
  opacity: 1;
}

.solve-popup__dialog {
  position: relative;
  background: #111113;
  border: 1px solid #333333;
  border-radius: 0;
  padding: 28px clamp(24px, 5vw, 36px);
  width: min(90%, 420px);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateY(18px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: auto;
}

.solve-popup--visible .solve-popup__dialog {
  transform: translateY(0);
  opacity: 1;
}

.solve-popup__title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  color: #f3f3f5;
}

.solve-popup__details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
  color: #c7c7cd;
}

.solve-popup__puzzle {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.solve-popup__puzzle-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8f8f95;
}

.solve-popup__puzzle-date {
  font-size: 0.95rem;
  font-weight: 500;
  color: #c7c7cd;
}

.solve-popup__stat {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
}

.solve-popup__stat--countdown {
  font-size: 0.95rem;
  color: #a0a0a8;
  margin-top: 6px;
}

.solve-popup__actions {
  display: flex;
  flex-direction: row;
  gap: 12px;
  justify-content: center;
}

.solve-popup__action-button {
  flex: 1 1 0;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 0;
  cursor: pointer;
  border: 1px solid #333333;
  background: #111113;
  color: #f3f3f5;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.solve-popup__action-button:hover:not(:disabled) {
  background: #1f1f22;
  border-color: #2a2a2d;
}

.solve-popup__share-button,
.solve-popup__copy-button {
  border-color: #3d6bff;
  color: #e0e5ff;
  background: #1b2542;
}

.solve-popup__share-button:hover:not(:disabled),
.solve-popup__copy-button:hover:not(:disabled) {
  background: #223059;
  border-color: #5f7bff;
}

.solve-popup__close-button {
  color: #c7c7cd;
}

.solve-popup__action-button:focus-visible {
  outline: 2px solid #b7b7bd;
  outline-offset: 2px;
}

.hint-popup .solve-popup__dialog {
  width: min(90%, 360px);
  gap: 12px;
  text-align: center;
}

.hint-popup__title {
  font-size: 1.4rem;
}

.hint-popup__message {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: #c7c7cd;
}

.hint-popup__actions {
  justify-content: center;
}

.hint-popup__close-button {
  flex: 0 0 auto;
  min-width: 120px;
}

.welcome-popup__dialog {
  width: min(92%, 480px);
  padding: clamp(32px, 7vw, 44px) clamp(28px, 7vw, 48px);
  gap: clamp(18px, 4vw, 26px);
  align-items: center;
  text-align: center;
}

.welcome-popup__title {
  margin: 0;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #f7f7fa;
}

.welcome-popup__subtitle {
  margin: 0;
  font-size: clamp(0.85rem, 2.6vw, 1.1rem);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #b5b5bd;
}

.welcome-popup__difficulty {
  margin: 0;
  font-size: clamp(0.85rem, 2.6vw, 1.1rem);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #b5b5bd;
}

.welcome-popup__difficulty-value {
  font-weight: 600;
  letter-spacing: inherit;
  margin-left: 0.35em;
  color: inherit;
}

.welcome-popup__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.welcome-popup__button {
  width: 100%;
  padding: 14px 22px;
  border: 1px solid #3a3a3f;
  background: #19191c;
  color: #f3f3f5;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.welcome-popup__button--secondary {
  background: #18181b;
  border-color: #34343a;
  color: #f3f3f5;
}

.welcome-popup__button--secondary:hover {
  background: #1f1f23;
  border-color: #46464c;
}

.welcome-popup__button--primary {
  background: linear-gradient(135deg, #1d1d22, #28282f);
  border-color: #4f4f58;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 18px 40px rgba(0, 0, 0, 0.55);
  padding: 18px 24px;
  font-size: 1.05rem;
  font-weight: 700;
}

.welcome-popup__button--primary:hover {
  background: linear-gradient(135deg, #24242a, #313139);
  border-color: #5f5f69;
  transform: translateY(-1px);
}

.welcome-popup__button:focus-visible {
  outline: 2px solid #b7b7bd;
  outline-offset: 2px;
}

.welcome-popup__start-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.08em;
  letter-spacing: 0.08em;
  font-size: 1.5em;
  color: #ffffff;
}

.welcome-popup__start-letter {
  display: inline-block;
  font-weight: 700;
  line-height: 1;
  color: inherit;
  text-shadow: none;
}

.welcome-popup__start-letter:nth-child(1) {
  color: #e74c5c;
}

.welcome-popup__start-letter:nth-child(2) {
  color: #9b69b6;
}

.welcome-popup__start-letter:nth-child(3) {
  color: #4498db;
}

.welcome-popup__start-letter:nth-child(4) {
  color: #37ae60;
}

.welcome-popup__start-letter:nth-child(5) {
  color: #f1c43f;
}
.radial-menu {
  position: fixed;
  width: 140px;
  height: 140px;
  display: none;
  z-index: 2000;
  pointer-events: none;
}

.radial-menu.visible {
  display: block;
}

.radial-menu-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(12, 12, 14, 0.92);
  border: 2px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.radial-menu-center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(24, 24, 28, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.05);
}

.radial-menu-option {
  position: absolute;
  width: 44px;
  height: 44px;
  line-height: 44px;
  text-align: center;
  font-weight: 600;
  font-size: 1.4rem;
  color: #f3f3f5;
  border-radius: 50%;
  background: rgba(32, 32, 36, 0.95);
  transform: translate(-50%, -50%);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
}

.radial-menu-option.active {
  transform: translate(-50%, -50%) scale(1.12);
  background: rgba(52, 52, 58, 1);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18), 0 10px 20px rgba(0, 0, 0, 0.45);
}

@media (max-width: 600px) {
  .page {
    margin: 24px auto 32px;
    padding: 0 var(--page-side-padding) 32px;
    gap: 16px;
  }

  .puzzle-area {
    gap: 16px;
  }

  .puzzle-selector {
    gap: 10px;
  }

  .puzzle-selector:not(.puzzle-selector--daily) {
    padding: 12px 16px;
  }

  .puzzle-selector--daily {
    gap: 4px;
  }

  .daily-puzzle-banner {
    font-size: 0.95rem;
  }
}
