:root {
    --bg-color: #f8f9fa;
    --text-color: #333;
    --panel-bg: #ffffff;
    --score-text: #2e7d32;
    --timer-bg: #f1f3f4;
    --timer-text: #202124;
    --timer-border: #e8eaed;
    --canvas-border: #fff;
    --shadow-color: rgba(0,0,0,0.1);
    --header-bg: #2e7d32;
    --header-text: #fff;
    --link-color: #2e7d32;
    --footer-bg: #f1f3f4;
    --footer-text: #666;
    --card-bg: #fff;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --panel-bg: #1e1e1e;
    --score-text: #81c784;
    --timer-bg: #333;
    --timer-text: #fff;
    --timer-border: #444;
    --canvas-border: #333;
    --shadow-color: rgba(0,0,0,0.5);
    --header-bg: #1b5e20;
    --header-text: #e0e0e0;
    --link-color: #81c784;
    --footer-bg: #1e1e1e;
    --footer-text: #aaa;
    --card-bg: #1e1e1e;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-color);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

a:focus-visible,
button:focus-visible {
    outline: 3px solid #ffca28;
    outline-offset: 3px;
}

/* Header */
.site-header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-title {
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: -1px;
}

.site-title a {
    color: inherit;
    text-decoration: none;
}

.site-nav ul {
    display: flex;
    list-style: none;
    gap: 24px;
}

.site-nav a {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: opacity 0.2s;
}

.site-nav a:hover {
    opacity: 0.8;
}

#themeToggle {
    background: rgba(255,255,255,0.15);
    border: none;
    color: inherit;
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#themeToggle:hover {
    background: rgba(255,255,255,0.25);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

#topRestartButton {
    padding: 9px 18px;
    border: 1px solid rgba(255,255,255,0.65);
    border-radius: 24px;
    background: rgba(255,255,255,0.15);
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

#topRestartButton:hover {
    background: rgba(255,255,255,0.28);
}

#restartDialog {
    width: min(440px, calc(100% - 32px));
    margin: auto;
    padding: 28px;
    color: var(--text-color);
    background: var(--panel-bg);
    border: 1px solid var(--timer-border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

#restartDialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

#restartDialog h2 {
    margin-bottom: 8px;
    color: var(--score-text);
}

#restartDialog p {
    margin-bottom: 20px;
}

.restart-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.restart-dialog-actions button {
    padding: 10px 16px;
    color: var(--header-bg);
    background: var(--panel-bg);
    border: 1px solid var(--header-bg);
    border-radius: 24px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.restart-dialog-actions button:first-child {
    color: #fff;
    background: var(--header-bg);
}

.restart-dialog-actions button:hover {
    filter: brightness(1.12);
}

.language-toggle {
    padding: 9px 14px;
    border: 1px solid rgba(255,255,255,0.65);
    border-radius: 24px;
    background: rgba(255,255,255,0.15);
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.language-toggle:hover {
    background: rgba(255,255,255,0.28);
}

/* Main Layout */
.site-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.content-section {
    max-width: 860px;
    margin: 0 auto;
    padding: 32px;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: 0 10px 30px var(--shadow-color);
}

.content-section h2 {
    margin-bottom: 8px;
    color: var(--score-text);
    font-size: 2rem;
}

.content-section h3 {
    margin: 28px 0 8px;
    color: var(--score-text);
    font-size: 1.25rem;
}

.content-section p {
    margin-bottom: 14px;
}

.content-section a {
    color: var(--link-color);
}

/* Game View */
.game-view {
    display: flex;
    justify-content: center;
    margin-bottom: 80px;
}

.game-layout {
    display: flex;
    align-items: center;
    gap: 24px;
    max-width: 100%;
}

.game-wrapper {
    width: 600px;
    max-width: 100%;
    position: relative;
}

.ball-legend {
    width: 160px;
    padding: 20px 16px;
    color: var(--text-color);
    background: var(--panel-bg);
    border-radius: 20px;
    box-shadow: 0 12px 28px var(--shadow-color);
}

.ball-legend h2 {
    margin-bottom: 12px;
    color: var(--score-text);
    font-size: 1.1rem;
    text-align: center;
}

.ball-legend ul {
    display: flex;
    flex-direction: column;
    gap: 12px;
    list-style: none;
}

.ball-legend li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.ball-emoji {
    font-size: 1.6rem;
    line-height: 1;
}

.canvas-container {
    position: relative;
    display: flex;
    flex-direction: column;
}

canvas {
    width: 100%;
    height: auto;
    border: 4px solid var(--canvas-border);
    background-color: #fff;
    box-shadow: 0 20px 40px var(--shadow-color);
    border-radius: 0 0 24px 24px;
    touch-action: none; /* Prevent scrolling/zooming while playing */
}

#scorePanel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-bg);
    padding: 20px 40px;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 20px var(--shadow-color);
    transition: background-color 0.3s;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 2rem;
    font-weight: 800;
    color: var(--score-text);
}

#timerDisplay {
    font-size: 1.8rem;
    font-family: 'Courier New', Courier, monospace;
    background: var(--timer-bg);
    color: var(--timer-text);
    padding: 6px 24px;
    border-radius: 32px;
    border: 2px solid var(--timer-border);
    font-weight: bold;
}

/* Content View */
.content-view {
    padding-top: 40px;
}

.section-header {
    text-align: center;
    margin-bottom: 50px;
}

.section-header h2 {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--score-text);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--footer-text);
    font-weight: 500;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 32px;
}

.content-card {
    background: var(--card-bg);
    padding: 32px;
    border-radius: 24px;
    box-shadow: 0 10px 30px var(--shadow-color);
    transition: transform 0.3s, background-color 0.3s;
}

.content-card:hover {
    transform: translateY(-5px);
}

.content-card h3 {
    color: var(--score-text);
    font-size: 1.5rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.content-card p {
    margin-bottom: 16px;
    font-size: 1.05rem;
    color: var(--text-color);
}

.content-card ul {
    list-style: none;
    margin-top: 15px;
}

.content-card li {
    margin-bottom: 12px;
    padding-left: 24px;
    position: relative;
}

.content-card li::before {
    content: "•";
    color: var(--score-text);
    font-weight: bold;
    font-size: 1.4rem;
    position: absolute;
    left: 0;
    top: -2px;
}

.content-card strong {
    color: var(--score-text);
}

#faq {
    grid-column: 1 / -1;
}

.faq-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 32px;
}

.faq-item h4 {
    color: var(--score-text);
    font-size: 1.1rem;
    margin-bottom: 6px;
}

.faq-item p {
    margin-bottom: 0;
}

/* Game over actions */
#gameOverActions {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    z-index: 100;
}

#gameOverActions button {
    padding: 20px 50px;
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
    background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 15px 30px rgba(46, 125, 50, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#gameOverActions button:hover {
    box-shadow: 0 20px 40px rgba(46, 125, 50, 0.5);
    transform: scale(1.05);
}

@media (max-width: 600px) {
    #gameOverActions {
        gap: 10px;
        padding: 0 12px;
        box-sizing: border-box;
    }

    #gameOverActions button {
        padding: 16px 20px;
        font-size: 1rem;
    }
}

/* Footer */
.site-footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 60px 0;
    margin-top: 100px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.footer-nav ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    list-style: none;
    gap: 32px;
}

.footer-nav a {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
}

/* Responsive */
@media (max-width: 900px) {
    .game-layout {
        flex-direction: column;
        width: min(600px, 100%);
        gap: 16px;
    }

    .ball-legend {
        width: 100%;
        padding: 12px 20px;
    }

    .ball-legend h2 {
        margin-bottom: 8px;
    }

    .ball-legend ul {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 10px 6px;
    }

    .ball-legend li {
        justify-content: center;
    }

    .header-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .site-nav ul {
        gap: 16px;
        font-size: 0.9rem;
    }
    
    .section-header h2 {
        font-size: 2rem;
    }
}

@media (max-width: 650px) {
    .content-section {
        padding: 24px;
    }

    .faq-grid {
        grid-template-columns: 1fr;
    }

    .score-item {
        font-size: 1.5rem;
    }
    
    #timerDisplay {
        font-size: 1.4rem;
        padding: 4px 16px;
    }
    
    #scorePanel {
        padding: 15px 24px;
    }
    
    .content-card {
        padding: 24px;
    }
}
/* Add styles here */
