.theme-crossword {
  --def-color:      #5070cc;
  --fodder-color:   #c89020;
  --fodder-bg:      rgba(200, 144, 32, 0.28);
  --indicator-color: #2eb09f;

  --highlight:      #ea7ac1;
  --active:         #d449a6;

  /* slot highlighter colors */
  --slot-bg:        #ffffff;
  --slot-hover:     #faf2ff;
  --slot-active:    #e6d2ff;

  --cell-bg:        #ffffff;
  --cell-border:    var(--ink);
  --cell-border-w:  1.5px;
  /* 40px per cell on desktop, but the grid is 23 columns wide (~920px), so on
     narrow screens shrink cells to fit the viewport width instead of overflowing.
     letter/number sizes scale with the cell so they stay proportional. */
  --cell-size:      min(40px, (100vw - var(--space-9)) / 23);
  --cell-letter-sz: calc(var(--cell-size) * 0.42);
  --cell-num-sz:    calc(var(--cell-size) * 0.26);

  --font-display:   var(--serif);
  --font-body:      var(--serif);
  --font-mono:      var(--mono);
  --size-modal-title: var(--type-3);
  --size-poem:      var(--type-1);
  --size-answer:    var(--type-0);
  --size-clue:      var(--type--1);
  --size-button:    var(--type--1);
  --size-byline:    var(--type--2);
  --size-small:     var(--type--2);
  --size-label:     var(--type--3);
  --line-poem:      1.5;

  --max-width:      1400px;
  --section-gap:    var(--space-2);
  --side-pad:       var(--space-4);

  --legend-dot-size: 0.55rem;
  --reveal-dot-size: 0.85rem;
  --slot-pad-y:     1px;
  --slot-pad-x:     6px;
  --poem-slot-pad-x: 4px;
  --part-pad-x:     5px;
  --pill-radius:    3px;
  --part-radius:    4px;
  --cell-radius:    5px;
  --button-radius:  5px;
  --modal-radius:   10px;
  --modal-width:    30rem;
  --label-offset-y: 2px;
  --letter-offset-y: 4px;
  --slot-gap-inline: 1px;
  --cell-shadow-offset: 5px;
  --button-shadow-offset: 4px;
  --button-hover-offset: 2px;
  --modal-shadow-offset: 8px;
}

.theme-crossword .curtains { max-width: var(--max-width); margin: 0 auto; }

.theme-crossword header { text-align: center; margin-bottom: var(--section-gap); }
.theme-crossword header h1 { margin: 0; }
.theme-crossword header .byline {
  font-family: var(--font-body); font-style: normal;
  color: var(--ink-soft);
  letter-spacing: var(--track-l); text-transform: lowercase;
  font-size: var(--size-byline); margin-top: var(--space-1);
}

/* ─── grid ─── */
/* ─── sticky active clue bar ─── */
.theme-crossword .active-clue-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  padding: var(--space-1) var(--space-2);
  margin: 0 calc(-1 * var(--side-pad)) var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  border-bottom: 1.5px solid var(--ink);
  min-height: 80px;
}
.theme-crossword .active-clue-bar:empty { display: none; }
.theme-crossword .active-clue-bar .clue-label {
  font-family: var(--font-body);
  font-size: var(--size-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--track-l);
  color: var(--ink-soft);
  flex-shrink: 0;
  padding-top: var(--label-offset-y);
}
/* the slot inside the bar uses the same styling as poem slots,
   but forced into active state visually */
.theme-crossword .active-clue-bar .slot { background: var(--slot-bg); }
.theme-crossword .active-clue-bar .slot.solved { background: transparent; }

.theme-crossword .grid-wrap { display: flex; justify-content: center; margin: var(--space-2) 0; }
.theme-crossword .grid {
  display: grid;
  grid-auto-rows: var(--cell-size);
  grid-auto-columns: var(--cell-size);
}
.theme-crossword .cell {
  width: var(--cell-size); height: var(--cell-size);
  background: var(--cell-bg);
  border: var(--cell-border-w) solid var(--cell-border);
  border-radius: var(--cell-radius);
  box-shadow: var(--cell-shadow-offset) var(--cell-shadow-offset) #000;
  margin: calc(-1 * var(--cell-border-w) / 2);
  position: relative;
  font-family: var(--font-body);
  font-size: var(--cell-letter-sz); font-weight: 600;
  text-align: center;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; text-transform: uppercase; user-select: none;
  transition: background 0.12s;
}
.theme-crossword .cell.highlight { background: var(--highlight); }
.theme-crossword .cell.active    { background: var(--active); }
.theme-crossword .cell-num {
  position: absolute; top: 2px; left: 3px;
  font-size: var(--cell-num-sz); font-weight: 400;
  font-family: var(--font-body); line-height: 1;
  color: var(--ink-soft);
}
.theme-crossword .cell .letter { margin-top: var(--letter-offset-y); }

/* ─── controls ─── */
.theme-crossword .controls {
  display: flex; gap: var(--space-4); justify-content: center;
  margin: var(--space-1) 0 var(--space-2); flex-wrap: wrap;
}
.theme-crossword .controls button {
  background: var(--cell-bg);
  border: 2px solid var(--ink); color: var(--ink);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--button-radius);
  font-family: var(--font-body); font-size: var(--size-button); font-style: normal;
  font-weight: 600;
  cursor: pointer; letter-spacing: var(--track-xs);
  box-shadow: var(--button-shadow-offset) var(--button-shadow-offset) 0 var(--ink);
  transition: transform 0.1s, box-shadow 0.1s, background 0.12s, color 0.12s;
}
.theme-crossword .controls button:hover {
  transform: translate(var(--button-hover-offset), var(--button-hover-offset));
  box-shadow: var(--button-hover-offset) var(--button-hover-offset) 0 var(--ink);
}
.theme-crossword .controls button:active,
.theme-crossword .controls button.on {
  background: var(--ink); color: var(--paper);
  transform: translate(var(--button-shadow-offset), var(--button-shadow-offset));
  box-shadow: 0 0 0 var(--ink);
}

.theme-crossword .legend {
  display: flex; gap: var(--space-5); justify-content: center;
  font-size: var(--size-small); font-style: normal;
  color: var(--ink-soft); margin: var(--space-1) 0 0; flex-wrap: wrap;
  letter-spacing: var(--track-xs);
}
.theme-crossword .legend span { display: inline-flex; align-items: center; }
.theme-crossword .legend span::before {
  content: ''; display: inline-block;
  width: var(--legend-dot-size); height: var(--legend-dot-size); border-radius: 50%;
  margin-right: var(--space-1);
  border: 1.5px solid;
}
.theme-crossword .legend .l-def::before       { background: var(--def-color);       border-color: var(--def-color); }
.theme-crossword .legend .l-fodder::before    { background: var(--fodder-color);    border-color: var(--fodder-color); }
.theme-crossword .legend .l-indicator::before { background: var(--indicator-color); border-color: var(--indicator-color); }

/* ─── split layout: clues on the left, poem on the right ─── */
.theme-crossword .solve-area {
  margin: var(--section-gap) 0 var(--space-2);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-11);
  align-items: start;
}
@media (max-width: 720px) {
  .theme-crossword .solve-area {
    grid-template-columns: 1fr;
    gap: var(--space-7);
  }
}

.theme-crossword .section-label {
  font-family: var(--font-body);
  font-size: var(--size-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--track-l);
  color: var(--ink-soft);
  margin: 0 0 var(--space-2) 0;
  border-bottom: 1.5px solid var(--ink);
  padding-bottom: var(--space-1);
  text-align: left;
}

/* clues list */
.theme-crossword .clues-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.theme-crossword .clue-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.theme-crossword .clue-num {
  font-family: var(--font-body);
  font-size: var(--size-label);
  font-weight: 700;
  letter-spacing: var(--track-xs);
  color: var(--ink-soft);
  flex-shrink: 0;
  min-width: var(--space-7);
  text-transform: lowercase;
}
.theme-crossword .clue-item .slot { flex: 1; }

/* poem area */
.theme-crossword .poem {
  font-family: var(--font-display);
  font-size: var(--size-poem); line-height: var(--line-poem);
  font-weight: 400; font-style: normal;
  text-align: left;
}
.theme-crossword .poem-line { display: block; margin-bottom: var(--space-1); }

/* ─── slot base + states ───
   Default (resting) state inside the clues list = purple (--slot-active).
   Active (selected) state = white (--slot-bg), drawing the eye.
   Slot in poem stays subdued until solved. */
.theme-crossword .slot {
  display: inline; cursor: pointer;
  background: var(--slot-active);
  color: var(--ink);
  padding: var(--slot-pad-y) var(--slot-pad-x);
  border-radius: var(--pill-radius);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  transition: background 0.12s;
}
.theme-crossword .slot:hover  { background: var(--slot-hover); }
.theme-crossword .slot.active { background: var(--slot-bg); }
.theme-crossword .slot.solved { background: transparent; }

.theme-crossword .slot.unsolved .slot-text {
  font-family: var(--font-body); font-size: var(--size-clue);
  font-style: italic;
  font-weight: 700;
}
.theme-crossword .slot-enum {
  font-size: var(--size-small); color: var(--ink-soft);
  font-style: normal; margin-left: var(--space-1);
  font-family: var(--font-body);
}

.theme-crossword .slot.solved .slot-text {
  font-style: normal; font-family: var(--font-display);
  font-variant: small-caps; font-weight: 700;
  font-size: var(--size-answer); letter-spacing: var(--track-m);
  color: var(--ink);
  background: transparent; padding: 0;
}

/* ─── poem slot: blank-square placeholders that fill in as grid is solved ─── */
.theme-crossword .poem-slot {
  display: inline-block;
  cursor: pointer;
  padding: var(--slot-pad-y) var(--poem-slot-pad-x);
  margin: 0 var(--slot-gap-inline);
  border-radius: var(--pill-radius);
  background: var(--slot-active);
  font-family: var(--font-body);
  font-size: var(--size-clue);
  font-weight: 700;
  letter-spacing: var(--track-xl);
  color: var(--ink);
  transition: background 0.12s;
  vertical-align: baseline;
  white-space: nowrap;
}
.theme-crossword .poem-slot:hover  { background: var(--slot-hover); }
.theme-crossword .poem-slot.active { background: var(--slot-bg); }
.theme-crossword .poem-slot.solved {
  background: transparent;
  font-family: var(--font-display);
  font-variant: small-caps;
  font-size: var(--size-answer);
  letter-spacing: var(--track-s);
  padding: 0;
}

.basic-def {
  color: var(--def-color);
  border-bottom: 2.5px solid var(--def-color);
  font-weight: 500;
}

.basic-fodder {
  color: var(--fodder-color);
  background: var(--fodder-bg);
  padding: 0 var(--part-pad-x);
  border-radius: var(--part-radius);
  font-weight: 500;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.basic-indicator {
  color: var(--indicator-color);
  font-style: italic;
  font-weight: 500;
  text-decoration: underline dotted 2px;
  text-underline-offset: 4px;
}

/* ─── per-part highlight: each type controlled by its own class ─── */
.theme-crossword .slot.show-def .part-def {
  color: var(--def-color);
  border-bottom: 2.5px solid var(--def-color);
  font-weight: 500;
}
.theme-crossword .slot.show-fodder .part-fodder {
  color: var(--fodder-color);
  background: var(--fodder-bg);
  padding: 0 var(--part-pad-x);
  border-radius: var(--part-radius);
  font-weight: 500;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.theme-crossword .slot.show-indicator .part-indicator {
  color: var(--indicator-color);
  font-style: italic;
  font-weight: 500;
  text-decoration: underline dotted 2px;
  text-underline-offset: 4px;
}

/* ─── inline reveal dots ─── */
.theme-crossword .reveal-dots {
  display: inline-flex;
  gap: var(--space-1);
  margin-left: var(--space-2);
  vertical-align: middle;
  align-items: center;
}
.theme-crossword .reveal-dot {
  width: var(--reveal-dot-size);
  height: var(--reveal-dot-size);
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid;
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s, opacity 0.18s;
  display: inline-block;
  line-height: 0;
  opacity: 0.4;
}
.theme-crossword .reveal-dot.on,
.theme-crossword .slot:hover .reveal-dot { opacity: 1; }
.theme-crossword .reveal-dot:hover { transform: scale(1.2); opacity: 1; }

.theme-crossword .reveal-dot-def       { border-color: var(--def-color); }
.theme-crossword .reveal-dot-fodder    { border-color: var(--fodder-color); }
.theme-crossword .reveal-dot-indicator { border-color: var(--indicator-color); }

.theme-crossword .reveal-dot.on.reveal-dot-def       { background: var(--def-color); }
.theme-crossword .reveal-dot.on.reveal-dot-fodder    { background: var(--fodder-color); }
.theme-crossword .reveal-dot.on.reveal-dot-indicator { background: var(--indicator-color); }

.theme-crossword .hidden-input {
  position: fixed; top: 50%; left: 50%;
  opacity: 0; pointer-events: none;
  width: 1px; height: 1px; border: 0;
  background: transparent; font-size: 16px;
}

.theme-crossword footer {
  text-align: center; font-style: normal;
  color: var(--ink-soft); font-size: var(--size-small);
  margin-top: var(--space-3);
  letter-spacing: var(--track-2xs);
}
.theme-crossword footer code {
  font-family: var(--font-mono); font-style: normal;
  font-size: 0.9em;
  background: var(--cell-bg);
  border: 1px solid var(--ink);
  padding: var(--slot-pad-y) var(--slot-pad-x); border-radius: var(--pill-radius);
  color: var(--ink);
}

/* ─── win modal ─── */
.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: rgba(0, 0, 0, 0.55);
  animation: win-fade 0.3s ease both;
}
.win-overlay[hidden] { display: none; }

.win-modal {
  background: #eaa4ff;            /* the puzzle's own paper, even over the wash */
  color: #000;
  border: 2px solid #000;
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow-offset) var(--modal-shadow-offset) 0 #000;
  max-width: var(--modal-width);
  width: 100%;
  padding: var(--space-7) var(--space-7) var(--space-6);
  text-align: center;
  font-family: var(--font-display);
  animation: win-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.win-title {
  margin: 0 0 var(--space-4);
  font-size: var(--size-modal-title);
  font-weight: 900;
  letter-spacing: var(--track-xs);
  text-transform: uppercase;
}
.win-poem {
  font-size: var(--size-poem);
  line-height: 1.65;
  font-variant: small-caps;
  letter-spacing: var(--track-xs);
  margin-bottom: var(--space-6);
}
.win-poem-line { display: block; }
.win-actions { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; }
.win-actions button {
  background: #fff;
  border: 2px solid #000;
  color: #000;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--button-radius);
  font: 600 var(--size-button) var(--font-display);
  letter-spacing: var(--track-xs);
  cursor: pointer;
  box-shadow: var(--button-shadow-offset) var(--button-shadow-offset) 0 #000;
  transition: transform 0.1s, box-shadow 0.1s;
}
.win-actions button:hover {
  transform: translate(var(--button-hover-offset), var(--button-hover-offset));
  box-shadow: var(--button-hover-offset) var(--button-hover-offset) 0 #000;
}
.win-actions button:active {
  transform: translate(var(--button-shadow-offset), var(--button-shadow-offset));
  box-shadow: 0 0 0 #000;
}

@keyframes win-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes win-pop {
  from { opacity: 0; transform: translateY(var(--space-4)) scale(0.92); }
  to   { opacity: 1; transform: none; }
}

/* ─── emoji shower ─── */
.win-confetti {
  position: fixed;
  top: -40px;
  z-index: 1001;
  pointer-events: none;
  user-select: none;
  animation: win-fall linear forwards;
}
@keyframes win-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(540deg); opacity: 0.7; }
}

@media (prefers-reduced-motion: reduce) {
  .win-overlay, .win-modal { animation: none; }
}
