@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@700;900&family=Roboto+Condensed:wght@700&display=swap');

/* --- 1. THE VIEWPORT --- */
body {
    background-color: #1a0b2e;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Roboto Condensed', sans-serif;
    /* Minimalist Ethereal Background */
    background: radial-gradient(circle at 50% 50%, #2d1b4e 0%, #0f0518 100%);
}

/* --- 2. THE SCALER WRAPPER --- */
#gameScaler {
    width: 480px;
    height: 850px;
    position: relative;
    /* Soft floating shadow */
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.6));
}

/* --- 3. THE CABINET --- */
.game-wrapper {
    width: 100%;
    height: 100%;
    background: #1a0b2e;

    /* Smooth rounded corners */
    border-radius: 24px;

    /* Layered Border Effect using Box Shadow for smoothness */
    box-shadow:
        0 0 0 1px #2d1b4e, /* Inner dark line */
        0 0 0 4px #C0C0C0, /* Main Silver Border */
        0 0 0 5px #1a0b2e, /* Outer gap */
        0 0 0 8px #4B0082; /* Outer Indigo Ring */

    display: grid;
    /* Adjusted grid for better spacing */
    grid-template-rows: 60px 80px 1fr 130px;
    overflow: hidden;
    position: relative;
}

/* --- 4. SECTIONS --- */

/* A. Top Bar */
.top-bar {
    background: linear-gradient(180deg, #2d1b4e 0%, #1a0b2e 100%);
    border-bottom: 1px solid rgba(192, 192, 192, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 10;
    position: relative;
}

.theme-select {
    background: rgba(255, 255, 255, 0.05);
    color: #E6E6FA; /* Lavender */
    border: 1px solid rgba(192, 192, 192, 0.4);
    padding: 8px;
    min-height: 40px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    width: 140px;
    text-align: center;
    outline: none;
}

.sys-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(192, 192, 192, 0.4);
    color: #E6E6FA;
    font-size: 0.9rem;
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.sys-btn:active {
    background: #4B0082;
    border-color: #E6E6FA;
    color: #fff;
    transform: scale(0.95);
}

/* B. Header (Score) */
.header {
    background: #1a0b2e;
    /* Subtle separation */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    position: relative;
    overflow: hidden;
}

.stats-box {
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(192, 192, 192, 0.2);
    border-radius: 12px;
    padding: 8px 15px;
    min-width: 100px;
}

.label {
    font-size: 0.7rem;
    color: #a0a0c0;
    letter-spacing: 1.5px;
    display: block;
    margin-bottom: 4px;
    font-weight: bold;
    text-transform: uppercase;
}
.value {
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    color: #E6E6FA;
}
.value.highlight {
    color: #fff;
    text-shadow: 0 0 15px rgba(230, 230, 250, 0.6);
}

/* C. Game Screen */
.game-container {
    background: #0f0518;
    position: relative;
    width: 100%;
    height: 100%;
    /* Inner shadow for depth without borders */
    box-shadow: inset 0 0 50px rgba(0,0,0,0.8);
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Bonus Overlay */
.bonus-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 5, 24, 0.95);
    backdrop-filter: blur(5px);
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    animation: fade-in 0.5s ease-out;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.bonus-content {
    text-align: center;
    color: #E6E6FA;
    font-family: 'Cinzel', serif;
    padding: 40px;
    border: 2px solid #C0C0C0;
    border-radius: 20px;
    background: radial-gradient(circle, rgba(75, 0, 130, 0.4), transparent);
    box-shadow: 0 0 40px rgba(75, 0, 130, 0.3);
}

.bonus-content h2 {
    font-size: 3rem;
    margin: 0 0 20px 0;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

#bonusCounter {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #C0C0C0;
    font-family: 'Roboto Condensed', sans-serif;
}

#bonusWinDisplay {
    font-size: 2.5rem;
    margin-bottom: 40px;
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

#skipBonusButton {
    background: linear-gradient(135deg, #4B0082, #2d1b4e);
    border: 1px solid #C0C0C0;
    color: #fff;
    font-family: 'Roboto Condensed', sans-serif;
    font-size: 1.2rem;
    padding: 12px 35px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

#skipBonusButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(75, 0, 130, 0.6);
    border-color: #fff;
}

#skipBonusButton:active {
    transform: translateY(1px);
}

.bonus-indicator {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(75, 0, 130, 0.9);
    border: 1px solid #C0C0C0;
    border-radius: 20px;
    padding: 8px 20px;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: #E6E6FA;
    z-index: 10;
    display: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

/* Mechanical Frame - Minimalist Dividers Only */
.mechanical-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.frame-top, .frame-bottom, .frame-left, .frame-right, .frame-bottom-left, .frame-bottom-right, .glass-reflection {
    display: none; /* Hide heavy bezel elements */
}

.reel-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(180deg, transparent 0%, rgba(192, 192, 192, 0.2) 20%, rgba(192, 192, 192, 0.2) 80%, transparent 100%);
}

/* Slot Lever - Simplified or Hidden on Mobile */
.slot-lever {
    position: absolute;
    right: -45px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    opacity: 0.9;
}

.lever-ball {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #E6E6FA, #C0C0C0);
    position: absolute;
    top: -18px;
    left: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.lever-arm {
    width: 6px;
    height: 160px;
    background: linear-gradient(to right, #888, #aaa, #888);
    border-radius: 3px;
    transform-origin: top center;
}

.lever-base {
    width: 50px;
    height: 25px;
    background: #2d1b4e;
    border: 1px solid #C0C0C0;
    border-radius: 6px;
    position: absolute;
    bottom: -25px;
    left: -22px;
    box-shadow: 0 5px 10px rgba(0,0,0,0.5);
}

.lever-arm.pulling {
    animation: lever-swing 600ms ease-out;
}

@keyframes lever-swing {
    0% { transform: rotate(0deg); }
    30% { transform: rotate(25deg); }
    100% { transform: rotate(0deg); }
}

@media (max-width: 600px) {
    .slot-lever { display: none; }
}

/* Marquee Lights - Hidden for minimalist theme */
.marquee-lights {
    display: none;
}

/* D. Controls (Bottom) */
.controls {
    background: #1a0b2e;
    /* Subtle separator */
    border-top: 1px solid rgba(192, 192, 192, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    position: relative;
}

.control-group {
    background: rgba(255, 255, 255, 0.03);
    padding: 5px;
    border-radius: 25px;
    border: 1px solid rgba(192, 192, 192, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
}

.display-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 50px;
}

.display-panel .label {
    font-size: 0.6rem;
    color: #888;
    margin-bottom: 2px;
    font-weight: bold;
}

.display-panel span:not(.label) {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: bold;
    color: #E6E6FA;
}

/* Buttons */
.circle-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid #C0C0C0;
    color: #C0C0C0;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.circle-btn:hover {
    background: rgba(192, 192, 192, 0.1);
    color: #fff;
    border-color: #fff;
}
.circle-btn:active {
    transform: scale(0.9);
}

.spin-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    /* Clean gradient */
    background: radial-gradient(circle at 30% 30%, #E6E6FA, #C0C0C0);
    border: none;
    color: #1a0b2e;
    font-weight: 900;
    font-size: 1.6rem;
    font-family: 'Cinzel', serif;
    letter-spacing: 2px;
    cursor: pointer;
    /* Soft shadow lift */
    box-shadow:
        0 10px 20px rgba(0,0,0,0.4),
        0 0 0 4px #1a0b2e, /* Gap */
        0 0 0 6px #4B0082; /* Ring */
    margin-top: -40px;
    z-index: 20;
    transition: all 0.15s ease;
    position: relative;
}

.spin-btn:active {
    transform: scale(0.95);
    margin-top: -38px;
    box-shadow:
        0 5px 10px rgba(0,0,0,0.4),
        0 0 0 4px #1a0b2e,
        0 0 0 6px #4B0082;
}

.spin-btn.lever-pull {
    animation: lever-pull-animation 0.6s ease-out;
}

@keyframes lever-pull-animation {
    0% { transform: scale(1) translateY(0); }
    20% { transform: scale(0.95) translateY(10px); }
    100% { transform: scale(1) translateY(0); }
}

.spin-btn:disabled {
    background: #555;
    color: #888;
    box-shadow: none;
    border: 2px solid #444;
    cursor: not-allowed;
}

/* Win Overlay */
.win-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
    transition: 0.2s;
}
.win-overlay.active {
    box-shadow: inset 0 0 60px rgba(192, 192, 192, 0.4);
    border-radius: 0; /* Let container clip it */
}

/* Modal */
.modal-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 100;
    display: none; justify-content: center; align-items: center;
    backdrop-filter: blur(3px);
}
.modal-overlay.active { display: flex; }
.modal-content {
    background: #1a0b2e;
    border: 1px solid #C0C0C0;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    max-height: 80%;
    overflow-y: auto;
    color: #E6E6FA;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #2d1b4e;
    border-bottom: 1px solid rgba(192, 192, 192, 0.2);
    position: sticky;
    top: 0;
    z-index: 10;
}
.modal-header h2 { color: #fff; margin: 0; font-size: 1.2rem; letter-spacing: 1px; }
.modal-body { padding: 15px; }
.modal-footer { padding: 15px; font-size: 0.85rem; text-align: center; color: #888; }
.pay-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 12px 0;
}
.pay-icon { font-size: 2rem; width: 60px; text-align: center; }
.pay-info { flex: 1; font-size: 1rem; color: #ccc; }
.close-btn {
    background: none;
    border: none;
    color: #C0C0C0;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
}

/* Toast */
.toast-container {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 90;
    width: 90%;
    text-align: center;
}
.toast {
    background: rgba(26, 11, 46, 0.9);
    color: #fff;
    padding: 15px 25px;
    border: 1px solid #C0C0C0;
    border-radius: 50px;
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}
.toast.show { opacity: 1; transform: translateX(-50%) scale(1.05); }
.toast.win { border-color: #ffd700; color: #ffd700; }
.toast.error { border-color: #ff4444; color: #ff4444; }

/* Decorations - Bolts */
.bolt {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #C0C0C0;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #1a0b2e;
    font-size: 8px;
    z-index: 50;
    box-shadow: 0 0 5px rgba(192, 192, 192, 0.5);
}
/* Inset bolts slightly more */
.bolt.tl { top: 12px; left: 12px; }
.bolt.tr { top: 12px; right: 12px; }
.bolt.bl { bottom: 12px; left: 12px; }
.bolt.br { bottom: 12px; right: 12px; }

/* Mobile Optimizations */
@media (orientation: landscape) and (max-height: 600px) {
    #gameScaler { max-height: 95vh; }
    .top-bar { padding: 0 10px; }
    .spin-btn { width: 80px; height: 80px; font-size: 1.2rem; margin-top: -25px; }
    .game-wrapper { border-radius: 16px; }
}

* { user-select: none; }
.modal-content * { user-select: text; }
.touch-active { opacity: 0.7; }
