:root {
    --bg-color: #fce8d2;
    --primary-color: #ff9f43;
    --secondary-color: #54a0ff;
    --text-color: #2f3542;
    --hole-color: #8d6e63;
    --hole-shadow: #5d4037;
    --grass-color: #7bed9f;
}

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

body {
    margin: 0;
    padding: 20px;
    font-family: 'ZCOOL KuaiLe', cursive, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.game-container {
    background: white;
    width: 100%;
    max-width: 800px;
    border-radius: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

header h1 {
    color: var(--primary-color);
    margin: 0 0 10px 0;
    font-size: 2.5rem;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

header p {
    margin: 0;
    color: #666;
    font-size: 1.1rem;
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    background: #f1f2f6;
    padding: 8px;
    border-radius: 50px;
}

.holes-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #dfe6e9;
    border-radius: 25px;
    padding: 4px 10px;
    font-size: 0.95rem;
}

.holes-selector label {
    color: #636e72;
    font-weight: bold;
}

.holes-selector select {
    border: none;
    border-radius: 18px;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 0.95rem;
    background: white;
    color: var(--text-color);
    cursor: pointer;
}

.difficulty-toggle {
    background: #dfe6e9;
    border-radius: 25px;
    padding: 4px;
    display: flex;
    gap: 4px;
}

.mode-btn {
    border: none;
    padding: 6px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
    background: transparent;
    color: #636e72;
}

.mode-btn.active {
    background-color: white;
    color: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    font-weight: bold;
}

.btn {
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    transition: transform 0.1s, opacity 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn:active {
    transform: scale(0.95);
}

.btn.primary {
    background-color: var(--primary-color);
    color: white;
}

.btn.secondary {
    background-color: var(--secondary-color);
    color: white;
}

.small-btn {
    padding: 4px 10px;
    font-size: 0.8rem;
    background: #b2bec3;
    color: white;
}

.audio-btn {
    width: 42px;
    justify-content: center;
}

.status-bar {
    text-align: center;
}

#day-display {
    font-size: 1.5rem;
    margin-bottom: 5px;
    color: var(--secondary-color);
}

#message {
    font-size: 1.2rem;
    height: 1.5em;
}

/* Scene & Holes */
.scene {
    width: 100%;
    background: var(--grass-color);
    border-radius: 20px;
    padding: 40px 20px;
    position: relative;
    overflow: hidden;
    background-image: radial-gradient(#96f2b4 15%, transparent 16%),
        radial-gradient(#96f2b4 15%, transparent 16%);
    background-size: 60px 60px;
    background-position: 0 0, 30px 30px;
}

.holes-container {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-end;
    min-height: 120px;
    width: 100%;
}

.holes-container.disabled {
    pointer-events: none;
}

.hole-wrapper {
    position: relative;
    flex: 1;
    max-width: 80px;
    min-width: 52px;
    height: 80px;
    cursor: pointer;
    transition: transform 0.2s;
}

.hole-wrapper:hover {
    transform: scale(1.05);
}

.hole {
    width: 100%;
    height: 40px;
    background: var(--hole-color);
    border-radius: 50%;
    position: absolute;
    bottom: 0;
    box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.3), 0 5px 0 var(--hole-shadow);
    z-index: 1;
}

.hole-wrapper::after {
    content: attr(data-index);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: bold;
    color: rgba(0, 0, 0, 0.5);
}

/* Fox & Styling content inside hole */
.content {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    font-size: 3rem;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s;
    z-index: 0;
}

/* States */
.hole-wrapper.checked .content {
    transform: translateX(-50%) translateY(-20px);
}

.hole-wrapper.checked .hole {
    background: #795548;
}

/* Replay & Logs */
#replay-controls {
    width: 100%;
    background: #ffeaa7;
    padding: 15px;
    border-radius: 15px;
    text-align: center;
}

.hidden {
    display: none !important;
}

.playback-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 10px 0;
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

#log-container {
    width: 100%;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.log-header h3 {
    margin: 0;
}

#game-log {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

#game-log li {
    padding: 5px 10px;
    border-bottom: 1px solid #eee;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

#game-log li span.fox-loc {
    color: #e67e22;
    font-weight: bold;
    margin-left: auto;
}

#game-log li:last-child {
    border-bottom: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    /* Limit height to viewport */
    display: flex;
    /* Use flexbox */
    flex-direction: column;
    /* Stack children vertically */
    text-align: center;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-content h2 {
    color: var(--primary-color);
    margin-top: 0;
    flex-shrink: 0;
    /* Keep header fixed */
}

.intro-body {
    text-align: left;
    margin: 15px 0;
    line-height: 1.6;
    overflow-y: auto;
    /* Enable internal scrolling */
    flex: 1;
    /* Take up remaining space */
    padding-right: 10px;
    /* Prevent scrollbar overlap */
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll on iOS */
    border-top: 1px solid #f0f0f0;
    /* Visual separator */
    border-bottom: 1px solid #f0f0f0;
    /* Visual separator */
    padding-top: 10px;
}

.difficulty-hint {
    background: #fff3e0;
    padding: 10px;
    border-radius: 10px;
    font-size: 0.9rem;
    flex-shrink: 0;
    /* Keep hint fixed if possible, or inside body */
}

.big-btn {
    font-size: 1.2rem;
    padding: 10px 40px;
    box-shadow: 0 5px 0 #e67e22;
}

.big-btn:active {
    box-shadow: 0 2px 0 #e67e22;
    transform: translateY(3px);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Animations */
@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(0);
    }
}

.animate-shake {
    animation: shake 0.3s ease-in-out;
}

/* --- Responsive Design --- */

/* Tablet (Portrait & Landscape: 600px - 1024px) */
@media (min-width: 600px) and (max-width: 1024px) {
    .game-container {
        padding: 30px;
        max-width: 90%;
    }

    .hole-wrapper {
        width: 100px;
        height: 100px;
    }

    .content {
        font-size: 3.5rem;
    }

    header h1 {
        font-size: 3rem;
    }
}

/* Mobile (Phone: < 600px) */
@media (max-width: 599px) {
    body {
        padding: 10px;
    }

    .game-container {
        padding: 15px;
        border-radius: 15px;
        gap: 15px;
    }

    header h1 {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }

    header p {
        font-size: 0.9rem;
    }

    .controls {
        flex-direction: column;
        width: 100%;
        gap: 10px;
        padding: 10px;
    }

    .difficulty-toggle {
        width: 100%;
        justify-content: center;
    }

    .difficulty-toggle .mode-btn {
        flex: 1;
    }

    .holes-selector {
        width: 100%;
        justify-content: center;
    }

    .holes-selector select {
        flex: 1;
        max-width: 160px;
    }

    #restart-btn,
    #strategy-btn {
        width: 100%;
    }

    .scene {
        padding: 20px 5px;
        background-size: 40px 40px;
    }

    .holes-container {
        min-height: 80px;
        gap: 6px;
    }

    .hole-wrapper {
        flex: 1;
        width: auto;
        height: 16vw;
        max-width: 70px;
        max-height: 70px;
        min-width: 30px;
    }

    .hole {
        height: 50%;
    }

    .content {
        font-size: 2rem;
        bottom: 5px;
    }

    .hole-wrapper::after {
        font-size: 0.8rem;
        bottom: -20px;
    }

    .result-actions {
        flex-direction: column;
        width: 100%;
    }

    .result-actions .btn {
        width: 100%;
    }

    #log-container {
        padding: 10px;
    }

    #game-log li {
        font-size: 0.85rem;
    }
}

/* Strategy Table */
.strategy-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9rem;
}

.strategy-table th,
.strategy-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
}

.strategy-table th {
    background-color: #f2f2f2;
    color: var(--primary-color);
}

.strategy-table tr:nth-child(even) {
    background-color: #f9f9f9;
}
