* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --black: #000000;
    --yellow: #FFD700;
    --white: #FFFFFF;
    --dark-gray: #1a1a1a;
    --light-gray: #333333;
    --text-shadow: #666666;
}

body {
    font-family: 'VT323', 'Courier New', monospace;
    background: var(--black);
    color: var(--white);
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-size: 18px;
    letter-spacing: 0.5px;
    line-height: 1.4;
}

#app {
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    width: 100%;
    background: linear-gradient(180deg, var(--black) 0%, var(--dark-gray) 100%);
}

/* Telegram Web App specific styles */
html, body {
    height: 100%;
    height: 100dvh;
    overflow-x: hidden;
}

/* CSS variable for Telegram header height - can be set by JS */
:root {
    --tg-header-height: 0px;
}

/* Add top padding to account for Telegram Web App header */
#app {
    padding-top: var(--tg-header-height, 0px);
}

/* Safe area insets for notched phones and Telegram Web App */
.container {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

.bottom-nav {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

/* Telegram Web App header offset - the app header needs extra top padding */
.header {
    padding-top: max(50px, calc(env(safe-area-inset-top) + 35px));
}

/* Loading Screen */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 15px;
    background: var(--black);
}

.preloader-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 2px;
    animation: fadeInUp 0.8s ease-out;
}

.logo-cofin {
    color: var(--yellow);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.logo-x {
    color: var(--white);
    font-size: 20px;
    opacity: 0.7;
}

.logo-telegram {
    color: #0088cc;
    text-shadow: 0 0 10px rgba(0, 136, 204, 0.5);
}

.preloader-slogan {
    font-size: 14px;
    color: var(--yellow);
    letter-spacing: 4px;
    text-transform: uppercase;
    animation: fadeInUp 0.8s ease-out 0.2s both;
    opacity: 0.9;
}

.preloader-footer {
    position: absolute;
    bottom: 30px;
    font-size: 11px;
    color: var(--text-shadow);
    letter-spacing: 1px;
    animation: fadeIn 1s ease-out 0.5s both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pixel-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--yellow);
    border-top: 3px solid transparent;
    border-radius: 0;
    animation: spin 1s linear infinite;
    image-rendering: pixelated;
    margin-top: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Header - Redesigned for Telegram Mini App */
.header {
    background: var(--dark-gray);
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    padding: 10px 15px;
    padding-top: max(56px, calc(env(safe-area-inset-top) + 40px));
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.header-logo {
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 3px;
    text-shadow: 2px 2px var(--black);
    margin-bottom: 8px;
}

.header-balance {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.balance-pill {
    background: rgba(255, 215, 0, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    font-size: 12px;
    color: var(--white);
}

/* Legacy header styles for compatibility */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 18px;
    color: var(--yellow);
    text-shadow: 2px 2px var(--black);
}

.balance-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    font-size: 14px;
}

.balance-item {
    background: rgba(255, 215, 0, 0.1);
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

/* Main Container */
.container {
    padding: 20px;
    max-width: 100%;
}

/* User Info Card */
.user-card {
    background: var(--dark-gray);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.user-name {
    font-size: 20px;
    color: var(--yellow);
    margin-bottom: 10px;
}

.user-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 14px;
    margin-top: 15px;
}

.stat-item {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.stat-label {
    color: var(--text-shadow);
    margin-bottom: 5px;
    font-size: 12px;
}

.stat-value {
    color: var(--yellow);
    font-size: 16px;
}

/* Menu Grid */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.menu-item {
    background: var(--dark-gray);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.menu-item:active {
    transform: scale(0.95);
    background: rgba(255, 215, 0, 0.1);
}

.menu-item:hover {
    background: rgba(255, 215, 0, 0.05);
    border-color: rgba(255, 215, 0, 0.4);
}

.menu-item.full-width {
    grid-column: 1 / -1;
}

.menu-icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.menu-label {
    font-size: 14px;
    color: var(--white);
}

/* Button Styles */
.btn {
    background: var(--yellow);
    color: var(--black);
    border: none;
    border-radius: 10px;
    padding: 15px 30px;
    font-family: 'VT323', monospace;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
    transition: all 0.2s;
    width: 100%;
    margin: 10px 0;
}

.btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.btn-secondary {
    background: rgba(255, 215, 0, 0.1);
    color: var(--yellow);
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-secondary:active {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-danger {
    background: rgba(255, 0, 0, 0.8);
    color: var(--white);
    border: none;
    border-radius: 10px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #FFD700, #FFA500);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* List Items */
.list-container {
    margin-bottom: 20px;
}

.list-item {
    background: var(--dark-gray);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.list-item-title {
    font-size: 16px;
    color: var(--yellow);
}

.list-item-badge {
    background: var(--yellow);
    color: var(--black);
    padding: 5px 10px;
    font-size: 14px;
    border-radius: 6px;
}

.list-item-content {
    font-size: 14px;
    color: var(--text-shadow);
    line-height: 1.6;
}

.list-item-footer {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Input Fields */
.input-group {
    margin-bottom: 20px;
}

.input-label {
    display: block;
    font-size: 14px;
    color: var(--yellow);
    margin-bottom: 10px;
}

.input-field {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    color: var(--white);
    padding: 15px;
    font-family: 'VT323', monospace;
    font-size: 16px;
}

.input-field:focus {
    outline: none;
    border-color: var(--yellow);
    background: rgba(0, 0, 0, 0.7);
}

select.input-field {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23FFD700' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 40px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--dark-gray);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 16px;
    padding: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-header {
    font-size: 20px;
    color: var(--yellow);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--yellow);
}

.modal-close {
    float: right;
    cursor: pointer;
    font-size: 16px;
}

/* Tournament Card */
.tournament-card {
    background: var(--dark-gray);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tournament-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.tournament-title {
    font-size: 16px;
    color: var(--yellow);
}

.tournament-status {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
    border: none;
}

.status-active {
    background: rgba(0, 255, 0, 0.2);
    color: #00ff00;
    border: 1px solid rgba(0, 255, 0, 0.3);
}

.status-pending {
    background: rgba(255, 215, 0, 0.2);
    color: var(--yellow);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.status-completed {
    background: rgba(102, 102, 102, 0.2);
    color: var(--text-shadow);
    border: 1px solid rgba(102, 102, 102, 0.3);
}

.tournament-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    font-size: 14px;
    margin: 10px 0;
}

.info-item {
    background: rgba(0, 0, 0, 0.5);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-label {
    color: var(--text-shadow);
    font-size: 12px;
}

.info-value {
    color: var(--yellow);
    margin-top: 5px;
    font-size: 14px;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-btn {
    background: rgba(255, 215, 0, 0.1);
    color: var(--white);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 8px;
    padding: 10px 20px;
    font-family: 'VT323', monospace;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--yellow);
    color: var(--black);
    border-color: var(--yellow);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.2);
    margin: 10px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--yellow);
    transition: width 0.3s;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--yellow);
    color: var(--black);
    border: none;
    border-radius: 12px;
    padding: 15px;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
    }
    to {
        transform: translateX(0);
    }
}

.notification.error {
    background: #ff0000;
    color: var(--white);
}

.notification.success {
    background: #00ff00;
    color: var(--black);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--dark-gray);
    border-top: 1px solid rgba(255, 215, 0, 0.2);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 5px 15px;
}

.nav-item.active {
    color: var(--yellow);
}

.nav-icon {
    font-size: 22px;
}

.nav-label {
    font-size: 11px;
}

/* App Footer */
.app-footer {
    text-align: center;
    padding: 20px 15px 100px;
    background: linear-gradient(180deg, transparent, rgba(0,0,0,0.5));
    margin-top: 30px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.footer-links span {
    color: var(--text-shadow);
    font-size: 11px;
    cursor: pointer;
    transition: color 0.2s;
}

.footer-links span:hover {
    color: var(--yellow);
}

.footer-memorial {
    color: #888;
    font-size: 10px;
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(255, 215, 0, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.1);
}

.footer-memorial strong {
    color: var(--yellow);
}

.footer-copyright {
    color: var(--text-shadow);
    font-size: 9px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--black);
}

::-webkit-scrollbar-thumb {
    background: var(--yellow);
    border: 2px solid var(--black);
}

/* Responsive */
@media (max-width: 480px) {
    .logo {
        font-size: 16px;
    }
    
    .balance-display {
        font-size: 12px;
    }
    
    .menu-label {
        font-size: 12px;
    }
    
    .btn {
        font-size: 16px;
        padding: 12px 20px;
    }
    
    .list-item-content {
        font-size: 13px;
    }
    
    .nav-label {
        font-size: 10px;
    }
}

/* Hide scrollbar for cleaner look */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

/* Pixel art effect */
.pixel-art {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Text size utilities for Telegram mini app readability */
.text-xs { font-size: 12px !important; }
.text-sm { font-size: 14px !important; }
.text-md { font-size: 16px !important; }
.text-lg { font-size: 18px !important; }
.text-xl { font-size: 20px !important; }
.text-2xl { font-size: 24px !important; }

/* Override small inline font sizes for better mobile readability */
[style*="font-size: 5px"] { font-size: 11px !important; }
[style*="font-size: 6px"] { font-size: 12px !important; }
[style*="font-size: 7px"] { font-size: 13px !important; }
[style*="font-size: 8px"] { font-size: 14px !important; }
[style*="font-size: 9px"] { font-size: 15px !important; }
[style*="font-size: 10px"] { font-size: 16px !important; }

/* Animation for menu items */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.menu-item:hover {
    animation: pulse 0.5s infinite;
}
