:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #ec4899;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-family: 'Inter', sans-serif;
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: drift 20s infinite alternate;
}

.blob-1 {
    width: min(300px, 40vw);
    height: min(300px, 40vw);
    background: var(--primary-color);
    top: -50px;
    left: -50px;
}

.blob-2 {
    width: min(400px, 50vw);
    height: min(400px, 50vw);
    background: var(--secondary-color);
    bottom: -100px;
    right: -100px;
    animation-delay: -5s;
}

.blob-3 {
    width: min(200px, 30vw);
    height: min(200px, 30vw);
    background: #8b5cf6;
    top: 40%;
    left: 40%;
    animation-duration: 25s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30px, 50px) scale(1.1);
    }
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: clamp(16px, 4vw, 24px);
    padding: clamp(1.25rem, 5vw, 2rem);
    width: min(90%, 400px);
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

h1.game-title {
    font-weight: 800;
    font-size: clamp(1.75rem, 8vw, 2.5rem);
    background: linear-gradient(135deg, #a5b4fc 0%, #f472b6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

h2 {
    font-weight: 600;
    font-size: clamp(1.25rem, 5vw, 1.5rem);
    margin-bottom: 1rem;
}

.subtitle {
    color: #94a3b8;
    margin-bottom: clamp(1rem, 4vw, 2rem);
    font-size: clamp(0.875rem, 4vw, 1rem);
}

.player-count-container {
    margin-bottom: clamp(1.5rem, 5vw, 2.5rem);
    width: 100%;
}

.player-count-container label {
    font-size: clamp(0.875rem, 4vw, 1rem);
}

.counter-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(1rem, 4vw, 1.5rem);
    margin-top: 1rem;
    background: rgba(0, 0, 0, 0.2);
    padding: clamp(0.375rem, 2vw, 0.5rem);
    border-radius: 12px;
}

.icon-btn {
    background: none;
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    width: clamp(36px, 10vw, 48px);
    height: clamp(36px, 10vw, 48px);
    border-radius: 50%;
    font-size: clamp(1.25rem, 5vw, 1.75rem);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s, transform 0.1s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.icon-btn:active {
    transform: scale(0.95);
}

#player-count-display {
    font-size: clamp(1.25rem, 5vw, 1.75rem);
    font-weight: 600;
    min-width: 2ch;
    text-align: center;
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: clamp(0.75rem, 4vw, 1rem);
    border-radius: 12px;
    border: none;
    font-size: clamp(1rem, 4vw, 1.1rem);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
}

.btn-primary:active,
.btn-secondary:active {
    transform: scale(0.98);
}

.screen {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    padding: clamp(0.5rem, 3vw, 1rem);
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

.hidden {
    display: none !important;
}

.player-avatar {
    width: clamp(60px, 20vw, 100px);
    height: clamp(60px, 20vw, 100px);
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    font-weight: bold;
    margin: clamp(0.5rem, 3vw, 1rem) auto clamp(1rem, 4vw, 2rem);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

.secret-word {
    font-size: clamp(1.75rem, 8vw, 2.75rem);
    font-weight: 800;
    margin: clamp(1rem, 4vw, 2rem) 0;
    color: #fcd34d;
    text-shadow: 0 0 10px rgba(252, 211, 77, 0.3);
    word-break: break-word;
    max-width: 100%;
}

.imposter-hint {
    color: var(--secondary-color);
    font-size: clamp(1rem, 4vw, 1.25rem);
    font-weight: 600;
    margin-top: -0.5rem;
    margin-bottom: clamp(1rem, 4vw, 2rem);
}

.instruction {
    opacity: 0.8;
    margin-bottom: clamp(1rem, 4vw, 2rem);
    font-size: clamp(0.875rem, 3.5vw, 1rem);
}

.success-icon {
    font-size: clamp(3rem, 12vw, 5rem);
    color: #4ade80;
    margin-bottom: clamp(0.5rem, 3vw, 1rem);
    text-shadow: 0 0 20px rgba(74, 222, 128, 0.4);
}

.helper-text {
    font-size: clamp(0.8rem, 3vw, 0.9rem);
    color: #cbd5e1;
}

.game-loop-panel {
    gap: clamp(1rem, 4vw, 1.5rem);
}

.game-loop-title {
    font-size: clamp(1.5rem, 6vw, 2rem);
    margin-top: 0.5rem;
}

.game-loop-text {
    color: #94a3b8;
    margin-bottom: clamp(1rem, 4vw, 2rem);
}

@media (min-width: 768px) {
    .glass-panel {
        padding: 2.5rem;
        width: min(85%, 450px);
    }

    h1.game-title {
        font-size: 3rem;
    }

    .secret-word {
        font-size: 3rem;
    }

    .player-avatar {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }

    .icon-btn {
        width: 52px;
        height: 52px;
    }
}

@media (min-width: 1024px) {
    .glass-panel {
        width: min(80%, 500px);
        padding: 3rem;
    }

    h1.game-title {
        font-size: 3.5rem;
    }

    .blob-1 {
        width: 400px;
        height: 400px;
    }

    .blob-2 {
        width: 500px;
        height: 500px;
    }

    .blob-3 {
        width: 300px;
        height: 300px;
    }
}

@media (max-height: 600px) {
    .glass-panel {
        padding: 1rem;
        max-height: 95vh;
        max-height: 95dvh;
    }

    .player-avatar {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
        margin: 0.5rem auto 1rem;
    }

    .secret-word {
        font-size: 1.5rem;
        margin: 1rem 0;
    }

    .instruction {
        margin-bottom: 1rem;
    }

    .success-icon {
        font-size: 2.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .blob {
        animation: none;
    }

    .glass-panel,
    .screen,
    .btn-primary,
    .btn-secondary,
    .icon-btn {
        transition: none;
    }
}

@supports not (height: 100dvh) {
    body {
        min-height: 100vh;
    }

    .glass-panel {
        max-height: 90vh;
    }
}