/* Telegram Mini App Master Stylesheet */
:root {
    --bg-color: var(--tg-theme-bg-color, #17212b);
    --secondary-bg-color: var(--tg-theme-secondary-bg-color, #232e3c);
    --text-color: var(--tg-theme-text-color, #ffffff);
    --hint-color: var(--tg-theme-hint-color, #708499);
    --link-color: var(--tg-theme-link-color, #5288c1);
    --button-color: var(--tg-theme-button-color, #2ea6ff);
    --button-text-color: var(--tg-theme-button-text-color, #ffffff);
    --card-bg: rgba(255, 255, 255, 0.05);
    --border-radius: 14px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    direction: rtl;
    user-select: none;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--secondary-bg-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.user-meta {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 15px;
    font-weight: 600;
}

.user-badge {
    font-size: 11px;
    color: var(--hint-color);
}

.wallet-badge {
    background: rgba(46, 166, 255, 0.15);
    border: 1px solid var(--button-color);
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
    color: #ffc107;
}

/* Views */
.view {
    display: none;
    padding: 16px;
}

.view.active {
    display: block;
}

.banner {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

.banner h2 {
    font-size: 18px;
    margin-bottom: 6px;
}

.banner p {
    font-size: 13px;
    opacity: 0.85;
}

/* Games Grid */
.games-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}

.game-card {
    background-color: var(--secondary-bg-color);
    border-radius: var(--border-radius);
    padding: 16px;
    position: relative;
    border: 1px solid rgba(255,255,255,0.08);
}

.game-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255,255,255,0.1);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    color: #4cd964;
}

.game-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.game-card h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.game-card p {
    font-size: 12px;
    color: var(--hint-color);
    margin-bottom: 12px;
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background-color: var(--button-color);
    color: var(--button-text-color);
    width: 100%;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--hint-color);
    color: var(--text-color);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

/* Transactions */
.transactions-section h3 {
    font-size: 15px;
    margin-bottom: 12px;
}

.transactions-list {
    background: var(--secondary-bg-color);
    border-radius: var(--border-radius);
    padding: 12px;
}

.tx-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 13px;
}

.tx-item:last-child {
    border-bottom: none;
}

.tx-positive {
    color: #4cd964;
    font-weight: bold;
}

.tx-negative {
    color: #ff3b30;
    font-weight: bold;
}

/* Game Screen Layout */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    background: var(--secondary-bg-color);
    padding: 10px 14px;
    border-radius: var(--border-radius);
}

.turn-indicator {
    font-size: 12px;
    color: #ffc107;
    margin-top: 2px;
    display: block;
}

.timer-badge {
    background: rgba(255, 59, 48, 0.2);
    border: 1px solid #ff3b30;
    color: #ff3b30;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: bold;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--secondary-bg-color);
    padding: 24px;
    border-radius: 20px;
    text-align: center;
    max-width: 320px;
    width: 90%;
    animation: popIn 0.3s ease-out;
}

.modal-icon {
    font-size: 54px;
    margin-bottom: 12px;
}

.modal-reward {
    font-size: 22px;
    font-weight: bold;
    color: #4cd964;
    margin: 16px 0;
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
