:root {
    --bg-grad-start: #004d40;
    --bg-grad-end: #00241a;
    --gold: #ffd700;
    --emerald-light: #00e676;
    --emerald-dark: #00c853;
}

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

body {
    background: radial-gradient(circle, var(--bg-grad-start) 0%, var(--bg-grad-end) 100%);
    color: white;
    font-family: 'Poppins', sans-serif;
    height: 100vh;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background FX */
#stars-container,
#bubbles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle alternate infinite;
}

.bubble {
    position: absolute;
    background: radial-gradient(circle at 30% 30%, rgba(255, 215, 0, 0.8), rgba(255, 215, 0, 0.2));
    border-radius: 50%;
    bottom: -50px;
    animation: floatUp linear infinite;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.5);
}

@keyframes twinkle {
    0% {
        opacity: 0.2;
        transform: scale(0.8);
        box-shadow: 0 0 2px white;
    }

    100% {
        opacity: 1;
        transform: scale(1.2);
        box-shadow: 0 0 8px white;
    }
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0;
    }

    10% {
        opacity: 0.6;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(-110vh) scale(1.5);
        opacity: 0;
    }
}

/* Main App Layout */
#app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 650px;
    height: 98vh;
    max-height: 98vh;
    padding: 15px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 24px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

header {
    width: 100%;
    margin-bottom: 5px;
    display: flex;
    flex-direction: column;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-title {
    font-size: 22px;
    font-weight: 900;
    color: transparent;
    background: linear-gradient(180deg, #fff200 0%, #ff8c00 100%);
    -webkit-background-clip: text;
    background-clip: text;
    text-transform: uppercase;
    letter-spacing: 1px;
    filter: drop-shadow(0 0 10px rgba(0, 255, 0, 0.8)) drop-shadow(0 0 20px rgba(0, 255, 0, 0.4));
    line-height: 1.1;
    text-align: left;
}

.header-subtitle {
    font-size: 13px;
    color: #eee;
    font-weight: 600;
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    width: 100%;
}

.balance-container {
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 15px;
    border-radius: 16px;
    border: 2px solid var(--gold);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8), 0 0 15px rgba(255, 215, 0, 0.2);
    min-width: 150px;
}

.balance-label {
    font-size: 12px;
    color: #ffd;
    font-weight: 800;
    margin-bottom: 2px;
    letter-spacing: 1px;
}

.balance-container .value {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    color: var(--gold);
    text-shadow: 0 0 15px var(--gold);
    letter-spacing: 1px;
    line-height: 1;
}

main {
    position: relative;
    width: 100%;
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Grid & Symbols Overlay */
.grid-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    /* Use max height so the grid shrinks when screen is short */
    max-height: calc(98vh - 220px);
    aspect-ratio: 6 / 5;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 16px;
    border: 2px solid rgba(255, 215, 0, 0.2);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

.grid-container.screenshake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

#grid-backgrounds {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(5, 1fr);
    width: 100%;
    height: 100%;
}

.cell-bg {
    border: 1px solid rgba(255, 215, 0, 0.05);
    background: rgba(255, 255, 255, 0.05);
}

#symbols-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Individual symbol styles */
.symbol {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 40px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.4s, background 0.4s;
    will-change: transform, filter;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

.symbol.falling {
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.symbol.selected {
    z-index: 15 !important;
    filter: drop-shadow(0 0 25px var(--gold)) brightness(1.4);
    background: radial-gradient(circle, rgba(255, 215, 0, 0.4) 0%, transparent 70%);
    border-radius: 50%;
}

.symbol.vanish {
    transform: scale(0) !important;
    opacity: 0;
    transition: transform 0.3s ease-in, opacity 0.3s ease-in;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-2px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(4px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-5px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(5px, 0, 0);
    }
}

/* Floating Text */
#floating-text-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 20;
}

.floating-text {
    position: absolute;
    font-family: 'Poppins', sans-serif;
    font-size: 32px;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold), 0 0 40px var(--gold), 0 4px 4px rgba(0, 0, 0, 0.8);
    -webkit-text-stroke: 1px #fff;
    transform: translate(-50%, -50%);
    animation: floatUpWord 1.5s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
}

@keyframes floatUpWord {
    0% {
        transform: translate(-50%, 10px) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -20px) scale(1.5);
        opacity: 1;
    }

    80% {
        transform: translate(-50%, -40px) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -60px) scale(1.1);
        opacity: 0;
    }
}

/* Control Bar (Footer) */
footer {
    width: 100%;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 16px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 215, 0, 0.2);
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 1);
}

.control-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    padding: 6px 10px;
    border: 1px solid #333;
    min-width: 100px;
}

.box-label {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 5px;
    font-weight: 700;
}

.box-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold);
}

/* Center Controls */
.control-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.spin-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.spin-label {
    font-size: 12px;
    color: #fff;
    font-weight: 700;
    margin-bottom: 5px;
}

.spin-indicators {
    display: flex;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #333;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
    transition: all 0.3s;
}

.dot.active {
    background: var(--gold);
    box-shadow: 0 0 10px var(--gold), inset 0 2px 4px rgba(255, 255, 255, 0.4);
}

.btn-putar {
    background: linear-gradient(135deg, var(--emerald-light), var(--emerald-dark));
    color: white;
    border: none;
    border-radius: 50px;
    padding: 10px 36px;
    font-size: 20px;
    font-weight: 900;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    box-shadow: 0 0 25px rgba(0, 230, 118, 0.5), inset 0 4px 8px rgba(255, 255, 255, 0.3);
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-putar:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 0 35px rgba(0, 230, 118, 0.8), inset 0 4px 8px rgba(255, 255, 255, 0.4);
}

.btn-putar:active:not(:disabled) {
    transform: scale(0.95);
}

.btn-putar:disabled {
    background: linear-gradient(135deg, #444, #222);
    color: #777;
    box-shadow: none;
    cursor: not-allowed;
    border-color: #111;
}

/* Modals */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background: linear-gradient(135deg, #00332a, #001a14);
    border: 2px solid var(--gold);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    max-width: 90%;
    width: 380px;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.8);
    transform: scale(1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal {
    transform: scale(0.5);
}

#confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 101;
}

.win-blessing {
    font-size: 16px;
    color: #00e676;
    font-weight: 700;
    margin-bottom: 12px;
    text-shadow: 0 0 10px #00e676;
    line-height: 1.5;
}

.modal h2 {
    color: var(--gold);
    font-size: 28px;
    margin-bottom: 20px;
    text-shadow: 0 0 15px var(--gold);
    font-weight: 900;
}

.win-amount {
    font-family: 'Orbitron', sans-serif;
    font-size: 38px;
    color: #fff;
    text-shadow: 0 0 20px var(--emerald-light);
    margin: 15px 0 25px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    border: 1px solid var(--emerald-dark);
}

.btn-collect {
    background: var(--gold);
    color: #000;
    border: none;
    border-radius: 30px;
    padding: 12px 30px;
    font-size: 18px;
    font-weight: 800;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
    transition: all 0.2s;
    width: 100%;
}

.btn-collect:hover {
    transform: scale(1.05);
}

.controls-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.btn-small {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 15px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

@media (max-width: 480px) {
    .header-top {
        flex-direction: column;
        gap: 10px;
        align-items: center;
        text-align: center;
    }

    .header-title {
        font-size: 20px;
        text-align: center;
    }

    .balance-container {
        align-items: center;
    }

    .controls-bar {
        padding: 10px;
        flex-direction: row;
        gap: 5px;
    }

    .control-box {
        min-width: 80px;
        padding: 5px;
    }

    .box-label {
        font-size: 9px;
    }

    .box-value {
        font-size: 16px;
    }

    .btn-putar {
        padding: 12px 25px;
        font-size: 18px;
    }

    .symbol {
        font-size: 32px;
        filter: none;
    }
}