
        /* ===== Site Header / Footer (new design) ===== */
        .site-header {
            background-color: #ffffff;
            display: flex; justify-content: space-between; align-items: center;
            height: 64px; padding: 0 24px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.05);
            width: 100%; flex-shrink: 0;
        }
        .site-logo { display: flex; align-items: center; gap: 10px; }
        .site-logo img.bigtoe { height: 60px; width: auto; display: block; }
        .site-logo img.logotext { height: 30px; width: auto; display: block; }
        .site-nav { display: flex; align-items: center; gap: 26px; }
        .site-nav a { text-decoration: none; color: #334155; font-weight: 500; font-size: 0.9rem; transition: color 0.2s; }
        .site-nav a:hover { color: #0d9488; }
        .site-nav a.site-play {
            background: #14b8a6; color: #fff; padding: 8px 18px; border-radius: 999px; font-weight: 600;
        }
        .site-nav a.site-play:hover { background: #0d9488; color: #fff; }
        /* Menu hidden for launch — flip this back to show it */
        .site-nav { display: none; }
        /* Language switch */
        .header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
        .lang-switch { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
        .lang-switch button {
            border: 1px solid #d5d5d5; background: #fff; color: #555;
            border-radius: 999px; padding: 4px 12px; font-size: 0.8rem;
            font-weight: 600; cursor: pointer; transition: all 0.15s;
        }
        /* Language burger menu (mobile only) */
        .lang-menu { position: relative; }
        .lang-menu-btn {
            display: none;
            border: 1px solid #d5d5d5; background: #fff; color: #555;
            border-radius: 999px; padding: 4px 12px; font-size: 0.8rem;
            font-weight: 600; cursor: pointer; white-space: nowrap;
            transition: all 0.15s;
        }
        .lang-menu-btn:hover { border-color: #0d9488; color: #0d9488; }
        html.dark .lang-menu-btn { background: #1a1a2e; border-color: #3f3f5a; color: #e8e8f0; }
        html.dark .lang-menu-btn:hover { border-color: #14b8a6; color: #5eead4; }
        .lang-switch button:hover { border-color: #0d9488; color: #0d9488; }
        .lang-switch button.active { background: #14b8a6; border-color: #14b8a6; color: #fff; }
        /* Theme toggle (site-wide dark mode) */
        .theme-toggle {
            border: 1px solid #d5d5d5; background: #fff; color: #555;
            border-radius: 999px; padding: 4px 12px; font-size: 0.9rem; line-height: 1.5;
            font-weight: 600; cursor: pointer; transition: all 0.15s; flex-shrink: 0;
        }
        .theme-toggle:hover { border-color: #0d9488; color: #0d9488; }
        .theme-toggle .icon-dark { display: none; }
        /* Site-wide dark theme */
        html.dark .site-header { background: #1a1a2e; box-shadow: 0 2px 5px rgba(0,0,0,0.4); }
        html.dark .site-footer { background: #1a1a2e; border-top-color: #2d2d44; color: #9ca3af; }
        html.dark .site-footer-links a { color: #9ca3af; }
        html.dark .site-footer-links a:hover { color: #5eead4; }
        html.dark .site-nav a { color: #cbd5e1; }
        html.dark .site-nav a:hover { color: #5eead4; }
        html.dark .lang-switch button { background: #1a1a2e; border-color: #3f3f5a; color: #cbd5e1; }
        html.dark .lang-switch button:hover { border-color: #14b8a6; color: #5eead4; }
        html.dark .lang-switch button.active { background: #14b8a6; border-color: #14b8a6; color: #fff; }
        html.dark .theme-toggle { background: #1a1a2e; border-color: #3f3f5a; color: #e8e8f0; }
        html.dark .theme-toggle:hover { border-color: #14b8a6; color: #5eead4; }
        html.dark .theme-toggle .icon-light { display: none; }
        html.dark .theme-toggle .icon-dark { display: inline; }
        /* The wordmark PNG has an opaque white background — invert it in dark mode */
        html.dark .site-logo img.logotext { filter: invert(1) hue-rotate(180deg); }
        .site-footer {
            background-color: #ffffff; border-top: 1px solid #e5e5e5;
            padding: 18px 20px; display: flex; flex-direction: column; align-items: center; gap: 4px;
            font-size: 0.85rem; color: #555; width: 100%; flex-shrink: 0; text-align: center;
        }
        .site-footer-links { display: flex; gap: 20px; }
        .site-footer-links a { text-decoration: none; color: #555; }
        .site-footer-links a:hover { color: #5f9bb9; }
        @media (max-width: 720px) {
            .site-nav { display: none; }
            .site-logo img.bigtoe { height: 44px; }
            .site-logo img.logotext { height: 20px; }
            .lang-menu-btn { display: inline-block; }
            .lang-menu-dd {
                display: none;
                position: absolute; right: 0; top: calc(100% + 8px);
                background: #fff; border: 1px solid #d5d5d5; border-radius: 12px;
                box-shadow: 0 8px 24px rgba(0,0,0,0.15);
                padding: 6px; z-index: 500; min-width: 120px;
            }
            .lang-menu-dd.open { display: block; }
            .lang-menu-dd .lang-switch { flex-direction: column; align-items: stretch; gap: 4px; }
            .lang-menu-dd .lang-switch button { display: block; width: 100%; text-align: left; border: none; }
            html.dark .lang-menu-dd { background: #1a1a2e; border-color: #3f3f5a; }
        }

/* ========================================
   Lazers — Light & Dark Mode Styles
   ======================================== */

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

/* --- Light Mode (default) --- */
:root {
    --bg:            #f4f6f9;
    --surface:       #ffffff;
    --text:          #1a1a2e;
    --text-muted:    #6b7280;
    --border:        #e2e4e9;
    --primary:       #e63946;
    --primary-glow:  #ff6b6b;
    --grid-line:     #d1d5db;
    --cell-bg:       #ffffff;
    --btn-bg:        #ffffff;
    --btn-hover:     #f3f4f6;
    --btn-active:    #e5e7eb;
    --shadow:        0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg:     0 8px 30px rgba(0,0,0,0.08);
    --canvas-bg:     #fafbfc;
}

/* --- Dark Mode --- */
.dark {
    --bg:            #0f0f1a;
    --surface:       #1a1a2e;
    --text:          #e8e8f0;
    --text-muted:    #9ca3af;
    --border:        #2d2d44;
    --primary:       #ff4757;
    --primary-glow:  #ff6b81;
    --grid-line:     #2a2a40;
    --cell-bg:       #16162b;
    --btn-bg:        #1e1e35;
    --btn-hover:     #2a2a44;
    --btn-active:    #333355;
    --shadow:        0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg:     0 8px 30px rgba(0,0,0,0.5);
    --canvas-bg:     #12121f;
}

/* --- Base --- */
html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s, color 0.3s;
}

#app {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 0;
    padding: 16px;
}

/* --- Header --- */
header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 20px;
    user-select: none;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--primary), #ff8c42);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.level-badge {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2px 12px;
}

/* Beta / preview notice on the game screen itself */
.beta-badge {
    font-size: 0.8rem;
    font-weight: 700;
    color: #ffffff;
    background: #f59e0b;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 2px 12px;
    cursor: help;
    white-space: nowrap;
}

/* --- Game Board --- */
main {
    position: relative;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 16px;
    margin-bottom: 20px;
    transition: background 0.3s, box-shadow 0.3s;
}

canvas {
    display: block;
    border-radius: 8px;
    background: var(--canvas-bg);
    transition: background 0.3s;
    max-width: 100%;
    height: auto;
}

/* --- Toolbar --- */
footer {
    display: flex;
    gap: 12px;
}

footer button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text);
    background: var(--btn-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    user-select: none;
}

footer button:hover {
    background: var(--btn-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

footer button:active {
    background: var(--btn-active);
    transform: translateY(0);
    box-shadow: var(--shadow);
}

footer button:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

footer button svg {
    flex-shrink: 0;
}

/* --- Utility --- */
.hidden {
    display: none !important;
}

#editor-link {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    opacity: 0.7;
}

#editor-link:hover { opacity: 1; text-decoration: underline; }

/* --- Stage progress --- */
#stage-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(432px, 92vw);
    margin: -8px 0 14px;
    user-select: none;
}

#stage-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

#stage-bar {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

#stage-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), #ff8c42);
    transition: width 0.5s ease;
}

#stage-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

#stage-trophy {
    color: var(--text-muted);
    opacity: 0.35;
    flex-shrink: 0;
    transition: opacity 0.4s, color 0.4s, transform 0.4s;
}

#stage-trophy.earned {
    color: #fbbf24;
    opacity: 1;
    transform: scale(1.1);
}

/* --- HUD (moves / time / best) --- */
#hud {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 4px 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    min-height: 22px;
    user-select: none;
}

#hud span {
    white-space: nowrap;
}

#hud-best {
    opacity: 0.75;
}

/* --- Win dialog stats --- */
.win-stats {
    margin-top: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* --- Help button (stage progress row) --- */
#btn-howto {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}

#btn-howto:hover {
    color: var(--text);
    background: var(--btn-hover);
    transform: translateY(-1px);
}

/* --- Rule balloon (target lit, mirrors unused) --- */
.rule-balloon {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 46px;
    margin: 0 auto;
    width: fit-content;
    max-width: min(92vw, 420px);
    background: linear-gradient(135deg, #fbbf24, #f97316);
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    padding: 14px 24px;
    border-radius: 22px;
    border: 3px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 12px 28px rgba(251, 146, 60, 0.55), 0 4px 10px rgba(0, 0, 0, 0.28);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    text-align: center;
    pointer-events: none;
    z-index: 20;
    transform-origin: bottom center;
    will-change: transform, opacity;
    /* Centred with margin auto, so the keyframes animate only pure
       pixel transforms — calc(-50% ± Npx) interpolates jerkily. */
    animation: rule-balloon-rise 4s ease-in-out forwards;
}

.rule-balloon::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -10px;
    transform: translateX(-50%);
    border: 10px solid transparent;
    border-top-color: #f97316;
    border-bottom: 0;
}

@keyframes rule-balloon-rise {
    0%   { transform: translateY(0) scale(0.4) rotate(-8deg);           opacity: 0; }
    10%  { transform: translateY(-10px) scale(1.12) rotate(3deg);       opacity: 1; }
    18%  { transform: translateY(-18px) scale(0.96) rotate(-1.5deg);    opacity: 1; }
    24%  { transform: translateY(-22px) scale(1) rotate(0deg);          opacity: 1; }
    38%  { transform: translateY(-95px) translateX(14px) rotate(2deg);  opacity: 1; }
    54%  { transform: translateY(-195px) translateX(-12px) rotate(-2deg); opacity: 1; }
    70%  { transform: translateY(-305px) translateX(10px) rotate(1.5deg); opacity: 0.85; }
    85%  { transform: translateY(-415px) translateX(-8px) rotate(-1deg); opacity: 0.35; }
    100% { transform: translateY(-520px) rotate(0deg);                   opacity: 0; }
}

/* --- Stage intro dialog --- */
#intro-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 16px;
}

.intro-dialog {
    position: relative;
    background: var(--surface);
    color: var(--text);
    border-radius: 18px;
    padding: 26px 28px 22px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
    text-align: center;
    max-height: 92vh;
    overflow-y: auto;
}

.intro-dialog h2 {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.intro-goal {
    font-size: 0.92rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.intro-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 4px 8px;
}

.intro-demo {
    background: var(--canvas-bg);
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 14px;
}

#intro-canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.intro-caption {
    margin-top: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    min-height: 1.2em;
}

.intro-rules {
    list-style: none;
    text-align: left;
    margin: 0 0 16px;
    padding: 0;
    display: grid;
    gap: 8px;
}

.intro-rules li {
    position: relative;
    padding-left: 22px;
    font-size: 0.88rem;
    line-height: 1.35;
}

.intro-rules li::before {
    content: '◆';
    position: absolute;
    left: 2px;
    top: 1px;
    font-size: 0.62rem;
    color: var(--primary);
}

.intro-start {
    padding: 11px 26px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #ff8c42);
    border: none;
    border-radius: 24px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(230, 57, 70, 0.35);
    transition: transform 0.15s;
}

.intro-start:hover {
    transform: translateY(-1px);
}
