/* Controller Style CSS - Modern, Clean, Interactive, Adaptive Light/Dark */

:root {
    /* Adaptive colors: Default to Light Mode */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: rgba(15, 23, 42, 0.08);
    --glass: rgba(255, 255, 255, 0.85);
    --primary: #0f172a;
    --primary-dark: #1e293b;
    --primary-light: #334155;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.75rem;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08);
    
    --transition-fast: 150ms;
    --transition-base: 300ms;
    --font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        /* Adaptive colors: Dark Mode */
        --bg-primary: #09090b;
        --bg-secondary: #18181b;
        --bg-tertiary: #27272a;
        --text-primary: #fafafa;
        --text-secondary: #d4d4d8;
        --text-muted: #a1a1aa;
        --border: rgba(250, 250, 250, 0.08);
        --glass: rgba(24, 24, 27, 0.85);
        --primary: #fafafa;
        --primary-dark: #e4e4e7;
        --primary-light: #a1a1aa;
    }
}
:root[data-theme="dark"] {
    --bg-primary: #09090b;
    --bg-secondary: #18181b;
    --bg-tertiary: #27272a;
    --text-primary: #fafafa;
    --text-secondary: #d4d4d8;
    --text-muted: #a1a1aa;
    --border: rgba(250, 250, 250, 0.08);
    --glass: rgba(24, 24, 27, 0.85);
    --primary: #fafafa;
    --primary-dark: #e4e4e7;
    --primary-light: #a1a1aa;
}
:root[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: rgba(15, 23, 42, 0.08);
    --glass: rgba(255, 255, 255, 0.85);
    --primary: #0f172a;
    --primary-dark: #1e293b;
    --primary-light: #334155;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    padding: 1rem;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Container */
.container {
    width: 100%;
    max-width: 440px;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    text-align: center;
    animation: fadeIn var(--transition-base) forwards;
    gap: 1.5rem;
}

.screen.active {
    display: flex;
}

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

/* Typography */
h1 {
    font-size: clamp(1.8rem, 6vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h2 {
    font-size: clamp(1.4rem, 5vw, 1.7rem);
    font-weight: 700;
    color: var(--text-primary);
}

p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Inputs & Form Elements */
.input-field {
    width: 100%;
    padding: 1.1rem 1.25rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    outline: none;
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}

html[data-theme="dark"] .input-field:focus {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 1.1rem 1.5rem;
    border-radius: var(--radius-md);
    border: none;
    background: var(--primary);
    color: var(--bg-primary);
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn.cancel {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: none;
}

.btn.cancel:active {
    background: var(--bg-secondary);
}

.btn-danger {
    background: var(--error) !important;
    color: #ffffff !important;
}

.btn-danger:active {
    opacity: 0.8;
}

/* Waiting / Connecting Screen */
.multiplayer-connecting {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.waiting-dots span {
    display: inline-block;
    animation: dotBounce 1.4s infinite;
    font-size: 2rem;
    color: var(--primary);
    line-height: 1;
}
.waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-8px); opacity: 1; }
}

/* Controller View */
.controller-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 1rem;
}

.host-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Question number + money badge inside the status bar */
#controllerQuestionNum {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.ctrl-q-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}
.ctrl-q-money {
    font-size: 0.78rem;
    font-weight: 800;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: var(--radius-sm);
    padding: 0.1rem 0.45rem;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}


.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.settings-gear-btn {
    background: none;
    border: none;
    font-size: 1.15rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast) ease;
}

.settings-gear-btn:active {
    transform: rotate(45deg) scale(0.9);
}

.controller-question {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    width: 100%;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
    min-height: 80px;
    display: flex;
    align-items: center;
}

.controller-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    width: 100%;
}

.controller-option {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    line-height: 1.4;
    min-height: 64px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.controller-option:active:not(.disabled) {
    transform: scale(0.98);
}

.controller-option.selected {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.1);
}

.controller-option.correct {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.controller-option.wrong {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.controller-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.controller-option.hidden-answer {
    opacity: 0.15;
    pointer-events: none;
}

.controller-lifelines {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.25rem;
}

.controller-lifeline-btn {
    padding: 0.9rem 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.controller-lifeline-btn:active:not(.disabled) {
    background: var(--bg-tertiary);
    border-color: var(--text-primary);
    transform: scale(0.95);
}

.controller-lifeline-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Confirmation Overlay */
.controller-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.controller-confirm-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.controller-confirm-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    max-width: 320px;
    width: 90%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: var(--shadow-xl);
    transform: scale(0.9);
    transition: transform var(--transition-fast);
}

.controller-confirm-overlay.active .controller-confirm-box {
    transform: scale(1);
}

.controller-confirm-box h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.controller-confirm-box p {
    font-size: 0.9rem;
}

.controller-confirm-actions {
    display: flex;
    gap: 0.75rem;
}

.controller-confirm-actions .btn {
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
}

/* End screen options */
.controller-end-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 300px;
}

/* Footer & Powered */
.footer-powered {
    margin-top: auto;
    padding: 1.5rem 0 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Loader Screen styles */
#pre-load {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-base);
}

.loader-inner {
    position: relative;
    width: 100px;
    height: 100px;
}

.loader-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-logo svg {
    width: 100%;
    height: 100%;
}

.loader-inner .box {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--text-primary);
    border-radius: 50%;
    animation: loaderPulse 1.2s infinite ease-in-out;
}

.loader-inner .box:nth-child(2) { top: 10px; left: 10px; }
.loader-inner .box:nth-child(3) { top: 10px; right: 10px; animation-delay: 0.2s; }
.loader-inner .box:nth-child(4) { bottom: 10px; right: 10px; animation-delay: 0.4s; }
.loader-inner .box:nth-child(5) { bottom: 10px; left: 10px; animation-delay: 0.6s; }
.loader-inner .box:nth-child(6) { top: 50%; left: 50%; transform: translate(-50%, -50%); animation-delay: 0.8s; }

@keyframes loaderPulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.5); opacity: 1; }
}

.loader-progress {
    width: 160px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 1.5rem;
}

.loader-progress-bar {
    width: 0%;
    height: 100%;
    background: var(--primary);
    transition: width var(--transition-fast) ease-out;
}

/* Custom Controller Settings Menu Styling Rules */
.btn-active {
    background: var(--error) !important;
    color: #ffffff !important;
    border-color: var(--error) !important;
}

#ctrlQuestionsList::-webkit-scrollbar {
    width: 6px;
}
#ctrlQuestionsList::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}
#ctrlQuestionsList::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}
#ctrlQuestionsList::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.controller-confirm-box select.input-field {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.5rem;
    padding-right: 2rem;
    appearance: none;
}

.btn-github-file {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    font-family: var(--font-primary);
    transition: all var(--transition-fast);
}
.btn-github-file:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-primary);
}
.btn-github-file.selected {
    background: var(--primary);
    color: var(--bg-secondary);
    border-color: var(--primary);
}
/* ── Correct-answer badge (Feature 5) ──────────────────────────── */
.ctrl-correct-badge {
    width: 100%;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-md);
    border: 2px solid #10b981;
    background: rgba(16, 185, 129, 0.08);
    color: #10b981;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.02em;
}

/* ── Settings button (Feature 7) ───────────────────────────────── */
.ctrl-settings-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.ctrl-settings-btn:active { transform: scale(0.95); background: var(--bg-secondary); }
.ctrl-settings-btn svg { flex-shrink: 0; }

/* ── Quick-action panel ─────────────────────────────────────────── */
.ctrl-quick-panel {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.ctrl-quick-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.ctrl-quick-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    min-width: 52px;
}
.ctrl-quick-buttons {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.ctrl-quick-btn {
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.ctrl-quick-btn:active { transform: scale(0.94); }
.ctrl-quick-btn.ctrl-end-btn { border-color: var(--error); color: var(--error); }
.ctrl-quick-btn.ctrl-end-btn:active { background: rgba(239,68,68,0.12); }
