/* ---- CORE STYLES ---- */
:root {
    --bg-dark: #0a0a0f;
    --primary-color: #7b2cbf;
    --primary-glow: rgba(123, 44, 191, 0.5);
    --secondary-color: #3a86ff;
    --secondary-glow: rgba(58, 134, 255, 0.5);
    --error-color: #ef233c;
    --success-color: #06d6a0;
    --text-main: #f8f9fa;
    --text-muted: #adb5bd;
    
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* ---- BACKGROUND ANIMATIONS ---- */
.blob {
    position: absolute;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: float 10s infinite alternate ease-in-out;
}

.blob-1 {
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
    top: -10%;
    left: -10%;
}

.blob-2 {
    width: 35vw;
    height: 35vw;
    background: radial-gradient(circle, var(--secondary-color) 0%, transparent 70%);
    bottom: -10%;
    right: -10%;
    animation-delay: -5s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.1); }
}

/* ---- LAYOUT & SCREENS ---- */
.app-container {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    max-height: 900px;
    position: relative;
    padding: 20px;
    perspective: 1000px;
}

.screen {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* ---- UI COMPONENTS ---- */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 24px;
    padding: 20px 30px;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    justify-content: center;
}

.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(10px);
}

/* LOGO */
.logo {
    text-align: center;
    margin-bottom: 0px;
}
.app-logo {
    max-width: 500px;
    max-height: 240px;
    object-fit: contain;
    height: auto;
    filter: drop-shadow(0 0 15px var(--primary-glow));
    animation: floatLogo 4s ease-in-out infinite alternate;
}

@keyframes floatLogo {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}

/* MODES */
.mode-selection {
    display: flex;
    background: rgba(0,0,0,0.3);
    padding: 6px;
    border-radius: 14px;
    margin-bottom: 10px;
}

.mode-toggle {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.mode-toggle.active {
    background: var(--glass-bg);
    color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 1px solid var(--glass-border);
}

.hidden { display: none !important; }

/* INPUTS */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: all 0.3s ease;
}

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

.input-wrapper i {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.input-wrapper input {
    width: 100%;
    padding: 12px 16px 12px 48px;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.1rem;
    outline: none;
}

.input-wrapper.large input {
    padding: 20px;
    font-size: 1.5rem;
    text-align: center;
    font-weight: 600;
    letter-spacing: 1px;
}
.input-wrapper.large i { display: none; }

/* BUTTONS */
.time-options, .difficulty-options, .length-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.time-btn, .diff-btn, .len-btn {
    flex: 1;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.time-btn.active, .diff-btn.active, .len-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-glow);
}

.spacer-v {
    height: 5px;
}

.primary-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.glow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px var(--primary-glow);
}

.secondary-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}
.secondary-btn:hover {
    color: white;
}
.secondary-btn.outline {
    border: 1px solid rgba(255,255,255,0.2);
    padding: 14px;
    border-radius: 12px;
    width: 100%;
}

.icon-btn {
    position: absolute;
    right: 10px;
    background: var(--secondary-color);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--secondary-glow);
}

/* ONLINE LAYOUT */
.online-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.code-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.4);
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px dashed var(--primary-color);
    margin-top: 8px;
}

#room-id-display {
    font-family: monospace;
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 800;
}

#copy-id-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.3s;
}
#copy-id-btn:hover { color: white; }

.lobby-status {
    font-size: 0.85rem;
    color: var(--success-color);
    margin-top: 10px;
    text-align: center;
    font-style: italic;
}

.divider {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 800;
    position: relative;
}
.divider::before, .divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 35%;
    height: 1px;
    background: var(--glass-border);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

.full-width { width: 100%; }

/* ---- GAME SCREEN STYLES ---- */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.player-score {
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 15px 25px;
    border-radius: 16px;
    min-width: 120px;
    backdrop-filter: blur(10px);
}

.p1-score { text-align: left; border-left: 4px solid var(--primary-color); }
.p2-score { text-align: right; border-right: 4px solid var(--secondary-color); }

.p-name { font-size: 0.9rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.score { font-size: 2rem; font-weight: 800; color: white; }

/* TIMER RING */
.timer-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.timer-ring {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 6;
}

.ring-progress {
    fill: none;
    stroke: var(--success-color);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 226; /* 2 * pi * r (r=36) */
    stroke-dashoffset: 0;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    transition: stroke-dashoffset 1s linear, stroke 0.5s;
}

.ring-progress.warning { stroke: #ffd166; }
.ring-progress.danger { stroke: var(--error-color); }

#timer-text {
    position: absolute;
    font-size: 1.5rem;
    font-weight: 800;
}

/* GAME BOARD */
.game-board {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
}

.turn-indicator {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 2px;
    animation: pulse 2s infinite;
}

/* WORDLE GRID */
.guess-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    margin: 20px 0;
}

.grid-row {
    display: flex;
    gap: 6px;
    width: 100%;
    justify-content: center;
}

.letter-box {
    flex: 1;
    min-width: 35px;
    max-width: 60px;
    aspect-ratio: 1/1;
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: min(2rem, 5vw);
    font-weight: 800;
    color: white;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
}

.letter-box.pop {
    animation: pop 0.1s ease-in-out;
}

.letter-box.correct {
    background: var(--success-color);
    border-color: var(--success-color);
    box-shadow: 0 0 15px rgba(6, 214, 160, 0.3);
}

.letter-box.present {
    background: #ffd166;
    border-color: #ffd166;
    color: #000;
    box-shadow: 0 0 15px rgba(255, 209, 102, 0.3);
}

.letter-box.absent {
    background: #3d3d3d;
    border-color: #3d3d3d;
    color: var(--text-muted);
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.feedback {
    margin-top: 10px;
    text-align: center;
    min-height: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.3s;
}
.feedback.error { color: var(--error-color); animation: shake 0.5s; }
.feedback.success { color: var(--success-color); }

.game-footer {
    display: flex;
    justify-content: center;
    margin-top: auto;
}

/* ---- END SCREEN STYLES ---- */
.text-center { text-align: center; }

.trophy {
    font-size: 5rem;
    color: #ffd166;
    text-shadow: 0 0 40px rgba(255, 209, 102, 0.4);
    animation: float 3s infinite alternate;
}

#winner-text {
    font-size: 2.5rem;
    margin-bottom: 30px;
    background: linear-gradient(45deg, #ffd166, #f77f00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stats-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(0,0,0,0.3);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 40px;
}

.stat-box { display: flex; flex-direction: column; gap: 10px; }
.stat-label { font-size: 1.1rem; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: 3rem; font-weight: 800; }
.stat-divider { font-size: 1.5rem; font-weight: 800; color: rgba(255,255,255,0.2); font-style: italic;}

.action-buttons { display: flex; flex-direction: column; gap: 15px; }

/* ---- ANIMATIONS ---- */
@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; text-shadow: 0 0 10px rgba(255,255,255,0.3); }
    100% { opacity: 0.7; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* RESPONSIVENESS */
@media (max-height: 700px) {
    .glass-panel { padding: 20px; }
    .logo h1 { font-size: 2rem; }
    .target-word { font-size: 2.2rem; }
}
