/* Premium Crystal Glassmorphism & Modern Web Aesthetic System */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800&family=Plus+Jakarta+Sans:wght@500;700;800&display=swap');

:root {
    --bg-dark: #090d16;
    --bg-gradient: radial-gradient(ellipse at 50% -10%, #1e1b4b 0%, #090d16 80%);
    --card-bg: rgba(26, 32, 53, 0.65);
    --card-border: rgba(255, 255, 255, 0.14);
    --glass-glow: rgba(99, 102, 241, 0.15);
    
    --text-main: #f8fafc;
    --text-sub: #94a3b8;

    --p0-color: #ff4757;
    --p0-glow: rgba(255, 71, 87, 0.5);
    --p1-color: #ffa502;
    --p1-glow: rgba(255, 165, 2, 0.5);
    --p2-color: #1e90ff;
    --p2-glow: rgba(30, 144, 255, 0.5);

    --accent-green: #2ed573;
    --accent-purple: #a855f7;
}

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

body {
    font-family: 'Plus Jakarta Sans', 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Ambient Background Glow Effect */
body::before {
    content: '';
    position: absolute;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.25) 0%, transparent 70%);
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    filter: blur(40px);
    pointer-events: none;
}

/* Main Container Shell */
#app {
    width: 100%;
    max-width: 480px;
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    padding: 12px;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

/* Header Bar */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 48px;
    padding: 0 8px;
    z-index: 10;
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ff4757, #ffa502, #1e90ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(255, 71, 87, 0.3));
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.icon-btn:hover {
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

/* Player Cards Bar */
.players-bar {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 6px 0;
}

.player-card {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.player-card.active-turn {
    border-color: var(--accent-green);
    transform: translateY(-3px);
    box-shadow: 0 0 16px rgba(46, 213, 115, 0.5), inset 0 0 12px rgba(46, 213, 115, 0.2);
}

.avatar-badge {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
    color: #fff;
    margin-bottom: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.p0-badge { background: linear-gradient(135deg, #ff4757, #ff6b81); }
.p1-badge { background: linear-gradient(135deg, #ffa502, #ff7f50); }
.p2-badge { background: linear-gradient(135deg, #1e90ff, #70a1ff); }

.player-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

/* Main Board Stage */
.game-stage {
    flex: 1;
    width: 100%;
    min-height: 340px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Bottom Action Bar */
.bottom-bar {
    height: 56px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 0 12px;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.btn-action {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 10px 22px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-action:active {
    transform: scale(0.94);
}

.btn-action:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

/* Lobby View & Banners */
.lobby-view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

.game-cards {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.game-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    position: relative;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.game-card:hover {
    transform: translateY(-3px);
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.25);
}

.game-banner {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-bottom: 1px solid var(--card-border);
    transition: transform 0.4s ease;
}

.game-card:hover .game-banner {
    transform: scale(1.04);
}

.game-content {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-title {
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 2px;
}

.game-desc {
    font-size: 0.78rem;
    color: var(--text-sub);
}

.game-tag {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.4);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 8px;
    white-space: nowrap;
}

/* Modal Popup */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
}

.modal-content {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    width: 100%;
    max-width: 360px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.7);
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    text-align: center;
}

.form-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: #6366f1;
}

/* Valid Move Highlight Animation */
.valid-move-highlight {
    animation: pulseRing 1.5s infinite alternate ease-in-out;
}

@keyframes pulseRing {
    from { r: 10; opacity: 0.5; }
    to { r: 13; opacity: 0.9; }
}

/* Floating Emoji Reactions */
.emoji-float {
    position: absolute;
    font-size: 2.8rem;
    animation: floatUp 2.2s ease-out forwards;
    pointer-events: none;
    z-index: 50;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(0.6); }
    50% { transform: translateY(-60px) scale(1.3); }
    100% { opacity: 0; transform: translateY(-120px) scale(1); }
}

/* Active Rooms Search List */
.rooms-list-container {
    max-height: 130px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 4px;
}

.room-item-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-item-card:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
}

.btn-join-item {
    background: linear-gradient(135deg, #2ed573, #26af5f);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(46, 213, 115, 0.3);
}

.btn-join-item:active {
    transform: scale(0.95);
}
