#crossword-plus-root {
  display: none;
}

body.crossword-plus-active {
  overflow: hidden;
}

body.crossword-plus-active #root main {
  visibility: hidden;
  pointer-events: none;
}

body.crossword-plus-active #crossword-plus-root {
  display: block;
  position: fixed;
  inset: var(--crossword-plus-top, 0px) 0 0 0;
  z-index: 24;
  overflow: auto;
  background:
    radial-gradient(circle at 12% 0%, rgba(20, 184, 166, 0.18), transparent 34rem),
    radial-gradient(circle at 90% 5%, rgba(99, 102, 241, 0.14), transparent 28rem),
    linear-gradient(180deg, #f7fbfd 0%, #edf3f8 54%, #e4eef6 100%);
  color: #172033;
}

.cw-page {
  min-height: calc(100dvh - var(--crossword-plus-top, 0px));
  padding: clamp(18px, 3vw, 34px);
}

.cw-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
}

.cw-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.cw-kicker {
  margin: 0 0 8px;
  color: #56657a;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.cw-hero h1 {
  margin: 0;
  color: #121a2b;
  font-size: clamp(2rem, 4.3vw, 4.65rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.cw-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  color: #56657a;
}

.cw-meta span,
.cw-progress,
.cw-segment,
.cw-actions button,
.cw-message {
  border: 1px solid rgba(30, 41, 59, 0.12);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px) saturate(1.08);
}

.cw-meta span {
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.9rem;
}

.cw-progress {
  min-width: 154px;
  border-radius: 20px;
  padding: 14px 16px;
  text-align: right;
}

.cw-progress strong {
  display: block;
  color: #111827;
  font-size: 1.5rem;
  line-height: 1;
}

.cw-progress span {
  color: #667085;
  font-size: 0.86rem;
}

.cw-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.cw-segment {
  display: inline-flex;
  gap: 4px;
  border-radius: 999px;
  padding: 4px;
}

.cw-segment button,
.cw-actions button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 0 14px;
  color: #283449;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.cw-segment button {
  background: transparent;
}

.cw-segment button.is-active {
  background: linear-gradient(135deg, #5b5ff0, #18b7a3);
  color: #fff;
  box-shadow: 0 10px 22px rgba(91, 95, 240, 0.22);
}

.cw-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.cw-actions button:hover,
.cw-segment button:hover {
  transform: translateY(-1px);
}

.cw-primary {
  background: linear-gradient(135deg, #5b5ff0, #18b7a3) !important;
  color: #fff !important;
}

.cw-ghost {
  background: rgba(255, 255, 255, 0.72) !important;
}

.cw-danger {
  background: rgba(255, 247, 237, 0.88) !important;
  color: #9a3412 !important;
}

.cw-message {
  margin: 0 0 14px;
  border-radius: 14px;
  padding: 12px 14px;
  color: #27364d;
  font-weight: 800;
}

.cw-message.is-success {
  border-color: rgba(16, 185, 129, 0.28);
  color: #047857;
}

.cw-message.is-warn {
  border-color: rgba(245, 158, 11, 0.32);
  color: #92400e;
}

.cw-message.is-info {
  border-color: rgba(91, 95, 240, 0.28);
  color: #3730a3;
}

.cw-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  gap: clamp(14px, 2vw, 22px);
  align-items: start;
}

.cw-board-card,
.cw-clues-card {
  border: 1px solid rgba(30, 41, 59, 0.12);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 22px 58px rgba(15, 23, 42, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.cw-board-card {
  padding: clamp(10px, 1.7vw, 18px);
}

.cw-board-wrap {
  width: min(100%, 760px);
  margin: 0 auto;
}

.cw-board {
  display: grid;
  grid-template-columns: 34px repeat(var(--cw-size), minmax(0, 1fr));
  grid-template-rows: 34px repeat(var(--cw-size), minmax(0, 1fr));
  gap: 5px;
  aspect-ratio: 1 / 1;
}

.cw-axis {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(226, 232, 240, 0.7);
  color: #59677b;
  font-size: 0.78rem;
  font-weight: 900;
}

.cw-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: 9px;
}

.cw-block {
  background:
    linear-gradient(145deg, rgba(45, 55, 72, 0.92), rgba(22, 30, 44, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.cw-block-coord {
  position: absolute;
  top: 4px;
  left: 5px;
  color: rgba(226, 232, 240, 0.42);
  font-size: clamp(0.44rem, 1vw, 0.62rem);
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.cw-open {
  display: block;
  border: 1px solid rgba(30, 41, 59, 0.16);
  background: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72), 0 8px 16px rgba(15, 23, 42, 0.04);
}

.cw-open:focus-within {
  border-color: rgba(91, 95, 240, 0.72);
  box-shadow: 0 0 0 3px rgba(91, 95, 240, 0.18), 0 14px 22px rgba(15, 23, 42, 0.08);
}

.cw-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0 !important;
  background: transparent !important;
  color: #111827 !important;
  text-align: center;
  text-transform: uppercase;
  font-size: clamp(1.02rem, 3.2vw, 2rem);
  font-weight: 900;
  line-height: 1;
  outline: 0;
  padding: 17px 3px 3px !important;
}

.cw-coord,
.cw-start {
  position: absolute;
  z-index: 1;
  line-height: 1;
  pointer-events: none;
  letter-spacing: 0;
}

.cw-coord {
  top: 4px;
  left: 5px;
  color: #64748b;
  font-size: clamp(0.48rem, 1.2vw, 0.66rem);
  font-weight: 900;
}

.cw-start {
  right: 4px;
  bottom: 4px;
  border-radius: 999px;
  padding: 2px 4px;
  background: rgba(91, 95, 240, 0.12);
  color: #3730a3;
  font-size: clamp(0.46rem, 1.1vw, 0.62rem);
  font-weight: 900;
}

.cw-board.is-arrows .cw-open.has-start {
  border-color: rgba(24, 183, 163, 0.48);
  background: linear-gradient(180deg, #ffffff 0%, #ecfdf5 100%);
}

.cw-open.is-correct {
  border-color: rgba(16, 185, 129, 0.52);
  background: #ecfdf5;
}

.cw-open.is-wrong {
  border-color: rgba(239, 68, 68, 0.5);
  background: #fef2f2;
}

.cw-open.is-missing {
  border-color: rgba(245, 158, 11, 0.46);
  background: #fffbeb;
}

.cw-clues-card {
  padding: 18px;
  max-height: min(78dvh, 780px);
  overflow: auto;
}

.cw-clues-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.cw-clues-head h2,
.cw-clue-group h3 {
  margin: 0;
  color: #172033;
}

.cw-clues-head h2 {
  font-size: 1.25rem;
}

.cw-clues-head span {
  display: inline-flex;
  min-width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(24, 183, 163, 0.12);
  color: #0f766e;
  font-weight: 900;
}

.cw-clue-group + .cw-clue-group {
  margin-top: 18px;
}

.cw-clue-group h3 {
  margin-bottom: 8px;
  color: #56657a;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.cw-clue-list {
  display: grid;
  gap: 8px;
}

.cw-clue {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: start;
  gap: 8px;
  width: 100%;
  border: 1px solid rgba(30, 41, 59, 0.11);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
  color: #27364d;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.cw-clue:hover {
  border-color: rgba(91, 95, 240, 0.26);
  background: rgba(255, 255, 255, 0.9);
}

.cw-clue-id,
.cw-clue-coordinate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 24px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
}

.cw-clue-id {
  background: rgba(91, 95, 240, 0.12);
  color: #3730a3;
}

.cw-clue-coordinate {
  background: rgba(226, 232, 240, 0.76);
  color: #475569;
}

.cw-clue-text {
  color: #27364d;
  font-size: 0.94rem;
  line-height: 1.35;
}

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

  .cw-actions {
    width: 100%;
    margin-left: 0;
  }

  .cw-actions button {
    flex: 1 1 148px;
  }

  .cw-clues-card {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .cw-page {
    padding: 14px;
  }

  .cw-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .cw-progress {
    text-align: left;
  }

  .cw-toolbar {
    align-items: stretch;
  }

  .cw-segment,
  .cw-actions {
    width: 100%;
  }

  .cw-segment button {
    flex: 1;
  }

  .cw-board {
    grid-template-columns: 25px repeat(var(--cw-size), minmax(0, 1fr));
    grid-template-rows: 25px repeat(var(--cw-size), minmax(0, 1fr));
    gap: 3px;
  }

  .cw-axis {
    border-radius: 7px;
    font-size: 0.66rem;
  }

  .cw-cell {
    border-radius: 6px;
  }

  .cw-input {
    font-size: clamp(0.92rem, 6vw, 1.35rem);
    padding-top: 13px !important;
  }

  .cw-coord {
    top: 3px;
    left: 3px;
    font-size: 0.44rem;
  }

  .cw-block-coord {
    top: 3px;
    left: 3px;
    font-size: 0.4rem;
  }

  .cw-start {
    display: none;
  }

  .cw-clue {
    grid-template-columns: auto auto;
  }

  .cw-clue-text {
    grid-column: 1 / -1;
  }
}
