* {
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    overflow: hidden;
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    background: #1a3e2f;
    font-family: 'Segoe UI', 'Roboto', system-ui, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    transition: filter 0.2s ease;
}

.game-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    background: #2c2c2c;
    border-radius: 32px;
    padding: 20px;
    box-shadow: 0 20px 35px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-top-row {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    position: relative;
}

.settings-gear {
    font-size: 2.5rem;
    cursor: pointer;
    background: #3b2a1f;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 5px 12px rgba(0,0,0,0.3);
    transition: 0.2s;
    margin-top: 10px;
}
.settings-gear:hover {
    background: #5e4230;
    transform: rotate(20deg) scale(1.02);
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 180px;
}

.score-panel {
    background: #2c2c2c;
    border-radius: 32px;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 5px 12px rgba(0,0,0,0.3);
}

.player-score-card {
    background: #1e1e1e;
    border-radius: 24px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 6px solid;
}

.player-color-badge {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    box-shadow: 0 2px 6px black;
}

.player-score-info {
    flex-grow: 1;
}

.player-name {
    font-weight: bold;
    font-size: 1rem;
    color: #f0e6d2;
}

.player-score {
    font-size: 1.6rem;
    font-weight: bold;
    color: #ffd966;
    line-height: 1;
}

.neutral-score-card {
    background: #1e1e1e;
    border-radius: 24px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 6px solid #aaaaaa;
}

.neutral-badge {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    background: #aaaaaa;
    box-shadow: 0 2px 6px black;
}

.neutral-info {
    flex-grow: 1;
}

.neutral-name {
    font-weight: bold;
    font-size: 1rem;
    color: #f0e6d2;
}

.neutral-score {
    font-size: 1.6rem;
    font-weight: bold;
    color: #cccccc;
    line-height: 1;
}

.turn-counter-box {
    background: #3b2a1f;
    padding: 10px 16px;
    border-radius: 40px;
    color: #f7e5c2;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2), 0 4px 8px rgba(0,0,0,0.2);
}

.timer-box {
    background: #2c2b26;
    padding: 10px 16px;
    border-radius: 40px;
    color: #ffd966;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    font-family: monospace;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2), 0 4px 8px rgba(0,0,0,0.2);
}

.reset-button {
    background: #3b2a1f;
    border: none;
    color: #f7e5c2;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 10px 16px;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 6px black;
    width: 100%;
}

.reset-button:hover {
    background: #5e4230;
    transform: scale(0.97);
    color: white;
}

canvas {
    display: block;
    border-radius: 12px;
    box-shadow: 0 0 0 4px #d9c8a9, 0 10px 25px rgba(0,0,0,0.3);
    cursor: crosshair;
    background: #2a2a2a;
}

.canvas-info {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    color: #f7e5c2;
    background: #3b2a1f80;
    padding: 8px 16px;
    border-radius: 30px;
    backdrop-filter: blur(4px);
}

.field-size-label, .bots-label, .rotate-hint {
    background: #2c2b26;
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-block;
}

.rotate-hint {
    background: #3c3a2e;
    color: #ffd966;
}

.info-panel {
    background: #ecd9b4;
    border-radius: 40px;
    padding: 15px 25px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    font-weight: bold;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.1), 0 5px 10px rgba(0,0,0,0.2);
}

.turn-indicator {
    padding: 8px 18px;
    border-radius: 60px;
    color: white;
    font-size: 1.3rem;
    letter-spacing: 1px;
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.3), 0 4px 8px rgba(0,0,0,0.2);
    transition: background 0.2s;
}

.dice-area {
    background: #2c2b26;
    padding: 8px 20px;
    border-radius: 50px;
    color: #ffd966;
    font-size: 1.6rem;
    font-family: monospace;
    font-weight: bold;
}

button {
    background: #3b2a1f;
    border: none;
    color: #f7e5c2;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 8px 18px;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 6px black;
}

button:hover {
    background: #5e4230;
    transform: scale(0.97);
    color: white;
}

.message {
    background: #2e2b24;
    padding: 8px 20px;
    border-radius: 36px;
    color: #fadfaa;
    font-size: 0.9rem;
    max-width: 300px;
    text-align: center;
}

.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(3px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #2c2c2c;
    border-radius: 32px;
    overflow: hidden;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 35px black;
    animation: fadeIn 0.2s;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #5e4230;
    color: #f7e5c2;
}

.modal-header h3 {
    margin: 0;
}

.close-modal {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}
.close-modal:hover {
    color: #ffa500;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #f0e6d2;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 5px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1e1e1e;
    padding: 6px 14px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.15s;
    color: #f0e6d2;
    font-size: 0.9rem;
}

.radio-label:hover {
    background: #5e4230;
    transform: scale(0.97);
}

.radio-label input {
    accent-color: #e8b323;
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

.colorblind-group .radio-label {
    background: #2c2b26;
}

.colorblind-group .radio-label:hover {
    background: #5e4230;
}

input[type="range"] {
    width: 100%;
    cursor: pointer;
    background: #5e4230;
    height: 4px;
    border-radius: 5px;
    -webkit-appearance: none;
}
input[type="range"]:focus {
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffd966;
    cursor: pointer;
    border: none;
}
.hint {
    font-size: 0.75rem;
    opacity: 0.8;
}

.custom-size-inputs {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 5px;
    flex-wrap: wrap;
}

.custom-size-inputs input {
    background: #1e1e1e;
    border: 1px solid #5e4230;
    border-radius: 30px;
    padding: 6px 12px;
    color: #ffd966;
    font-weight: bold;
    text-align: center;
    width: 80px;
}

.warning-message {
    width: 100%;
    margin-top: 5px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #5e4230;
    transition: 0.3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: #f7e5c2;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #3c9e3c;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #5e4230;
}

/* Модальное окно результатов */
.result-modal .result-modal-content {
    max-width: 500px;
    background: #2c2c2c;
    border-radius: 32px;
    animation: fadeIn 0.2s;
    color: #f0e6d2;
}

.winner-block {
    background: #1e1e1e;
    border-radius: 24px;
    padding: 16px;
    text-align: center;
    margin-bottom: 20px;
    border-left: 6px solid;
    color: #f0e6d2;
}
.winner-name {
    font-size: 1.6rem;
    font-weight: bold;
}
.winner-score {
    font-size: 1.2rem;
    color: #ffd966;
}

.rankings-list {
    background: #1e1e1e;
    border-radius: 24px;
    padding: 12px;
    margin-bottom: 20px;
    color: #f0e6d2;
}
.rankings-list > div:first-child {
    color: #ffd966;
    margin-bottom: 8px;
}
.ranking-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid #5e4230;
    font-size: 1rem;
    color: #f0e6d2;
}
.ranking-item:last-child {
    border-bottom: none;
}
.rank-place {
    font-weight: bold;
    color: #ffd966;
}
.rank-name {
    flex: 1;
    margin-left: 12px;
    color: #f0e6d2;
}
.rank-score {
    font-weight: bold;
    color: #ffd966;
}

.result-stats {
    background: #1e1e1e;
    border-radius: 24px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.stat-card {
    background: #2c2b26;
    padding: 8px 12px;
    border-radius: 20px;
    text-align: center;
    flex: 1;
    color: #f0e6d2;
}
.stat-label {
    font-size: 0.8rem;
    opacity: 0.9;
    color: #ccccaa;
}
.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #ffd966;
}

.result-modal .modal-header {
    background: #2c2c2c;
    border-bottom: 1px solid #5e4230;
    color: #ffd966;
}
.result-modal .modal-header h3 {
    color: #ffd966;
}
.result-modal .close-result-modal {
    color: #f0e6d2;
}
.result-modal .close-result-modal:hover {
    color: #ffa500;
}

.result-modal .modal-footer button {
    background: #3b2a1f;
    border: none;
    color: #f7e5c2;
    font-size: 1rem;
    font-weight: bold;
    padding: 8px 18px;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.15s;
}
.result-modal .modal-footer button:hover {
    background: #5e4230;
    transform: scale(0.97);
    color: white;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95);}
    to { opacity: 1; transform: scale(1);}
}

@media (max-width: 900px) {
    .game-top-row {
        flex-direction: column;
        align-items: stretch;
    }
    .left-panel {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .score-panel {
        flex-direction: row;
        flex-wrap: wrap;
        flex: 1;
    }
    .player-score-card, .neutral-score-card {
        min-width: 130px;
    }
    .info-panel {
        flex-direction: column;
        align-items: stretch;
    }
    .message {
        max-width: none;
        text-align: center;
    }
    .settings-gear {
        align-self: center;
    }
    .canvas-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.settings-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (max-width: 700px) {
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}
