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

body {
    background: linear-gradient(180deg, #a89888 0%, #c4b8a8 20%, #d4c4b4 50%, #b8a894 80%, #8a7a66 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Zen Maru Gothic', sans-serif;
    color: #4a4038;
    overflow: hidden;
}

#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: rgba(248, 240, 232, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 12px rgba(74, 64, 56, 0.15);
    z-index: 100;
    gap: 16px;
    min-height: 60px;
}

.hud-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.hud-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hud-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex: 1;
}

.distance-counter {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    color: #4a4038;
    white-space: nowrap;
}

.energy-bar-container {
    width: 100px;
    height: 16px;
    background: #d4c4b4;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.energy-bar {
    height: 100%;
    width: 100%;
    background: #7ab87a;
    transition: width 0.2s, background 0.3s;
    border-radius: 6px;
}

.coffee-count {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    color: #8b5a2b;
    white-space: nowrap;
}

.high-score {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    color: #8a7e72;
    white-space: nowrap;
}

.chill-badge {
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    color: #d4a574;
    padding: 6px 10px;
    background: rgba(212, 165, 116, 0.2);
    border-radius: 4px;
    animation: glow 2s ease-in-out infinite;
    white-space: nowrap;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(212, 165, 116, 0.5); }
    50% { box-shadow: 0 0 15px rgba(212, 165, 116, 0.8); }
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 50px;
}

#canvas {
    display: block;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(74, 64, 56, 0.3);
    transition: transform 0.05s;
}

@media (max-width: 768px) {
    body {
        justify-content: flex-start;
        padding: 0;
    }
    
    #hud {
        padding: 12px 16px;
        min-height: 56px;
    }
    
    .distance-counter {
        font-size: 10px;
    }
    
    .energy-bar-container {
        width: 80px;
        height: 14px;
    }
    
    .coffee-count {
        font-size: 12px;
    }
    
    .high-score {
        font-size: 10px;
    }
    
    .chill-badge {
        font-size: 8px;
        padding: 5px 8px;
    }
    
    #game-container {
        max-width: 100%;
        height: calc(100vh - 150px);
        height: calc(100dvh - 150px);
        margin-top: 56px;
    }
    
    #canvas {
        border-radius: 0;
        box-shadow: none;
    }
}

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(196, 184, 168, 0.95);
    border-radius: 8px;
    padding: 20px;
    z-index: 10;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
    #start-screen {
        border-radius: 0;
        padding: 30px 20px;
    }
}

.title-container {
    text-align: center;
    margin-bottom: 20px;
}

.title-jp {
    font-family: 'Zen Maru Gothic', sans-serif;
    font-size: clamp(24px, 6vw, 42px);
    font-weight: 700;
    color: #4a4038;
    text-shadow: 2px 2px 0 #d4c4b4;
    margin-bottom: 8px;
}

.title-en {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(10px, 2.5vw, 14px);
    color: #6e6358;
    letter-spacing: 1px;
}

.character-preview {
    width: 64px;
    height: 80px;
    background: #5a4e44;
    border-radius: 4px;
    margin: 20px 0;
    position: relative;
    animation: bob 2s ease-in-out infinite;
}

.character-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10px;
    right: 10px;
    height: 24px;
    background: #d4c4b4;
    border-radius: 4px 4px 0 0;
}

.character-preview::after {
    content: '😴';
    position: absolute;
    top: -25px;
    right: -10px;
    font-size: 18px;
    animation: float 1.5s ease-in-out infinite;
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-10deg); opacity: 0.8; }
    50% { transform: translateY(-10px) rotate(10deg); opacity: 1; }
}

.start-info {
    text-align: center;
}

.high-score-display {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    color: #8a7e72;
    margin-bottom: 15px;
}

.chill-mode-toggle {
    margin: 15px 0;
}

.chill-mode-toggle label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    touch-action: manipulation;
}

.chill-mode-toggle {
    pointer-events: auto;
}

.chill-mode-toggle input {
    display: none;
}

.toggle-slider {
    width: 40px;
    height: 22px;
    background: #9e8e7a;
    border-radius: 11px;
    position: relative;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #f8f0e8;
    border-radius: 50%;
    transition: transform 0.3s;
}

.chill-mode-toggle input:checked + .toggle-slider {
    background: #d4a574;
}

.chill-mode-toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.toggle-label {
    color: #6e6358;
}

.tap-start {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(8px, 2vw, 12px);
    color: #5a4e44;
    animation: pulse 1.5s ease-in-out infinite;
    margin-top: 20px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(196, 184, 168, 0.95);
    border-radius: 8px;
    padding: 20px;
    z-index: 10;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
    #game-over-screen {
        border-radius: 0;
        padding: 30px 20px;
    }
}

.game-over-title {
    font-family: 'Zen Maru Gothic', sans-serif;
    font-size: clamp(20px, 5vw, 32px);
    color: #4a4038;
    margin-bottom: 20px;
}

.final-stats {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(10px, 2.5vw, 14px);
    color: #6e6358;
    text-align: center;
    margin-bottom: 15px;
}

.final-stats p {
    margin: 8px 0;
}

.new-record {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(10px, 2.5vw, 14px);
    color: #d4a574;
    animation: celebrate 0.5s ease-in-out infinite alternate;
    margin-bottom: 20px;
}

@keyframes celebrate {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.restart-button {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    padding: 15px 30px;
    background: #5a4e44;
    color: #f8f0e8;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.restart-button:hover {
    background: #7a6e64;
    transform: translateY(-2px);
}





footer {
    margin-top: auto;
    text-align: center;
    padding: 16px 20px 20px;
    flex-shrink: 0;
    width: 100%;
    background: rgba(138, 122, 102, 0.3);
}

.remix-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', cursive;
    font-size: 13px;
    color: #f8f0e8;
    background: linear-gradient(135deg, #d4a574 0%, #8b5a2b 100%);
    text-decoration: none;
    padding: 18px 36px;
    border-radius: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(139, 90, 43, 0.3);
    min-height: 56px;
    min-width: 220px;
}

.remix-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 90, 43, 0.4);
    background: linear-gradient(135deg, #e4b584 0%, #9b6a3b 100%);
}

.remix-link:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(139, 90, 43, 0.3);
}

@media (max-width: 768px) {
    footer {
        margin-top: 0;
        padding: 14px 16px 22px;
        background: rgba(138, 122, 102, 0.4);
    }
    
    .remix-link {
        font-size: 12px;
        padding: 16px 32px;
        min-height: 54px;
        min-width: 200px;
        border-radius: 10px;
        width: auto;
        max-width: 90%;
    }
}

@media (max-width: 400px) {
    footer {
        padding: 12px 12px 20px;
    }
    
    .remix-link {
        font-size: 10px;
        padding: 14px 24px;
        min-width: 160px;
        min-height: 50px;
    }
}

@media (max-width: 600px) {
    #hud {
        padding: 10px 12px;
        gap: 10px;
        min-height: 50px;
    }
    
    .distance-counter {
        font-size: 8px;
    }
    
    .energy-bar-container {
        width: 65px;
        height: 12px;
    }
    
    .coffee-count {
        font-size: 10px;
    }
    
    .high-score {
        font-size: 8px;
    }
    
    .chill-badge {
        font-size: 7px;
        padding: 4px 6px;
    }
    
    #game-container {
        height: calc(100vh - 140px);
        height: calc(100dvh - 140px);
        margin-top: 50px;
    }
}

@media (max-width: 400px) {
    #hud {
        padding: 8px 10px;
        gap: 8px;
        min-height: 46px;
    }
    
    .hud-left {
        gap: 8px;
    }
    
    .energy-bar-container {
        width: 55px;
        height: 10px;
    }
    
    .distance-counter {
        font-size: 7px;
    }
    
    .coffee-count {
        font-size: 9px;
    }
    
    .high-score {
        font-size: 7px;
    }
    
    #game-container {
        height: calc(100vh - 130px);
        height: calc(100dvh - 130px);
        margin-top: 46px;
    }
}

@media (max-height: 600px) and (max-width: 768px) {
    #game-container {
        height: calc(100vh - 120px);
        height: calc(100dvh - 120px);
    }
    
    .control-zone {
        height: 60px;
    }
    
    #mobile-controls {
        bottom: 10px;
    }
    
    footer {
        padding: 10px 12px 16px;
    }
    
    .remix-link {
        font-size: 9px;
        padding: 12px 20px;
        min-height: 44px;
    }
}