:root {
    --bg-color: #1a1a1a;
    --card-bg: #2d2d2d;
    --text-main: #f0f0f0;
    --text-dim: #a0a0a0;
    --accent-green: #00e676;
    --accent-orange: #ff9800;
    --accent-red: #ff1744;
    --border-radius: 10px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    padding: 10px;
}

/* Шапка */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 10px;
}

.header h1 {
    font-size: clamp(1rem, 2vw, 1.5rem);
    font-weight: 700;
}

.legend {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: clamp(0.6rem, 1vw, 0.8rem);
    color: var(--text-dim);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot.green {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

.legend-dot.red {
    background: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
}

.legend-dot.gray {
    background: #666;
}

/* Сетка столов */
.tables-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: clamp(4px, 0.5vw, 8px);
    padding: clamp(5px, 0.5vw, 10px);
    min-height: 0;
    max-width: 1920px;
    width: 100%;
    margin: 0 auto;
}

/* Карточка стола */
.table-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: clamp(4px, 0.5vw, 8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 0;
    position: relative;
    width: 100%;
    height: 100%;
}

.table-card:active {
    transform: scale(0.95);
}

.table-card.is-running {
    border-color: var(--accent-green);
    box-shadow: 0 0 15px rgba(0, 230, 118, 0.6);
}

.table-card.is-expired {
    border-color: var(--accent-red);
    animation: pulse-red 0.8s infinite;
}

@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 15px rgba(255, 23, 68, 0.7); }
    50% { box-shadow: 0 0 30px rgba(255, 23, 68, 1); }
}

/* Верхняя часть карточки */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 4px;
}

.table-name {
    font-size: clamp(0.7rem, 1vw, 1rem);
    font-weight: 700;
}

.table-status {
    font-size: clamp(0.5rem, 0.7vw, 0.7rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    text-align: right;
}

.status-idle { color: var(--text-dim); }
.status-running { color: var(--accent-green); }
.status-expired { color: var(--accent-red); font-weight: 800; }

/* Средняя часть */
.table-main {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.btn-start-side {
    width: 50%;
    height: 100%;
    min-height: 50px;
    border: none;
    border-radius: 8px;
    font-size: clamp(0.6rem, 0.8vw, 0.9rem);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    background: #388e3c;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

.btn-start-side:active {
    background: #2e7d32;
    transform: scale(0.95);
}

.btn-start-side .btn-icon {
    font-size: clamp(1.2rem, 1.5vw, 1.5rem);
    margin-bottom: 4px;
}

.btn-start-side .btn-text {
    font-size: clamp(0.5rem, 0.6vw, 0.7rem);
    text-align: center;
}

.timer-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.timer-display {
    font-size: clamp(1.2rem, 2vw, 2rem);
    font-weight: 800;
    text-align: center;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.timer-display.expired-time {
    color: var(--accent-red);
    font-size: clamp(1rem, 1.8vw, 1.8rem);
}

/* Кнопки действий */
.action-buttons {
    display: flex;
    gap: 4px;
    width: 100%;
    margin-top: 4px;
}

.action-btn {
    flex: 1;
    padding: 6px;
    border: none;
    border-radius: 6px;
    font-size: clamp(0.5rem, 0.7vw, 0.8rem);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.btn-reset {
    background: #f57c00;
}

.btn-reset:active {
    background: #e65100;
    transform: scale(0.95);
}

.btn-stop {
    background: #616161;
}

.btn-stop:active {
    background: #424242;
    transform: scale(0.95);
}

/* Кнопки времени */
.time-actions {
    display: flex;
    gap: 3px;
    margin-top: 4px;
    width: 100%;
}

.time-btn {
    background: #424242;
    border: none;
    color: var(--text-main);
    padding: 4px;
    border-radius: 4px;
    font-size: clamp(0.5rem, 0.6vw, 0.7rem);
    font-weight: 600;
    flex: 1;
    cursor: pointer;
    transition: all 0.2s;
}

.time-btn:active {
    background: #616161;
    transform: scale(0.9);
}

/* Адаптация для разных экранов */
@media (min-width: 1920px) {
    .tables-grid {
        max-width: 1600px;
    }
    .table-card {
        padding: 12px;
    }
    .timer-display {
        font-size: 2.5rem;
    }
}

@media (max-width: 1024px) {
    .tables-grid {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(5, 1fr);
        gap: 4px;
    }
    .table-card {
        padding: 4px;
    }
    .btn-start-side {
        min-height: 40px;
        padding: 4px;
    }
}

@media (max-width: 768px) {
    .tables-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(10, 1fr);
    }
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-height: 600px) {
    .table-card {
        padding: 3px;
    }
    .table-name {
        font-size: 0.6rem;
    }
    .timer-display {
        font-size: 1rem;
    }
    .btn-start-side {
        min-height: 30px;
        padding: 2px;
    }
    .btn-start-side .btn-icon {
        font-size: 0.8rem;
        margin-bottom: 2px;
    }
    .btn-start-side .btn-text {
        font-size: 0.4rem;
    }
    .action-btn {
        padding: 3px;
        font-size: 0.5rem;
    }
    .time-btn {
        padding: 2px;
        font-size: 0.4rem;
    }
}