.color-memory {
    --memory-ink: #20344b;
    --memory-muted: #53657a;
    --memory-accent: #185bb8;
    --memory-tile-frame: 8px;
    --memory-tile-frame-color: #ededed;
    --memory-tile-inner-radius: 6px;
    color: var(--memory-ink);
}
.color-memory, .color-memory * { box-sizing: border-box; }
.color-memory p, .color-memory h1, .color-memory h2 { padding: 0; }
.color-memory h1, .color-memory h2 { font-family: 'Open Sans', sans-serif; }
.color-memory [hidden] { display: none !important; }
div.content.color-memory { padding: clamp(16px, 4vw, 40px); max-width: 970px; }
.color-memory .memory-intro { margin-bottom: 28px; }
.color-memory .memory-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--memory-accent); margin-bottom: 10px; }
.color-memory h1 { font-size: clamp(25px, 4vw, 36px); line-height: 1.2; margin-bottom: 12px; letter-spacing: -.035em; }
.color-memory .memory-intro > p:last-child { color: var(--memory-muted); font-size: 15px; line-height: 1.7; }
.color-memory .memory-difficulty { border: 0; padding: 0; margin: 0; min-width: 0; }
.color-memory legend { font-size: 12px; font-weight: 700; margin-bottom: 10px; padding: 0; }
.color-memory .memory-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.color-memory .memory-options label { position: relative; cursor: pointer; min-width: 0; }
.color-memory .memory-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.color-memory .memory-options span { display: block; border: 1px solid #d6dee8; border-radius: 10px; padding: 12px; font-weight: 700; background: #fff; min-height: 68px; }
.color-memory .memory-options small { display: block; font-size: 11px; font-weight: 400; color: var(--memory-muted); margin-top: 5px; }
.color-memory .memory-options input:checked + span { border-color: var(--memory-accent); background: #eff5ff; box-shadow: inset 0 0 0 1px var(--memory-accent); }
.color-memory .memory-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 18px 0 24px; }
.color-memory .memory-round-label { color: var(--memory-muted); font-size: 12px; margin-right: auto; }
.color-memory.is-active .memory-intro { margin-bottom: 16px; }
.color-memory.is-active .memory-intro h1 { font-size: 25px; }
.color-memory.is-active .memory-intro p, .color-memory.is-active .memory-difficulty, .color-memory.is-active .memory-assist { display: none; }
.color-memory.is-active .memory-actions { margin-top: 0; }
.color-memory .memory-assist { display: grid; grid-template-columns: 22px 1fr; column-gap: 8px; align-items: center; min-height: 44px; font-size: 13px; cursor: pointer; }
.color-memory .memory-assist input { width: 20px; height: 20px; accent-color: var(--memory-accent); grid-row: span 2; margin: 0; }
.color-memory .memory-assist small { grid-column: 2; color: var(--memory-muted); font-size: 11px; line-height: 1.5; }
.color-memory button { font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.color-memory .memory-primary, .color-memory .memory-secondary { border-radius: 8px; min-height: 46px; padding: 12px 18px; font-weight: 700; font-size: 13px; }
.color-memory .memory-primary { color: #fff; background: var(--memory-accent); white-space: nowrap; }
.color-memory .memory-primary:hover { background: #10478f; }
.color-memory .memory-secondary { color: var(--memory-ink); background: #e9eff7; }
.color-memory .memory-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0; padding: 17px 0; }
.color-memory .memory-stats div { margin: 0; padding-left: 20px; border-left: 1px solid #e2e8f0; }
.color-memory .memory-stats div:first-child { padding-left: 0; border: 0; }
.color-memory .memory-stats span { display: block; color: var(--memory-muted); font-size: 11px; margin-bottom: 5px; }
.color-memory .memory-stats strong { display: block; font-size: clamp(16px, 3vw, 23px); font-weight: 700; font-variant-numeric: tabular-nums; }
.color-memory .memory-status { min-height: 54px; display: flex; align-items: center; justify-content: center; padding: 12px 0; color: var(--memory-muted); text-align: center; font-size: 13px; }
.color-memory .memory-stage { background: #f4f7fb; border: 1px solid #e5ebf3; border-radius: 14px; padding: clamp(10px, 2.5vw, 24px); }
.color-memory .memory-welcome { text-align: center; padding: 25px 0; }
.color-memory .memory-swatches { display: flex; justify-content: center; margin-bottom: 24px; }
.color-memory .memory-swatches span { width: 55px; height: 65px; border: 3px solid #fff; border-radius: 10px; background: #087e78; transform: rotate(-12deg); box-shadow: 0 3px 8px #20344b18; }
.color-memory .memory-swatches span:nth-child(2) { background: #f3d547; transform: translateY(-6px); margin-left: -8px; }
.color-memory .memory-swatches span:nth-child(3) { background: #be123c; transform: rotate(12deg); margin-left: -8px; }
.color-memory .memory-welcome h2 { font-size: 18px; margin-bottom: 10px; }
.color-memory .memory-welcome p { font-size: 13px; line-height: 1.8; color: var(--memory-muted); }
.color-memory .memory-welcome .memory-hint { margin-top: 16px; font-size: 12px; }
.color-memory .memory-board {
    --memory-columns: 3;
    --memory-reference-width: 600px;
    --memory-gap: 22px;
    --memory-reference-gap: clamp(8px, 1.5vw, 14px);
    display: grid;
    grid-template-columns: repeat(var(--memory-columns), minmax(0, 1fr));
    gap: var(--memory-gap);
    width: 100%;
    /* Enlarge the original cards by 20%, then add the approved airy gaps.
       The available container width naturally limits card growth on phones. */
    max-width: calc((var(--memory-reference-width) - (var(--memory-columns) - 1) * var(--memory-reference-gap)) * 1.2 + (var(--memory-columns) - 1) * var(--memory-gap));
}
.color-memory .memory-board[data-difficulty="easy"] { --memory-reference-width: 440px; }
.color-memory .memory-board[data-difficulty="hard"] { --memory-columns: 4; }
.color-memory .memory-card { position: relative; width: 100%; min-width: 44px; min-height: 44px; aspect-ratio: 1; border-radius: calc(var(--memory-tile-frame) + var(--memory-tile-inner-radius)); border: var(--memory-tile-frame) solid var(--memory-tile-frame-color); background: #e2eaf5; transition: background-color .16s; display: grid; place-items: center; }
.color-memory .memory-card::before { content: ''; position: absolute; width: 20px; height: 20px; border: 2px solid #8b9fb9; border-radius: 5px; transform: rotate(45deg); }
.color-memory .memory-card:hover:not(.is-revealed) { background: #d5e2f4; }
.color-memory .memory-card.is-revealed { background: var(--card-color); }
.color-memory .memory-card.is-revealed::before { display: none; }
.color-memory .memory-card.is-matched::after { content: '✓'; position: absolute; right: calc(-1 * var(--memory-tile-frame)); bottom: calc(-1 * var(--memory-tile-frame)); background: #fff; color: #20344b; border: 1px solid #d0dbea; border-radius: 50%; width: 18px; height: 18px; font-size: 12px; font-weight: 700; line-height: 16px; }
.color-memory .memory-card[aria-disabled="true"] { cursor: default; }
.color-memory .memory-card:disabled { opacity: 1; cursor: default; }
.color-memory .memory-card-letter:not(:empty) { display: grid; place-items: center; background: #fff; color: #20344b; border-radius: 50%; width: 30px; height: 30px; max-width: 100%; max-height: 100%; font-size: 17px; font-weight: 700; }
.color-memory .memory-result { margin-bottom: 20px; border: 1px solid #bfd3ee; border-radius: 12px; padding: 24px; background: #f3f7fe; text-align: center; }
.color-memory .memory-result h2 { font-size: 25px; margin-bottom: 10px; }
.color-memory .memory-result p { line-height: 1.7; }
.color-memory .memory-result-best { font-size: 12px; color: var(--memory-muted); margin-top: 8px; }
.color-memory .memory-result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.color-memory .memory-board-toggle { display: block; margin: 16px auto 0; }
.color-memory .memory-notice { padding: 15px; background: #fff4cf; border-radius: 8px; }
@media (min-width: 540px) {
    .color-memory .memory-board[data-difficulty="medium"] { --memory-columns: 4; }
    .color-memory .memory-board[data-difficulty="hard"] { --memory-columns: 6; }
}
@media (max-width: 539px) {
    .color-memory .memory-board { --memory-gap: 16px; }
}
@media (max-width: 450px) {
    .color-memory .memory-actions { flex-direction: column; align-items: stretch; gap: 12px; }
    .color-memory .memory-options span { padding: 10px 7px; }
    .color-memory .memory-options small { font-size: 10px; }
    .color-memory .memory-stats div { padding-left: 10px; }
    .color-memory .memory-result { padding: 20px 12px; }
    .color-memory.is-active .memory-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .color-memory.is-active .memory-round-label { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
    .color-memory .memory-card { transition: none; }
}
.color-memory .memory-games-link { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 8px; color: #3558b4; font-size: 14px; }
.color-memory .memory-games-link:focus-visible { outline: 3px solid #3558b4; outline-offset: 3px; border-radius: 3px; }
