/* Shared colors for game cells, clues, keyboard and tutorial. */
:root{
  --game-correct:#e6e8e5;--game-correct-ink:#27312b;--game-correct-line:#bac3b9;--game-inset:#667568;
  --game-near:#c6e6b4;--game-near-ink:#294d27;--game-near-line:#85ad72;
  --game-far:#f7e4a6;--game-far-ink:#70561a;--game-far-line:#c8ae61;
  --clue-absent-fill:var(--game-far);--clue-absent-ink:var(--game-far-ink);
}
:root[data-theme="dark"]{
  --game-correct:#3b403d;--game-correct-ink:#edf2e8;--game-correct-line:#667269;--game-inset:#b0b8b1;
}
html :is(.tile.correct,.tutorial-cell.correct,.entry-slot.correct,.legend-tile.correct,.history-letter.correct,.axis-button.solved,.palette-swatch.correct){
  position:relative;background:var(--game-correct)!important;color:var(--game-correct-ink)!important;border-color:var(--game-correct-line)!important;
}
html :is(.tile.correct .tile-letter,.tutorial-cell.correct .tutorial-letter){background:transparent!important;color:var(--game-correct-ink)!important}
html :is(.tile.correct,.tile.correct.has-hints,.tutorial-cell.correct,.entry-slot.correct,.legend-tile.correct,.history-letter.correct,.palette-swatch.correct)::after{
  content:'';display:block;position:absolute;inset:4px;border:2px solid var(--game-inset);border-radius:4px;pointer-events:none;z-index:0;
}
html :is(.history-letter.correct,.legend-tile.correct)::after{inset:2px;border-width:1px;border-radius:2px}
html .tutorial-cell.correct::after{inset:3px;border-width:1.5px;border-radius:3px}
html .cell-hints,html .tutorial-notes{z-index:2}
html :is(.cell-hint.present,.tutorial-note.present,.legend-tile.present,.history-letter.present,.hint-letter,.palette-swatch.present){background:var(--game-near);color:var(--game-near-ink)}
html :is(.cell-hint.absent,.tutorial-note.absent,.legend-tile.absent,.history-letter.absent,.palette-swatch.absent){background:var(--game-far);color:var(--game-far-ink)}
html :is(.cell-hint,.tutorial-note,.legend-tile)[data-hint-directions]{background:transparent}
html .keyboard-panel .key.present{background:var(--game-near);color:var(--game-near-ink);border-color:var(--game-near-line)}
html .keyboard-panel .key.absent{background:var(--game-far);color:var(--game-far-ink);border-color:var(--game-far-line)}
html .tutorial-color-dot.correct{background:var(--game-correct);box-shadow:inset 0 0 0 2px var(--game-inset)}
html .tutorial-color-dot.present{background:var(--game-near)}
html .tutorial-color-dot.absent{background:var(--game-far)}
html .tutorial-cell.candidate.present{background:var(--game-near);border-color:var(--game-near-line);color:var(--game-near-ink)}
html .tutorial-cell.candidate.absent{background:var(--game-far);border-color:var(--game-far-line);color:var(--game-far-ink)}
html .tutorial-cell.target.origin-present{outline-color:#6b9657}
html .tutorial-cell.target.origin-absent{outline-color:#c7a753!important}
html .word-complete{animation-name:confirmed-word-glow!important}
@keyframes confirmed-word-glow{0%,100%{box-shadow:0 0 0 0 transparent}35%{box-shadow:0 0 0 3px var(--game-inset);transform:translateY(-2px)}70%{box-shadow:0 0 0 1px var(--game-inset)}}

.game-color-items{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.game-color-items>span{display:flex;align-items:center;gap:8px;font-size:12px}
.palette-swatch{display:grid;place-items:center;flex:none;position:relative;width:26px;height:26px;border-radius:5px;font:700 15px Arial,Helvetica,sans-serif}
.palette-swatch.red{background:var(--red);color:transparent;-webkit-mask-image:var(--letter-cutout);mask-image:var(--letter-cutout);mask-size:100% 100%;mask-repeat:no-repeat}
@media(max-width:520px){.game-color-items>span{flex-direction:column}}
/* Intended permanent position: after the counter, before the play surface. */
.game-heading{margin-bottom:14px}
.game-color-legend{width:min(100%,460px);margin:0 auto 18px;color:var(--theme-muted)}
.game-color-legend .game-color-items{gap:14px}
.game-color-legend .game-color-items>span{justify-content:center;font-size:11px;gap:7px;white-space:nowrap}
.game-color-legend .palette-swatch{width:26px;height:26px;border-radius:5px;font-size:15px}
.game-color-legend .palette-swatch.correct::after{inset:3px;border-width:1px;border-radius:2px}
@media(max-width:520px){.game-color-legend{margin-bottom:14px}.game-color-legend .game-color-items{gap:6px}.game-color-legend .game-color-items>span{font-size:10px;gap:5px}.game-color-legend .palette-swatch{width:24px;height:24px;font-size:14px}}

/* The legend is visible only inside the open keyboard. */
.keyboard-panel .game-color-legend{width:min(100%,510px);margin:0 auto 12px}
.keyboard-panel .game-color-legend .game-color-items{gap:8px}
.keyboard-panel .game-color-legend .game-color-items>span{flex-direction:row;font-size:10px;gap:5px}
.keyboard-panel .game-color-legend .palette-swatch{width:20px;height:20px;font-size:12px;border-radius:4px}
.keyboard-panel .game-color-legend .palette-swatch.correct::after{inset:2px;border-width:1px;border-radius:2px}
@media(max-width:360px){.keyboard-panel .game-color-legend .game-color-items{gap:4px}.keyboard-panel .game-color-legend .game-color-items>span{font-size:9px;gap:4px}.keyboard-panel .game-color-legend .palette-swatch{width:18px;height:18px;font-size:11px}}

/* Four equal areas give each legend item and the close control the same rhythm. */
.keyboard-panel .keyboard-heading{
  --legend-gap:12px;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));
  align-items:center;gap:var(--legend-gap);min-height:40px;padding:0 6px;margin-bottom:12px;
}
#keyboard-color-slot{grid-column:1 / span 3;min-width:0}
#keyboard-color-slot .game-color-legend{width:100%;margin:0}
#keyboard-color-slot .game-color-items{grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--legend-gap)}
.keyboard-panel .game-color-legend .game-color-items>span{font-size:11px;gap:6px}
.keyboard-panel #close-keyboard{justify-self:center;min-width:44px;min-height:40px;width:44px;height:40px;padding:0}
@media(max-width:360px){
  .keyboard-panel .keyboard-heading{--legend-gap:8px;padding:0 4px}
  .keyboard-panel .game-color-legend .game-color-items>span{font-size:10px;gap:5px}
}

@media(prefers-reduced-motion:reduce){html .word-complete{animation:none!important;outline-color:var(--game-inset)}}

/* The optional palette also uses marks: a dot for nearby letters, two bars
   for distant letters, and an angled corner stroke for excluded letters.
   Marks sit below the glyph, inside the rounded body, clear of the tips.
   Correct letters retain their neutral inset frame in both palettes. */
html[data-contrast="high"]{
  --game-near:#0066b3;--game-near-ink:#ffffff;--game-near-line:#0066b3;
  --game-far:#ffc34d;--game-far-ink:#2b1b00;--game-far-line:#806000;
  --game-excluded:#252c36;--game-excluded-ink:#ffffff;
}
html[data-contrast="high"] :is(.cell-hint,.tutorial-note,.legend-tile)[data-hint-directions]::before{background-image:var(--hint-art-high,var(--hint-art))}
html[data-contrast="high"] :is(.cell-hint.present,.tutorial-note.present,.legend-tile.present,.history-letter.present,.hint-letter,.palette-swatch.present,.tutorial-cell.candidate.present,.tutorial-color-dot.present){color:var(--game-near-ink)}
html[data-contrast="high"] :is(.cell-hint.absent,.tutorial-note.absent,.legend-tile.absent,.history-letter.absent,.palette-swatch.absent,.tutorial-cell.candidate.absent,.tutorial-color-dot.absent){color:var(--game-far-ink)}
html[data-contrast="high"] :is(.cell-hint.excluded,.tutorial-note.excluded,.legend-tile.excluded,.history-letter.excluded,.palette-swatch.red,.tutorial-color-dot.excluded),
html[data-contrast="high"] .keyboard-panel .key.excluded{
  background:var(--game-excluded);color:var(--game-excluded-ink);border-color:var(--game-excluded-ink);
  -webkit-mask-image:none;mask-image:none;
}
html[data-contrast="high"] .keyboard-panel .key:is(.present,.absent,.excluded):disabled{opacity:1}
html[data-contrast="high"] .tutorial-cell.target.origin-present{outline-color:var(--game-near)}
html[data-contrast="high"] .tutorial-cell.target.origin-absent{outline-color:var(--game-far-line)!important}
html[data-contrast="high"] :is(.cell-hint,.tutorial-note,.legend-tile,.history-letter,.hint-letter,.palette-swatch,.key,.tutorial-cell.candidate,.tutorial-color-dot){position:relative}
html[data-contrast="high"] :is(.cell-hint.present,.tutorial-note.present,.legend-tile.present,.history-letter.present,.hint-letter,.palette-swatch.present,.key.present,.tutorial-cell.candidate.present,.tutorial-color-dot.present)::after{
  content:'';position:absolute;left:50%;bottom:17%;width:8%;height:8%;min-width:1px;min-height:1px;
  border:0;border-radius:50%;background:currentColor;transform:translateX(-50%);pointer-events:none;
}
html[data-contrast="high"] :is(.cell-hint.absent,.tutorial-note.absent,.legend-tile.absent,.history-letter.absent,.palette-swatch.absent,.key.absent,.tutorial-cell.candidate.absent,.tutorial-color-dot.absent)::after{
  content:'';position:absolute;left:50%;bottom:18%;width:36%;height:4%;min-height:1px;
  border:0;border-radius:0;background:linear-gradient(to right,currentColor 0 40%,transparent 40% 60%,currentColor 60% 100%);
  transform:translateX(-50%);pointer-events:none;
}
html[data-contrast="high"] :is(.cell-hint.excluded,.tutorial-note.excluded,.legend-tile.excluded,.history-letter.excluded,.palette-swatch.red,.key.excluded,.tutorial-color-dot.excluded)::after{
  content:'';position:absolute;right:11%;bottom:15%;width:18%;height:4%;min-height:1px;
  border:0;border-radius:0;background:currentColor;transform:rotate(-45deg);pointer-events:none;
}
