:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: #f1f5f9; /* Lighter background for the outside */
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
}

#app-wrapper {
    background-color: var(--bg-dark);
    max-width: 480px;
    width: 100%;
    min-height: 100vh;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.container {
    padding: 0 1.5rem;
}

/* Background Glow (constrained inside app wrapper) */
.bg-glow {
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 100%;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.1) 0%, rgba(56, 189, 248, 0) 70%);
    z-index: -1;
    filter: blur(80px);
}

.bg-glow-1 { top: -200px; left: -200px; }
.bg-glow-2 { bottom: -200px; right: -200px; }

/* Header */
header {
    height: 80px;
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon { font-size: 2rem; }
.logo h1 { font-size: 1.5rem; letter-spacing: 2px; font-weight: 700; color: #fff; }
.logo h1 span { color: var(--accent); }

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.coin-balance {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
}

.profile-pic {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Controls Section */
.controls {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.search-box {
    position: relative;
    max-width: 600px;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

#game-search {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    padding: 1rem 1rem 1rem 3rem;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

#game-search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.1);
}

.categories-wrapper {
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.categories-wrapper::-webkit-scrollbar { height: 4px; }
.categories-wrapper::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }

.categories {
    display: flex;
    gap: 0.8rem;
    white-space: nowrap;
}

.cat-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.cat-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.cat-btn.active {
    background: var(--accent);
    color: var(--bg-dark);
    border-color: var(--accent);
    font-weight: 700;
}

/* Game Grid */
.game-grid {
    margin: 2rem 0 4rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

/* Game Card */
.game-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
}

.game-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.game-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    background: #1e293b;
    position: relative;
    overflow: hidden;
}

.game-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.game-card:hover .game-thumb img {
    transform: scale(1.1);
}

.game-info {
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.game-info .title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.game-info .sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.play-badge {
    position: absolute;
    bottom: 1.2rem;
    right: 1.2rem;
    background: var(--accent);
    color: var(--bg-dark);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    opacity: 0;
    transform: scale(0.5);
    transition: var(--transition);
}

.game-card:hover .play-badge {
    opacity: 1;
    transform: scale(1);
}

/* Modal */
.game-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none; /* Controlled by JS */
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    width: 95%;
    height: 90%;
    max-width: 1000px;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 1001;
    box-shadow: var(--shadow);
}

.modal-header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.game-wrapper {
    flex: 1;
    background: #000;
}

#game-frame {
    width: 100%;
    height: 100%;
}

.modal-footer {
    padding: 0.8rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    justify-content: flex-end;
}

.fullscreen-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.fullscreen-btn:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }

/* Loader */
.loader {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 0;
    color: var(--text-secondary);
    font-size: 1.2rem;
}
