/* Turing Machine — blueprint / proto-computer theme.
   Layout mirrors orapa: fixed topbar, swappable screens, modal overlays. */

:root {
    --bg-color:        #0e1622;
    --surface-color:   #182333;
    --surface-elev:    #233244;
    --surface-2:       #2c3e57;
    --primary-color:   #00d4aa;
    --primary-hover:   #4be6c5;
    --accent-color:    #ffb74d;
    --text-color:      #e8f0fb;
    --text-muted:      rgba(232, 240, 251, 0.62);
    --text-dim:        rgba(232, 240, 251, 0.4);
    --border-color:    #2c3e57;
    --border-soft:     rgba(0, 212, 170, 0.18);
    --ok-color:        #4caf50;
    --fail-color:      #ef5350;
    --warn-color:      #ffb74d;

    --color-blue:      #1e88e5;
    --color-yellow:    #ffd54f;
    --color-purple:    #ab47bc;

    --font-display:    'Georgia', 'Times New Roman', serif;
    --font-family:     -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono:       'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.6);
    --glow-primary: 0 0 18px rgba(0, 212, 170, 0.35);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body {
    background:
        radial-gradient(ellipse at top, rgba(0, 212, 170, 0.05), transparent 60%),
        radial-gradient(ellipse at bottom, rgba(30, 136, 229, 0.04), transparent 60%),
        var(--bg-color);
}

#app {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    margin: 0 auto;
    background-color: var(--surface-color);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

[hidden] { display: none !important; }

/* --- Topbar --- */
#topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 0.4rem;
    padding: 0.25rem 0.85rem;
    min-height: 48px;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    z-index: 500;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
#topbar-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.topbar-logo {
    width: 38px; height: 30px;
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}
#topbar-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--primary-color);
    letter-spacing: 3px;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
#topbar-actions {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.topbar-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    width: 36px; height: 36px;
    border-radius: 4px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.topbar-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: rgba(0, 212, 170, 0.08);
}

/* --- Screens --- */
#screens {
    flex: 1;
    position: relative;
    min-height: 0;
}
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.25rem;
    background:
        radial-gradient(ellipse at top, rgba(0, 212, 170, 0.04), transparent 70%),
        var(--bg-color);
    overflow-y: auto;
}
.screen.hidden { display: none; }
/* Vertically center content WHEN it fits — but never clip overflow behind the
   topbar. justify-content:center on a flex container pushes overflow above
   the start edge, so for screens that can outgrow the viewport (end screen
   especially) we use safe centering instead. */
.v-center {
    justify-content: safe center;
    overflow-y: auto;
}

.screen-content {
    text-align: center;
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* --- Main menu logo --- */
.logo-wrap {
    margin: 1rem 0 0.25rem;
    width: 280px;
    max-width: 80%;
}
.title-logo {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5));
    animation: logo-breathe 3.6s ease-in-out infinite;
}
@keyframes logo-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}

.title {
    font-family: var(--font-display);
    font-size: 2.8rem;
    font-weight: 400;
    letter-spacing: 3px;
    color: var(--primary-color);
    margin-top: 0.5rem;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4), 0 0 24px rgba(0, 212, 170, 0.25);
}
.title::after {
    content: '';
    display: block;
    width: 60px;
    height: 1px;
    margin: 0.6rem auto 0;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}
.subtitle {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--primary-color);
    letter-spacing: 2px;
    margin-bottom: 0.25rem;
}
.byline {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}
.level-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}
#intro-rules {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 520px;
}

/* --- Buttons --- */
.menu-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
    margin-top: 0.5rem;
}
.menu-buttons.vertical {
    flex-direction: column;
    width: 100%;
    max-width: 380px;
}
.menu-buttons button,
.ctrl-btn {
    background: var(--surface-elev);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.7rem 1.4rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}
.ctrl-btn .btn-icon { flex-shrink: 0; }
.menu-buttons button:hover,
.ctrl-btn:hover {
    background: var(--surface-2);
    border-color: var(--primary-color);
    color: var(--primary-hover);
    box-shadow: var(--glow-primary);
}
.menu-buttons button.btn-back,
.ctrl-btn.btn-back {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-muted);
}
.menu-buttons button.btn-back:hover,
.ctrl-btn.btn-back:hover {
    color: var(--text-color);
    box-shadow: none;
}
.menu-buttons button.primary,
.ctrl-btn.primary {
    background: linear-gradient(180deg, #00d4aa, #00a386);
    color: #08231e;
    border-color: #00a386;
    font-weight: 600;
}
.menu-buttons button.primary:hover,
.ctrl-btn.primary:hover {
    color: #08231e;
    filter: brightness(1.08);
    box-shadow: 0 4px 12px rgba(0, 212, 170, 0.4), var(--glow-primary);
}
.menu-buttons button.danger,
.ctrl-btn.danger {
    color: var(--fail-color);
    border-color: rgba(239, 83, 80, 0.35);
}
.menu-buttons button.danger:hover,
.ctrl-btn.danger:hover {
    background: rgba(239, 83, 80, 0.08);
    box-shadow: 0 0 16px rgba(239, 83, 80, 0.2);
}
.menu-buttons button:disabled,
.ctrl-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Classic-verifiers stepper above the level options. */
.classic-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    background: var(--surface-elev);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.55rem 0.9rem;
    margin: 0.4rem auto 0.85rem;
    max-width: 380px;
}
.classic-stepper .cv-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.classic-stepper .cv-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.classic-stepper .cv-count {
    min-width: 1.6em;
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* Section separator in the level-options list (e.g. "Others" between
   the standard levels and the custom / create-game-for-my-number ones). */
.level-section-sep {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0.4rem 0 0.2rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 1.5px;
    font-family: var(--font-display);
}
.level-section-sep .sep-line {
    flex: 1 1 auto;
    height: 1px;
    background: var(--border-color);
}
.level-section-sep .sep-label { white-space: nowrap; }

/* "Create game for my number" modal layout — dial row + level picker. */
#mycode-dials {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 0.6rem 0;
    flex-wrap: wrap;
}
.mycode-level-pick {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 0.4rem 0 0.6rem;
    flex-wrap: wrap;
}
.mycode-level-pick .mycode-lv {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    color: var(--text-color);
    font-size: 0.95rem;
}
.mycode-level-pick .mycode-lv input { accent-color: var(--primary-color); }
#mycode-classic-stepper { margin: 0.4rem auto; }

/* level option cards on level select */
.level-option {
    text-align: left;
    padding: 0.85rem 1.1rem !important;
    position: relative;
    padding-right: 2.6rem !important;
    /* Override .menu-buttons button's inline-flex row layout so the
       <strong> label and <span> description stack vertically. */
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
}
.level-option strong {
    display: block;
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 0.2rem;
}
.level-option span:not(.level-info-icon) {
    display: block;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.35;
    text-align: center;
}
/* Magnifier icon on the right of each level option. Acts as its own
   click target — stops propagation so it doesn't start the game. */
.level-info-icon {
    position: absolute;
    top: 50%;
    right: 0.7rem;
    transform: translateY(-50%);
    width: 28px; height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.level-info-icon:hover {
    background: rgba(0, 212, 170, 0.12);
    color: var(--primary-color);
}

/* Level-info modal: list of every verifier card available in the level. */
.level-info-content {
    max-width: 760px;
    width: 90vw;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
}
#level-info-body {
    overflow-y: auto;
    flex: 1 1 auto;
    margin-top: 0.4rem;
    padding-right: 0.25rem;
}
.level-info-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    counter-reset: lvcard;
}
.lvcard-num {
    font-family: var(--font-display);
    color: var(--text-muted);
    font-weight: 700;
    min-width: 1.7em;
    text-align: right;
    flex-shrink: 0;
}
.lvcard {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    background: var(--surface-elev);
}
.lvcard-body {
    flex: 1 1 auto;
    min-width: 0;
}
.lvcard-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}
.lvcard-topic {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.95rem;
}
.lvtag {
    font-family: var(--font-display);
    font-size: 0.62rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}
.lvtag-multi { background: rgba(255, 213, 79, 0.15); color: var(--color-yellow); }
.lvtag-hp    { background: rgba(255, 100, 100, 0.18); color: var(--fail-color); }

/* Inline "color" placeholder on colorParam cards in the level-info modal —
   visually distinct so the player reads the rule as parametric over color. */
.color-placeholder {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.78em;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: linear-gradient(90deg,
        var(--color-blue) 0%, var(--color-blue) 33%,
        var(--color-yellow) 33%, var(--color-yellow) 66%,
        var(--color-purple) 66%, var(--color-purple) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    font-weight: 700;
    padding: 0 0.15em;
    border: 1px dashed var(--border-color);
    border-radius: 3px;
    vertical-align: 0;
}
.lvcard-opts {
    list-style: disc;
    margin: 0;
    padding-left: 1.2rem;
    color: var(--text-color);
    font-size: 0.86rem;
    line-height: 1.5;
}

/* --- Game Screen --- */
#screen-game {
    padding: 0.75rem 1rem 1rem;
    align-items: stretch;
}
#game-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.25rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
    font-size: 0.92rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 0.5rem;
}
#game-info .sep { margin: 0 0.5rem; color: var(--text-dim); }
#info-level    { color: var(--accent-color); font-weight: 600; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 0.18em; }
#info-level:hover { color: var(--primary-color); }

/* Expected-effort modal: 2-column rows of label + value, like a stat sheet. */
.expected-list {
    list-style: none;
    padding: 0;
    margin: 0.6rem 0 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.expected-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface-elev);
}
.expected-row.highlight {
    border-color: var(--primary-color);
    background: rgba(0, 212, 170, 0.08);
}
.expected-label { color: var(--text-muted); font-size: 0.88rem; }
.expected-val   { color: var(--text-color); font-weight: 700; font-family: var(--font-display); }
#info-round    { color: var(--primary-color); font-weight: 600; }
#info-questions { color: var(--text-color); }

#game-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.section-title {
    font-family: var(--font-display);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    font-weight: 400;
}

/* --- Verifier cards row --- */
#verifier-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.85rem;
}
.verifier-card {
    background: var(--surface-elev);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.8rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    position: relative;
    max-width: 100%;
    box-sizing: border-box;
    /* Width is set per-render by ui.js → _equalizeVerifierCardWidths so every
       card is exactly as wide as the widest one (driven by the longest
       unwrapped vqlog row / vtopic). flex: 0 0 auto so the cards don't
       grow or shrink off that measured width. */
    flex: 0 0 auto;
}
.verifier-card .vcard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 0.45rem;
}
.verifier-card .vletter {
    font-family: var(--font-display);
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 600;
    width: 32px; height: 32px;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 212, 170, 0.08);
}
.verifier-card .vtopic {
    flex: 1;
    margin-left: 0.55rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.25;
    white-space: nowrap;
}
.verifier-card .vbtn {
    background: var(--surface-2);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 0.32rem 0.55rem;
    font-size: 0.78rem;
    cursor: pointer;
    margin-left: 0.25rem;
    transition: all 0.15s;
}
.verifier-card .vbtn:hover:not(:disabled) {
    background: var(--primary-color);
    color: var(--bg-color);
    border-color: var(--primary-color);
}
.verifier-card .vbtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    /* Keep hover events firing so the native `title` tooltip showing
       WHY the button is disabled actually appears (some browsers
       suppress mouseover on disabled buttons entirely). */
    pointer-events: auto;
}

.verifier-card .voptions {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.verifier-card .vopt {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.32rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
    user-select: none;
    transition: background 0.15s;
}
.verifier-card .vopt .preview {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 0.35rem;
    line-height: 1;
}
.verifier-card .vopt .preview.pass {
    color: var(--color-yellow);
}
.verifier-card .vopt .preview .arrow-svg {
    width: 1.1em;
    height: 1.1em;
    display: block;
    filter: drop-shadow(0 0 4px rgba(255, 213, 79, 0.35));
}
.verifier-card .vopt .preview.hidden-preview { display: none; }
/* Confirmed rows used to be filled with green tint, but the marker (left ✓)
   already carries that signal — the row itself stays neutral so the live
   yellow arrow can still appear on it like on any other option. */
/* Inline color-name substitute. Sized to sit naturally inside running text;
   --color-X vars feed the per-name modifier classes. */
.color-dot {
    display: inline-block;
    width: 0.85em; height: 0.85em;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.45);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) inset;
    vertical-align: -0.08em;
    margin: 0 0.1em;
}
.color-dot.blue   { background: var(--color-blue); }
.color-dot.yellow { background: var(--color-yellow); }
.color-dot.purple { background: var(--color-purple); }

/* Proposal chip rows (vqlog, notes table, deduction modal): a colored
   dot tagging each color slot, no separator between slots. */
.proposal-chips { display: inline-flex; gap: 0.45rem; align-items: baseline; }
.proposal-chips .pchip { display: inline-flex; gap: 0.15rem; align-items: baseline; }

/* Settings modal — list of toggleable settings. */
.settings-list {
    list-style: none;
    padding: 0;
    margin: 0.6rem 0 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-elev);
}
.settings-label { flex: 1 1 auto; cursor: pointer; }
.settings-label strong { display: block; color: var(--text-color); margin-bottom: 0.15rem; }
.settings-label .hint  { display: block; color: var(--text-muted); font-size: 0.82rem; }
/* iOS-style slider toggle. The native checkbox is visually hidden but
   still focusable — keyboard users can tab to it and toggle with space. */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
    cursor: pointer;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 26px;
    transition: background 0.2s, border-color 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--text-dim);
    border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--primary-color);
    border-color: var(--primary-color);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translate(20px, -50%);
    background: #fff;
}
.toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* OR divider between the two halves of a combo card's option list. */
.verifier-card .vopt-or-sep {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.2rem 0;
    padding: 0 0.25rem;
    cursor: default;
    user-select: none;
}
.verifier-card .vopt-or-sep .or-sep-line {
    flex: 1 1 auto;
    height: 1px;
    background: var(--border-color);
}
.verifier-card .vopt-or-sep .or-sep-label {
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    background: rgba(0, 212, 170, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 0.05rem 0.45rem;
}

/* Hand-set user marker — clickable checkbox on the LEFT of each option,
   in front of the auto-deduction marker. Cycles empty → ✓ → ✗ → ?. */
.verifier-card .vopt .user-marker {
    width: 16px; height: 16px;
    border: 1.5px solid var(--text-dim);
    border-radius: 3px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-color);
    background: rgba(0, 0, 0, 0.18);
    user-select: none;
    transition: transform 0.1s ease, background 0.15s;
}
.verifier-card .vopt .user-marker:hover {
    transform: scale(1.18);
    background: rgba(255, 255, 255, 0.06);
}
.verifier-card .vopt .user-marker.um-check {
    color: var(--ok-color);
    border-color: var(--ok-color);
    background: rgba(0, 212, 170, 0.12);
}
.verifier-card .vopt .user-marker.um-cross {
    color: var(--fail-color);
    border-color: var(--fail-color);
    background: rgba(255, 100, 100, 0.12);
}
.verifier-card .vopt .user-marker.um-question {
    color: var(--color-yellow);
    border-color: var(--color-yellow);
    background: rgba(255, 213, 79, 0.12);
    font-weight: 700;
}

.verifier-card .vopt .marker {
    width: 14px; height: 14px;
    border: 1.5px solid var(--text-dim);
    border-radius: 3px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    line-height: 1;
    cursor: help;
    transition: transform 0.1s ease;
}
.verifier-card .vopt.confirmed .marker:hover,
.verifier-card .vopt.passed .marker:hover,
.verifier-card .vopt.ruledout .marker:hover {
    transform: scale(1.25);
}
.verifier-card .vopt.confirmed .marker,
.verifier-card .vopt.passed .marker {
    border-color: var(--ok-color);
    background: var(--ok-color);
    color: #fff;
}
.verifier-card .vopt.ruledout .marker {
    border-color: var(--fail-color);
    color: var(--fail-color);
}
/* The row itself is NOT visually ruled out — no strike-through, no dim. */
/* "Passed" (a past query confirmed this option) without yet being the sole
   surviving possibility — give it the green ✓ on the marker but keep the
   row's text styling neutral so it doesn't look like the criterion. */
.verifier-card .vopt.passed {
    color: var(--text-color);
}
.verifier-card .vqlog {
    margin-top: 0.25rem;
    font-size: 0.74rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
    border-top: 1px dashed var(--border-color);
    padding-top: 0.45rem;
    line-height: 1.4;
}
/* Each query row stays on one line — verifier-card's min-width: min-content
   uses this to derive the shared minimum width. */
.verifier-card .vqlog > div {
    white-space: nowrap;
}
.verifier-card .vqlog .ok   { color: var(--ok-color); }
.verifier-card .vqlog .fail { color: var(--fail-color); }
.verifier-card .vqlog .vqlog-rule { color: var(--text-color); }
.verifier-card .vqlog .vqlog-round {
    cursor: pointer;
    color: var(--primary-color);
    text-decoration: underline dotted;
    text-underline-offset: 0.18em;
}
.verifier-card .vqlog .vqlog-round:hover { color: var(--accent-color); }

/* Round-detail modal — proposal up top, verifier-card snapshot below. */
.rd-proposal {
    font-family: var(--font-display);
    font-size: 1.6rem;
    text-align: center;
    margin: 0.6rem 0 0.4rem;
}
.rd-proposal .proposal-chips { font-size: 1em; }
.rd-topic {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    margin: 0.4rem 0;
}
#round-detail-card {
    display: flex;
    justify-content: center;
    padding: 0.4rem 0;
}
/* Snapshot is read-only — disable the cursor: pointer / hover scaling on
   user-markers and auto-markers so the modal doesn't look interactive. */
.rd-snapshot .user-marker,
.rd-snapshot .marker { cursor: default; pointer-events: none; }
.rd-snapshot .user-marker:hover,
.rd-snapshot .marker:hover { transform: none; background: inherit; }
.rd-snapshot { width: auto; }

/* --- Extreme mode verifier layout --- */
/* Each extreme verifier wraps its TWO competing cards in .vcard-panes; each
   pane gets its own topic header and options list, separated by a divider so
   the player can see them as two distinct rules. */
.verifier-card.extreme .vcard-panes {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.verifier-card.extreme .vcard-pane {
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    background: rgba(255, 255, 255, 0.015);
    position: relative;
}
.verifier-card.extreme .vpane-topic {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    line-height: 1.25;
    white-space: nowrap;
}
/* Tag in the head explaining the slot is extreme. */
.verifier-card.extreme .vtopic-extreme {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-style: italic;
    white-space: normal;
}
.verifier-card.extreme .extreme-tag {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    background: var(--primary-color);
    color: var(--bg-color);
    padding: 0.05rem 0.4rem;
    border-radius: 3px;
    margin-right: 0.35rem;
    font-style: normal;
    vertical-align: 1px;
}
/* Dead pane — entire card has been ruled out as the active criterion. */
.verifier-card.extreme .vcard-pane.pane-dead {
    background: repeating-linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.02),
        rgba(255, 255, 255, 0.02) 6px,
        rgba(255, 100, 100, 0.06) 6px,
        rgba(255, 100, 100, 0.06) 12px);
    border-style: solid;
    border-color: rgba(255, 100, 100, 0.35);
    opacity: 0.72;
}
.verifier-card.extreme .vcard-pane.pane-dead .vpane-topic {
    text-decoration: line-through;
    color: var(--fail-color);
}
.verifier-card.extreme .vcard-pane.pane-dead .vopt-label {
    color: var(--text-dim);
}
/* "Greyed" marker for options on a dead pane that haven't been individually
   crossed — distinguishes pane-level elimination from per-option elimination. */
.verifier-card.extreme .vopt.pane-dead-opt .marker {
    border-color: var(--text-dim);
    color: var(--text-dim);
    background: transparent;
}

/* Pane tag in deduction modal subtitle ("card A" / "card B"). */
.pane-tag {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: rgba(0, 212, 170, 0.15);
    color: var(--primary-color);
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
}

/* End-screen decoy line under the active criterion. */
.end-decoy {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    margin-left: 1.3rem;
    font-style: italic;
}
/* End-screen "RED HERRING" tag on the extra Extreme verifier — and the
   muted explainer that follows. */
.end-herring .herring-tag {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.65rem;
    letter-spacing: 1.2px;
    background: rgba(255, 100, 100, 0.22);
    color: var(--fail-color);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    margin: 0 0.3rem;
    vertical-align: 1px;
}
.end-herring .herring-note {
    color: var(--text-muted);
    font-style: italic;
}

.end-decoy .decoy-tag {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.62rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    background: rgba(255, 100, 100, 0.18);
    color: var(--fail-color);
    padding: 0.05rem 0.32rem;
    border-radius: 3px;
    font-style: normal;
    margin-right: 0.35rem;
    vertical-align: 1px;
}

/* --- Proposal dials --- */
#proposal-dials, #submit-dials {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}
.dial {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    background: var(--surface-elev);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.5rem 0.6rem;
    min-width: 88px;
}
.dial-head {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}
.dial-label {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.dial-color {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.4);
    box-shadow: 0 2px 4px rgba(0,0,0,0.4) inset;
}
.dial.blue   .dial-color { background: var(--color-blue); }
.dial.yellow .dial-color { background: var(--color-yellow); }
.dial.purple .dial-color { background: var(--color-purple); }
.dial.blue   .dial-label { color: var(--color-blue); }
.dial.yellow .dial-label { color: var(--color-yellow); }
.dial.purple .dial-label { color: var(--color-purple); }
.dial-row {
    display: flex;
    gap: 0.2rem;
    align-items: center;
}
.dial-step {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
}
.dial-step:hover:not(:disabled) { background: var(--surface-2); }
.dial-step:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: var(--surface-color);
}
.dial.locked .dial-value { color: var(--text-muted); }
.dial.locked { opacity: 0.85; }
.dial-value {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-color);
    min-width: 24px;
    text-align: center;
}

.hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    text-align: center;
}

/* --- Note sheet table --- */
#notes-table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--surface-elev);
    max-width: 600px;
    margin: 0 auto;
}
#notes-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.86rem;
}
#notes-table th, #notes-table td {
    padding: 0.4rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}
#notes-table th {
    background: var(--surface-color);
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
    font-size: 0.78rem;
    text-transform: uppercase;
}
#notes-table .col-round  { width: 56px; color: var(--text-muted); }
#notes-table .prop-cell  { font-weight: 600; letter-spacing: 1px; }
/* .p<first-letter-of-color> — coloring is keyed by the slot name first letter
   so adding a color slot in GAME_CONFIG.colors only needs a matching rule
   here (and a --color-X var above). */
#notes-table .prop-cell .pb { color: var(--color-blue); }
#notes-table .prop-cell .py { color: var(--color-yellow); }
#notes-table .prop-cell .pp { color: var(--color-purple); }
#notes-table .res-ok { color: var(--ok-color); font-weight: 700; }
#notes-table .res-no { color: var(--fail-color); font-weight: 700; }
#notes-table .res-blank { color: var(--text-dim); }
#notes-table .col-verifier .verifier-tag {
    color: var(--primary-color);
    font-family: var(--font-display);
    font-weight: 600;
}
#notes-table .col-rule { text-align: center; vertical-align: middle; }
#notes-table .empty-row {
    padding: 0.9rem;
    color: var(--text-dim);
    font-style: italic;
}

/* --- Digit map (manual deduction aid) --- */
#digitmap-section .digitmap-hint {
    margin-top: -0.2rem;
    margin-bottom: 0.5rem;
    text-align: left;
}
#digitmap-wrap {
    display: block;
    max-width: 300px;
    width: 100%;
    margin: 0 auto;
    background: var(--surface-elev);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
}
#digitmap-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 6px;
    font-family: var(--font-mono);
    table-layout: fixed;
}
#digitmap-table .dm-th {
    text-align: center;
    padding: 0.3rem 0;
    white-space: nowrap;
}
#digitmap-table .dm-th .color-dot {
    width: 1.25em;
    height: 1.25em;
    margin: 0;
    vertical-align: middle;
}
#digitmap-table .dm-th .dm-th-label {
    font-size: 0.65rem;
    letter-spacing: 1px;
    font-weight: 600;
    margin-left: 0.35rem;
    vertical-align: middle;
}
#digitmap-table .dm-th.dm-blue   .dm-th-label { color: var(--color-blue); }
#digitmap-table .dm-th.dm-yellow .dm-th-label { color: var(--color-yellow); }
#digitmap-table .dm-th.dm-purple .dm-th-label { color: var(--color-purple); }
#digitmap-table .dm-cell {
    height: 48px;
    text-align: center;
    background: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1.3rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    /* Long-press on iOS/Android pops a selection callout / magnifier and
       starts dragging the cell text — disable both so the cell behaves as
       a button, not selectable text. */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.12s ease;
}
#digitmap-table .dm-cell:focus,
#digitmap-table .dm-cell:focus-visible {
    outline: none;
}
/* Hover effects only on devices with a real pointer — otherwise the touch
   "hover" state sticks after a tap, leaving a stale teal border around the
   last-touched cell. */
@media (hover: hover) {
    #digitmap-table .dm-cell:hover {
        border-color: var(--primary-color);
        color: var(--primary-color);
    }
}
#digitmap-table .dm-cell {
    position: relative;
    overflow: hidden;
}
#digitmap-table .dm-cell.off {
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.02);
    border-color: var(--border-color);
    cursor: pointer;
}
/* Two diagonal lines drawn as ::before / ::after to form a real X overlay.
   Using a tall, thin rotated stripe so the cross scales with the cell size
   rather than relying on text-decoration. */
#digitmap-table .dm-cell.off::before,
#digitmap-table .dm-cell.off::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -10%;
    width: 120%;
    height: 3px;
    background: var(--fail-color);
    transform-origin: center;
    pointer-events: none;
    box-shadow: 0 0 6px rgba(239, 83, 80, 0.4);
}
#digitmap-table .dm-cell.off::before { transform: translateY(-50%) rotate(28deg); }
#digitmap-table .dm-cell.off::after  { transform: translateY(-50%) rotate(-28deg); }
@media (hover: hover) {
    #digitmap-table .dm-cell.off:hover {
        color: var(--text-muted);
    }
}
/* Candidate ring (right-click on PC, long-press on phone). A blue circle
   inside the cell, drawn as a positioned ::before — but ::before is already
   used by .off for the X. To allow co-existence we use a box-shadow inset
   ring on .candidate so it composes cleanly with the cross. */
#digitmap-table .dm-cell.candidate {
    box-shadow:
        inset 0 0 0 2px var(--color-blue),
        0 0 8px rgba(30, 136, 229, 0.45);
    color: var(--color-blue);
    background: rgba(30, 136, 229, 0.08);
    border-radius: 999px;
}
@media (hover: hover) {
    #digitmap-table .dm-cell.candidate:hover {
        background: rgba(30, 136, 229, 0.15);
    }
}
/* When both flags are set, mute the cell so the candidate ring still reads
   but the digit is visibly retired. The X still draws on top. */
#digitmap-table .dm-cell.off.candidate {
    color: var(--text-dim);
    background: rgba(30, 136, 229, 0.03);
    box-shadow:
        inset 0 0 0 2px rgba(30, 136, 229, 0.45),
        none;
}

/* --- Game footer: proposal panel locked above the action buttons.
   Both sit outside #game-main so they stay pinned to the bottom while the
   verifiers / note-sheet / digit-map area scrolls behind them. --- */
#game-footer {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
}
#game-footer #proposal-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
}
#game-footer #proposal-section .section-title {
    margin-bottom: 0.2rem;
}
#game-footer #round-hint {
    margin-top: 0;
}
#game-controls {
    flex-shrink: 0;
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border-color);
}

/* --- End screen --- */
.end-content-container {
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
#end-title.win  { color: var(--ok-color); }
#end-title.lose { color: var(--fail-color); }
/* Expected-average line, sits above the ranking panel on the end screen. */
.end-expected {
    display: inline-flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: var(--surface-elev);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.88rem;
    color: var(--text-muted);
}
.end-expected .exp-label {
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-size: 0.7rem;
    color: var(--text-dim);
}
.end-expected .exp-vals {
    color: var(--text-color);
    font-family: var(--font-mono);
}

/* Funny ranking panel, only on win. Five tiers from "Turing's Heir" down to
   "Brute-Force Champion" — see classifyWin / WIN_TIERS in ui.js.

   Each tier carries an --rank-color set on the `.tier-N` modifier so the
   badge, title, and the highlighted ladder rung all light up in the same
   colour. Top tier = teal (primary), then yellow / orange / pinkish / red. */
.end-ranking.tier-0 { --rank-color: var(--primary-color); }
.end-ranking.tier-1 { --rank-color: #f1c40f; }
.end-ranking.tier-2 { --rank-color: #ffb74d; }
.end-ranking.tier-3 { --rank-color: #ff8a80; }
.end-ranking.tier-4 { --rank-color: #ef5350; }
.end-ranking.tier-5 { --rank-color: #ba68c8; } /* Lucky Gambler — purple/magic */
.end-ranking {
    width: 100%;
    max-width: 460px;
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.10), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--rank-color, var(--primary-color));
    border-radius: 12px;
    padding: 1rem 1.1rem;
    text-align: center;
    box-shadow: 0 0 18px color-mix(in srgb, var(--rank-color, var(--primary-color)) 35%, transparent);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.end-ranking .rank-badge {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-transform: uppercase;
}
.end-ranking .rank-title {
    font-family: var(--font-display);
    font-size: 1.7rem;
    color: var(--rank-color, var(--primary-color));
    letter-spacing: 1.5px;
    text-shadow: 0 0 14px color-mix(in srgb, var(--rank-color, var(--primary-color)) 40%, transparent);
}
.end-ranking .rank-flavor {
    font-style: italic;
    color: var(--text-color);
    font-size: 0.95rem;
    line-height: 1.4;
}
.end-ranking .rank-score {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    padding-bottom: 0.45rem;
    border-bottom: 1px dashed var(--border-color);
    text-align: left;
    line-height: 1.5;
}
.end-ranking .rank-score .score-hint {
    color: var(--text-dim);
}
.end-ranking .rank-score .score-combined {
    margin-top: 0.25rem;
}
.end-ranking .rank-score .score-combined strong {
    color: var(--rank-color, var(--primary-color));
    font-weight: 700;
}
.end-ranking .rank-ladder {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    text-align: left;
}
.end-ranking .rank-rung {
    display: grid;
    grid-template-columns: 1.6rem 1fr auto;
    align-items: baseline;
    gap: 0.55rem;
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-size: 0.9rem;
}
.end-ranking .rank-rung .rung-num {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-dim);
    text-align: right;
}
.end-ranking .rank-rung .rung-title { color: var(--text-color); }
.end-ranking .rank-rung .rung-threshold {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-dim);
}
/* Per-rung colour modifier — only the current one paints in its tier colour. */
.end-ranking .rank-rung.current.tier-0 { --rung-color: var(--primary-color); }
.end-ranking .rank-rung.current.tier-1 { --rung-color: #f1c40f; }
.end-ranking .rank-rung.current.tier-2 { --rung-color: #ffb74d; }
.end-ranking .rank-rung.current.tier-3 { --rung-color: #ff8a80; }
.end-ranking .rank-rung.current.tier-4 { --rung-color: #ef5350; }
.end-ranking .rank-rung.current.tier-5 { --rung-color: #ba68c8; }
/* Always emphasise the Lucky rung slightly — it's an outlier from the score
   scale, so a dashed border separates it visually from tiers 1–5. */
.end-ranking .rank-rung.lucky { border-top: 1px dashed var(--border-color); margin-top: 0.2rem; padding-top: 0.55rem; }
.end-ranking .rank-rung.lucky .rung-num { color: #ba68c8; }
.end-ranking .rank-rung.current {
    background: color-mix(in srgb, var(--rung-color) 14%, transparent);
    border-color: var(--rung-color);
    box-shadow: 0 0 10px color-mix(in srgb, var(--rung-color) 25%, transparent);
}
.end-ranking .rank-rung.current .rung-num,
.end-ranking .rank-rung.current .rung-title {
    color: var(--rung-color);
    font-weight: 600;
}
#end-stats { color: var(--text-muted); }
#end-solution-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.4rem;
}
.code-bead {
    width: 56px; height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    font-family: var(--font-mono);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.4), 0 4px 10px rgba(0,0,0,0.5);
}
.code-bead.blue   { background: var(--color-blue); }
.code-bead.yellow { background: var(--color-yellow); color: #2b1c00; }
.code-bead.purple { background: var(--color-purple); }
#end-criteria-list {
    list-style: none;
    width: 100%;
    text-align: left;
    background: var(--surface-elev);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
}
#end-criteria-list li {
    padding: 0.35rem 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 0.92rem;
}
#end-criteria-list li:last-child { border-bottom: none; }
#end-criteria-list .verifier-tag {
    display: inline-block;
    color: var(--primary-color);
    font-weight: 600;
    margin-right: 0.6rem;
    font-family: var(--font-display);
}
#end-share-section {
    width: 100%;
    text-align: left;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}
#end-share-section h4 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: 1px;
}

/* --- Modals --- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--surface-elev);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.modal-content h3 {
    font-family: var(--font-display);
    color: var(--primary-color);
    letter-spacing: 1.5px;
    font-weight: 400;
}
.modal-content p {
    color: var(--text-muted);
    line-height: 1.45;
    font-size: 0.92rem;
}
.rules-content { max-width: 600px; }
#rules-body p, #rules-body ol { margin-bottom: 0.65rem; }
#rules-body ol { padding-left: 1.5rem; }
#rules-body strong { color: var(--text-color); }
#rules-body .dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin: 0 2px -1px 0;
    border: 1px solid rgba(0,0,0,0.3);
}
#rules-body .dot.blue   { background: var(--color-blue); }
#rules-body .dot.yellow { background: var(--color-yellow); }
#rules-body .dot.purple { background: var(--color-purple); }
#rules-body .ok   { color: var(--ok-color); font-weight: 700; }
#rules-body .fail { color: var(--fail-color); font-weight: 700; }

.game-sheet-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.game-sheet-field label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.field-with-copy {
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
}
/* Single-line text input. We use <input type="text"> rather than <textarea>
   so there's never a scrollbar overlapping the text. Long URLs simply overflow
   inside the input — the user can scroll-by-cursor or just click Copy. */
.share-url-textarea {
    flex: 1;
    min-width: 0;
    height: 1.9rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 6px;
    padding: 0 0.55rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.9rem;   /* vertically center single line */
    outline: none;
}
.share-url-textarea:focus {
    border-color: var(--primary-color);
}
.copy-btn {
    flex-shrink: 0;
    background: var(--surface-2);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0 0.8rem;
    cursor: pointer;
    font-size: 0.78rem;
    height: 1.9rem;
}
/* Compact icon-only button — used for Copy / Share next to share fields. */
.icon-btn {
    flex-shrink: 0;
    width: 1.9rem;
    height: 1.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
}
.icon-btn:hover {
    background: var(--primary-color);
    color: var(--bg-color);
    border-color: var(--primary-color);
}
.icon-btn .icon {
    width: 0.95rem;
    height: 0.95rem;
    display: block;
}
.copy-btn:hover {
    background: var(--primary-color);
    color: var(--bg-color);
    border-color: var(--primary-color);
}
.error-msg {
    color: var(--fail-color);
    font-size: 0.85rem;
}

/* --- Custom level modal --- */
.custom-stepper-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin: 0.25rem 0 0.5rem;
}
.stepper-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.stepper-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.stepper-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.stepper-val {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    min-width: 1.6em;
    text-align: center;
    color: var(--primary-color);
}
.custom-status-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 1.8rem;
}
.custom-status {
    text-align: center;
    font-size: 0.92rem;
    padding: 0.4rem 0.2rem;
    color: var(--text-muted);
    margin: 0;
}
/* Reusable animated spinner. Spins forever via `spin` keyframes below. */
.spinner {
    display: inline-block;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid rgba(0, 212, 170, 0.25);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.custom-status.pending { color: var(--text-muted); font-style: italic; }
.custom-status.ok      { color: var(--ok-color); }
.custom-status.bad     { color: var(--fail-color); }
.custom-stats {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0.65rem;
    margin: 0.25rem 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
}
.custom-stats .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.2rem 0;
    border-bottom: 1px dashed var(--border-color);
}
.custom-stats .stat-row:last-child { border-bottom: none; }
.custom-stats .stat-row.highlight {
    border-bottom: none;
    padding-top: 0.4rem;
    margin-top: 0.15rem;
    border-top: 1px solid var(--border-color);
}
.custom-stats .stat-label {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.72rem;
}
.custom-stats .stat-val {
    font-family: var(--font-mono);
    color: var(--text-color);
    text-align: right;
}
.custom-stats .stat-row.highlight .stat-val {
    color: var(--primary-color);
    font-size: 1.05rem;
    font-weight: 600;
}

/* --- Deduction trace modal --- */
.ded-subtitle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    color: var(--text-color);
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
}
.ded-subtitle .verifier-tag {
    color: var(--primary-color);
    font-family: var(--font-display);
    font-weight: 600;
}
.ded-status {
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
    padding: 0.5rem 0;
}
.ded-status.is-ok { color: var(--ok-color); }
.ded-status.is-no { color: var(--fail-color); }
.ded-body { display: flex; flex-direction: column; gap: 0.6rem; }
.ded-explainer {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}
.ev-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.ev-list li {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0.55rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    flex-wrap: wrap;
}
.ev-list .ev-round { color: var(--text-muted); min-width: 4.5rem; }
.ev-list .ev-arrow { color: var(--text-dim); }
.ev-list .ev-result.ok   { color: var(--ok-color); font-weight: 700; }
.ev-list .ev-result.fail { color: var(--fail-color); font-weight: 700; }
.ev-list .ev-note {
    flex-basis: 100%;
    margin-left: 4.6rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-style: italic;
    font-family: var(--font-body);
}
.elim-list { display: flex; flex-direction: column; gap: 0.55rem; }
.elim-block {
    padding: 0.4rem 0.5rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 7px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.elim-block .elim-label {
    color: var(--text-color);
    font-size: 0.95rem;
}
.elim-block .ev-list li {
    background: rgba(0, 0, 0, 0.18);
}

/* --- Toast --- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    transform: translateX(-50%);
    background: var(--surface-2);
    color: var(--text-color);
    padding: 0.65rem 1.1rem;
    border-radius: 8px;
    border: 1px solid var(--primary-color);
    box-shadow: var(--shadow-md), var(--glow-primary);
    z-index: 2000;
    font-size: 0.92rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.toast.show {
    opacity: 1;
}

/* --- Responsive tweaks --- */
@media (max-width: 540px) {
    .title { font-size: 2.2rem; letter-spacing: 2px; }
    .dial { min-width: 76px; padding: 0.4rem 0.5rem; }
    .dial-value { font-size: 1.4rem; }
    .dial-step { width: 30px; height: 30px; font-size: 1.1rem; }
    #game-header { font-size: 0.85rem; }
    .ctrl-btn { padding: 0.55rem 0.9rem; font-size: 0.92rem; }
    .verifier-card { padding: 0.65rem 0.7rem; }
    .section-title { font-size: 0.9rem; }
}
