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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0f5132;
    background-image: 
        /* Poker table felt texture */
        radial-gradient(circle at 25% 25%, rgba(15, 81, 50, 0.8) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(20, 90, 60, 0.6) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(25, 100, 70, 0.4) 0%, transparent 70%),
        /* Subtle fabric texture */
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.02) 2px,
            rgba(255, 255, 255, 0.02) 4px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.02) 2px,
            rgba(0, 0, 0, 0.02) 4px
        );
    min-height: 100vh;
    color: #1a1a1a;
    position: relative;
}

/* Poker table felt overlay with subtle pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        /* Poker chip pattern */
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.03) 15px, transparent 16px),
        radial-gradient(circle at 80% 70%, rgba(255,255,255,0.03) 12px, transparent 13px),
        radial-gradient(circle at 40% 80%, rgba(255,255,255,0.02) 8px, transparent 9px),
        radial-gradient(circle at 90% 20%, rgba(255,255,255,0.02) 10px, transparent 11px),
        /* Table edge shadow */
        linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, transparent 20px),
        linear-gradient(to top, rgba(0,0,0,0.1) 0%, transparent 20px),
        linear-gradient(to right, rgba(0,0,0,0.1) 0%, transparent 20px),
        linear-gradient(to left, rgba(0,0,0,0.1) 0%, transparent 20px);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    color: #f5f5dc;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header h1 {
    font-size: 2.5rem;
    letter-spacing: 2px;
    font-weight: 700;
}

main {
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,248,248,0.95) 100%);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 
        0 20px 40px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.3),
        inset 0 -1px 0 rgba(0,0,0,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    position: relative;
}

/* Poker table felt texture on main content */
main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 20px;
    background: 
        radial-gradient(circle at 30% 20%, rgba(15, 81, 50, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(20, 90, 60, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.template-card {
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(248,248,248,0.9) 100%);
    box-shadow: 
        0 4px 15px rgba(0,0,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.5);
    backdrop-filter: blur(5px);
    position: relative;
}

.template-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 12px;
    background: 
        radial-gradient(circle at 20% 20%, rgba(15, 81, 50, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(20, 90, 60, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.template-card:hover {
    border-color: rgba(26, 107, 66, 0.5);
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        0 12px 30px rgba(13, 78, 46, 0.2),
        inset 0 1px 0 rgba(255,255,255,0.6);
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(252,252,252,0.95) 100%);
}

.template-card h3 {
    color: #1a6b42;
    margin-bottom: 10px;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.template-card p {
    color: #666;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.template-card .details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.tournament-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.tournament-header h2 {
    color: #0d4e2e;
    font-weight: 600;
}

.tournament-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.info-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.8) 0%, rgba(248,248,248,0.8) 100%);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 
        0 2px 10px rgba(0,0,0,0.08),
        inset 0 1px 0 rgba(255,255,255,0.4);
    backdrop-filter: blur(3px);
    position: relative;
}

.info-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 12px;
    background: radial-gradient(circle at 50% 50%, rgba(15, 81, 50, 0.02) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.info-card label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
    position: relative;
    z-index: 1;
}

.info-card .value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #0d4e2e;
    position: relative;
    z-index: 1;
}

.timer-container {
    text-align: center;
    margin: 30px 0;
}

.timer {
    font-size: 4rem;
    font-weight: bold;
    color: #dc143c;
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.status {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.status.not-started {
    background: #f5f5f5;
    color: #666;
}

.status.running {
    background: #4caf50;
    color: white;
}

.status.paused {
    background: #ff9800;
    color: white;
}

.status.finished {
    background: #f44336;
    color: white;
}

.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 30px;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #0d4e2e;
    color: white;
    font-weight: 500;
}

.btn-primary:hover {
    background: #1a6b42;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(13, 78, 46, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-warning {
    background: #ff9800;
    color: white;
}

.btn-warning:hover {
    background: #e68900;
}

.btn-success {
    background: #4caf50;
    color: white;
}

.btn-success:hover {
    background: #45a049;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #da190b;
}

footer {
    text-align: center;
    color: white;
    margin-top: 30px;
}

footer a {
    color: white;
    text-decoration: underline;
}

.blinds-progress {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.blinds-progress h3 {
    margin-bottom: 15px;
    color: #0d4e2e;
    font-weight: 600;
}

.blinds-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.blind-level-item {
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    font-size: 0.85rem;
    border: 2px solid #e0e0e0;
    background: white;
    transition: all 0.3s ease;
}

.blind-level-item.current {
    border-color: #dc143c;
    background: #dc143c;
    color: white;
    font-weight: bold;
}

.blind-level-item.passed {
    opacity: 0.5;
    background: #e0e0e0;
}

.blind-level-item .level-num {
    font-weight: bold;
    margin-bottom: 5px;
}

.blind-level-item .blinds-info {
    font-size: 0.75rem;
}

.tournaments-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.tournament-item {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tournament-item:hover {
    border-color: #0d4e2e;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.tournament-item h4 {
    color: #1a6b42;
    margin-bottom: 10px;
    font-weight: 600;
}

.tournament-item:hover {
    border-color: #1a6b42;
}

.tournament-item .tournament-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: bold;
    margin-top: 5px;
}

.existing-tournaments {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.existing-tournaments h3 {
    color: #0d4e2e;
    margin-bottom: 15px;
    font-weight: 600;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    main {
        padding: 20px;
    }

    .templates-grid {
        grid-template-columns: 1fr;
    }

    .timer {
        font-size: 3rem;
    }

    .tournament-header {
        flex-direction: column;
        gap: 15px;
    }

    .controls {
        flex-direction: column;
    }

    button {
        width: 100%;
    }

    .blinds-list {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .tournaments-list {
        grid-template-columns: 1fr;
    }
}

/* Loading spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0d4e2e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    color: #666;
    font-size: 0.9rem;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    color: white;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    min-width: 300px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast::before {
    content: '';
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    flex-shrink: 0;
}

.toast-success::before {
    content: '✓';
    text-align: center;
    line-height: 20px;
}

.toast-error::before {
    content: '✕';
    text-align: center;
    line-height: 20px;
}

.toast-info::before {
    content: 'ℹ';
    text-align: center;
    line-height: 20px;
}

.toast-warning::before {
    content: '⚠';
    text-align: center;
    line-height: 20px;
}

.toast-success {
    background: #4caf50;
}

.toast-error {
    background: #f44336;
}

.toast-info {
    background: #0d4e2e;
}

.toast-warning {
    background: #ff9800;
}

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

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

.toast-remove {
    animation: slideOut 0.3s ease forwards;
}

/* Error messages */
.error-message {
    background: #ffebee;
    border-left: 4px solid #f44336;
    padding: 12px 15px;
    border-radius: 4px;
    color: #c62828;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-message::before {
    content: '⚠';
    font-size: 1.2em;
}

/* Form validation */
.field-error {
    border-color: #f44336 !important;
    background-color: #ffebee;
}

.field-success {
    border-color: #4caf50 !important;
    background-color: #f1f8e9;
}

.error-text {
    color: #f44336;
    font-size: 0.85rem;
    margin-top: 5px;
    display: block;
}

/* Disabled state */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #1a6b42, #0d4e2e);
    transition: width 0.3s ease;
}

/* Template creation form improvements */
#create-template-view {
    max-width: 900px;
    margin: 0 auto;
}

#create-template-view h2 {
    color: #0d4e2e;
    margin-bottom: 30px;
    font-weight: 600;
}

.template-form-section {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
}

.template-form-section h3 {
    color: #1a6b42;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.form-row {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row.three-cols {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-row.two-cols {
    grid-template-columns: 1fr 1fr;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus {
    outline: none;
    border-color: #0d4e2e;
    box-shadow: 0 0 0 3px rgba(13, 78, 46, 0.1);
}

.form-group input[type="text"]:hover,
.form-group input[type="number"]:hover {
    border-color: #1a6b42;
}

.form-hint {
    font-size: 0.85rem;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

/* Blind levels table */
.blind-levels-container {
    background: white;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.blind-levels-header {
    display: grid;
    grid-template-columns: 60px 100px 100px 80px 100px 50px;
    gap: 15px;
    padding: 12px 15px;
    background: #0d4e2e;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    align-items: center;
}

.blind-levels-list {
    max-height: 400px;
    overflow-y: auto;
}

.blind-level-row {
    display: grid;
    grid-template-columns: 60px 100px 100px 80px 100px 50px;
    gap: 15px;
    padding: 12px 15px;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s ease;
}

.blind-level-row:hover {
    background: #f9f9f9;
}

.blind-level-row input[type="number"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
    text-align: center;
    background: white;
}

.blind-level-row input[type="number"]:focus {
    outline: none;
    border-color: #0d4e2e;
    box-shadow: 0 0 0 2px rgba(13, 78, 46, 0.1);
}

.blind-level-row input[disabled] {
    background: #f5f5f5;
    color: #666;
    font-weight: 600;
    cursor: not-allowed;
}

.btn-remove-level {
    background: #dc143c;
    color: white;
    border: none;
    border-radius: 4px;
    width: 35px;
    height: 35px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}

.btn-remove-level:hover {
    background: #c01235;
    transform: scale(1.1);
}

.btn-add-level {
    width: 100%;
    padding: 12px;
    margin-top: 15px;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
    margin-top: 30px;
}

.form-actions button {
    min-width: 150px;
}

/* Preview section */
.template-preview {
    background: #f0f7ff;
    border: 2px solid #4a90e2;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.template-preview h4 {
    color: #4a90e2;
    margin-bottom: 15px;
    font-weight: 600;
}

.preview-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.preview-stat {
    text-align: center;
    padding: 10px;
    background: white;
    border-radius: 6px;
}

.preview-stat-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 5px;
}

.preview-stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #0d4e2e;
}

/* Responsive template form */
@media (max-width: 768px) {
    .form-row.three-cols,
    .form-row.two-cols {
        grid-template-columns: 1fr;
    }
    
    .blind-levels-header,
    .blind-level-row {
        grid-template-columns: 50px 80px 80px 70px 80px 40px;
        gap: 8px;
        padding: 10px 8px;
        font-size: 0.85rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        width: 100%;
    }
    
    .preview-stats {
        grid-template-columns: 1fr;
    }
}
