#game-root {
    --mch-accent: #10B981;
    --mch-accent-dark: #0e9c6f;
    --mch-accent-light: #e3f9ef;
    --mch-accent-border: #a7f3d0;
    border-radius: var(--kw-radius, 16px);
}

#game-root button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.kwg-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
}

.mch-wrap {
    max-width: 540px;
    margin: 0 auto;
}

.mch-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.mch-header-icon {
    display: flex;
    font-size: 18px;
    line-height: 1;
}

.mch-header-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--mch-accent);
}

/* ---- Setup screen ---- */

.mch-setup-card {
    background: #fff;
    border-radius: var(--kw-radius, 16px);
    padding: 20px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .07);
}

.mch-setup-section {
    margin-bottom: 20px;
}

.mch-setup-section-last {
    margin-bottom: 0;
}

.mch-setup-label {
    font-size: 13px;
    font-weight: 800;
    color: #888;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 10px;
}

.mch-opponent-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.mch-difficulty-grid,
.mch-side-grid,
.mch-theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.mch-time-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.mch-option-card,
.mch-difficulty-card,
.mch-side-card,
.mch-theme-card,
.mch-time-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    border: 2px solid var(--mch-accent-border);
    border-radius: var(--kw-radius, 14px);
    background: #fff;
    padding: 12px 8px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.mch-option-card:hover,
.mch-difficulty-card:hover,
.mch-side-card:hover,
.mch-theme-card:hover,
.mch-time-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 14px rgba(0, 0, 0, .1);
}

.mch-option-card.mch-option-selected,
.mch-difficulty-card.mch-option-selected,
.mch-side-card.mch-option-selected,
.mch-theme-card.mch-option-selected,
.mch-time-card.mch-option-selected {
    border-color: var(--mch-accent);
    background: var(--mch-accent-light);
}

.mch-option-selected::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    background: var(--mch-accent);
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mch-option-emoji {
    font-size: 22px;
    line-height: 1;
}

.mch-side-preview {
    font-size: 30px;
}

/* The king-chess icon's own artwork fills more of its 16x16 viewBox than
   this repo's other Bootstrap icons typically do, so it reads visually
   larger at the same 1em size - scaled down to optically match. */
.mch-icon-king {
    display: inline-block;
    transform: scale(.82);
}

/* Authentic tones sampled from the generated 3D piece renders (img/pieces/),
   so the small decorative king icon matches the real board pieces - plain
   near-white was invisible against this game's white card/chip
   backgrounds, so these lean warm/cream and dark walnut instead of paper
   white/near-black. filter (not text-shadow, which doesn't apply to SVG)
   adds a touch of the same carved-piece depth. */
.mch-icon-piece-w {
    color: #f0c775;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35));
}

.mch-icon-piece-b {
    color: #462308;
    filter: drop-shadow(0 1px 1px rgba(255, 255, 255, .15));
}

.mch-option-label {
    font-size: 13px;
    font-weight: 800;
    color: var(--kw-text, #2D2A32);
}

.mch-option-sub {
    font-size: 11px;
    color: #888;
    font-weight: 600;
}

.mch-difficulty-bullets {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    font-size: 11px;
    color: #777;
    font-weight: 600;
    line-height: 1.5;
}

.mch-difficulty-bullets li::before {
    content: '• ';
    color: var(--mch-accent);
}

.mch-start-btn {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 16px;
    padding: 14px;
    margin-top: 20px;
}

/* ---- Match screen ---- */

.mch-mode-row {
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.mch-mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--mch-accent-light);
    color: var(--mch-accent-dark);
    border-radius: 999px;
    padding: 5px 12px;
    font-weight: 700;
    font-size: 12px;
}

.mch-mode-pill-icon {
    display: inline-flex;
    line-height: 1;
}

.mch-change-setup-btn {
    border: none;
    background: none;
    color: var(--mch-accent-dark);
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    padding: 4px;
}

.mch-change-setup-btn:hover {
    color: var(--mch-accent);
}

.mch-players-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 10px;
}

.mch-player-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 92px;
    padding: 8px 14px;
    border-radius: 14px;
    background: #fff;
    border: 2px solid var(--mch-accent-border);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.mch-player-piece {
    font-size: 26px;
    line-height: 1;
}

.mch-player-name {
    font-size: 11px;
    font-weight: 800;
    color: #999;
}

.mch-clock {
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #999;
    margin-top: 2px;
}

.mch-clock-active {
    color: var(--mch-accent-dark);
}

.mch-clock-low {
    color: #ef4444;
}

.mch-player-chip.mch-player-active {
    border-color: var(--mch-accent);
    box-shadow: 0 0 0 2px var(--mch-accent-light) inset, 0 4px 10px rgba(16, 185, 129, .25);
    transform: translateY(-2px);
}

.mch-player-chip.mch-player-active .mch-player-name {
    color: var(--mch-accent-dark);
}

.mch-players-vs {
    font-size: 12px;
    font-weight: 800;
    color: #bbb;
}

.mch-toolbar {
    justify-content: center;
    margin-top: 14px;
    margin-bottom: 0;
}

.mch-tool-btn {
    border: none;
    background: var(--mch-accent-light);
    color: var(--mch-accent-dark);
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: transform .1s ease, background .15s ease;
}

.mch-tool-btn:hover:not(:disabled) {
    background: var(--mch-accent-border);
    transform: translateY(-1px);
}

.mch-tool-btn:disabled {
    opacity: .45;
    cursor: default;
}

/* ---- Board (3D-tilted by default; .mch-flat below strips the tilt for
   the 2D theme) ---- */

.mch-board-3d {
    perspective: 1000px;
    padding: 0 0 26px;
}

.mch-board-3d.mch-flat {
    perspective: none;
}

.mch-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    margin: 0 auto;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 20px 34px -12px rgba(0, 0, 0, .35), 0 2px 0 rgba(0, 0, 0, .15);
    transform: rotateX(14deg);
    transform-style: preserve-3d;
    border: 6px solid #5c3a21;
}

.mch-board-3d.mch-flat .mch-board {
    transform: none;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .15);
}

.mch-square {
    position: relative;
    aspect-ratio: 1;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mch-square-light {
    background: #f0d9b5;
}

.mch-square-dark {
    background: #b58863;
}

.mch-square::after {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 2px 3px rgba(255, 255, 255, .25), inset 0 -3px 4px rgba(0, 0, 0, .2);
    pointer-events: none;
}

.mch-piece-visual {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    transform: translateZ(6px);
    transition: transform .12s ease;
}

.mch-piece-img {
    width: 97%;
    height: 97%;
    object-fit: contain;
    filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .35));
    pointer-events: none;
}

.mch-piece {
    font-size: clamp(26px, 8vw, 46px);
    line-height: 1;
    pointer-events: none;
    user-select: none;
}

.mch-piece-w {
    color: #f8fafc;
    text-shadow: 0 1px 0 #000, 0 -1px 1px rgba(0, 0, 0, .4), 1px 2px 3px rgba(0, 0, 0, .5);
}

.mch-piece-b {
    color: #1f2937;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .25), 0 -1px 1px rgba(0, 0, 0, .6), 1px 2px 3px rgba(0, 0, 0, .35);
}

.mch-square.mch-selected {
    box-shadow: inset 0 0 0 3px var(--mch-accent);
}

.mch-square.mch-selected .mch-piece-visual {
    transform: translateZ(20px) scale(1.12);
}

.mch-square.mch-last-move {
    background-image: linear-gradient(0deg, rgba(250, 204, 21, .35), rgba(250, 204, 21, .35));
}

.mch-square.mch-check {
    background-image: linear-gradient(0deg, rgba(239, 68, 68, .55), rgba(239, 68, 68, .55));
    animation: mch-check-pulse .8s ease infinite alternate;
}

.mch-square.mch-legal-target::before {
    content: '';
    position: absolute;
    width: 26%;
    height: 26%;
    border-radius: 50%;
    background: rgba(16, 185, 129, .55);
    z-index: 1;
}

.mch-square.mch-legal-capture::before {
    content: '';
    position: absolute;
    inset: 6%;
    border-radius: 50%;
    box-shadow: inset 0 0 0 4px rgba(239, 68, 68, .65);
    z-index: 1;
}

.mch-square.mch-hint-from,
.mch-square.mch-hint-to {
    box-shadow: inset 0 0 0 3px #3b82f6;
}

/* ---- Promotion overlay ---- */

.mch-promotion-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}

.mch-promotion-overlay[hidden] {
    display: none;
}

.mch-promotion-card {
    background: #fff;
    border-radius: var(--kw-radius, 16px);
    padding: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

.mch-promotion-title {
    font-size: 14px;
    font-weight: 800;
    color: #888;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 12px;
}

.mch-promotion-choices {
    display: flex;
    gap: 10px;
}

.mch-promotion-choice {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--mch-accent-border);
    border-radius: 12px;
    background: #b58863;
    cursor: pointer;
    font-size: 30px;
    transition: transform .12s ease, border-color .12s ease;
}

.mch-promotion-choice:hover,
.mch-promotion-choice.mch-promotion-default {
    border-color: var(--mch-accent);
    transform: translateY(-2px);
}

/* ---- Done screen ---- */

.mch-done-card {
    text-align: center;
    background: #fff;
    border-radius: var(--kw-radius, 16px);
    padding: 32px 20px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .07);
    animation: mch-pop .3s ease;
    border: 2px solid transparent;
}

.mch-done-card.mch-done-win {
    border-color: var(--mch-accent-border);
    box-shadow: 0 3px 16px rgba(16, 185, 129, .22);
}

.mch-done-card.mch-done-draw {
    border-color: #fde68a;
}

.mch-done-card.mch-done-loss {
    border-color: #fecaca;
}

.mch-done-emoji {
    font-size: 56px;
    margin-bottom: 8px;
}

.mch-done-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--mch-accent-dark);
    margin-bottom: 8px;
}

.mch-done-score {
    font-size: 16px;
    font-weight: 600;
    color: #555;
    margin-bottom: 10px;
}

.mch-done-stars {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    font-size: 24px;
}

.mch-done-share {
    justify-content: center;
    margin-top: 16px;
}

.mch-done-actions {
    justify-content: center;
    margin-top: 20px;
}

.mch-btn-primary,
.mch-btn-secondary {
    border: none;
    padding: 12px 22px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    transition: transform .1s ease;
}

.mch-btn-primary {
    background: var(--mch-accent);
    color: #fff;
    box-shadow: 0 3px 0 var(--mch-accent-dark);
}

.mch-btn-primary:hover {
    transform: translateY(-1px);
}

.mch-btn-secondary {
    background: var(--mch-accent-light);
    color: var(--mch-accent-dark);
}

.mch-btn-secondary:hover {
    background: var(--mch-accent-border);
}

@keyframes mch-pop {
    0% { transform: scale(.7); }
    100% { transform: scale(1); }
}

@keyframes mch-check-pulse {
    0% { opacity: .7; }
    100% { opacity: 1; }
}

@media (max-width: 420px) {
    .mch-opponent-grid {
        grid-template-columns: 1fr;
    }

    .mch-difficulty-grid,
    .mch-side-grid,
    .mch-theme-grid,
    .mch-time-grid {
        grid-template-columns: 1fr;
    }

    .mch-board-3d {
        perspective: 700px;
    }

    .mch-board {
        transform: rotateX(9deg);
    }
}
