* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: #000;
    color: #fff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(71, 60, 139, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(123, 104, 238, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(71, 60, 139, 0.1) 0%, transparent 50%);
    padding: 20px;
    animation: pageFadeIn 0.6s ease-out forwards;
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Allow scroll when in game screen if content exceeds viewport */
body.game-active {
    overflow-y: auto;
}

.container {
    background: #1e1e1e;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(123, 104, 238, 0.3);
    border: 2px solid #473c8b;
    overflow: visible;
}

/* Screens */
.screen {
    display: none;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Game Header */
.game-header {
    text-align: center;
    margin-bottom: 2rem;
}

.game-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #7b68ee;
    text-shadow: 0 0 20px rgba(123, 104, 238, 0.6);
}

@keyframes gradient-shift {

    0%,
    100% {
        background-position: 0% center;
    }

    50% {
        background-position: 100% center;
    }
}

.warning {
    color: #ff6b6b;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px;
    background-color: rgba(255, 107, 107, 0.1);
    border-radius: 8px;
    border: 2px solid rgba(255, 107, 107, 0.3);
}

/* Setup Form */
.setup-form {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.05);
    padding: 2rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #fff;
    font-size: 1rem;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 2px solid #473c8b;
    border-radius: 10px;
    background-color: #2d2d2d;
    color: #fff;
    transition: all 0.3s ease;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: #7b68ee;
    box-shadow: 0 0 15px rgba(123, 104, 238, 0.5);
}

.form-group input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#player-names-container {
    margin-bottom: 1.5rem;
}

.player-input {
    margin-bottom: 1rem;
}

/* Custom Percentages */
.custom-percentages-container {
    background-color: rgba(123, 104, 238, 0.05);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid rgba(123, 104, 238, 0.2);
}

.toggle-container {
    margin-bottom: 1rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-weight: 600;
    gap: 15px;
}

.toggle-label span:first-child {
    user-select: none;
    flex: 1;
}

/* Custom Toggle Switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: 0.3s;
    border-radius: 26px;
    border: 2px solid rgba(123, 104, 238, 0.3);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background-color: #7b68ee;
    border-color: #7b68ee;
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:focus+.toggle-slider {
    box-shadow: 0 0 8px rgba(123, 104, 238, 0.6);
}

.percentages-controls {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid rgba(123, 104, 238, 0.3);
}

.percentages-info {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 1rem;
    text-align: center;
}

.percentage-group {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    gap: 10px;
}

.percentage-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    margin-bottom: 0;
    font-size: 0.95rem;
}

.category-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.percentage-group input[type="number"] {
    width: 70px;
    padding: 8px;
    text-align: center;
    font-weight: 600;
}

.percentage-symbol {
    font-weight: 600;
    color: #7b68ee;
}

.percentage-total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid rgba(123, 104, 238, 0.3);
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #7b68ee;
}

.percentage-warning {
    display: inline-block;
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-left: 10px;
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}



.setting-group {
    margin-bottom: 1.5rem;
}

.custom-option {
    background-color: rgba(123, 104, 238, 0.05);
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid rgba(123, 104, 238, 0.2);
}


/* Buttons */
.btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.primary-btn {
    background: linear-gradient(45deg, #473c8b, #7b68ee);
    color: white;
    width: 100%;
    box-shadow: 0 4px 15px rgba(123, 104, 238, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(123, 104, 238, 0.6);
}

.primary-btn:active {
    transform: translateY(0);
}

/* Game Screen */
.round-counter {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: #7b68ee;
    margin-bottom: 2rem;
    padding: 10px 20px;
    background-color: rgba(123, 104, 238, 0.1);
    border-radius: 10px;
    border: 2px solid rgba(123, 104, 238, 0.3);
}

.phrase-container {
    height: 350px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    border-radius: 20px;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.phrase-type-label {
    font-size: 1.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.phrase-type-label.visible {
    opacity: 1;
}

.phrase-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    filter: blur(20px);
    opacity: 0.3;
    z-index: -1;
}

#phrase-text {
    font-size: 1.5rem;
    line-height: 1.6;
    text-align: center;
    font-weight: 600;
    position: relative;
    z-index: 1;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    word-wrap: break-word;
    transition: opacity 0.2s ease;
}

.phrase-container.normal {
    background: linear-gradient(135deg, #473c8b, #7b68ee);
}

.phrase-container.challenge {
    background: linear-gradient(135deg, #8B0000, #DC143C);
}

.phrase-container.vote {
    background: linear-gradient(135deg, #228B22, #32CD32);
}

.phrase-container.rule {
    background: linear-gradient(135deg, #FFD700, #FFA500);
}

.next-btn {
    background: linear-gradient(45deg, #473c8b, #7b68ee);
    color: white;
    width: 100%;
    font-size: 1.3rem;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(123, 104, 238, 0.4);
}

.next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(123, 104, 238, 0.6);
}

.next-btn:active {
    transform: translateY(0);
}

/* End Screen */
.end-message {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #7b68ee;
}

.reminder {
    font-size: 1rem;
    color: #7b68ee;
    margin-bottom: 2rem;
    padding: 15px;
    background-color: rgba(123, 104, 238, 0.1);
    border-radius: 10px;
    border: 2px solid rgba(123, 104, 238, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
    }

    /* Only when game is active */
    body.game-active .container {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    h1 {
        font-size: 2rem;
    }

    .phrase-text {
        font-size: 1.3rem;
    }

    .btn {
        font-size: 16px;
        padding: 12px;
    }

    #game-screen {
        overflow: visible;
    }
}

@media (max-width: 480px) {
    .game-header h1 {
        font-size: 1.7rem;
    }

    .setup-form {
        padding: 1.2rem;
    }

    .phrase-container {
        height: 250px;
        width: 100%;
        padding: 1.5rem;
    }

    .btn {
        font-size: 1rem;
        padding: 12px 20px;
    }

    .next-btn {
        font-size: 1.1rem;
        padding: 18px;
    }
}

/* Home Button */
.home-button {
    position: fixed;
    top: 10px;
    left: 10px;
    background-color: rgba(71, 60, 139, 0.8);
    color: white;
    border: 1px solid #7b68ee;
    border-radius: 5px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.home-button:hover {
    background-color: rgba(123, 104, 238, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(123, 104, 238, 0.3);
}

.home-icon {
    font-size: 16px;
}

/* Animations for phrase changes */
@keyframes phraseSlideIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.phrase-animate {
    animation: phraseSlideIn 0.4s ease;
}

/* Rules Badge - Minimal and Discrete */
.rules-badge {
    position: fixed;
    top: 40px;
    right: 40px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
    transition: all 0.3s ease;
}

.rules-badge svg {
    width: 24px;
    height: 24px;
    fill: #000;
}

.rules-badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    padding: 0 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.rules-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(255, 215, 0, 0.6);
}

.rules-badge:active {
    transform: scale(0.95);
}

/* Rules Panel - Slide-in from right */
.rules-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    background: #1e1e1e;
    border-left: 2px solid #FFD700;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: right 0.3s ease;
    padding: 20px;
    overflow-y: auto;
}

.rules-panel.active {
    right: 0;
}

.rules-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #FFD700;
}

.rules-panel-header h3 {
    color: #FFD700;
    font-size: 18px;
    margin: 0;
}

.close-panel-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.close-panel-btn:hover {
    color: #FFD700;
}

.rules-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rule-item {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid #FFD700;
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    line-height: 1.4;
}

.rule-item .rule-player {
    color: #FFD700;
    font-weight: 600;
    margin-bottom: 5px;
}

.rule-item .rule-text {
    color: #fff;
}

.rules-list:empty::after {
    content: "Nessuna regola attiva";
    color: #888;
    font-style: italic;
    text-align: center;
    display: block;
    padding: 20px;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .rules-badge {
        width: 40px;
        height: 40px;
        top: 30px;
        right: 40px;
    }

    .rules-badge svg {
        width: 22px;
        height: 22px;
    }

    .rules-badge-count {
        min-width: 16px;
        height: 16px;
        font-size: 10px;
        top: -3px;
        right: -3px;
    }

    .rules-panel {
        width: 280px;
        right: -300px;
        padding: 15px;
    }

    .rules-panel-header h3 {
        font-size: 16px;
    }

    .rule-item {
        font-size: 12px;
        padding: 10px;
    }
}