:root {
    --primary-color: #ff9800;
    --primary-dark: #f57c00;
    --accent-color: #ffd700;
    --bg-dark: #121212;
    --bg-card: #1e1e1e;
    --bg-input: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --danger-color: #cf6679;
    --success-color: #4caf50;
    --font-main: 'Roboto', sans-serif;
    --font-heading: 'Orbitron', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3 {
    font-family: var(--font-heading);
    letter-spacing: 1px;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    padding-bottom: 70px; /* Space for bottom nav */
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Auth Screen */
.auth-container {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.9)), url('../images/bg-auth.jpg') center/cover;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo .material-icons {
    font-size: 4rem;
    color: var(--primary-color);
}

.auth-logo h1 {
    font-size: 2rem;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
}

.auth-tabs {
    display: flex;
    margin-bottom: 2rem;
    background: var(--bg-input);
    border-radius: 8px;
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s;
}

.auth-tab.active {
    background: var(--primary-color);
    color: #000;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.form-group .material-icons {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
}

.form-group input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(45deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
}

.error-message {
    color: var(--danger-color);
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    display: none;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
}

.balance-info {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 152, 0, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    color: var(--primary-color);
    font-weight: bold;
}

/* Home Content */
.home-content {
    padding: 1.5rem;
}

.screen-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    border-left: 4px solid var(--primary-color);
    padding-left: 10px;
}

.mode-grid, .type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 2rem;
}

.type-grid {
    grid-template-columns: repeat(2, 1fr);
}

.mode-card, .type-card {
    background: var(--bg-card);
    padding: 1.5rem 1rem;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s, border-color 0.2s;
}

.mode-card:active, .type-card:active {
    transform: scale(0.95);
}

.mode-card.active, .type-card.active {
    border-color: var(--primary-color);
    background: rgba(255, 152, 0, 0.1);
}

.mode-card .material-icons, .type-card .material-icons {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.mode-card h3, .type-card h3 {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Tournament List */
.tournament-list {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tournament-card {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    text-transform: uppercase;
}

.badge-open { background: rgba(76, 175, 80, 0.2); color: var(--success-color); }
.badge-full { background: rgba(207, 102, 121, 0.2); color: var(--danger-color); }
.badge-completed { background: rgba(176, 176, 176, 0.2); color: var(--text-secondary); }

.tournament-info {
    padding: 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.info-row .material-icons {
    font-size: 1.1rem;
    color: var(--primary-color);
}

.tournament-footer {
    padding: 0.8rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
}

.mode-badge, .type-badge {
    background: rgba(255, 152, 0, 0.1);
    color: var(--primary-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Tournament Details */
.btn-back {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
}

.screen-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1rem;
    background: var(--bg-card);
}

.details-content {
    padding: 1rem;
}

.details-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.detail-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.detail-item .material-icons {
    color: var(--primary-color);
    background: rgba(255, 152, 0, 0.1);
    padding: 8px;
    border-radius: 8px;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.detail-value {
    font-size: 1rem;
    font-weight: 500;
}

.rules-section {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
    margin: 1.5rem 0;
}

.rules-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rules-list {
    list-style: none;
    padding-left: 0;
}

.rules-list li {
    margin-bottom: 0.5rem;
    padding-left: 20px;
    position: relative;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.rules-list li::before {
    content: "•";
    color: var(--primary-color);
    position: absolute;
    left: 0;
}

.btn-register {
    width: 100%;
    padding: 1rem;
    background: var(--success-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

/* Profile Screen */
.profile-content {
    padding: 2rem 1rem;
    text-align: center;
}

.profile-avatar {
    margin-bottom: 1rem;
}

.profile-avatar .material-icons {
    font-size: 5rem;
    color: var(--text-secondary);
}

.uid-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 5px;
    font-family: monospace;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 2rem 0;
}

.stat-card {
    background: var(--bg-card);
    padding: 1rem 0.5rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-card .material-icons {
    color: var(--primary-color);
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.stat-value {
    font-weight: bold;
    font-size: 1rem;
    margin-top: 2px;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-action {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    font-size: 1rem;
}

.btn-action .material-icons {
    color: var(--primary-color);
}

.btn-logout {
    margin-top: 1rem;
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.btn-logout .material-icons {
    color: var(--danger-color);
}

/* My Tournaments */
.tabs {
    display: flex;
    background: var(--bg-card);
    padding: 0 1rem;
    position: sticky;
    top: 60px;
    z-index: 90;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    position: relative;
    cursor: pointer;
}

.tab-btn.active {
    color: var(--primary-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-color);
    border-radius: 3px 3px 0 0;
}

.tab-content {
    display: none;
    padding: 1rem 0;
}

.tab-content.active {
    display: block;
}

.room-details {
    background: rgba(255, 152, 0, 0.1);
    border: 1px dashed var(--primary-color);
    padding: 1rem;
    margin-top: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-around;
}

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

.room-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.room-value {
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: 1px;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-card);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 1000;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    cursor: pointer;
}

.nav-btn span:last-child {
    font-size: 0.7rem;
}

.nav-btn.active {
    color: var(--primary-color);
}

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

.modal-content {
    background: var(--bg-card);
    width: 90%;
    max-width: 400px;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 1.5rem;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.amount-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 1rem 0;
}

.amount-btn {
    background: var(--bg-input);
    border: 1px solid transparent;
    color: white;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
}

.amount-btn.active {
    border-color: var(--primary-color);
    background: rgba(255, 152, 0, 0.1);
}

.transaction-item {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.transaction-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-input);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
}

.transaction-info {
    flex: 1;
}

.transaction-type {
    font-weight: 500;
}

.transaction-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.transaction-amount {
    font-weight: bold;
}

.transaction-amount.positive { color: var(--success-color); }
.transaction-amount.negative { color: var(--danger-color); }

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

.loading, .empty-state, .error {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.error {
    color: var(--danger-color);
}
