/* Mind Override games. They run inside a window body, which is opaque light
 * paper, so this is ink-on-light rather than the glass of the chrome around it.
 * The cards are the exception: they are deliberately loud, because their whole
 * point is colour against colour. */

.mg {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    height: 100%;
    min-height: 0;
    color: var(--jg-ink);
}

.mg-bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex: none;
}

.mg-how { font-size: 0.76rem; line-height: 1.35; color: var(--jg-muted); }

.mg-stat {
    font-family: var(--jg-mono);
    font-size: 0.66rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--jg-ink);
}

.mg-stage {
    container-type: size;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    overflow: auto;
}

.mg-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex: none;
    flex-wrap: wrap;
}

.mg-msg { font-size: 0.78rem; color: var(--jg-muted); flex: 1; min-width: 8rem; }
.mg-right { display: flex; align-items: center; gap: 0.5rem; flex: none; }

/* ---------- difficulty ---------- */

.mg-tiers { display: flex; border: 1px solid rgba(42, 46, 43, 0.28); border-radius: var(--r-pill); overflow: hidden; }

.mg-tiers button {
    font-family: var(--jg-mono);
    font-size: 0.58rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.3rem 0.5rem;
    border: 0;
    background: transparent;
    color: var(--jg-muted);
    cursor: pointer;
}

.mg-tiers button:not(:first-child) { border-left: 1px solid rgba(42, 46, 43, 0.18); }
.mg-tiers button.is-on { background: var(--jg-ink); color: var(--jg-paper); }
.mg-tiers button:disabled { opacity: 0.45; cursor: default; }

.mg-go {
    font-family: var(--jg-mono);
    font-size: 0.66rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    padding: 0.38rem 0.85rem;
    border: 1px solid var(--jg-ink);
    border-radius: var(--r-pill);
    background: var(--jg-ink);
    color: var(--jg-paper);
    cursor: pointer;
    flex: none;
}

.mg-go:disabled { opacity: 0.4; cursor: default; }
.mg-go:not(:disabled):hover { background: var(--jg-accent); border-color: var(--jg-accent); color: #2a2e2b; }

.ps-nochange {
    font-family: var(--jg-mono);
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.34rem 0.7rem;
    border: 1px dashed var(--jg-muted);
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--jg-ink);
    cursor: pointer;
    flex: none;
}

.ps-nochange:hover { border-style: solid; border-color: var(--jg-accent); }

/* ---------- grids ---------- */

.mg-grid {
    display: grid;
    grid-template-columns: repeat(var(--n), 1fr);
    gap: 5px;
    /* Square, and never larger than the stage in either direction. */
    width: min(100cqw, 100cqh, 20rem);
    aspect-ratio: 1;
    align-self: center;
}

.mg-cell {
    padding: 0;
    border: 1px solid rgba(42, 46, 43, 0.16);
    border-radius: 4px;
    background: rgba(42, 46, 43, 0.05);
    cursor: pointer;
    aspect-ratio: 1;
    transition: background 0.1s linear, border-color 0.1s linear;
}

/* Three results, three unmistakable states. Missed used to be a pale wash of
   the same amber as a live selection, which is the one pair you most need to
   tell apart afterwards. */
.mg-cell.is-on { background: var(--jg-accent); border-color: #c8862c; }
.mg-cell.is-right { background: #22c55e; border-color: #15803d; }
.mg-cell.is-wrong { background: #d92d20; border-color: #912018; }
.mg-cell.is-missed {
    background: repeating-linear-gradient(45deg,
        rgba(232, 163, 61, 0.55) 0 5px, rgba(232, 163, 61, 0.2) 5px 10px);
    border-color: var(--jg-accent);
}

.mg-grid-lg { gap: 7px; }

.mg-tile { display: grid; place-items: center; background: #fff; }
.mg-tile .mg-svg { width: 74%; height: 74%; }
.mg-tile.is-on { background: rgba(232, 163, 61, 0.32); }

.ls-stage { justify-content: center; gap: 0.8rem; }

.ls-size {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--jg-mono);
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--jg-muted);
}

.ls-size input { width: 7rem; }

/* ---------- memory match ----------
   Loud on purpose. Every ink is outlined in JS against its own luminance,
   because the card puts white on orange and yellow on white by design. */

.mm-stage { justify-content: flex-start; gap: 0.7rem; padding-top: 0.2rem; }
.mm-title { margin: 0; font-size: 0.82rem; color: var(--jg-muted); text-align: center; }
.mm-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.55rem; }

.mm-card {
    width: 9rem;
    min-height: 11.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    padding: 0.7rem 0.5rem;
    border: 2px solid rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.mm-back {
    background: #14181a;
    justify-content: center;
}

.mm-back span {
    font-family: var(--jg-display);
    font-size: 3.2rem;
    font-weight: 700;
    color: #fff;
}

/* Outlined with four shadows rather than a stroke. A stroke is drawn INTO the
   glyph, so at this size bold mono turns to mush — which is what made these
   read as smudges. --o is set per word from the ink's own luminance. */
.mm-word,
.mm-digit {
    text-shadow:
        -1px -1px 0 var(--o), 1px -1px 0 var(--o),
        -1px 1px 0 var(--o), 1px 1px 0 var(--o),
        0 2px 3px rgba(0, 0, 0, 0.35);
}

.mm-word {
    font-family: var(--jg-mono);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-align: center;
    line-height: 1.15;
}

.mm-mid {
    position: relative;
    width: 4.9rem;
    height: 4.9rem;
    display: grid;
    place-items: center;
}

.mm-mid > .mg-svg { width: 100%; height: 100%; }

.mm-inner {
    position: absolute;
    inset: 30%;
    display: grid;
    place-items: center;
}

.mm-inner .mg-svg { width: 100%; height: 100%; }

.mm-digit {
    position: absolute;
    font-family: var(--jg-display);
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1;
}

.mm-q {
    margin: 0;
    max-width: 30rem;
    text-align: center;
    font-family: var(--jg-mono);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1.45;
}

.mm-reveal {
    margin: 0;
    padding: 0.45rem 0.8rem;
    border-radius: 6px;
    background: #1b5e20;
    color: #fff;
    font-family: var(--jg-mono);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
}

/* ---------- quantum count ---------- */

.mg-canvas-wrap { justify-content: flex-start; width: 100%; }

.mg-canvas-wrap canvas {
    width: 100%;
    flex: 1;
    min-height: 0;
    border: 1px solid rgba(42, 46, 43, 0.14);
    border-radius: 6px;
    background: #fbfaf6;
}

/* ---------- answers ---------- */

.mg-answer { display: flex; gap: 0.4rem; align-items: center; flex: none; }
.mg-answer input:disabled { background: #eceae2; color: var(--jg-dim); }

.mg-clock {
    font-family: var(--jg-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    min-width: 2.2rem;
    text-align: right;
    color: var(--jg-muted);
}

.mg-clock.is-low { color: #c0392b; }

.mg-answer input {
    font: inherit;
    font-size: 0.88rem;
    padding: 0.38rem 0.6rem;
    width: 9rem;
    border: 1px solid rgba(42, 46, 43, 0.3);
    border-radius: 6px;
    background: #fff;
    color: var(--jg-ink);
}

.mg-answer-wide input { width: 14rem; }
.mg-answer input:focus { outline: 2px solid var(--jg-accent); outline-offset: 1px; }

.mg-answer button {
    font-family: var(--jg-mono);
    font-size: 0.64rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--jg-ink);
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--jg-ink);
    cursor: pointer;
}

.mg-answer button:hover { background: var(--jg-ink); color: var(--jg-paper); }

/* ---------- word flash ---------- */

.mg-word { gap: 1.4rem; }

.mg-big {
    font-family: var(--jg-display);
    font-weight: 700;
    font-size: clamp(1.3rem, 9cqw, 2.1rem);
    letter-spacing: 0.02em;
    text-align: center;
}

.mg-big.is-right { color: #15803d; }
.mg-big.is-wrong { color: #c0392b; }

@keyframes mg-pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
.mg-flash { animation: mg-pop 0.16s ease-out; }

.mg-choice { display: flex; gap: 0.6rem; }

.mg-choice button {
    font-family: var(--jg-mono);
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 0.45rem 0.95rem;
    border: 1px solid var(--jg-ink);
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--jg-ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.mg-choice button:disabled { opacity: 0.35; cursor: default; }
.mg-choice button:not(:disabled):hover { background: var(--jg-ink); color: var(--jg-paper); }

.mg-choice kbd {
    font-family: var(--jg-mono);
    font-size: 0.58rem;
    padding: 0.05rem 0.28rem;
    border: 1px solid currentColor;
    border-radius: 3px;
    opacity: 0.75;
}

/* ---------- transform puzzle ---------- */

.mg-rules { justify-content: flex-start; gap: 0.6rem; padding-top: 0.2rem; }

.mg-rulelist {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.28rem;
    width: min(100%, 19rem);
}

.mg-rulelist li {
    font-family: var(--jg-mono);
    font-size: 0.72rem;
    padding: 0.34rem 0.6rem;
    background: #fff;
    border: 1px solid rgba(42, 46, 43, 0.16);
    border-radius: 5px;
}

.mg-rulelist li b { color: var(--jg-accent); margin-right: 0.4rem; }

/* Master swaps a rule after you have read the book. It is marked, but only
   once it is too late to matter. */
.mg-rulelist li.is-mutated { border-color: #c0392b; box-shadow: inset 2px 0 0 #c0392b; }

.tp-inputs {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
}

.tp-inputs li {
    font-family: var(--jg-mono);
    font-size: 0.74rem;
    padding: 0.28rem 0.55rem;
    background: #2a2e2b;
    color: #f2efe4;
    border-radius: 5px;
}

.tp-inputs li b { color: var(--jg-accent); margin-right: 0.35rem; }

.mg-q {
    margin: 0;
    max-width: 28rem;
    text-align: center;
    font-family: var(--jg-display);
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.35;
}

/* ---------- narrow ---------- */

@media (pointer: coarse) {
    /* Five tiers plus a go button on one row is a lot of small targets. */
    .mg-tiers button { padding: 0.42rem 0.55rem; font-size: 0.6rem; }
    .mg-go { padding: 0.5rem 1rem; }
    .mg-choice button { padding: 0.6rem 1.1rem; }
    .mg-cell { min-width: 1.9rem; min-height: 1.9rem; }
}

@media (max-width: 700px) {
    .mg-how { display: none; }              /* the bar is for the clock here */
    .mg-bar { justify-content: flex-end; }
    .mg-foot { gap: 0.45rem; }
    .mg-msg { min-width: 100%; order: 3; }  /* its own line, under the controls */
    .mm-card { width: 7.4rem; min-height: 9.4rem; }
    .mm-mid { width: 3.9rem; height: 3.9rem; }
    .mg-answer-wide input { width: 100%; min-width: 7rem; }
    .mg-answer { width: 100%; }
}
