:root {
    --primary-color: #FF6B6B;
    --secondary-color: #4ECDC4;
    --accent-color: #FFE66D;
    --dark-color: #2C3E50;
    --light-color: #F7F9F9;
    --gauge-bg: #e0e0e0;
    --gauge-fill: #2ecc71;
    --endless-color: #9b59b6;
    --font-main: 'Mochiy Pop One', sans-serif;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background-color: var(--light-color);
    color: var(--dark-color);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #A8E6CF 0%, #DCEDC1 100%);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

@media (min-width: 768px) {
    #game-container {
        width: 90%;
        max-width: 1000px;
        height: 90%;
        max-height: 700px;
        border-radius: 30px;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 20px;
        background: linear-gradient(135deg, #A8E6CF 0%, #DCEDC1 100%);
    }

    #start-screen {
        border-radius: 20px;
    }

    #game-header {
        position: absolute;
        top: 20px;
        left: 20px;
        flex-direction: row;
        width: 300px;
        flex-wrap: wrap;
    }

    #field-area {
        margin-left: 320px;
        margin-right: 320px;
    }

    #interaction-area {
        position: absolute;
        right: 20px;
        bottom: 20px;
        width: 300px;
        flex-direction: column;
        justify-content: flex-end;
    }
    
    #pc-key-guide {
        display: block !important;
    }
    
    #action-button {
        cursor: default;
    }
    #action-button:active {
        transform: none;
    }
    #action-button.pressed {
        transform: translateY(10px) !important;
        box-shadow: 0 0 0 !important;
    }
}

/* Audio Toggle */
#sound-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    cursor: pointer;
    font-size: 1.2rem;
    z-index: 60;
}

/* User Input & Stats */
#user-stats {
    background: rgba(255,255,255,0.9);
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
}
.user-info-row {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: bold;
    margin-bottom: 5px;
}
.total-score-row {
    font-size: 1rem;
    color: var(--dark-color);
}
.hoe-level-row {
    font-size: 1.1rem;
    color: var(--dark-color);
    margin-top: 5px;
    border-top: 1px dashed #ccc;
    padding-top: 5px;
}
.hoe-highlight {
    color: var(--secondary-color);
    font-weight: bold;
}

#change-user-area {
    width: 90%;
    max-width: 400px;
    text-align: center;
    margin-bottom: 20px;
}
.switch-note {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin: 6px 0 0;
}
.btn-small {
    padding: 10px 24px;
    font-size: 1rem;
    margin-top: 0;
    box-shadow: 0 4px 0 #e6c518;
}
.btn-ghost {
    background: #fff;
    border: 2px solid var(--accent-color);
    box-shadow: none;
}

#change-confirm {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    z-index: 80;
    padding: 20px;
}
.confirm-card {
    background: #fff;
    padding: 20px;
    border-radius: 20px;
    width: 90%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    border: 3px solid var(--secondary-color);
}
.confirm-text {
    margin: 0 0 12px;
    font-size: 1rem;
    color: var(--dark-color);
}
.confirm-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

#login-area {
    width: 100%;
    max-width: 300px;
    text-align: center;
    margin-bottom: 20px;
}
#username-input {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    border: 3px solid #ccc;
    border-radius: 10px;
    font-family: var(--font-main);
    text-align: center;
}
#username-input:focus {
    border-color: var(--secondary-color);
    outline: none;
}
.error-msg {
    color: #e74c3c;
    font-size: 0.9rem;
    margin-top: 5px;
    font-weight: bold;
}
.save-notice {
    font-size: 0.8rem;
    color: #95a5a6;
    margin-top: 5px;
}

/* Difficulty Buttons */
.difficulty-select {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
    max-width: 450px;
    justify-content: center;
    margin-bottom: 20px;
}
.btn-diff {
    border: none;
    padding: 15px 10px;
    font-size: 1.1rem;
    font-family: var(--font-main);
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 5px 0 rgba(0,0,0,0.2);
    transition: transform 0.1s;
    color: white;
    flex: 1;
    min-width: 130px;
    position: relative;
    line-height: 1.4;
}
.btn-diff:active {
    transform: translateY(5px);
    box-shadow: none;
}
.hoe-badge {
    font-size: 0.8rem;
    background: rgba(0,0,0,0.2);
    padding: 2px 6px;
    border-radius: 5px;
    display: inline-block;
    margin-top: 3px;
}

.btn-diff.easy { background: #2ecc71; }
.btn-diff.normal { background: #f1c40f; }
.btn-diff.hard { background: #e74c3c; }
.btn-diff.endless { background: var(--endless-color); min-width: 200px; }

/* Start Screen */
#start-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 100%);
    z-index: 50;
    padding: 20px;
    overflow-y: auto;
}

#start-screen h1 {
    font-size: 2.5rem;
    color: white;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
    margin: 20px 0;
    text-align: center;
    flex-shrink: 0;
}

.instruction {
    color: white;
    font-size: 1rem;
    margin-bottom: 10px;
    margin-top: 10px;
    font-weight: bold;
}

.pc-only-hint {
    display: none;
}
@media (min-width: 768px) {
    .pc-only-hint { display: block; font-size: 0.8rem; opacity: 0.8; }
}

/* Header */
#game-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    z-index: 10;
    gap: 10px;
}
.score-board, .timer-board {
    background: rgba(255, 255, 255, 0.8);
    padding: 8px 15px;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    flex: 1;
    min-width: 80px;
    margin-bottom: 10px;
}
.label {
    font-size: 0.7rem;
    color: #7f8c8d;
    font-weight: bold;
}
#score-display, #timer-display, #harvest-counter {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--dark-color);
}
#timer-display {
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
}

/* Main Field, Gauge, Combo, Interaction */
#field-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    padding-bottom: 20px;
}
#crop-display {
    font-size: 8rem;
    transition: transform 0.1s;
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.2));
    margin-bottom: 20px;
}
.crop-bounce { animation: bounce 0.1s ease-out; }
@keyframes bounce { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }
#gauge-container {
    width: 60%;
    height: 20px;
    background-color: var(--gauge-bg);
    border-radius: 10px;
    overflow: hidden;
    border: 3px solid white;
    box-shadow: 0 5px 0 rgba(0,0,0,0.1);
}
#gauge-bar {
    width: 0%;
    height: 100%;
    background-color: var(--gauge-fill);
    transition: width 0.1s linear;
}
#combo-container {
    position: absolute;
    top: 5%;
    text-align: center;
    pointer-events: none;
    z-index: 5;
}
#combo-count {
    font-size: 4rem;
    font-weight: 900;
    color: var(--primary-color);
    text-shadow: 3px 3px 0px #fff;
    display: block;
    line-height: 1;
}
.combo-label { font-size: 1rem; color: var(--dark-color); text-transform: uppercase; }
.pop-text {
    position: absolute;
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent-color);
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    animation: floatUp 0.6s ease-out forwards;
}
@keyframes floatUp {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    20% { transform: translateY(-20px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-80px) scale(1); opacity: 0; }
}
/* Tractor Effect */
.tractor-pop {
    position: absolute;
    font-size: 2.5rem;
    font-weight: 900;
    color: #e67e22; /* Orange for Tractor */
    text-shadow: 3px 3px 0 #fff, 0 0 10px rgba(0,0,0,0.3);
    pointer-events: none;
    animation: tractorPop 1.2s ease-out forwards;
    z-index: 50;
    white-space: nowrap;
}
@keyframes tractorPop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    15% { transform: translate(-50%, -80%) scale(1.5); opacity: 1; }
    100% { transform: translate(-50%, -200%) scale(1); opacity: 0; }
}

#pc-key-guide {
    margin-top: 20px;
    font-size: 1.2rem;
    color: #7f8c8d;
    font-weight: bold;
    border: 3px solid #7f8c8d;
    padding: 5px 20px;
    border-radius: 10px;
    display: none;
}
#interaction-area {
    padding: 20px;
    padding-bottom: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}
#action-button {
    width: 100%;
    height: 100px;
    border: none;
    border-radius: 30px;
    background-color: var(--primary-color);
    color: white;
    font-family: var(--font-main);
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 10px 0 #c0392b;
    transition: all 0.05s;
    position: relative;
    overflow: hidden;
    max-width: 400px;
}
#action-button:active {
    transform: translateY(10px);
    box-shadow: 0 0 0;
}
#stop-button {
    background-color: #95a5a6;
    border: none;
    color: white;
    font-family: var(--font-main);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 4px 0 #7f8c8d;
}
#stop-button:active { transform: translateY(4px); box-shadow: none; }
.shake-screen { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
}

/* Result Overlay */
#result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}
.result-card {
    background: white;
    padding: 30px;
    border-radius: 30px;
    width: 85%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    border: 5px solid var(--secondary-color);
    max-height: 90vh;
    overflow-y: auto;
}
.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
    border-bottom: 2px dashed #eee;
    padding-bottom: 5px;
}
.result-row span:last-child {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--dark-color);
}
#result-title {
    font-size: 2.5rem;
    margin: 0 0 20px 0;
    color: var(--primary-color);
}
#levelup-message, #player-levelup-message {
    color: #2ecc71;
    font-weight: bold;
    font-size: 1.1rem;
    margin: 10px 0;
    background: #eaffee;
    padding: 10px;
    border-radius: 10px;
}
#fail-message {
    color: #e74c3c;
    font-weight: bold;
    font-size: 1.2rem;
    margin: 20px 0;
    background: #ffeeee;
    padding: 10px;
    border-radius: 10px;
}
#ranking-area h3 {
    color: var(--endless-color);
    border-bottom: 2px solid var(--endless-color);
    padding-bottom: 5px;
}
#ranking-list {
    margin: 10px 0;
    font-size: 0.9rem;
    text-align: left;
}
.rank-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px dotted #ccc;
}
.rank-item.highlight {
    color: var(--primary-color);
    font-weight: bold;
    background: #fff0f0;
}
.sub-text { font-size: 0.8rem; color: #7f8c8d; font-weight: normal; }
.hidden { display: none !important; }
.btn-secondary {
    background-color: var(--accent-color);
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-main);
    color: var(--dark-color);
    box-shadow: 0 5px 0 #e6c518;
    margin-top: 10px;
    transition: transform 0.1s;
}
.btn-secondary:active { transform: translateY(5px); box-shadow: none; }
