* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
}

:root {
    --font-game: 'Luckiest Guy', cursive;
    --font-ui: 'Poppins', sans-serif;
    --color-wood-light: #b07d4f;
    --color-wood-dark: #654321;
    --color-water-dark: #0984e3;
    --color-water-light: #74b9ff;
    --shadow-game: 0 6px 0 rgba(0, 0, 0, 0.2);
}

body {
    font-family: var(--font-ui);
    background-color: #2d3436;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    color: white;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
}

#portrait-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: radial-gradient(circle, #34495e, #2c3e50);
    color: white;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    text-align: center;
    padding: 20px;
}

.warning-content h1 {
    font-family: var(--font-game);
    font-size: clamp(2rem, 5vw, 2.5rem);
    margin-bottom: 10px;
    color: #fab1a0;
}

.rotate-icon {
    font-size: clamp(3rem, 10vw, 5rem);
    display: block;
    margin-bottom: 20px;
    animation: rotatePhones 2s infinite;
}

@keyframes rotatePhones {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}

@media screen and (orientation: portrait) {
    #portrait-warning { display: flex; }
    #start-screen, #game-container { display: none !important; }
}

h1, h2, h3 {
    font-family: var(--font-game);
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 #000, 4px 4px 0 rgba(0, 0, 0, 0.2);
}

.wood-btn {
    position: relative;
    padding: clamp(8px, 2.5dvh, 15px) clamp(15px, 4vw, 40px);
    font-family: var(--font-game);
    font-size: clamp(14px, 3.5dvh, 22px);
    color: #fff8e1;
    border: clamp(2px, 0.5vw, 4px) solid #5d4037;
    border-radius: 50px;
    cursor: pointer;
    background: repeating-linear-gradient(45deg, #8e6e46, #8e6e46 10px, #7d5c36 10px, #7d5c36 20px);
    background-image: url('./assets/kayu.jpg');
    background-size: cover;
    box-shadow: 0 clamp(3px, 1dvh, 6px) 0 #4e342e, 0 clamp(4px, 1.5dvh, 8px) 15px rgba(0, 0, 0, 0.4);
    transition: all 0.1s ease;
    overflow: hidden;
    text-transform: uppercase;
}

.wood-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #4e342e, 0 4px 10px rgba(0, 0, 0, 0.3);
}

.menu-btn {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(12px, 3.5dvh, 20px);
    font-size: clamp(16px, 4dvh, 24px);
    border-radius: 10px;
}

.big-btn {
    font-size: clamp(22px, 6dvh, 30px);
    padding: 5vh 14vh;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-content: center;
    justify-content: center;
    align-items: center;
}

.small-btn {
    padding: 3vh 5vh;
    font-size: clamp(11px, 2.8dvh, 16px);
}

.wood-btn .kinclong {
    position: absolute;
    top: 0; left: -150%;
    width: 100%; height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.7) 50%, rgba(255,255,255,0) 100%);
    transform: skewX(-20deg);
}
.wood-btn:hover .kinclong { animation: shineEffect 0.75s infinite; }
@keyframes shineEffect { 100% { left: 150%; } }

.wood-circle-btn {
    width: clamp(35px, 10dvh, 60px) !important;
    height: clamp(35px, 10dvh, 60px) !important;
    border-radius: 50% !important;
    padding: 0 !important;
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(18px, 5dvh, 28px) !important;
}

.wood-panel {
    background-color: #8e6e46;
    background-image: url('./assets/kayu.jpg');
    background-size: cover;
    border: clamp(2px, 0.5vw, 4px) solid #5d4037;
    border-radius: 15px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5), 0 5px 15px rgba(0, 0, 0, 0.3);
}

#start-screen {
    display: flex;
    position: relative;
    height: 100dvh;
    width: 100vw;
    background-color: #2d3436;
    overflow: hidden;
}

.parallax-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
    overflow: hidden;
}

.parallax-layer {
    position: absolute;
    top: -10%; left: -10%;
    width: 120%; height: 120%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.p-layer-1 { background-image: url('./assets/bg_start.jpg'); z-index: 2; }
.p-layer-2 { background-color: transparent; z-index: 3; }
.p-layer-3 { background-color: transparent; z-index: 4; }

.menu-panel {
    position: absolute;
    left: 0; top: 0;
    width: clamp(300px, 35vw, 450px);
    height: 100%;
    background: rgba(30, 30, 30, 0.9);
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding: clamp(20px, 5vw, 40px);
    box-shadow: 10px 0 30px rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    border-right: 2px solid rgba(255,255,255,0.1);
}

.menu-panel .game-title {
    font-size: clamp(40px, 10dvh, 70px);
    text-align: center;
    margin-bottom: 10px;
    color: #f1c40f;
    -webkit-text-stroke: 2px #ad9d44;
}

.menu-divider {
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, transparent, #ad9d44, transparent);
    margin-bottom: 30px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    width: 100%;
}

#home-history-list::-webkit-scrollbar { width: 6px; }
#home-history-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 10px; }
#home-history-list::-webkit-scrollbar-thumb { background: #f1c40f; border-radius: 10px; }

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.5);
    padding: clamp(6px, 1.5dvh, 8px) clamp(8px, 2vw, 15px);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
}
.history-info {
    text-align: left;
    font-size: clamp(11px, 2.8dvh, 14px);
    font-family: var(--font-ui);
}
.history-info strong {
    color: #f1c40f;
    font-size: clamp(12px, 3dvh, 15px);
}
.play-history-btn { font-size: clamp(10px, 2.5dvh, 12px); padding: 5px 10px; }

#game-container {
    height: 100dvh;
    width: 100vw;
    position: relative;
    background: linear-gradient(to bottom, #81ecec 0%, #74b9ff 15%, #0984e3 100%);
    overflow: hidden;
}

.river-bank {
    position: absolute;
    left: 0; width: 100%;
    height: clamp(30px, 8dvh, 66px);
    background-image: url('./assets/rumput_tepi.png');
    background-repeat: repeat-x; background-size: contain; z-index: 10;
    transition: top 1s ease-out, bottom 1s ease-out, opacity 1s ease-out;
}
.bank-top { top: clamp(8%, 10dvh, 10%); transform: rotate(180deg); }
.bank-bottom { bottom: clamp(8%, 10dvh, 9%); }

.bank-top.zoom-hidden {
    top: -15%;
    opacity: 0;
}
.bank-bottom.zoom-hidden {
    bottom: -15%;
    opacity: 0;
}

#top-ui {
    position: absolute;
    top: clamp(5px, 2dvh, 15px);
    width: 100%;
    padding: 0 clamp(10px, 3vw, 30px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

#timer-box {
    padding: clamp(5px, 1.5dvh, 10px) clamp(15px, 4vw, 40px);
    font-size: clamp(18px, 5dvh, 30px);
    color: #fff;
    display: flex; align-items: center; gap: clamp(5px, 1.5vw, 15px);
}
.clock-icon { animation: strobe 1.5s infinite; }
@keyframes strobe { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

#river {
    position: absolute;
    top: clamp(12%, 15dvh, 15%);
    bottom: clamp(10%, 12dvh, 12%);
    width: 100%;
    background: linear-gradient(to bottom, #0984e3 0%, #076bba 50%, #054f8a 100%);
    overflow: hidden;
    box-shadow: inset 0 15px 25px rgba(0, 0, 0, 0.3), inset 0 -15px 25px rgba(0, 0, 0, 0.3);
}

.wave {
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 200%;
    height: 100%;
    background-repeat: repeat;
    pointer-events: none;
}

.wave1 {
    background-image: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 60%);
    background-size: 301px 571px;
    background-position: 0 15%;
    animation: flowRight 50s linear infinite; 
    z-index: 1; 
}
.wave2 {
    background-image: radial-gradient(ellipse at center, rgba(116, 185, 255, 0.25) 0%, rgba(255, 255, 255, 0) 70%);
    background-size: 264px 83px;
    background-position: 0 45%;
    animation: flowLeft 40s linear infinite; 
    z-index: 2; 
}
.wave3 {
    background-image: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 60%);
    background-size: 177px 124px;
    background-position: 0 80%;
    animation: flowRight 45s linear infinite; 
    z-index: 3;
}

@keyframes flowRight {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

@keyframes flowLeft {
    0% { transform: translateX(-50%); }
    100% { transform: translateX(0); }
}

#finish-line {
    position: absolute; right: 15%; top: 0; 
    width: clamp(60px, 10vw, 120px); height: 100%;
    background-image: url('./assets/finis_kayu.png');
    background-size: 100% 100%; z-index: 5; filter: drop-shadow(-5px 0 10px rgba(0,0,0,0.3));
}

.duck-container {
    position: absolute; left: -150px;
    display: flex; flex-direction: column; align-items: center;
    transition: top 0.2s ease-out; filter: drop-shadow(0 clamp(5px, 2dvh, 10px) 5px rgba(0,0,0,0.3));
}
.duck-img {
    width: clamp(35px, 12dvh, 80px);
    height: auto;
    animation: duckSwim 1s infinite alternate ease-in-out;
}
@keyframes duckSwim { 0% { transform: translateY(0) rotate(-3deg); } 100% { transform: translateY(-5px) rotate(3deg); } }

.player-name {
    font-family: var(--font-ui); font-weight: bold;
    background: rgba(255, 255, 255, 0.85); color: #2d3436;
    padding: 1px clamp(4px, 1vw, 10px); 
    border-radius: 20px; 
    font-size: clamp(9px, 2.5dvh, 12px);
    margin-bottom: 2px; white-space: nowrap; z-index: 2;
    border: 1px solid #ccc;
}

#bottom-banner {
    position: absolute; bottom: 0; left: 0; 
    width: 100%; 
    height: clamp(55px, 14dvh, 12%);
    background: linear-gradient(to bottom, #e74c3c, #c0392b);
    background-image: url('./assets/kayu.jpg'); background-blend-mode: multiply;
    border-top: 4px solid #a93226;
    clip-path: polygon(0 15%, 100% 0, 100% 100%, 0 100%); 
    display: flex; align-items: center; justify-content: space-between; 
    padding: clamp(5px, 1.5dvh, 10px) clamp(10px, 3vw, 30px);
    z-index: 100;
}

.banner-text {
    font-size: clamp(16px, 4.5dvh, 36px);
    color: #fff; text-shadow: 2px 2px 0 #851e13;
    animation: titlePulse 2s infinite;
    margin-top: auto; margin-bottom: 2px;
}
@keyframes titlePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); opacity: 0.9; } }

.banner-controls {
    display: flex; gap: clamp(5px, 1vw, 10px); align-items: center; 
    z-index: 101; margin-top: auto; margin-bottom: 2px;
}

.modal-overlay, #winner-announcement {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh;
    background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(5px);
    z-index: 1000; display: none; justify-content: center; align-items: center;
    animation: fadeIn 0.3s;
}

.modal-content, .winner-content {
    padding: clamp(15px, 4dvh, 40px) clamp(15px, 4vw, 60px);
    text-align: center;
    max-width: min(95vw, 550px);
    max-height: 95dvh;
    display: flex; flex-direction: column; gap: clamp(8px, 2dvh, 15px);
    overflow-y: auto;
    animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
.modal-content::-webkit-scrollbar, .winner-content::-webkit-scrollbar { display: none; }

.modal-content h2 { font-size: clamp(22px, 6dvh, 32px); color: #f1c40f; margin: 0; }
.modal-content p { font-size: clamp(12px, 3dvh, 14px); margin: 0; }

#bulk-input {
    width: 100%; 
    height: clamp(80px, 20dvh, 150px);
    padding: 10px; border-radius: 10px; border: 3px solid #5d4037;
    font-family: var(--font-ui); font-size: clamp(12px, 3dvh, 16px);
    background-color: #fff8e1; color: #333; resize: none;
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.2);
}

.modal-actions { display: flex; justify-content: space-between; gap: 15px; margin-top: auto; }
.modal-actions .wood-btn { flex: 1; }

.winner-content h2 { font-size: clamp(35px, 8dvh, 60px); margin: 5px 0; }
.winner-content p { font-size: clamp(14px, 3.5dvh, 20px); margin: 0;}

#leaderboard-container {
    font-size: clamp(12px, 3.2dvh, 16px);
    text-align: left; background: rgba(0, 0, 0, 0.5);
    padding: clamp(10px, 2.5dvh, 15px) clamp(10px, 3vw, 20px);
    border-radius: 10px;
    max-height: 35dvh;
    overflow-y: auto;
}
.leaderboard-title { text-align: center; margin-bottom: 8px; font-size: clamp(14px, 3.5dvh, 18px); }
.leaderboard-list { list-style: none; line-height: 1.5; }
.leaderboard-item {
    display: flex; justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: clamp(3px, 1dvh, 5px); padding-bottom: clamp(3px, 1dvh, 5px);
}
.leaderboard-item:last-child { border: none; margin: 0; padding: 0; }
.leaderboard-name { color: #f1c40f; margin-left: 10px; }

#winner-btn-container { display: flex; justify-content: center; flex-wrap: wrap; gap: clamp(5px, 1vw, 10px); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }

@media screen and (max-width: 650px) {
    .banner-text {
        display: none;
    }
    .banner-controls {
        width: 100%;
        justify-content: center;
    }
}

.room-item {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.2); 
    padding: 10px 0;
}
.room-item:last-child { 
    border-bottom: none; 
}
.room-name-text { 
    color: #f1c40f; 
    font-weight: bold; 
}

#loading-screen {
    position: fixed;
    top: 0; 
    left: 0;
    width: 100vw; 
    height: 100vh;
    height: 100dvh;
    background: #2d3436 url('./assets/bg_start.jpg') center/cover no-repeat;
    background-blend-mode: multiply;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    flex-direction: column;
}

.loading-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.loading-bar-wrapper {
    width: clamp(200px, 50vw, 400px);
    height: 25px;
    background-color: #5d4037;
    border: 3px solid #fff8e1;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

#loading-bar-progress {
    width: 0%;
    height: 100%;
    background: repeating-linear-gradient(45deg, #f1c40f, #f1c40f 10px, #f39c12 10px, #f39c12 20px);
    transition: width 0.3s ease;
}

#loading-text {
    color: #fff8e1;
    font-size: clamp(12px, 3dvh, 18px);
    font-weight: bold;
    animation: pulseText 1.5s infinite;
}

@keyframes pulseText { 
    0%, 100% { opacity: 1; } 
    50% { opacity: 0.5; } 
}

input[type=range] {
    background: #5d4037;
    height: 12px;
    border-radius: 6px;
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: #f1c40f;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}