:root {
    --bg: #0f0e0d;
    --surface: #1a1816;
    --surface2: #24211e;
    --border: #332f2b;
    --accent: #e8c84a;
    --accent-hover: #f0d060;
    --accent2: #ff6b35;
    --text: #f0edea;
    --muted: #8c837a;
    --green: #4ade80;
    --red: #f87171;
    --win: #a78bfa;
    --safe-area-top: env(safe-area-inset-top, 0px);
}

* {
    margin: 0; padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 10% 10%, rgba(232, 200, 74, 0.05), transparent 40%),
                radial-gradient(circle at 90% 90%, rgba(167, 139, 250, 0.05), transparent 40%);
    z-index: -1;
    pointer-events: none;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    padding-top: calc(var(--safe-area-top) + 80px);
    padding-bottom: 80px;
    min-height: 100vh;
}

/* Glassmorphism Panel */
.glass-panel {
    background: rgba(22, 25, 33, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(42, 48, 72, 0.5);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* Profile Header */
.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    margin-bottom: 30px;
    animation: slideDown 0.4s ease forwards;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar-container {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--accent);
    box-shadow: 0 0 15px rgba(232, 200, 74, 0.2);
    flex-shrink: 0;
}

.avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-details h2 {
    font-family: 'Unbounded', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.user-details p {
    font-size: 0.85rem;
    color: var(--muted);
}

.rank-badge {
    background: linear-gradient(135deg, rgba(232,200,74,0.1), rgba(255,107,53,0.1));
    color: var(--accent);
    border: 1px solid rgba(232, 200, 74, 0.2);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Unbounded', sans-serif;
    text-transform: uppercase;
}

/* Typography */
.section-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::before {
    content: '';
    display: block;
    width: 4px;
    height: 18px;
    background: var(--accent);
    border-radius: 2px;
}

/* Games Grid */
.games-section {
    margin-bottom: 40px;
}

.games-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.game-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    display: flex;
    padding: 16px;
    gap: 20px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.game-card:hover:not(.disabled) {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(232, 200, 74, 0.1);
}

.game-card:active:not(.disabled) {
    transform: translateY(-2px);
}

.game-cover {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.game-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.game-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}

.game-info h4 {
    font-family: 'Unbounded', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.game-info p {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.4;
    margin-bottom: 12px;
}

.btn-play {
    align-self: flex-start;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: 8px;
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
    pointer-events: none; /* handled by card click */
}

.game-card:hover:not(.disabled) .btn-play {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.game-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-disabled {
    background: rgba(255,255,255,0.05);
    color: var(--muted);
    border-color: transparent;
}

/* Loading State */
.loading {
    opacity: 0.7;
    cursor: wait !important;
}

.loading .game-icon {
    animation: rotate 2s infinite linear;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.history-item:hover {
    background: var(--surface2);
}

.history-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-icon {
    width: 40px;
    height: 40px;
    background: var(--surface2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.history-details h5 {
    font-family: 'Unbounded', sans-serif;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.history-date {
    font-size: 0.75rem;
    color: var(--muted);
}

.history-score {
    text-align: right;
}

.score-val {
    font-family: 'Unbounded', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--accent);
}

.score-rank {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 2px;
}

.history-loading, .history-empty {
    text-align: center;
    padding: 30px;
    color: var(--muted);
    font-size: 0.9rem;
    background: var(--surface);
    border-radius: 16px;
    border: 1px dashed var(--border);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    .app-container { padding: 16px; }
    .game-card { padding: 12px; gap: 12px; }
    .game-cover { width: 64px; height: 64px; }
    .game-icon { font-size: 2rem; }
    .game-info h4 { font-size: 1rem; }
}
