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

body {
    font-family: 'Arial', sans-serif;
    background: #2D1B4E;
}

body.fullscreen {
    overflow: hidden;
    width: 100%;
    height: 100dvh;
}

body.fullscreen #game-container {
    height: 100dvh;
}

#game-container {
    width: 100%;
    min-height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

#background {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2D1B4E 0%, #6A0DAD 25%, #9370DB 50%, #4B0082 75%, #2D1B4E 100%);
    z-index: 0;
}

#background::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(148, 0, 211, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(138, 43, 226, 0.4) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(106, 13, 173, 0.2) 0%, transparent 60%);
    animation: magicPulse 13s ease-in-out infinite;
}

@keyframes magicPulse {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.75; }
    50% { transform: scale(1.13) rotate(-3deg); opacity: 1; }
}

#game-title {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: 20px;
}

#game-title h1 {
    font-size: 4em;
    background: linear-gradient(45deg, #9370DB, #FFD700, #DA70D6, #9370DB);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: magicShimmer 2.5s linear infinite;
    text-shadow:
        3px 3px 0 #2D1B4E,
        5px 5px 12px rgba(148, 0, 211, 0.7);
    letter-spacing: 0.15em;
    font-weight: bold;
}

@keyframes magicShimmer {
    0% { background-position: 0% 50%; filter: brightness(1); }
    50% { background-position: 100% 50%; filter: brightness(1.6); }
    100% { background-position: 0% 50%; filter: brightness(1); }
}

.subtitle {
    color: #DA70D6;
    font-size: 1.5em;
    letter-spacing: 0.3em;
    text-shadow:
        2px 2px 0 #2D1B4E,
        3px 3px 8px rgba(138, 43, 226, 0.8);
    font-weight: bold;
    font-style: italic;
}

#slot-machine {
    position: relative;
    z-index: 1;
    margin: 20px 0;
}

.slot-frame {
    background: linear-gradient(135deg, #4B0082 0%, #2D1B4E 50%, #6A0DAD 100%);
    border: 10px solid #9370DB;
    border-radius: 25px;
    padding: 30px;
    box-shadow:
        0 15px 60px rgba(106, 13, 173, 0.7),
        inset 0 0 40px rgba(147, 112, 219, 0.3),
        0 0 0 3px #DA70D6;
}

#reels-container {
    display: flex;
    gap: 10px;
    background: linear-gradient(180deg, #1a0d2e 0%, #2D1B4E 100%);
    padding: 20px;
    border-radius: 15px;
    border: 5px solid #9370DB;
    box-shadow: inset 0 0 30px rgba(106, 13, 173, 0.5);
}

.reel {
    width: 120px;
    height: 360px;
    background: linear-gradient(180deg, #2D1B4E 0%, #1a0d2e 50%, #2D1B4E 100%);
    border: 4px solid #6A0DAD;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow:
        inset 0 0 20px rgba(147, 112, 219, 0.3),
        0 5px 15px rgba(0, 0, 0, 0.6);
}

.symbol {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4.5em;
    background: linear-gradient(135deg, rgba(106, 13, 173, 0.15) 0%, rgba(45, 27, 78, 0.1) 100%);
    border-bottom: 3px solid rgba(147, 112, 219, 0.3);
    transition: all 0.2s;
    user-select: none;
}

.symbol.winning {
    animation: enchantedGlow 0.6s ease-in-out infinite;
    background: linear-gradient(135deg, rgba(147, 112, 219, 0.9) 0%, rgba(218, 112, 214, 0.8) 100%);
    box-shadow:
        0 0 30px rgba(147, 112, 219, 1),
        inset 0 0 20px rgba(255, 215, 0, 0.5);
}

@keyframes enchantedGlow {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1) drop-shadow(0 0 10px #9370DB);
    }
    50% {
        transform: scale(1.12);
        filter: brightness(1.7) drop-shadow(0 0 20px #DA70D6);
    }
}

.reel.spinning .symbol {
    animation: magicSpin 0.08s linear infinite;
}

@keyframes magicSpin {
    0% { filter: blur(0px); transform: translateY(0); }
    50% { filter: blur(7px); transform: translateY(-4px); }
    100% { filter: blur(0px); transform: translateY(0); }
}

.symbol.cascading {
    animation: mysticalFall 0.5s ease-in forwards;
}

@keyframes mysticalFall {
    0% {
        transform: translateY(-120px) rotate(-15deg) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
}

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

#control-panel {
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, #4B0082 0%, #2D1B4E 50%, #6A0DAD 100%);
    border: 6px solid #9370DB;
    border-radius: 20px;
    padding: 25px;
    min-width: 640px;
    box-shadow:
        0 8px 40px rgba(106, 13, 173, 0.6),
        inset 0 3px 15px rgba(147, 112, 219, 0.3);
}

.info-display {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.label {
    color: #DA70D6;
    font-size: 0.95em;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.value {
    color: #FFF;
    font-size: 2.1em;
    font-weight: bold;
    text-shadow:
        0 0 15px rgba(147, 112, 219, 1),
        2px 2px 6px rgba(0, 0, 0, 0.8),
        0 0 25px rgba(106, 13, 173, 0.6);
    min-width: 85px;
    text-align: center;
}

.win-value {
    color: #FFD700;
    text-shadow:
        0 0 20px rgba(255, 215, 0, 1),
        2px 2px 6px rgba(0, 0, 0, 0.9);
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.btn {
    padding: 16px 28px;
    font-size: 1.15em;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.5);
}

.btn:active {
    transform: translateY(3px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.btn-primary {
    background: linear-gradient(135deg, #9370DB 0%, #DA70D6 50%, #9370DB 100%);
    color: #2D1B4E;
    font-size: 1.6em;
    padding: 22px 55px;
    border: 5px solid #6A0DAD;
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.8);
    box-shadow:
        0 8px 25px rgba(147, 112, 219, 0.7),
        inset 0 3px 8px rgba(255, 255, 255, 0.6);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #BA55D3 0%, #FF69B4 50%, #BA55D3 100%);
    box-shadow:
        0 0 35px rgba(147, 112, 219, 1),
        inset 0 3px 10px rgba(255, 255, 255, 0.8);
    transform: scale(1.08);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, #6A0DAD 0%, #4B0082 50%, #6A0DAD 100%);
    color: #DA70D6;
    border: 4px solid #2D1B4E;
    padding: 16px 32px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}

.btn-secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, #8A2BE2 0%, #6A0DAD 50%, #8A2BE2 100%);
    box-shadow: 0 0 25px rgba(138, 43, 226, 0.8);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(45, 27, 78, 0.95);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: linear-gradient(135deg, #4B0082 0%, #2D1B4E 50%, #6A0DAD 100%);
    border: 6px solid #9370DB;
    border-radius: 25px;
    padding: 40px;
    max-width: 650px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow:
        0 0 60px rgba(147, 112, 219, 0.8),
        inset 0 3px 25px rgba(106, 13, 173, 0.3);
}

.modal-content h2 {
    color: #DA70D6;
    font-size: 2.8em;
    text-align: center;
    margin-bottom: 15px;
    text-shadow:
        2px 2px 0 #2D1B4E,
        4px 4px 12px rgba(138, 43, 226, 0.9);
}

.paytable-note {
    text-align: center;
    color: #DA70D6;
    font-size: 1.15em;
    margin-bottom: 20px;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.5);
    padding: 12px;
    border-radius: 12px;
    border: 2px solid #9370DB;
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 22px;
    font-size: 2.8em;
    color: #DA70D6;
    cursor: pointer;
    transition: all 0.3s;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.8);
}

.close-btn:hover {
    color: #FFF;
    transform: rotate(90deg) scale(1.2);
}

.paytable-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.paytable-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 16px;
    border-radius: 12px;
    border: 3px solid #6A0DAD;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

.paytable-item.special {
    background: linear-gradient(135deg, #9370DB 0%, #DA70D6 100%);
    border-color: #4B0082;
}

.symbol-display {
    font-size: 1.6em;
    color: #DA70D6;
    font-weight: bold;
}

.payout {
    color: #DA70D6;
    font-size: 1.4em;
    font-weight: bold;
}

.paytable-item.special .symbol-display,
.paytable-item.special .payout {
    color: #2D1B4E;
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.6);
}

.cascade-info {
    background: rgba(0, 0, 0, 0.6);
    padding: 20px;
    border-radius: 15px;
    border: 3px solid #9370DB;
}

.cascade-info h3 {
    color: #DA70D6;
    font-size: 1.8em;
    margin-bottom: 10px;
    text-align: center;
}

.cascade-info p {
    color: #FFF;
    line-height: 1.6;
    text-align: center;
}

#win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(75, 0, 130, 0.92);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

#win-overlay.hidden {
    display: none;
}

.win-message {
    text-align: center;
    animation: magicWinAnim 0.7s ease-out;
}

.win-message h2 {
    font-size: 6em;
    background: linear-gradient(45deg, #9370DB, #FFD700, #DA70D6);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: magicShimmer 1s linear infinite;
    text-shadow:
        0 0 30px rgba(147, 112, 219, 1),
        0 0 50px rgba(218, 112, 214, 0.8);
    margin-bottom: 25px;
}

.win-message .win-amount {
    font-size: 3.5em;
    color: #FFF;
    font-weight: bold;
    text-shadow:
        3px 3px 0 #2D1B4E,
        5px 5px 15px rgba(147, 112, 219, 0.9);
}

@keyframes magicWinAnim {
    0% {
        transform: scale(0) rotate(720deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.25) rotate(-20deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

#cascade-counter {
    position: fixed;
    top: 50%;
    right: 25px;
    transform: translateY(-50%);
    z-index: 45;
}

#cascade-counter.hidden {
    display: none;
}

.cascade-badge {
    background: linear-gradient(135deg, #4B0082 0%, #2D1B4E 100%);
    border: 5px solid #9370DB;
    border-radius: 15px;
    padding: 20px;
    box-shadow:
        0 0 35px rgba(147, 112, 219, 0.9),
        inset 0 2px 12px rgba(106, 13, 173, 0.3);
    animation: spellPulse 0.8s ease-in-out infinite;
}

.cascade-text {
    font-size: 1.8em;
    font-weight: bold;
    color: #DA70D6;
    text-shadow:
        2px 2px 0 #000,
        3px 3px 6px rgba(138, 43, 226, 0.8);
}

@keyframes spellPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 35px rgba(147, 112, 219, 0.9); }
    50% { transform: scale(1.12); box-shadow: 0 0 50px rgba(147, 112, 219, 1); }
}

@media (max-width: 768px) {
    .slot-frame {
        padding: 15px;
    }

    #game-title h1 {
        font-size: 2.5em;
    }

    .subtitle {
        font-size: 1.1em;
    }

    .reel {
        width: 75px;
        height: 245px;
    }

    .symbol {
        height: 81px;
        font-size: 3em;
    }

    #control-panel {
        min-width: auto;
        width: 92%;
    }

    .controls {
        gap: 10px;
        flex-wrap: wrap;
    }

    .btn-primary {
        padding: 14px 28px;
        font-size: 1.2em;
    }

    .btn-secondary {
        padding: 12px 18px;
        font-size: 0.95em;
    }

    .value {
        min-width: 60px;
    }

    #cascade-counter {
        right: 12px;
    }

    .cascade-badge {
        padding: 12px;
    }

    .cascade-text {
        font-size: 1.3em;
    }
}

@media (max-width: 480px) {
    #game-title h1 {
        font-size: 1.6em;
    }

    .subtitle {
        font-size: 0.85em;
    }

    .slot-frame {
        padding: 10px;
        border-width: 4px;
        border-radius: 15px;
    }

    #reels-container {
        gap: 4px;
        padding: 8px;
    }

    .reel {
        width: 52px;
        height: 168px;
    }

    .symbol {
        height: 56px;
        font-size: 2em;
    }

    #control-panel {
        width: 96%;
        padding: 10px;
        border-width: 3px;
    }

    .info-display {
        gap: 8px;
    }

    .label {
        font-size: 0.75em;
    }

    .value {
        font-size: 1.4em;
    }

    .btn-primary {
        padding: 10px 18px;
        font-size: 1em;
    }

    .btn-secondary {
        padding: 6px 10px;
        font-size: 0.8em;
        border-width: 3px;
    }

    .controls {
        gap: 5px;
        flex-wrap: wrap;
    }

    .value {
        min-width: auto;
    }

    #game-title {
        margin-bottom: 8px;
    }

    #slot-machine {
        margin: 8px 0;
    }

    #game-container {
        padding: 8px 0;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    #game-title {
        display: none;
    }

    #game-container {
        padding: 5px 0;
    }

    #slot-machine {
        margin: 5px 0;
    }

    .slot-frame {
        padding: 8px;
        border-width: 4px;
    }

    #reels-container {
        padding: 8px;
    }

    .reel {
        height: 135px;
    }

    .symbol {
        height: 45px;
        font-size: 2em;
    }

    #control-panel {
        padding: 10px;
        border-width: 3px;
    }

    .info-display {
        margin-bottom: 8px;
    }

    .value {
        font-size: 1.4em;
        min-width: auto;
    }

    .btn-primary {
        padding: 8px 20px;
        font-size: 1em;
        border-width: 3px;
    }

    .btn-secondary {
        padding: 8px 16px;
        font-size: 0.85em;
    }

    #cascade-counter {
        display: none;
    }
}
