* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #f5f5f5;
    margin: 0;
    position: relative;
}

.config-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 100;
}

.config-panel h3 {
    margin-bottom: 8px;
    font-size: 16px;
    color: #333;
}

.config-option {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.config-option label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.config-option input[type="radio"] {
    cursor: pointer;
}

.header {
    background-color: #555;
    color: white;
    width: 100%;
    padding: 15px 0;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    flex: 1;
    justify-content: center;
    padding: 20px;
}

.arrow-container {
    position: relative;
    height: 40px;
    width: 100%;
    display: flex;
    justify-content: center;
    transition: height 0.3s ease;
}

.arrow-container.butterfly-mode {
    height: 0px; /* Wyższa pozycja dla trybu butterfly */
}

.arrow {
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 30px solid #333;
    position: absolute;
    bottom: 0;
    z-index: 10;
    transition: bottom 0.3s ease;
}

.butterfly-mode .arrow {
    bottom: 20px; /* Dodatkowe przesunięcie strzałki w górę dla trybu butterfly */
}

.wheel-container {
    position: relative;
    width: 400px;
    height: 400px;
    transition: width 0.3s ease, height 0.3s ease;
}

.wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: relative;
    overflow: hidden; /* Domyślnie hidden dla trybu "Wheel" */
    border: 5px solid #333;
    transition: transform 4s cubic-bezier(0.25, 1, 0.5, 1), border 0.3s ease, overflow 0.3s ease, width 0.3s ease, height 0.3s ease;
}

.segment {
    position: absolute;
    width: 50%;
    height: 50%;
    left: 50%;
    top: 0;
    transform-origin: 0% 100%;
    border: 1px solid #333;
    overflow: visible; /* Zmienione z hidden na visible */
    text-align: center;
    transition: width 0.3s ease, height 0.3s ease;
}

/* Zmniejszenie elementów o 20% dla urządzeń mobilnych o niskiej rozdzielczości */
@media screen and (max-width: 768px) {
    .wheel-container {
        width: 320px; /* 400px * 0.8 = 320px */
        height: 320px; /* 400px * 0.8 = 320px */
    }
    
    .arrow {
        border-left: 16px solid transparent; /* 20px * 0.8 = 16px */
        border-right: 16px solid transparent; /* 20px * 0.8 = 16px */
        border-top: 24px solid #333; /* 30px * 0.8 = 24px */
    }
}

/* Dodatkowe zmniejszenie o 30% dla trybu Butterfly na urządzeniach mobilnych */
@media screen and (max-width: 768px) {
    .butterfly-mode-active .wheel-container {
        width: 280px; /* 400px * 0.7 = 280px */
        height: 280px; /* 400px * 0.7 = 280px */
    }
    
    .butterfly-mode-active .arrow {
        border-left: 14px solid transparent; /* 20px * 0.7 = 14px */
        border-right: 14px solid transparent; /* 20px * 0.7 = 14px */
        border-top: 21px solid #333; /* 30px * 0.7 = 21px */
    }
}

.segment:nth-child(1) {
    transform: rotate(0deg) skewY(-30deg);
    background-color: #FF6B6B;
}

.segment:nth-child(2) {
    transform: rotate(60deg) skewY(-30deg);
    background-color: #FFD93D;
}

.segment:nth-child(3) {
    transform: rotate(120deg) skewY(-30deg);
    background-color: #6BCB77;
}

.segment:nth-child(4) {
    transform: rotate(180deg) skewY(-30deg);
    background-color: #4D96FF;
}

.segment:nth-child(5) {
    transform: rotate(240deg) skewY(-30deg);
    background-color: #9D65C9;
}

.segment:nth-child(6) {
    transform: rotate(300deg) skewY(-30deg);
    background-color: #F2C1D1;
}

.segment span {
    display: block;
    position: absolute;
    width: 70px;
    transform: skewY(30deg) rotate(30deg);
    left: 16%;
    top: 47%;
    font-size: 14px;
    font-weight: bold;
    color: #000;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.7);
    text-align: center;
    white-space: nowrap;
    background-color: rgba(255, 255, 255, 0.5);
    padding: 6px 10px;
    border-radius: 18px;
    box-sizing: content-box;
    transition: width 0.3s ease, font-size 0.3s ease, padding 0.3s ease, border-radius 0.3s ease;
}

/* Zmniejszenie tekstu i elementów wewnątrz segmentów dla urządzeń mobilnych */
@media screen and (max-width: 768px) {
    .segment span {
        width: 56px; /* 70px * 0.8 = 56px */
        font-size: 11px; /* 14px * 0.8 = 11.2px ≈ 11px */
        padding: 5px 8px; /* 6px * 0.8 = 4.8px ≈ 5px, 10px * 0.8 = 8px */
        border-radius: 14px; /* 18px * 0.8 = 14.4px ≈ 14px */
    }
}

/* Dodatkowe zmniejszenie dla trybu Butterfly na urządzeniach mobilnych */
@media screen and (max-width: 768px) {
    .butterfly-mode-active .segment span {
        width: 49px; /* 70px * 0.7 = 49px */
        font-size: 10px; /* 14px * 0.7 = 9.8px ≈ 10px */
        padding: 4px 7px; /* 6px * 0.7 = 4.2px ≈ 4px, 10px * 0.7 = 7px */
        border-radius: 13px; /* 18px * 0.7 = 12.6px ≈ 13px */
    }
}

.segment.highlight {
    background-color: #4CAF50 !important; /* Zielony kolor dla wygranego segmentu */
    transform-origin: 0% 100%;
    transform: scale(1.1) rotate(var(--rotation)) skewY(-30deg) !important;
    z-index: 10;
}

#spin-button {
    position:absolute;
    bottom: 20px;
    padding: 12px 24px;
    font-size: 18px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, padding 0.3s, font-size 0.3s;
}

#spin-button:hover {
    background-color: #45a049;
}

#spin-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Dostosowanie przycisku dla urządzeń mobilnych */
@media screen and (max-width: 768px) {
    #spin-button {
        padding: 10px 19px; /* 12px * 0.8 = 9.6px ≈ 10px, 24px * 0.8 = 19.2px ≈ 19px */
        font-size: 14px; /* 18px * 0.8 = 14.4px ≈ 14px */
    }
    
    .butterfly-mode-active #spin-button {
        padding: 8px 17px; /* 12px * 0.7 = 8.4px ≈ 8px, 24px * 0.7 = 16.8px ≈ 17px */
        font-size: 13px; /* 18px * 0.7 = 12.6px ≈ 13px */
    }
}

/* Popup styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.popup-content {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    max-width: 80%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transform: scale(0.8);
    transition: transform 0.3s;
    cursor: pointer;
}

.popup-overlay.active .popup-content {
    transform: scale(1);
}

.popup-title {
    font-size: 28px;
    color: #4CAF50;
    margin-bottom: 15px;
    font-weight: bold;
}

.popup-title.try-again {
    color: #FF0000; /* Czerwony kolor dla "Try Again" */
}

.popup-message {
    font-size: 20px;
    margin-bottom: 15px;
}

.popup-instruction {
    font-size: 14px;
    color: #777;
    margin-top: 20px;
}

/* Mobile adjustments for popup */
@media screen and (max-width: 768px) {
    .popup-content {
        padding: 20px;
    }
    
    .popup-title {
        font-size: 24px;
    }
    
    .popup-message {
        font-size: 16px;
    }
}