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

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

th, td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: center;
}

/* Уменьшаем ширину столбца "Грязное значение" */
th:nth-child(6), td:nth-child(6) {
    width: calc(100% / 8 - 20px);
    min-width: 80px;
    max-width: 120px;
}

th {
    background-color: #8B0000;
    color: white;
    font-weight: bold;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

tr:hover {
    background-color: #f0f0f0;
}

.hero-row {
    background-color: #fff3cd !important;
    border-left: 4px solid #ffc107;
}

.hero-row:hover {
    background-color: #ffeaa7 !important;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

input[type="text"]:focus, input[type="number"]:focus, select:focus {
    outline: none;
    border-color: #8B0000;
    box-shadow: 0 0 5px rgba(139, 0, 0, 0.3);
}

/* Стили для валидации */
input[type="text"]:invalid, input[type="text"].invalid {
    border-color: #dc3545 !important;
    background-color: #ffebee !important;
}

input[type="text"]:valid {
    border-color: #28a745;
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #28a745;
    color: white;
}

.btn-primary:hover {
    background-color: #218838;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: #007bff;
    color: white;
}

.btn-secondary:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.btn-tertiary {
    background-color: #6f42c1;
    color: white;
}

.btn-tertiary:hover {
    background-color: #5a32a3;
    transform: translateY(-2px);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    padding: 8px 16px;
    font-size: 14px;
}

.btn-danger:hover {
    background-color: #c82333;
    transform: translateY(-2px);
}

.btn-danger:disabled {
    background-color: #6c757d !important;
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

.btn-danger:disabled:hover {
    background-color: #6c757d !important;
    transform: none !important;
}

.btn-roll {
    background-color: #fd7e14;
    color: white;
    padding: 8px 16px;
    font-size: 14px;
}

.btn-roll:hover {
    background-color: #e8690b;
    transform: translateY(-2px);
}

.initiative-value {
    font-weight: bold;
    font-size: 18px;
}

.advantage {
    color: #28a745;
}

.disadvantage {
    color: #dc3545;
}

/* Стили для кубиков */
.dice-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    min-height: 40px;
}

.dice {
    width: 40px;
    height: 40px;
    border: 2px solid #333;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    box-shadow: 3px 3px 6px #bebebe, -3px -3px 6px #ffffff;
    transition: all 0.3s ease;
    position: relative;
}

.dice::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 8px;
    background: linear-gradient(225deg, rgba(255,255,255,0.3), transparent 50%, rgba(0,0,0,0.1));
    pointer-events: none;
    z-index: 0;
}

.dice span {
    z-index: 1;
    position: relative;
}

.dice.selected {
    border-color: #007bff;
    background: linear-gradient(145deg, #cce7ff, #b3d9ff);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.5);
}

.dice.unselected {
    border-color: #999;
    background: linear-gradient(145deg, #e0e0e0, #c0c0c0);
    color: #666;
    opacity: 0.6;
    transform: scale(0.9);
    box-shadow: 2px 2px 4px #bebebe, -2px -2px 4px #ffffff;
}

.dice.critical-fail {
    border-color: #dc3545;
    background: linear-gradient(145deg, #ffcccc, #ffb3b3);
    color: #dc3545;
    animation: shake 0.5s;
}

.dice.critical-success {
    border-color: #28a745;
    background: linear-gradient(145deg, #ccffcc, #b3ffb3);
    color: #28a745;
    animation: glow 0.5s;
}

.dice.selected.critical-fail {
    border-color: #dc3545;
    background: linear-gradient(145deg, #ff9999, #ff6666);
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.7);
}

.dice.selected.critical-success {
    border-color: #28a745;
    background: linear-gradient(145deg, #99ff99, #66ff66);
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.7);
}

.dice.unselected.critical-fail {
    border-color: #999;
    background: linear-gradient(145deg, #e0e0e0, #c0c0c0);
    color: #666;
}

.dice.unselected.critical-success {
    border-color: #999;
    background: linear-gradient(145deg, #e0e0e0, #c0c0c0);
    color: #666;
}

/* Анимации */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

@keyframes glow {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Цветовое выделение полей инициативы */
.critical-fail-bg {
    background-color: #ffebee !important;
    border-color: #dc3545 !important;
}

.critical-success-bg {
    background-color: #e8f5e8 !important;
    border-color: #28a745 !important;
}

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

    h1 {
        font-size: 2em;
    }

    table {
        font-size: 14px;
    }

    th, td {
        padding: 8px;
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
        max-width: 200px;
    }
}

/* Стили для форм создания */
.form-section {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.form-section h6 {
    color: #495057;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #dee2e6;
}

.existing-player-btn {
    cursor: pointer;
    transition: all 0.2s ease;
}

.existing-player-btn:hover {
    background-color: #e9ecef;
}

.existing-player-btn.active {
    background-color: #007bff;
    color: white;
}

.card {
    border: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card-header {
    background-color: #007bff;
    color: white;
    border-radius: 8px 8px 0 0 !important;
}

.alert {
    border: none;
    border-radius: 8px;
}

.btn-group .btn {
    margin-right: 0;
}

/* Стили для отключенных кнопок */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: #fff !important;
}

/* Соответствие классов сообщений Django и Bootstrap */
.alert-error {
    color: #842029;
    background-color: #f8d7da;
    border-color: #f5c2c7;
}

.alert-success {
    color: #0f5132;
    background-color: #d1e7dd;
    border-color: #badbcc;
}

.alert-warning {
    color: #664d03;
    background-color: #fff3cd;
    border-color: #ffecb5;
}

.alert-info {
    color: #055160;
    background-color: #cff4fc;
    border-color: #b6effb;
}
