/* style.css - WORD BOMB 2.0 OPTIMIZED */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&family=JetBrains+Mono:wght@500&display=swap');

:root {
    --bg-dark: #0f172a;
    --glass: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-hover: rgba(255, 255, 255, 0.15);
    
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --accent: #ec4899;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
}

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

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- UTILS --- */
.container {
    width: 100%; 
    max-width: 1400px; 
    margin: 0 auto;
    display: flex; 
    flex-direction: column;
    align-items: center; 
    justify-content: center;
    padding: clamp(15px, 3vw, 20px);
    position: relative;
    min-height: 100vh;
}

.card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: clamp(1.5rem, 4vw, 2rem);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    text-align: center;
    transition: transform 0.2s;
    width: 100%;
    max-width: 600px;
}

/* --- TYPOGRAPHY --- */
h1 { 
    font-weight: 800; 
    font-size: clamp(2rem, 6vw, 3rem);
    letter-spacing: -1px; 
    margin: 0 0 1rem 0; 
    background: linear-gradient(to right, #818cf8, #f472b6); 
    -webkit-background-clip: text; 
    background-clip: text;
    color: transparent; 
}

h2 { 
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    margin-bottom: 1rem; 
    color: var(--text-main); 
}

h3 {
    font-size: clamp(1rem, 3vw, 1.2rem);
    margin-bottom: 1rem;
    color: var(--text-main);
}

.mono { 
    font-family: 'JetBrains Mono', monospace; 
}

/* --- INFO SECTIONS --- */
.info-section {
    text-align: left;
    background: rgba(0, 0, 0, 0.2);
    padding: clamp(0.75rem, 2vw, 1rem);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-list li {
    padding: clamp(0.4rem, 1.5vw, 0.5rem) 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: clamp(0.85rem, 2vw, 0.9rem);
    line-height: 1.5;
}

.info-list li:last-child {
    border-bottom: none;
}

.info-list strong {
    color: var(--primary);
}

/* --- BUTTONS & INPUTS --- */
.btn {
    background: var(--primary);
    color: white; 
    border: none;
    padding: clamp(12px, 3vw, 14px) clamp(20px, 5vw, 28px);
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: 600;
    border-radius: var(--radius-sm); 
    cursor: pointer;
    transition: all 0.2s; 
    width: 100%;
    box-shadow: 0 4px 12px var(--primary-glow);
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px;
    min-height: 48px;
}

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

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

.btn:disabled { 
    opacity: 0.5; 
    cursor: not-allowed; 
    box-shadow: none; 
    background: var(--glass-hover); 
}

.btn.secondary { 
    background: var(--glass-hover); 
    box-shadow: none; 
    border: 1px solid var(--glass-border); 
}

.btn.danger { 
    background: var(--danger); 
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4); 
}

.btn.success {
    background: var(--success);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

input[type="text"], 
input[type="number"] {
    width: 100%; 
    padding: clamp(12px, 3vw, 14px);
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: white; 
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    text-align: center;
    font-weight: 600; 
    outline: none;
    transition: border-color 0.2s;
    min-height: 48px;
}

input:focus { 
    border-color: var(--primary); 
}

/* --- EMOJI & COLOR PICKER --- */
.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
    gap: clamp(6px, 2vw, 8px);
    margin-top: 10px;
}

.picker-item {
    width: 100%;
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    transition: all 0.2s;
    min-height: 48px;
}

.picker-item:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}

.picker-item.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.2);
    box-shadow: 0 0 12px var(--primary-glow);
}

.color-picker-item {
    border-radius: 50%;
}

/* --- GAME UI HOST --- */
.dashboard {
    display: grid; 
    grid-template-columns: minmax(280px, 320px) 1fr; 
    gap: 20px;
    width: 100%; 
    height: 100vh;
    padding: 20px;
    max-width: 100%;
}

.panel-side {
    background: rgba(0,0,0,0.2); 
    border-radius: var(--radius-md);
    padding: clamp(15px, 3vw, 20px);
    display: flex; 
    flex-direction: column; 
    gap: 15px;
    border: 1px solid var(--glass-border);
    overflow-y: auto;
    max-height: calc(100vh - 40px);
}

.panel-main {
    position: relative;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    background: rgba(0,0,0,0.1);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    padding: clamp(15px, 3vw, 20px);
    overflow-y: auto;
}

.syllable-box {
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-main);
    text-shadow: 0 0 30px var(--primary-glow);
    margin: 20px 0;
}

.timer-track {
    width: clamp(200px, 80%, 600px);
    height: clamp(8px, 2vw, 12px);
    background: rgba(255,255,255,0.1);
    border-radius: 20px; 
    overflow: hidden; 
    margin-bottom: 20px;
    position: relative;
}

.timer-fill {
    height: 100%; 
    width: 100%; 
    background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
    transform-origin: left; 
    transition: width 0.1s linear;
}

/* --- PLAYERS GRID --- */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 150px));
    gap: clamp(10px, 2vw, 15px);
    justify-content: center;
    width: 100%; 
    max-height: 45vh; 
    overflow-y: auto; 
    padding: 10px;
}

.player-card {
    background: var(--glass); 
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); 
    padding: clamp(10px, 2vw, 12px);
    min-width: 130px;
    display: flex; 
    flex-direction: column; 
    align-items: center;
    position: relative; 
    transition: all 0.3s;
}

.player-card.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 0 20px var(--primary-glow);
}

.player-card.eliminated { 
    opacity: 0.4; 
    filter: grayscale(1); 
}

.p-avatar { 
    font-size: clamp(2rem, 5vw, 2.5rem);
    margin-bottom: 8px; 
}

.p-name { 
    font-weight: 600; 
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    max-width: 100%; 
}

.p-lives { 
    display: flex; 
    gap: 3px; 
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    margin-top: 8px; 
}

.p-ping {
    position: absolute; 
    top: 8px; 
    right: 8px;
    font-size: clamp(0.6rem, 1.5vw, 0.65rem);
    color: var(--text-muted);
    font-family: 'JetBrains Mono';
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 4px;
}

.p-color-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    width: clamp(14px, 3vw, 16px);
    height: clamp(14px, 3vw, 16px);
    border-radius: 50%;
    border: 2px solid white;
}

/* --- LOBBY PLAYERS LIST --- */
.lobby-player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: clamp(8px, 2vw, 10px);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--glass-border);
}

.lobby-player-avatar {
    font-size: clamp(1.5rem, 4vw, 2rem);
    width: clamp(35px, 8vw, 40px);
    height: clamp(35px, 8vw, 40px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid;
    flex-shrink: 0;
}

.lobby-player-info {
    flex: 1;
    min-width: 0;
}

.lobby-player-name {
    font-weight: 600;
    font-size: clamp(0.85rem, 2vw, 0.9rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lobby-player-ping {
    font-family: 'JetBrains Mono';
    font-size: clamp(0.7rem, 1.8vw, 0.75rem);
}

/* --- SETTINGS SECTION --- */
.settings-group {
    margin-bottom: 15px;
}

.settings-title {
    font-size: clamp(0.85rem, 2vw, 0.9rem);
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.setting-row {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    font-size: clamp(0.85rem, 2vw, 0.9rem);
    color: var(--text-muted);
    margin-bottom: 12px;
    gap: 10px;
}

.setting-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.setting-label-main {
    color: var(--text-main);
    font-weight: 500;
}

.setting-label-sub {
    font-size: clamp(0.7rem, 1.8vw, 0.75rem);
    color: var(--text-muted);
}

/* --- SWITCHES --- */
.switch { 
    position: relative; 
    display: inline-block; 
    width: 44px; 
    height: 24px;
    flex-shrink: 0;
}

.switch input { 
    opacity: 0; 
    width: 0; 
    height: 0; 
}

.slider {
    position: absolute; 
    cursor: pointer; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0;
    background-color: rgba(255,255,255,0.2); 
    transition: .4s; 
    border-radius: 34px;
}

.slider:before {
    position: absolute; 
    content: ""; 
    height: 18px; 
    width: 18px; 
    left: 3px; 
    bottom: 3px;
    background-color: white; 
    transition: .4s; 
    border-radius: 50%;
}

input:checked + .slider { 
    background-color: var(--primary); 
}

input:checked + .slider:before { 
    transform: translateX(20px); 
}

/* --- RANGE INPUTS --- */
input[type="range"] {
    width: 100%;
    max-width: 120px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 8px var(--primary-glow);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 8px var(--primary-glow);
    border: none;
}

/* --- MODE SELECTOR --- */
.mode-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(8px, 2vw, 10px);
    margin-top: 10px;
}

.mode-option {
    padding: clamp(10px, 2.5vw, 12px);
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-height: 48px;
}

.mode-option:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.mode-option.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.2);
    box-shadow: 0 0 12px var(--primary-glow);
}

.mode-icon {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 5px;
}

.mode-name {
    font-weight: 600;
    font-size: clamp(0.8rem, 2vw, 0.85rem);
    margin-bottom: 3px;
}

.mode-desc {
    font-size: clamp(0.65rem, 1.5vw, 0.7rem);
    color: var(--text-muted);
}

/* --- ANIMATIONS --- */
@keyframes float { 
    0%, 100% { transform: translateY(0); } 
    50% { transform: translateY(-10px); } 
}

.bomb-icon-animated {
    font-size: clamp(3rem, 8vw, 4rem);
    margin-bottom: 10px;
    display: inline-block;
}

.shake { 
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both; 
}

@keyframes shake { 
    10%, 90% { transform: translate3d(-1px, 0, 0); } 
    20%, 80% { transform: translate3d(2px, 0, 0); } 
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 
    40%, 60% { transform: translate3d(4px, 0, 0); } 
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

/* --- MOBILE SPECIFIC --- */
.mobile-wrapper { 
    height: 100vh; 
    display: flex; 
    flex-direction: column; 
    padding: clamp(12px, 3vw, 15px);
}

.mobile-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 15px;
    flex-shrink: 0;
}

.mobile-status { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    overflow-y: auto;
}

.latency-pill {
    background: rgba(0,0,0,0.4); 
    padding: clamp(5px, 2vw, 6px) clamp(8px, 2.5vw, 10px);
    border-radius: 12px;
    font-size: clamp(0.7rem, 2vw, 0.75rem);
    color: var(--success); 
    display: flex; 
    align-items: center; 
    gap: 4px;
    min-height: 32px;
}

.latency-pill.bad { 
    color: var(--danger); 
}

/* --- STATS DISPLAY --- */
.stats-bar {
    display: flex;
    justify-content: space-around;
    padding: clamp(10px, 2.5vw, 12px);
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
    border: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: clamp(0.65rem, 1.8vw, 0.7rem);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- PLAYERS INFO COMPACT --- */
.players-info-compact {
    padding: clamp(8px, 2vw, 10px);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
    text-align: center;
    flex-shrink: 0;
}

.players-count {
    font-size: clamp(1rem, 3vw, 1.2rem);
    font-weight: 700;
    color: var(--primary);
}

.players-names {
    font-size: clamp(0.75rem, 2vw, 0.8rem);
    color: var(--text-muted);
    margin-top: 5px;
}

/* --- HOST INPUT OVERLAY --- */
#host-input-overlay {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass);
    backdrop-filter: blur(12px);
    padding: 15px;
    border-radius: 12px;
    border: 2px solid var(--primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    align-items: center;
    gap: 10px;
    z-index: 1000;
    width: calc(100% - 40px);
    max-width: 500px;
}

#host-input-overlay input {
    flex: 1;
    min-width: 0;
}

#host-input-overlay button {
    width: auto;
    padding: 12px 24px;
    flex-shrink: 0;
}

/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
    .dashboard {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }
    
    .panel-side {
        order: 2;
        max-height: none;
    }
    
    .panel-main {
        order: 1;
        min-height: 50vh;
    }
}

@media (max-width: 768px) {
    .syllable-box {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }
    
    .mode-selector {
        grid-template-columns: 1fr;
    }
    
    .picker-grid {
        grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
    }
    
    .grid-container {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        max-height: 50vh;
    }
    
    #host-input-overlay {
        flex-direction: column;
        bottom: 10px;
        width: calc(100% - 20px);
    }
    
    #host-input-overlay input,
    #host-input-overlay button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 1.5rem;
    }
    
    .info-list li {
        font-size: 0.85rem;
    }
    
    .player-card {
        min-width: 100px;
    }
}

/* --- SCROLLBAR CUSTOM --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* --- TOUCH IMPROVEMENTS --- */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .picker-item,
    .mode-option,
    input[type="text"],
    input[type="number"] {
        min-height: 48px;
    }
    
    .switch {
        width: 52px;
        height: 28px;
    }
    
    .slider:before {
        height: 22px;
        width: 22px;
    }
}
