@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    /* iOS 26 / Future Apple Design Tokens */
    --bg-base: #000000;
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-tertiary: rgba(255, 255, 255, 0.4);

    --accent-blue: #5354b0;
    --accent-indigo: #ad62b5;
    --accent-red: #FF3B30;
    --accent-green: #34C759;
    --accent-gold: #FFD60A;

    --status-bar-height: env(safe-area-inset-top, 0px);

    --glass-background: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: 30px;

    --card-radius: 32px;
    --button-radius: 20px;

    --font-main: 'Outfit', -apple-system, system-ui, sans-serif;

    --ios-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    --ios-inner-glow: inset 0 1px 1px rgba(255, 255, 255, 0.1);

    --ease-ios: cubic-bezier(0.33, 1, 0.68, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100dvh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image:
        radial-gradient(circle at 50% -20%, rgba(173, 98, 181, 0.15) 0%, transparent 60%),
        radial-gradient(circle at 10% 80%, rgba(119, 186, 195, 0.1) 0%, transparent 50%);
    background-attachment: fixed;
}

#app {
    width: 100%;
    max-width: 440px;
    height: 100dvh;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    position: relative;
    overflow: hidden;
}

/* --- Views & Transitions --- */
.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding-left: 1.8rem;
    padding-right: 1.8rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
    transition:
        opacity 0.3s var(--ease-ios),
        transform 0.3s var(--ease-ios);
    overflow-y: hidden;
    /* Prevent scroll by default */
    scrollbar-width: none;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
}

/* Base padding for views without headers */
#view-home {
    padding-top: 1.5rem;
}

/* Enable scrolling only for views that need it */
#view-lobby,
#view-settings,
#view-create,
#view-join {
    overflow-y: auto;
}

#view-home {
    justify-content: center;
}

.view::-webkit-scrollbar {
    display: none;
}

.view.active {
    opacity: 1;
    pointer-events: all;
    transform: scale(1);
}

/* --- Navigation --- */
.nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    width: calc(100% + 3.6rem);
    margin-left: -1.8rem;
    margin-right: -1.8rem;
    padding: calc(env(safe-area-inset-top, 0px) + 1rem) 1.8rem 1rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-btn {
    background: var(--glass-background);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s var(--ease-ios);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.back-btn i {
    width: 24px;
    height: 24px;
    stroke-width: 2.5px;
}

.back-btn:active {
    transform: scale(0.9);
}

/* --- Branding --- */
.hero-img {
    mix-blend-mode: screen;
    /* Blends black background away */
}

/* --- Typography --- */
h1 {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 0.9;
    text-align: center;
    margin-bottom: 0.5rem;

    background: linear-gradient(-45deg,
            #ffffff 20%,
            #5354b0 40%,
            #db75be 50%,
            #5354b0 60%,
            #ffffff 80%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shine 8s linear infinite;
    filter: drop-shadow(0 0 20px rgba(0, 122, 255, 0.2));
}

@keyframes shine {
    to {
        background-position: 200% center;
    }
}

h2 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 1.5rem;
}

.subheadline {
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 2.5rem;
}

/* --- Components --- */
.hero-container {
    padding: 1rem 0;
    text-align: center;
}

.hero-img {
    width: 100%;
    max-width: 280px;
    max-height: 35dvh;
    aspect-ratio: 1;
    object-fit: contain;
    margin: 0 auto 1.5rem;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.8));
    animation: floating 8s ease-in-out infinite;
}

@keyframes floating {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-15px) rotate(2deg);
    }
}

.btn {
    width: 100%;
    height: 64px;
    border: none;
    border-radius: var(--button-radius);
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s var(--ease-ios);
    margin-bottom: 1rem;
    box-shadow: var(--ios-shadow);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 10px 30px rgba(0, 122, 255, 0.3);
}

.btn-secondary {
    background: var(--glass-background);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    color: white;
}

.btn-danger {
    background: var(--accent-red);
    color: white;
}

.btn:active {
    transform: scale(0.96);
    filter: brightness(0.8);
}

.card {
    background: var(--glass-background);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--glass-blur));
    border-radius: var(--card-radius);
    padding: 1.5rem;
    box-shadow: var(--ios-shadow), var(--ios-inner-glow);
    margin-bottom: 1.5rem;
}

/* --- Configuration Tabs & Options --- */
.config-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 14px;
    margin-bottom: 1.5rem;
    gap: 4px;
}

.tab-item {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-item.active {
    background: var(--glass-background);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.category-chip {
    padding: 8px 16px;
    background: var(--glass-background);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    font-size: 0.9rem;
    margin: 4px;
    cursor: pointer;
    transition: 0.2s;
}

.category-chip.selected {
    background: var(--accent-blue);
    border-color: transparent;
    color: white;
}

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

.input-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    display: block;
    padding-left: 8px;
}

input[type="text"] {
    width: 100%;
    height: 60px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 0 1.2rem;
    color: white;
    font-size: 1.1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.08);
}

/* --- Lobby Styles --- */
.room-code-display {
    text-align: center;
    padding: 1rem;
    margin-bottom: 2.5rem;
}

.nav-code-box {
    display: flex;
    flex-direction: column;
}

.code-title {
    font-size: 0.6rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 2px;
}

.code-value {
    font-size: 4rem;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--accent-gold);
    text-shadow: 0 0 30px rgba(255, 214, 10, 0.3);
}

.code-value-small {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--accent-gold);
    text-shadow: 0 0 20px rgba(255, 214, 10, 0.2);
    line-height: 1;
}

.player-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.player-chip {
    background: var(--glass-background);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 1.5rem 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: transform 0.3s var(--ease-ios);
    position: relative;
    overflow: visible;
}

.status-dot {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.8);
    display: none;
}

.player-chip.claimed .status-dot {
    display: block;
}

.player-chip.glow-active {
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px rgba(0, 122, 255, 0.2);
}

.player-chip.eliminated {
    opacity: 0.5;
    filter: grayscale(1);
}

.kick-x {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 26px;
    height: 26px;
    background: var(--accent-red);
    color: white;
    border: 2px solid var(--bg-base);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(255, 59, 48, 0.4);
}

.kick-x:active {
    transform: scale(0.8);
}

.player-emoji {
    width: 2.2rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.player-emoji i {
    width: 100%;
    height: 100%;
    stroke-width: 2px;
}

.player-name {
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
}


/* --- Mode Selection --- */
.config-section {
    margin-top: 1rem;
}

.mode-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 1.5rem;
}

.mode-option {
    background: var(--glass-background);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1rem;
    cursor: pointer;
    transition: 0.3s;
}

.mode-option.active {
    background: var(--accent-blue);
    border-color: transparent;
}

.mode-option h4 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.mode-option p {
    font-size: 0.7rem;
    opacity: 0.6;
    line-height: 1.2;
}

/* --- Reveal Card --- */
.ios-card-3d {
    width: 280px;
    height: 420px;
    perspective: 1200px;
    margin: 2rem auto;
}

.ios-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ios-card-3d.flipped .ios-card-inner {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 1px solid var(--glass-border);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
}

.card-front {
    background: linear-gradient(145deg, #1c1c1e, #111111);
}

.card-back {
    background: linear-gradient(145deg, #2c2c2e, #1c1c1e);
    transform: rotateY(180deg);
}

.card-back.imposter {
    border: 2px solid var(--accent-red);
    box-shadow: 0 0 40px rgba(255, 59, 48, 0.2);
}

.role-title {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--text-tertiary);
    margin-bottom: 1rem;
}

.role-value {
    font-size: 2.2rem;
    font-weight: 800;
    text-align: center;
}

.secret-word-display {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(to bottom, #fff, #999);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: 1rem;
}

/* --- Utilities --- */
.hidden {
    display: none !important;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.7;
    }

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

    100% {
        transform: scale(0.95);
        opacity: 0.7;
    }
}

/* --- Custom Overlay --- */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    width: 100%;
    max-width: 320px;
    background: var(--glass-background);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    padding: 2rem;
    text-align: center;
}