:root {
    --bg-deep: #150b2a;
    --bg-primary: #251347;
    --bg-card: rgba(45, 25, 82, 0.85);
    --bg-card-solid: #2b1850;
    --border-light: rgba(255, 255, 255, 0.14);
    --text-main: #ffffff;
    --text-muted: #cbbde5;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Iconic Kahoot 4 Colors */
    --k-red: #e21b3c;
    --k-red-dark: #b0102b;
    --k-blue: #1368ce;
    --k-blue-dark: #0d4a96;
    --k-yellow: #d89e00;
    --k-yellow-dark: #a67800;
    --k-green: #26890c;
    --k-green-dark: #1b6308;
}

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

html, body {
    overscroll-behavior-y: none;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: radial-gradient(circle at 20% 20%, #3b1c71 0%, #1d0e38 55%, #110722 100%);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
}

a {
    color: #c4b5fd;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.75rem;
    background: rgba(17, 7, 34, 0.82);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff;
}

.brand-badge {
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    padding: 0.25rem 0.65rem;
    border-radius: 10px;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.35);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

/* Container & Layout */
.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 1.5rem;
}

.container-narrow {
    max-width: 860px;
    margin: 0 auto;
    padding: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
    margin-bottom: 1.25rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.2rem;
    border-radius: 11px;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease;
    color: #fff;
    text-decoration: none;
}

.btn:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
    text-decoration: none;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

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

.btn-primary {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    box-shadow: 0 4px 0 #4c1d95;
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 4px 0 #14532d;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 4px 0 #78350f;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 0 #7f1d1d;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid var(--border-light);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.84rem;
    border-radius: 8px;
}

.btn-lg {
    padding: 0.95rem 1.75rem;
    font-size: 1.1rem;
    border-radius: 14px;
}

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

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 0.72rem 0.95rem;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background: rgba(15, 7, 30, 0.75);
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    background: rgba(15, 7, 30, 0.55);
    padding: 0.45rem;
    border-radius: 14px;
    border: 1px solid var(--border-light);
}

.tab-btn {
    flex: 1;
    min-width: 140px;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-btn.active {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff;
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.4);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.45);
}

.badge-approved {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.45);
}

.badge-rejected {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.45);
}

.badge-code {
    font-family: 'Consolas', 'Courier New', monospace;
    background: rgba(139, 92, 246, 0.25);
    color: #e9d5ff;
    border: 1px dashed #a78bfa;
    font-size: 0.95rem;
    padding: 0.28rem 0.7rem;
}

/* Kahoot 4 Answer Buttons Grid */
.kahoot-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    row-gap: 1.15rem;
    column-gap: 0.85rem;
    margin-top: 1rem;
}

@media (max-width: 640px) {
    .kahoot-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* Sempre 2 colonne affiancate su mobile */
        row-gap: 1.5rem !important; /* Ampio spazio verticale tra la riga superiore e inferiore */
        column-gap: 0.75rem !important;
        margin-top: 1.15rem !important;
        margin-bottom: 0.75rem !important;
    }
}

.kahoot-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    border: none;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    text-align: left;
    min-height: 68px;
    transition: transform 0.1s ease, filter 0.15s ease, opacity 0.2s ease;
    user-select: none;
    box-sizing: border-box;
    overflow: hidden;
    word-break: break-word;
}

.kahoot-btn .kahoot-text {
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.25;
}

@media (max-width: 640px) {
    .kahoot-btn {
        padding: 0.95rem 0.85rem !important;
        min-height: 90px !important; /* Pulsanti sensibilmente più alti e comodi da premere su smartphone */
        font-size: 1.02rem !important;
        border-radius: 14px !important;
        gap: 0.65rem !important;
    }
}

.kahoot-btn:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-2px);
}

.kahoot-btn:active:not(:disabled) {
    transform: translateY(2px);
}

.kahoot-btn.opt-0 {
    background: var(--k-red);
    box-shadow: 0 4px 0 var(--k-red-dark);
}

.kahoot-btn.opt-1 {
    background: var(--k-blue);
    box-shadow: 0 4px 0 var(--k-blue-dark);
}

.kahoot-btn.opt-2 {
    background: var(--k-yellow);
    box-shadow: 0 4px 0 var(--k-yellow-dark);
}

.kahoot-btn.opt-3 {
    background: var(--k-green);
    box-shadow: 0 4px 0 var(--k-green-dark);
}

.kahoot-shape {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .kahoot-shape {
        width: 38px !important;
        height: 38px !important;
        font-size: 1.35rem !important;
        border-radius: 9px !important;
    }
}

.kahoot-btn.dimmed {
    opacity: 0.32;
    filter: grayscale(35%);
}

.kahoot-btn.correct-highlight {
    outline: 4px solid #ffffff;
    box-shadow: 0 0 28px rgba(34, 197, 94, 0.9);
    transform: scale(1.02);
}

/* Roster chips */
.roster-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-light);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
}

.player-chip.captain {
    background: rgba(245, 158, 11, 0.22);
    border-color: rgba(245, 158, 11, 0.55);
    color: #fde68a;
}

.player-chip button {
    background: none;
    border: none;
    color: #fca5a5;
    cursor: pointer;
    font-weight: 800;
    font-size: 0.9rem;
    padding: 0 0.15rem;
}

/* Progress bar for 100 players */
.progress-wrap {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 999px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6, #ec4899);
    transition: width 0.25s ease;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 0.9rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

th {
    color: var(--text-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* Timer Circle */
.timer-circle {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 900;
    box-shadow: 0 0 24px rgba(236, 72, 153, 0.5);
    border: 4px solid #fff;
    flex-shrink: 0;
}

/* Podium */
.podium-wrap {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1.25rem;
    margin: 2rem 0 1.5rem;
    min-height: 260px;
}

.podium-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 180px;
    text-align: center;
}

.podium-bar {
    width: 100%;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem 0.5rem;
    font-weight: 900;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.podium-1 .podium-bar {
    height: 190px;
    background: linear-gradient(180deg, #fbbf24, #b45309);
}

.podium-2 .podium-bar {
    height: 145px;
    background: linear-gradient(180deg, #e2e8f0, #64748b);
}

.podium-3 .podium-bar {
    height: 115px;
    background: linear-gradient(180deg, #fb923c, #9a3412);
}

/* Toast notification */
#toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.toast {
    padding: 0.85rem 1.2rem;
    border-radius: 12px;
    background: #1e1136;
    border: 1px solid var(--border-light);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.2s ease;
}

.toast.error {
    border-left: 5px solid var(--danger);
}

.toast.success {
    border-left: 5px solid var(--success);
}

@keyframes slideIn {
    from {
        transform: translateY(15px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.hidden {
    display: none !important;
}

/* Question Image Containers (Auto-fit & preserve aspect ratio) */
.question-media-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 680px;
    margin: 0.75rem auto 1.25rem;
    background: rgba(10, 4, 22, 0.55);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 0.5rem;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.question-media-box img {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
}

.question-media-projector img {
    max-height: 270px;
}

.question-media-player img {
    max-height: 190px;
}

@media (max-width: 640px) {
    .question-media-player {
        margin: 0.35rem auto 0.65rem !important;
        padding: 0.25rem !important;
    }
    .question-media-player img {
        max-height: 110px !important;
    }
}

/* Player Bottom Status Bar (Score & Position) */
.player-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: rgba(18, 9, 36, 0.95);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 0.65rem 1rem;
    margin-top: 0.85rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.player-bottom-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.player-bottom-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.player-bottom-val {
    font-size: 1.25rem;
    font-weight: 900;
    color: #fde68a;
    line-height: 1.2;
}

.player-bottom-divider {
    width: 1px;
    height: 26px;
    background: rgba(255, 255, 255, 0.12);
}

.question-media-editor {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.28);
    border: 1px dashed var(--border-light);
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.75rem;
}

.question-media-editor-preview {
    width: 120px;
    height: 80px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.question-media-editor-preview img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Modal Overlay & Popup */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 4, 20, 0.82);
    backdrop-filter: blur(8px);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeInModal 0.18s ease;
}

.modal-card {
    background: var(--bg-card-solid);
    border: 2px solid #a78bfa;
    border-radius: 20px;
    padding: 1.65rem;
    width: 100%;
    max-width: 490px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
    max-height: 92vh;
    overflow-y: auto;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}


