/* ==========================================
   BUZZER APP - Dark Mode Styles
   ========================================== */

/* CSS Variables */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #252538;
    --bg-input: #2a2a42;

    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;

    --accent-blue: #00d4ff;
    --accent-green: #00ff88;
    --accent-red: #ff4757;
    --accent-yellow: #ffd93d;
    --accent-purple: #a855f7;

    --shadow-color: rgba(0, 0, 0, 0.4);
    --glow-blue: rgba(0, 212, 255, 0.4);
    --glow-green: rgba(0, 255, 136, 0.5);
    --glow-red: rgba(255, 71, 87, 0.5);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 50%;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

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

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

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

/* Container */
.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

.player-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 48px);
    min-height: calc(100dvh - 48px);
}

/* ==========================================
   LOGO & LANDING
   ========================================== */

.logo {
    text-align: center;
    margin-bottom: 48px;
}

.logo-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.logo h1 {
    font-size: 48px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.tagline {
    color: var(--text-secondary);
    font-size: 18px;
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    user-select: none;
    -webkit-user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #0099cc);
    color: white;
    box-shadow: 0 4px 15px var(--glow-blue);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 25px var(--glow-blue);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--bg-input);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent-blue);
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent-yellow), #e6b800);
    color: #1a1a2e;
}

.btn-large {
    width: 100%;
    padding: 20px 32px;
    font-size: 18px;
    border-radius: var(--radius-lg);
}

.btn-small {
    padding: 10px 16px;
    font-size: 14px;
}

.btn-icon {
    font-size: 24px;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.btn-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 24px;
    transition: color var(--transition-fast);
}

.btn-back:hover {
    color: var(--text-primary);
}

/* ==========================================
   FORMS
   ========================================== */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 16px 20px;
    font-size: 18px;
    font-family: inherit;
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.code-input {
    text-transform: uppercase;
    letter-spacing: 4px;
    text-align: center;
    font-weight: 700;
}

.error-message {
    color: var(--accent-red);
    text-align: center;
    margin-top: 16px;
    min-height: 24px;
}

/* ==========================================
   HOST SCREEN
   ========================================== */

.room-header {
    text-align: center;
    margin-bottom: 32px;
}

.room-header h2 {
    font-size: 28px;
    margin-top: 12px;
}

.badge {
    display: inline-block;
    padding: 6px 16px;
    background: linear-gradient(135deg, var(--accent-yellow), #e6b800);
    color: #1a1a2e;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 20px;
}

.badge-player {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
}

.room-code-display {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-lg);
    text-align: center;
    margin-bottom: 32px;
}

.room-code-display p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.code {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: 8px;
    color: var(--accent-blue);
    text-shadow: 0 0 20px var(--glow-blue);
    margin-bottom: 16px;
}

/* Players Section */
.players-section {
    margin-bottom: 32px;
}

.players-section h3 {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#player-count {
    color: var(--accent-blue);
}

.player-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent-blue);
    transition: all var(--transition-fast);
}

.player-list li.winner {
    border-left-color: var(--accent-green);
    background: rgba(0, 255, 136, 0.1);
}

.player-list li.loser {
    border-left-color: var(--accent-red);
    opacity: 0.6;
}

.player-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.empty-message {
    color: var(--text-muted);
    text-align: center;
    padding: 32px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 2px dashed var(--bg-input);
}

/* Winner Display */
.winner-display {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.1), rgba(0, 212, 255, 0.1));
    border: 2px solid var(--accent-green);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    margin-top: 24px;
    animation: winnerPulse 1s ease-in-out infinite alternate;
}

@keyframes winnerPulse {
    from {
        box-shadow: 0 0 20px var(--glow-green);
    }

    to {
        box-shadow: 0 0 40px var(--glow-green);
    }
}

.winner-display.hidden {
    display: none;
}

.winner-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.winner-display p {
    color: var(--text-secondary);
}

.winner-display h3 {
    font-size: 32px;
    color: var(--accent-green);
}

/* Host Controls */
.host-controls {
    margin-top: 24px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--accent-yellow);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.3s ease;
    z-index: 1000;
}

.toast.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.toast-icon {
    font-size: 24px;
}

/* ==========================================
   PLAYER SCREEN
   ========================================== */

.player-header {
    text-align: center;
    margin-bottom: 24px;
}

.player-name {
    font-size: 28px;
    font-weight: 700;
    margin-top: 12px;
}

.room-info {
    color: var(--text-muted);
    margin-top: 4px;
}

.room-info span {
    color: var(--accent-blue);
    font-weight: 600;
}

/* ==========================================
   BUZZER BUTTON - 3D Effect
   ========================================== */

.buzzer-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 0;
}

.buzzer-btn {
    width: 220px;
    height: 220px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    position: relative;

    /* 3D Effect Base */
    background: linear-gradient(145deg, #ff6b7a, #ff3344);
    box-shadow:
        0 15px 0 #cc2233,
        0 20px 30px rgba(0, 0, 0, 0.4),
        inset 0 -5px 20px rgba(0, 0, 0, 0.2),
        inset 0 5px 20px rgba(255, 255, 255, 0.2);

    transition: all var(--transition-fast);
    transform: translateY(0);

    display: flex;
    align-items: center;
    justify-content: center;

    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.buzzer-btn::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 20%;
    width: 30%;
    height: 20%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 100%);
    border-radius: 50%;
}

.buzzer-btn:active:not(:disabled) {
    transform: translateY(12px);
    box-shadow:
        0 3px 0 #cc2233,
        0 5px 15px rgba(0, 0, 0, 0.4),
        inset 0 -2px 10px rgba(0, 0, 0, 0.2),
        inset 0 2px 10px rgba(255, 255, 255, 0.1);
}

.buzzer-btn:disabled {
    cursor: not-allowed;
}

.buzzer-text {
    font-family: 'Inter', sans-serif;
    font-size: 36px;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
}

/* Buzzer States */
.buzzer-btn.winner {
    background: linear-gradient(145deg, #00ff99, #00cc77);
    box-shadow:
        0 15px 0 #009955,
        0 20px 30px rgba(0, 0, 0, 0.4),
        0 0 60px var(--glow-green),
        inset 0 -5px 20px rgba(0, 0, 0, 0.2),
        inset 0 5px 20px rgba(255, 255, 255, 0.2);
    animation: winnerGlow 0.5s ease-in-out infinite alternate;
}

@keyframes winnerGlow {
    from {
        box-shadow: 0 15px 0 #009955, 0 20px 30px rgba(0, 0, 0, 0.4), 0 0 40px var(--glow-green);
    }

    to {
        box-shadow: 0 15px 0 #009955, 0 20px 30px rgba(0, 0, 0, 0.4), 0 0 80px var(--glow-green);
    }
}

.buzzer-btn.loser {
    background: linear-gradient(145deg, #666, #444);
    box-shadow:
        0 15px 0 #333,
        0 20px 30px rgba(0, 0, 0, 0.4),
        inset 0 -5px 20px rgba(0, 0, 0, 0.3);
    opacity: 0.7;
}

.buzzer-btn.locked {
    background: linear-gradient(145deg, #555, #333);
    box-shadow:
        0 10px 0 #222,
        0 15px 20px rgba(0, 0, 0, 0.3);
}

/* Buzzer Status */
.buzzer-status {
    text-align: center;
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
}

.buzzer-status p {
    font-size: 18px;
    font-weight: 600;
}

.buzzer-status.winner {
    background: rgba(0, 255, 136, 0.15);
    border: 2px solid var(--accent-green);
}

.buzzer-status.winner p {
    color: var(--accent-green);
}

.buzzer-status.loser {
    background: rgba(255, 71, 87, 0.15);
    border: 2px solid var(--accent-red);
}

.buzzer-status.loser p {
    color: var(--accent-red);
}

/* Player List Mini */
.player-list-mini {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--bg-input);
}

.player-list-mini h4 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.player-list-mini ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.player-list-mini li {
    padding: 8px 14px;
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 14px;
}

.player-list-mini li.self {
    background: var(--accent-blue);
    color: #1a1a2e;
    font-weight: 600;
}

/* ==========================================
   MODAL
   ========================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 26, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.modal-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.modal-content h3 {
    font-size: 24px;
    margin-bottom: 12px;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 400px) {
    .screen {
        padding: 16px;
    }

    .logo h1 {
        font-size: 40px;
    }

    .code {
        font-size: 32px;
        letter-spacing: 4px;
    }

    .buzzer-btn {
        width: 180px;
        height: 180px;
    }

    .buzzer-text {
        font-size: 28px;
    }
}

/* Landscape on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .buzzer-wrapper {
        padding: 16px 0;
    }

    .buzzer-btn {
        width: 140px;
        height: 140px;
    }

    .buzzer-text {
        font-size: 24px;
    }
}