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

:root {
    --bg-dark: #0f1118;
    --bg-card: #1a1d2e;
    --bg-card-hover: #232740;
    --bg-sidebar: #151825;
    --text-primary: #e8eaf0;
    --text-secondary: #8b8fa3;
    --accent: #4f8cff;
    --accent-hover: #6ba0ff;
    --green-field: #2d7a3a;
    --gold: #ffc107;
    --red: #ff4757;
    --green: #2ed573;
    --border: #2a2d40;
    --radius: 10px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.balance-display {
    background: linear-gradient(135deg, #1e3a5f, #1a2744);
    padding: 8px 18px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid #2a4a6f;
}

.balance-display span {
    color: var(--gold);
    font-size: 1.1rem;
}

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: #3a4060;
    color: #666;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #2e3250;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

.btn-bet {
    background: var(--green);
    color: #111;
    font-weight: 700;
}

.btn-bet:hover {
    background: #3ae882;
}

.btn-bet:disabled {
    background: #3a4060;
    color: #666;
}

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    min-height: calc(100vh - 56px);
}

.matches-section {
    padding: 20px;
}

.matches-section h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

.matches-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.match-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.match-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.85rem;
}

.match-teams {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.team-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.match-score {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
    min-width: 50px;
    text-align: center;
}

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

.match-time.live {
    color: var(--red);
    font-weight: 600;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.match-canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 800 / 520;
}

.match-canvas-wrapper canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Sidebar */
.sidebar {
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar h2 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Standings */
.standings-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
}

#standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

#standings-table th {
    color: var(--text-secondary);
    font-weight: 500;
    padding: 6px 4px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
}

#standings-table th:nth-child(2) {
    text-align: left;
}

#standings-table td {
    padding: 7px 4px;
    text-align: center;
    border-bottom: 1px solid rgba(42, 45, 64, 0.5);
}

#standings-table td:nth-child(2) {
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

#standings-table tr:hover {
    background: rgba(79, 140, 255, 0.05);
}

#standings-table td:first-child {
    font-weight: 700;
    color: var(--text-secondary);
}

#standings-table td:last-child {
    font-weight: 700;
    color: var(--accent);
}

.team-name-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Betting */
.betting-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
}

.betting-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bet-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid var(--border);
}

.bet-match-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
}

.bet-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.bet-option {
    padding: 6px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-card-hover);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.bet-option:hover {
    border-color: var(--accent);
    background: rgba(79, 140, 255, 0.1);
}

.bet-option.selected {
    border-color: var(--green);
    background: rgba(46, 213, 115, 0.15);
}

.bet-option .odds {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    color: var(--gold);
}

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

.bet-input-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.bet-input-row input {
    flex: 1;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 0.85rem;
    width: 80px;
}

.bet-input-row input:focus {
    outline: none;
    border-color: var(--accent);
}

.bet-payout {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 4px;
}

/* Advertisers panel */
.ads-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
}

.ads-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.ads-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.ads-form input[type="text"] {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.ads-form input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.ad-color-row {
    display: flex;
    gap: 10px;
}

.ad-color-row label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.ad-color-row input[type="color"] {
    width: 36px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
}

.ad-preview {
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
    text-align: center;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), inset 0 -1px 0 rgba(0,0,0,0.18);
    border: 1px solid rgba(0,0,0,0.4);
    overflow: hidden;
    white-space: nowrap;
    padding: 0 8px;
}

.ads-list-wrap {
    margin-top: 14px;
}

.ads-subheading {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

.user-ads-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}

.user-ad-item {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.user-ad-banner {
    flex: 1;
    height: 26px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.78rem;
    letter-spacing: 0.5px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), inset 0 -1px 0 rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.4);
    overflow: hidden;
    white-space: nowrap;
    padding: 0 8px;
    text-overflow: ellipsis;
}

.ad-remove-btn {
    width: 26px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: all 0.15s;
}

.ad-remove-btn:hover {
    background: var(--red);
    color: white;
    border-color: var(--red);
}

.ads-empty {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-style: italic;
    text-align: center;
    padding: 8px 0;
}

/* Results log */
.results-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
}

.results-log {
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.8rem;
}

.result-item {
    padding: 6px 0;
    border-bottom: 1px solid rgba(42, 45, 64, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-item .result-match {
    font-weight: 600;
}

.result-item .result-score {
    color: var(--gold);
    font-weight: 700;
}

.result-item .result-round {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    max-width: 860px;
    width: 95%;
    border: 1px solid var(--border);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
}

.modal-close:hover {
    color: var(--text-primary);
}

#modal-canvas {
    width: 100%;
    border-radius: 8px;
}

.modal-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    font-size: 0.95rem;
}

.modal-info .teams {
    font-weight: 700;
    font-size: 1.1rem;
}

.modal-info .score {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold);
}

.modal-info .time {
    color: var(--text-secondary);
}

/* Event toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 18px;
    font-size: 0.85rem;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 3s forwards;
    max-width: 320px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast.goal {
    border-color: var(--gold);
    background: linear-gradient(135deg, #2a2510, var(--bg-card));
}

.toast.bet-win {
    border-color: var(--green);
    background: linear-gradient(135deg, #102a15, var(--bg-card));
}

.toast.bet-lose {
    border-color: var(--red);
    background: linear-gradient(135deg, #2a1015, var(--bg-card));
}

@keyframes slideIn {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(10px); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a3d55;
}

@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        max-height: none;
        border-left: none;
        border-top: 1px solid var(--border);
    }
    .matches-grid {
        grid-template-columns: 1fr;
    }
}
