:root {
    --primary: #8a2be2;
    --primary-glow: rgba(138, 43, 226, 0.5);
    --secondary: #ff007f;
    --secondary-glow: rgba(255, 0, 127, 0.5);
    --bg-dark: #0f0c29;
    --bg-mid: #302b63;
    --bg-light: #24243e;
    --text-main: #ffffff;
    --text-muted: #b0b0cc;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --success: #00e676;
    --danger: #ff1744;
    --number-drawn: var(--primary);
    --number-marked: var(--secondary);
}

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

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-mid), var(--bg-light));
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

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

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

#particle-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: -1;
    background: radial-gradient(circle at 15% 50%, rgba(138, 43, 226, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(255, 0, 127, 0.15), transparent 25%);
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(45deg, #fff, var(--text-muted));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.home-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    transition: 0.3s;
}

.home-btn:hover {
    color: var(--text-main);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.screen {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.screen.active {
    display: block;
}

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

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

/* LOBBY */
#screen-lobby .glass-panel {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

h2 {
    margin-bottom: 1.5rem;
    font-weight: 600;
}

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

input {
    width: 100%;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-main);
    font-size: 1.1rem;
    font-family: inherit;
    outline: none;
    transition: 0.3s;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn {
    cursor: pointer;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    color: white;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    width: 100%;
}

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

.btn-primary {
    background: linear-gradient(45deg, var(--primary), #a855f7);
    box-shadow: 0 4px 15px var(--primary-glow);
}

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

.btn-secondary {
    background: linear-gradient(45deg, var(--secondary), #ff4081);
    box-shadow: 0 4px 15px var(--secondary-glow);
}

.btn-secondary:hover {
    box-shadow: 0 6px 25px var(--secondary-glow);
}

.divider {
    margin: 2rem 0;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--glass-border);
    z-index: 0;
}

.divider span {
    position: relative;
    background: var(--bg-mid);
    padding: 0 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 10px;
    z-index: 1;
}

.error-msg {
    color: var(--danger);
    margin-top: 1rem;
    font-size: 0.9rem;
    height: 20px;
}

/* WAITING ROOM */
#screen-waiting .glass-panel {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.highlight {
    color: var(--secondary);
    font-size: 1.5rem;
    letter-spacing: 2px;
}

.room-code-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 0.5rem;
}

.copy-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 5px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: var(--primary);
}

.copy-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.players-list {
    margin: 2rem 0;
    text-align: left;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
    max-height: 250px;
    overflow-y: auto;
}

.mode-selector {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 10;
    position: relative;
}

.mode-selector label {
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: 0.5px;
}

/* Custom Dropdown */
.custom-dropdown {
    position: relative;
    width: 240px;
    text-align: left;
    user-select: none;
}

.dropdown-selected {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px 15px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(5px);
    transition: 0.3s;
}

.dropdown-selected::after {
    content: '▼';
    font-size: 0.8rem;
    color: var(--primary);
    transition: transform 0.3s ease;
}

.dropdown-selected.open::after {
    transform: rotate(180deg);
}

.dropdown-selected:hover {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    background: rgba(0, 0, 0, 0.4);
}

.dropdown-options {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: rgba(15, 12, 41, 0.95);
    /* Dark matching theme */
    border: 1px solid var(--primary);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 100;
}

.custom-dropdown.open .dropdown-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-option {
    padding: 12px 15px;
    font-size: 0.95rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option:hover {
    background: rgba(138, 43, 226, 0.2);
    color: var(--text-main);
}

.dropdown-option.selected {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.players-list h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

ul {
    list-style: none;
}

ul li {
    padding: 0.8rem 1rem;
    background: var(--glass-bg);
    margin-bottom: 0.5rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    background: var(--primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.info-msg {
    color: var(--text-muted);
    margin-top: 1rem;
    font-weight: 600;
}

/* GAME SCREEN */
.game-layout {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
}

.draw-area {
    text-align: center;
    margin-bottom: 2rem;
}

.latest-draw {
    font-size: 5rem;
    font-weight: 800;
    color: var(--text-main);
    text-shadow: 0 0 30px var(--primary-glow);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    width: 150px;
    height: 150px;
    line-height: 150px;
    border-radius: 50%;
    margin: 1rem auto;
    border: 4px solid var(--glass-border);
    animation: pulseNum 2s infinite alternate;
}

@keyframes pulseNum {
    from {
        transform: scale(1);
        box-shadow: 0 0 20px var(--primary-glow);
    }

    to {
        transform: scale(1.05);
        box-shadow: 0 0 40px var(--secondary-glow);
    }
}

.btn-action {
    background: linear-gradient(45deg, #00c6ff, #0072ff);
    box-shadow: 0 4px 15px rgba(0, 198, 255, 0.4);
    width: auto;
    padding: 0.8rem 1.5rem;
}

.board-area h3 {
    margin-bottom: 1rem;
    text-align: center;
}

.housie-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 12px;
}

.board-num {
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--glass-bg);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: 0.3s;
}

.board-num.drawn {
    background: var(--number-drawn);
    color: white;
    box-shadow: 0 0 10px var(--primary-glow);
    transform: scale(1.1);
    z-index: 1;
}

.ticket-panel {
    margin-bottom: 2rem;
}

.housie-ticket {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
    background: #fff;
    padding: 10px;
    border-radius: 12px;
    border: 4px solid #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.ticket-cell {
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f0f0f0;
    color: #333;
    font-weight: 800;
    font-size: 1.2rem;
    border-radius: 4px;
    cursor: default;
    transition: 0.2s;
    user-select: none;
}

.ticket-cell.empty {
    background: #ffffff;
    border: 1px dashed #ccc;
    color: transparent;
}

.ticket-cell.has-num {
    cursor: pointer;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.1);
}

.ticket-cell.has-num:hover {
    transform: translateY(-2px);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.2);
}

.ticket-cell.marked {
    background: var(--secondary);
    color: white;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.3);
    animation: stamp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes stamp {
    0% {
        transform: scale(1.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.claims-panel {
    margin-bottom: 2rem;
}

.claims-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.claim-full-house {
    grid-column: span 2;
    background: linear-gradient(45deg, #f12711, #f5af19);
    box-shadow: 0 4px 15px rgba(245, 175, 25, 0.4);
}

.btn-claim {
    padding: 0.8rem;
    font-size: 0.95rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
}

.btn-claim:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-claim.claimed {
    background: var(--success);
    cursor: not-allowed;
    opacity: 0.8;
}

.log-panel ul {
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.9rem;
}

.log-panel li {
    padding: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
    background: transparent;
}

/* Styled List for Scoreboard */
.styled-list {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
    text-align: left;
}

.styled-list li {
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 0.5rem;
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.styled-list .claim-type {
    font-weight: 800;
    color: var(--secondary);
}

.styled-list .claim-player {
    font-weight: 600;
    color: var(--text-main);
}

/* Modal/Toast */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease forwards;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--primary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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