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

:root {
    /* Dark Theme (Default) */
    --bg-primary: #1E1E1E;
    --bg-secondary: #2A2A2A;
    --bg-tertiary: #353535;
    --text-primary: #FFFFFF;
    --text-secondary: #B0B0B0;
    --accent: #00FF88;
    --accent-hover: #00CC6E;
    --border: #404040;
    --overlay-bg: rgba(30, 30, 30, 0.95);
    --shadow: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
    --bg-primary: #F5F5F5;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #E8E8E8;
    --text-primary: #1E1E1E;
    --text-secondary: #666666;
    --accent: #FF6B35;
    --accent-hover: #E85A2A;
    --border: #D0D0D0;
    --overlay-bg: rgba(255, 255, 255, 0.95);
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    min-height: 100vh;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    padding: 20px;
    padding-left: 100px;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    position: relative;
}

/* Vertical title on the left of the entire container */
.vertical-title-container {
    position: fixed;
    left: 50px;
    top: 50%;
    transform: translateY(-50%) rotate(180deg);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: 'Bitcount Prop Double Ink', monospace;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: 5px;
    color: var(--accent);
    padding: 20px 0;
    border-left: 5px solid var(--accent);
    padding-left: 15px;
    z-index: 999;
    opacity: 0.95;
}

.page-logo {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    animation: fadeIn 0.5s ease;
}

.logo-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 12px var(--shadow);
    border: 3px solid var(--accent);
    transition: all 0.3s ease;
}

.logo-img:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 20px var(--accent);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--shadow);
    overflow: hidden;
    max-width: 1000px;
    width: 100%;
    transition: background-color 0.3s ease;
}

.header {
    background: var(--bg-tertiary);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border);
    position: relative;
}

.header h1 {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 4px;
    color: var(--accent);
}

.theme-toggle {
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: 8px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.theme-toggle:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
    transform: scale(1.05);
}

.sun-icon {
    display: none;
}

[data-theme="light"] .sun-icon {
    display: block;
}

[data-theme="light"] .moon-icon {
    display: none;
}

.game-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
}

.sidebar {
    background: var(--bg-tertiary);
    padding: 25px 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    border-right: 2px solid var(--border);
    overflow-y: auto;
}

.stats-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 18px;
    border-radius: 12px;
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 900;
    color: var(--accent);
    line-height: 1;
}

.difficulty-section,
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-secondary);
}

.difficulty-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty-select:hover,
.difficulty-select:focus {
    border-color: var(--accent);
    outline: none;
}

.control-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.control-key {
    background: var(--bg-secondary);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12px;
    border: 2px solid var(--border);
    min-width: 70px;
    text-align: center;
}

.control-text {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.game-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    background: var(--bg-primary);
}

.game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template: repeat(25, 1fr) / repeat(25, 1fr);
    background: var(--bg-primary);
    padding: 20px;
    gap: 1px;
}

.food {
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 20px var(--accent);
    animation: pulse 0.8s ease-in-out infinite alternate;
    margin: 2px;
}

@keyframes pulse {
    from {
        transform: scale(0.85);
        opacity: 0.8;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.snake {
    background: var(--accent);
    border-radius: 3px;
    opacity: 0.7;
    margin: 2px;
}

.snake:first-of-type {
    background: var(--accent);
    border-radius: 5px;
    opacity: 1;
    box-shadow: 0 0 10px var(--accent);
    margin: 2px;
}

.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.game-over-screen {
    display: none;
}

.overlay-content {
    text-align: center;
    padding: 40px;
}

.overlay-content h2 {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: 4px;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.overlay-content p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 16px;
    font-weight: 500;
}

.final-score-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 32px;
}

.final-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-secondary);
}

.final-value {
    font-size: 56px;
    font-weight: 900;
    color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    padding: 16px 48px;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 2px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px var(--shadow);
}

.btn-primary:active {
    transform: translateY(0);
}

.pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    z-index: 5;
}

.pause-text {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: 6px;
    color: var(--accent);
}

/* Responsive Design */
@media (max-width: 968px) {
    body {
        padding-left: 85px;
    }
    
    .vertical-title-container {
        left: 40px;
        font-size: 18px;
        letter-spacing: 4px;
        padding-left: 12px;
        border-left-width: 4px;
    }
    
    .game-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        border-right: none;
        border-bottom: 2px solid var(--border);
        padding: 20px;
    }
    
    .stats-section {
        flex-direction: row;
        gap: 15px;
    }
    
    .stat-card {
        flex: 1;
    }
    
    .difficulty-section,
    .controls-section {
        display: none;
    }
    
    .game-wrapper {
        padding-bottom: 100%;
    }
    
    .vertical-title {
        font-size: 12px;
        letter-spacing: 2px;
    }
}

@media (max-width: 640px) {
    body {
        padding: 10px;
        padding-top: 90px;
        padding-left: 70px;
    }
    
    .vertical-title-container {
        left: 30px;
        font-size: 14px;
        letter-spacing: 3px;
        padding-left: 10px;
        border-left-width: 3px;
    }
    
    .page-logo {
        top: 15px;
        left: 15px;
    }
    
    .logo-img {
        width: 50px;
        height: 50px;
        border-width: 2px;
    }
    
    .container {
        border-radius: 12px;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header h1 {
        font-size: 22px;
        letter-spacing: 3px;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
    }
    
    .sidebar {
        padding: 15px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-label {
        font-size: 10px;
    }
    
    .stat-value {
        font-size: 28px;
    }
    
    .game-container {
        padding: 15px;
    }
    
    .overlay-content {
        padding: 30px 20px;
    }
    
    .overlay-content h2 {
        font-size: 36px;
    }
    
    .overlay-content p {
        font-size: 14px;
    }
    
    .final-value {
        font-size: 44px;
    }
    
    .btn-primary {
        padding: 14px 36px;
        font-size: 13px;
    }
    
    .pause-text {
        font-size: 36px;
    }
}

@media (max-width: 400px) {
    body {
        padding-top: 80px;
        padding-left: 60px;
    }
    
    .vertical-title-container {
        left: 25px;
        font-size: 11px;
        letter-spacing: 2px;
        padding-left: 8px;
        border-left-width: 3px;
    }
    
    .page-logo {
        top: 10px;
        left: 10px;
    }
    
    .logo-img {
        width: 45px;
        height: 45px;
    }
    
    .header h1 {
        font-size: 18px;
        letter-spacing: 2px;
    }
    
    .theme-toggle {
        width: 36px;
        height: 36px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .overlay-content h2 {
        font-size: 28px;
    }
    
    .final-value {
        font-size: 36px;
    }
}