:root {
    --primary-color: #6a11cb;
    --secondary-color: #2575fc;
    --accent-color: #ff0080;
    --text-color: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

html {
    background-color: #1a1a2e;
    height: 100%;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: #1a1a2e;
    /* Fallback for Safari */
    background: radial-gradient(circle at top left, #1a1a2e, #16213e, #0f3460);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic Background Blobs */
.background-blobs {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 10s infinite ease-in-out;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--primary-color);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--accent-color);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 200px;
    height: 200px;
    background: var(--secondary-color);
    top: 40%;
    left: 40%;
    animation-delay: -2s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, 30px);
    }
}

.app-container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    z-index: 1;
}

.app-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 2rem;
}

.logo-img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}

header h1 {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 0;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(to right, #ff00cc, #333399);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Glassmorphism Cards */
.card.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    animation: fadeIn 0.5s ease-out;
}

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

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

h2 {
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 500;
}

/* Buttons */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: inherit;
    color: white;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    box-shadow: 0 4px 15px rgba(37, 117, 252, 0.4);
}

.btn.secondary {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn.danger {
    background: linear-gradient(135deg, #ff416c, #ff4b2b);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.btn.secondary:hover {
    border-color: white;
}

.btn-back {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    margin-bottom: 1rem;
    font-size: 1rem;
    transition: color 0.3s;
}

.btn-back:hover {
    color: white;
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: -0.5rem;
    margin-left: 10px;
}

input,
select {
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--secondary-color);
    background: rgba(0, 0, 0, 0.4);
}

/* Player List */
.player-list {
    list-style: none;
    margin: 1.5rem 0;
    max-height: 300px;
    overflow-y: auto;
}

.player-list li {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.8rem 1.2rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-list li::before {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    background: var(--accent-color);
    border-radius: 50%;
}

/* Role Reveal Box */
.role-box {
    margin: 2rem 0;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.highlight {
    color: var(--accent-color);
    font-weight: bold;
}

.subtext {
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.7;
    margin-top: 1rem;
}

.hidden {
    display: none !important;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Pulse animation for start button */
.pulse {
    animation: pulse-anim 2s infinite;
}

@keyframes pulse-anim {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 128, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 0, 128, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 128, 0);
    }
}

/* Additions for Quiz App */

.upload-section {
    border: 2px dashed rgba(255, 255, 255, 0.3);
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
    margin: 1rem 0;
}

.timer-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.timer-bar {
    height: 100%;
    background: var(--accent-color);
    width: 100%;
    transition: width 1s linear;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 1rem;
}

.options-grid.vertical-layout {
    grid-template-columns: 1fr;
}

.option-btn {
    padding: 2rem 1rem;
    font-size: 1.2rem;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    color: white;
    transition: transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    word-break: break-word;
    /* Ensure long words don't overflow */
    hyphens: auto;

    /* Touch optimization */
    -webkit-user-select: none;
    /* Safari */
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.option-btn:active {
    transform: scale(0.95);
}

/* Colors for options */
/* Colors for options - UPDATED: Pink, DarkBlue, Violet, Green */
.opt-0 {
    background: linear-gradient(135deg, #ff00cc, #d900ad);
    /* Pink */
}

.opt-1 {
    background: linear-gradient(135deg, #0f3460, #16213e);
    /* Dark Blue */
}

.opt-2 {
    background: linear-gradient(135deg, #8a2be2, #6a11cb);
    /* Violet */
}

.opt-3 {
    background: linear-gradient(135deg, #26890c, #1e6b09);
    /* Green */
}

.pie-chart {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    margin: 0 auto;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.correct-box {
    background: #26890c;
    padding: 1rem;
    border-radius: 10px;
    margin: 1rem 0;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
}

.distribution-grid {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 150px;
    margin: 1rem 0;
}

.bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 15%;
}

.bar {
    width: 100%;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 5px 5px 0 0;
    transition: height 0.5s ease;
    min-height: 5px;
}

.leaderboard-list li {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
}

.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 15px;
    margin-top: 2rem;
    margin-bottom: 2rem;
    min-height: 150px;
}

/* Editor Specific Styles */
.editor-container {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 2rem;
}

.question-card {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.question-title {
    font-weight: bold;
    color: var(--secondary-color);
}

.btn-icon {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: #ff416c;
}

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

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row>* {
    flex: 1;
}

.options-editor {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.option-correct-check {
    width: 25px;
    height: 25px;
    accent-color: var(--secondary-color);
    cursor: pointer;
}

.option-input-group input[type="text"] {
    flex: 1;
}

.add-question-btn {
    width: 100%;
    padding: 1rem;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    background: none;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.add-question-btn:hover {
    border-color: var(--secondary-color);
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.editor-actions {
    display: flex;
    gap: 10px;
    margin-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
}

/* Scrollbar styling for editor */
.editor-container::-webkit-scrollbar {
    width: 8px;
}

.editor-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.editor-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.editor-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Podium Styles */
.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 15px;
    margin-top: 2rem;
    margin-bottom: 2rem;
    min-height: 150px;
}

.question-progress {
    text-align: center;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 1rem;
    font-weight: 500;
}

/* Larger screens styling for Host view on big displays */
@media (min-width: 1024px) {
    .app-container {
        max-width: 900px;
    }

    header h1 {
        font-size: 5rem;
    }

    .logo-img {
        width: 80px;
        height: 80px;
    }

    .card.glass {
        padding: 3rem;
    }

    .option-btn {
        font-size: 1.5rem;
        padding: 3rem;
    }

    h2 {
        font-size: 2.5rem;
    }

    .host-stat span {
        font-size: 2rem;
    }
}

/* Widen the container specifically for the Editor View on large screens */
@media (min-width: 1200px) {
    body:has(#view-editor.active) .app-container {
        max-width: 1400px;
    }
}