#game-root {
    --ms-accent: #10B981;
    --ms-accent-dark: #0c8d64;
    --ms-accent-light: #e3f9ef;
    --ms-accent-border: #a7f3d0;
    --ms-glass-bg: rgba(255, 255, 255, .62);
    --ms-glass-border: rgba(255, 255, 255, .45);
    /* Board palette modeled on the classic Minesweeper board: one flat gray
       for every tile, a white/dark-gray bevel to raise covered tiles, and a
       thin grid line between uncovered ones. */
    --ms-panel: #c9ced6;
    --ms-tile: #c9ced6;
    --ms-tile-hover: #d6dae1;
    --ms-open: #bcc2cb;
    --ms-gridline: #8e96a3;
    --ms-bevel-light: #ffffff;
    --ms-bevel-dark: #7d8594;
    --ms-exploded: #f87171;
    --ms-wrong-flag: #fde68a;
}

/*
 * The kwi-* modifier classes game.js passes to KidWorldIcons.svg() are only
 * ever *named* by the shared icon helper, never defined by it, so the
 * tier/status colors are given real values here, scoped to this game.
 */
#game-root .kwi-accent { color: var(--ms-accent); }
#game-root .kwi-success { color: #10B981; }
#game-root .kwi-danger { color: #EF4444; }
#game-root .kwi-trophy { color: #F59E0B; }
#game-root .kwi-stars { color: #8B5CF6; }
#game-root .kwi-thumbsup { color: #10B981; }
#game-root .kwi-lightning { color: #3B82F6; }
#game-root .kwi-smile { color: #F472B6; }
#game-root .kwi-muted { color: #cbd5e1; }

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

.ms-wrap {
    max-width: 480px;
    margin: 0 auto;
}

.ms-loading,
.ms-error {
    text-align: center;
    padding: 48px 16px;
}

.ms-loading-icon,
.ms-error-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.ms-loading-icon {
    animation: ms-pulse 1.2s ease-in-out infinite;
}

.ms-loading-text {
    font-size: 15px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.ms-error-text {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: #EF4444;
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
}

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

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

.ms-header-icon img {
    display: block;
    height: 38px;
    width: auto;
}

.ms-header-title {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.ms-levels {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.ms-level-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--ms-glass-border);
    border-radius: var(--kw-radius, 12px);
    background: var(--ms-glass-bg);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    transition: transform .15s ease, box-shadow .15s ease;
}

.ms-level-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 18px rgba(0, 0, 0, .14);
}

.ms-level-card:active {
    transform: translateY(-1px);
}

.ms-level-thumb {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 70px;
    font-size: 36px;
    background: linear-gradient(135deg, var(--ms-accent-light), var(--ms-accent-border));
    background-size: 70px 70px;
    background-repeat: no-repeat;
    background-position: center;
}

.ms-level-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 10px 16px;
}

.ms-level-name {
    font-size: 17px;
    font-weight: 800;
    color: var(--kw-text, #2D2A32);
    text-align: center;
}

.ms-level-age {
    font-size: 14px;
    font-weight: 700;
    color: var(--ms-accent-dark);
    background: var(--ms-accent-light);
    padding: 2px 10px;
    border-radius: 999px;
}

.ms-level-row {
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

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

.ms-level-pill-icon {
    display: inline-flex;
    line-height: 1;
}

.ms-level-pill-icon img {
    display: block;
    width: 14px;
    height: 14px;
    object-fit: cover;
    border-radius: 50%;
}

.ms-change-level-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--ms-glass-border);
    background: var(--ms-glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--ms-accent-dark);
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    padding: 6px 12px 6px 10px;
    transition: transform .1s ease, background .15s ease;
}

.ms-change-level-btn svg {
    width: 12px;
    height: 12px;
}

.ms-change-level-btn:hover {
    background: rgba(255, 255, 255, .8);
    transform: translateY(-1px);
}

.ms-change-level-btn:active {
    transform: translateY(0);
}

.ms-stat-row {
    justify-content: center;
    margin-bottom: 14px;
}

.ms-stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--ms-accent-light);
    color: var(--ms-accent-dark);
    border-radius: 999px;
    padding: 6px 14px;
    font-weight: 700;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.ms-stat-lives {
    gap: 3px;
}

.ms-control-row {
    justify-content: center;
    margin-top: 12px;
    margin-bottom: 0;
}

.ms-mode {
    display: inline-flex;
    background: var(--ms-glass-bg);
    border: 1px solid var(--ms-glass-border);
    border-radius: 999px;
    padding: 3px;
}

.ms-mode-btn {
    border: none;
    background: transparent;
    color: var(--ms-accent-dark);
    border-radius: 999px;
    padding: 7px 16px;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.ms-mode-btn-active {
    background: var(--ms-accent);
    color: #fff;
    box-shadow: 0 2px 0 var(--ms-accent-dark);
}

.ms-mode-btn:disabled {
    opacity: .5;
    cursor: default;
}

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

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

.ms-hint-btn:disabled {
    opacity: .45;
    cursor: default;
}

.ms-board-wrap {
    position: relative;
    max-width: 480px;
    margin: 0 auto;
    padding: 10px;
    background: var(--ms-panel);
    border: 3px solid;
    border-color: var(--ms-bevel-light) var(--ms-bevel-dark) var(--ms-bevel-dark) var(--ms-bevel-light);
    box-shadow: 0 3px 6px rgba(0, 0, 0, .18);
    text-align: center;
    box-sizing: border-box;
}

/* Sunken well the tiles sit in — the inverse bevel of the outer panel. */
.ms-grid {
    display: grid;
    width: 100%;
    container-type: inline-size;
    background: var(--ms-open);
    border: 3px solid;
    border-color: var(--ms-bevel-dark) var(--ms-bevel-light) var(--ms-bevel-light) var(--ms-bevel-dark);
    box-sizing: border-box;
    animation: ms-fade-in .25s ease;
    -webkit-user-select: none;
    user-select: none;
}

/* Every tile is the same color (no checkerboard); covered vs. uncovered is
   told apart purely by the raised bevel, like the classic board. The bevel
   width scales with the tile size (via the grid's container width) so a
   6x6 toddler board and a 12x12 tweens board both look proportioned. */
.ms-cell {
    --ms-bevel: max(2px, calc(100cqw / var(--ms-cols, 9) * .08));
    box-sizing: border-box;
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 0 solid transparent;
    border-radius: 0;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-weight: 900;
    line-height: 1;
    font-size: 16px;
    font-size: calc(100cqw / var(--ms-cols, 9) * .52);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.ms-cell-hidden {
    background: var(--ms-tile);
    border-width: var(--ms-bevel);
    border-color: var(--ms-bevel-light) var(--ms-bevel-dark) var(--ms-bevel-dark) var(--ms-bevel-light);
}

.ms-cell-hidden:hover {
    background: var(--ms-tile-hover);
}

.ms-cell-hidden:active {
    border-color: var(--ms-bevel-dark) var(--ms-tile) var(--ms-tile) var(--ms-bevel-dark);
}

/* Uncovered: flat, with a thin grid line on the top/left edge only, so
   neighboring uncovered cells share a single 1px line between them. */
.ms-cell-open {
    background: var(--ms-open);
    box-shadow: inset 1px 1px 0 var(--ms-gridline);
    cursor: default;
}

.ms-cell-open.ms-cell-exploded {
    background: var(--ms-exploded);
}

.ms-cell-open.ms-cell-wrong-flag {
    background: var(--ms-wrong-flag);
}

.ms-n1 { color: #1d4ed8; }
.ms-n2 { color: #15803d; }
.ms-n3 { color: #dc2626; }
.ms-n4 { color: #1e3a8a; }
.ms-n5 { color: #7f1d1d; }
.ms-n6 { color: #0f766e; }
.ms-n7 { color: #111827; }
.ms-n8 { color: #4b5563; }

.ms-cell.ms-cell-hint {
    box-shadow: inset 0 0 0 3px #3b82f6;
    animation: ms-hint-glow .5s ease-in-out 2;
}

.ms-shake {
    animation: ms-shake .4s ease;
}

.ms-tip {
    min-height: 20px;
    margin-top: 14px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.ms-done-card {
    text-align: center;
    background: var(--ms-glass-bg);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid var(--ms-glass-border);
    border-radius: var(--kw-radius, 12px);
    padding: 32px 20px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .12);
    animation: ms-pop .3s ease;
}

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

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

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

.ms-done-meta {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.ms-done-meta-item {
    background: var(--ms-accent-light);
    color: var(--ms-accent-dark);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
}

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

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

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

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

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

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

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

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

@keyframes ms-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes ms-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: .7; }
}

@keyframes ms-hint-glow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.25); }
}

@keyframes ms-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@media (max-width: 576px) {
    .ms-board-wrap {
        background: none;
        padding: 0;
        border: 0;
        box-shadow: none;
    }

    .ms-grid {
        border-radius: 3px;
    }
}
