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

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

.sd-wrap {
    max-width: 900px;
    margin: 0 auto;
}

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

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

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

.sd-loading-text {
    font-size: 15px;
    color: #666;
}

.sd-error-text {
    font-size: 15px;
    font-weight: 700;
    color: #EF4444;
}

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

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

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

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

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

.sd-level-card {
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: var(--kw-radius, 16px);
    background: #fff;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
    transition: transform .15s ease, box-shadow .15s ease;
}

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

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

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

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

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

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

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

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

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

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

.sd-change-level-btn {
    border: none;
    background: none;
    color: var(--sd-accent-dark);
    text-decoration: underline;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    padding: 4px;
}

.sd-change-level-btn:hover {
    color: var(--sd-accent);
}

.sd-stat-row {
    justify-content: center;
    margin-bottom: 10px;
}

.sd-stat {
    background: var(--sd-accent-light);
    color: var(--sd-accent-dark);
    border-radius: 999px;
    padding: 6px 14px;
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
}

.sd-scene-title {
    text-align: center;
    font-size: 16px;
    font-weight: 800;
    color: var(--sd-accent-dark, #2D2A32);
    margin-bottom: 12px;
}

.sd-boards {
    position: relative;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    justify-content: center;
    animation: sd-fade-in .25s ease;
}

.sd-board {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    border-radius: var(--kw-radius, 16px);
    overflow: hidden;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .1);
    cursor: crosshair;
    background: #eef8f3;
}

.sd-board-img {
    display: block;
    width: 100%;
    height: 100%;
    /* fill, not cover/contain: guarantees the rendered image box exactly
       matches the board's own aspect-ratio box (set from scene.width /
       scene.height in game.js), which is what the marker percentage math
       in addMarker()/handleTap() assumes — any crop or letterboxing would
       throw off marker alignment even by a few pixels of mismatch. */
    object-fit: fill;
    user-select: none;
    -webkit-user-drag: none;
}

.sd-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.sd-marker {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-left: -15px;
    margin-top: -15px;
    border-radius: 50%;
    font-size: 18px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

.sd-marker-found {
    background: var(--sd-accent);
    color: #fff;
    animation: sd-pop .25s ease;
}

.sd-marker-wrong {
    background: #EF4444;
    color: #fff;
    animation: sd-pop .2s ease;
}

.sd-marker-missed {
    background: rgba(239, 68, 68, .85);
    color: #fff;
}

.sd-marker-hint {
    width: 44px;
    height: 44px;
    margin-left: -22px;
    margin-top: -22px;
    background: transparent;
    box-shadow: none;
    border: 3px solid #fbbf24;
    animation: sd-hint-glow 1s ease-in-out infinite;
}

.sd-toast {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, .75);
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    padding: 14px 22px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: sd-toast-pop .3s ease;
    pointer-events: none;
    white-space: nowrap;
    z-index: 3;
}

.sd-hint-row {
    justify-content: center;
    margin-top: 16px;
    margin-bottom: 0;
}

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

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

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

.sd-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: sd-pop .3s ease;
}

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

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

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

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

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

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

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

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

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

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

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

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

@keyframes sd-pop {
    0% { transform: scale(.4); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes sd-toast-pop {
    0% { transform: translate(-50%, -50%) scale(.85); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

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

@keyframes sd-hint-glow {
    0%, 100% { filter: brightness(1); opacity: .7; }
    50% { filter: brightness(1.4); opacity: 1; }
}

@media (max-width: 640px) {
    .sd-boards {
        flex-direction: column;
        align-items: stretch;
    }

    /* .sd-board is `flex: 1 1 0` for the desktop row layout, where the
       main axis is width (two boards splitting it evenly) and the
       aspect-ratio box only needs to determine height from that width. In
       this column layout the main axis flips to height, and a `0` flex-
       basis on the main axis means the item's height starts at 0 and only
       grows via flex-grow to fill leftover space in .sd-boards — which
       itself has no set height, so there's ~nothing to grow into and the
       aspect-ratio-derived height a plain block would get is never
       consulted. Overriding to `flex: none` here takes it out of that
       flex-sizing math entirely: width still stretches to 100% (from
       align-items:stretch above), and height then comes from the
       inline aspect-ratio (set from scene.width/height in game.js) the
       normal block-layout way. */
    .sd-board {
        flex: none;
        width: 100%;
    }

    .sd-stat {
        font-size: 12px;
        padding: 5px 10px;
    }
}

@media (max-width: 380px) {
    .sd-levels {
        grid-template-columns: 1fr;
    }
}
