/* ==================== Переменные ==================== */
:root {
    --bg: #060e1a;
    --bg-light: #0d1b2e;
    --bg-card: #111f35;
    --primary: #00b4d8;
    --primary-dark: #0096b7;
    --primary-glow: rgba(0, 180, 216, 0.25);
    --success: #00c853;
    --success-glow: rgba(0, 200, 83, 0.3);
    --danger: #ff3d51;
    --danger-glow: rgba(255, 61, 81, 0.3);
    --warning: #ffab00;
    --text: #e0eaf5;
    --text-muted: #5a7a9a;
    --text-bright: #ffffff;
    --border: #1a3050;
    --border-light: #254060;

    --cell-size: 32px;
    --cell-small: 22px;
    --board-gap: 2px;

    /* Клетки поля */
    --cell-water: linear-gradient(135deg, #0c2340 0%, #0f2b4a 50%, #0c2340 100%);
    --cell-water-hover: linear-gradient(135deg, #0f3060 0%, #133a6a 50%, #0f3060 100%);
    --cell-ship-bg: linear-gradient(135deg, #1e5080 0%, #2a6090 50%, #1e5080 100%);
    --cell-ship-border: #3a8abf;
    --cell-miss-bg: #0a1a2e;
    --cell-hit-bg: linear-gradient(135deg, #cc2020 0%, #e63030 50%, #cc2020 100%);
    --cell-sunk-bg: linear-gradient(135deg, #8b1a1a 0%, #a02020 50%, #8b1a1a 100%);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Тонкая текстура воды на фоне */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(0, 100, 180, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 180, 216, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(0, 80, 150, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

#app {
    max-width: 420px;
    margin: 0 auto;
    padding: 10px 8px;
    position: relative;
    z-index: 1;
}

/* ==================== Screens ==================== */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* ==================== Loading ==================== */
#loading.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    gap: 16px;
}

#loading p {
    color: var(--text-muted);
    font-size: 14px;
    letter-spacing: 0.5px;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-right-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.loading-spinner.small {
    width: 18px;
    height: 18px;
    border-width: 2px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== Toast (уведомления ошибок) ==================== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #2a1015;
    color: var(--danger);
    border: 1px solid rgba(255, 61, 81, 0.3);
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(10px);
    max-width: 90vw;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ==================== Header ==================== */
.header {
    text-align: center;
    margin-bottom: 14px;
}

.header h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-bright);
}

.header p {
    font-size: 13px;
    color: var(--text-muted);
}

.players-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    font-size: 15px;
    font-weight: 700;
}

.player-name {
    color: var(--text);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vs {
    font-size: 18px;
    opacity: 0.8;
}

.turn-indicator {
    font-size: 13px;
    padding: 6px 18px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 8px;
    font-weight: 700;
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
}

.turn-indicator.my-turn {
    background: rgba(0, 200, 83, 0.15);
    color: var(--success);
    border: 1px solid rgba(0, 200, 83, 0.3);
    box-shadow: 0 0 20px rgba(0, 200, 83, 0.1);
}

.turn-indicator.enemy-turn {
    background: rgba(255, 61, 81, 0.12);
    color: var(--danger);
    border: 1px solid rgba(255, 61, 81, 0.25);
}

.turn-indicator.game-over {
    background: rgba(255, 171, 0, 0.15);
    color: var(--warning);
    border: 1px solid rgba(255, 171, 0, 0.3);
}

/* ==================== Board ==================== */
.board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.board {
    display: grid;
    grid-template-columns: 22px repeat(10, var(--cell-size));
    grid-template-rows: 22px repeat(10, var(--cell-size));
    gap: var(--board-gap);
    background: var(--border);
    border-radius: 6px;
    padding: 2px;
    user-select: none;
    box-shadow:
        0 2px 20px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    position: relative;
}

.board.small {
    grid-template-columns: 16px repeat(10, var(--cell-small));
    grid-template-rows: 16px repeat(10, var(--cell-small));
}

.board-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.board.small .board-label {
    font-size: 7px;
}

/* ==================== Ячейки ==================== */
.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cell-water);
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.15s ease;
    font-size: 12px;
    position: relative;
    overflow: hidden;
}

/* Лёгкая рябь воды — шахматный паттерн */
.cell::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.15s;
}

.board.small .cell {
    font-size: 9px;
}

.cell:hover:not(.disabled):not(.ship):not(.miss):not(.hit):not(.sunk) {
    background: var(--cell-water-hover);
    box-shadow: inset 0 0 8px rgba(0, 180, 216, 0.15);
}

/* === КОРАБЛЬ === */
.cell.ship {
    background: var(--cell-ship-bg);
    border: 1px solid rgba(58, 138, 191, 0.5);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Точка в центре корабля */
.cell.ship::after {
    content: '';
    width: 6px;
    height: 6px;
    background: rgba(58, 138, 191, 0.8);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(58, 138, 191, 0.4);
}

.board.small .cell.ship::after {
    width: 4px;
    height: 4px;
}

/* === ПРОМАХ === */
.cell.miss {
    background: var(--cell-miss-bg);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.cell.miss::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(90, 122, 154, 0.6) 0%, transparent 70%);
    box-shadow: 0 0 4px rgba(90, 122, 154, 0.2);
}

.board.small .cell.miss::after {
    width: 5px;
    height: 5px;
}

/* Анимация всплеска при промахе (Шаг 4.1) */
.cell.miss.splash-anim {
    animation: splashAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.cell.miss.splash-anim::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(100, 180, 230, 0.5);
    opacity: 0;
    animation: splashRing 0.6s ease-out forwards;
}

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

@keyframes splashRing {
    0% {
        transform: scale(0.3);
        opacity: 0.8;
        border-color: rgba(100, 180, 230, 0.7);
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
        border-color: rgba(100, 180, 230, 0);
    }
}

/* === ПОПАДАНИЕ === */
.cell.hit {
    background: var(--cell-hit-bg);
    border: 1px solid rgba(255, 100, 100, 0.5);
    box-shadow:
        0 0 12px rgba(255, 61, 81, 0.3),
        inset 0 0 8px rgba(255, 200, 50, 0.15);
}

.cell.hit::after {
    content: '🔥';
    font-size: 16px;
    filter: brightness(1.2);
    line-height: 1;
}

.board.small .cell.hit::after {
    font-size: 11px;
}

/* ===== Шаг 4.1: Анимация взрыва при попадании ===== */
.cell.hit.explode-anim {
    animation: explosionFlash 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Вспышка + ударная волна */
.cell.hit.explode-anim::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    opacity: 0;
    animation: explosionWave 0.6s ease-out forwards;
    background: radial-gradient(circle, rgba(255, 200, 50, 0.6) 0%, rgba(255, 80, 30, 0.3) 40%, transparent 70%);
    z-index: 2;
    pointer-events: none;
}

@keyframes explosionFlash {
    0% {
        transform: scale(1.4);
        filter: brightness(3) saturate(2);
        box-shadow:
            0 0 30px rgba(255, 200, 50, 0.8),
            0 0 60px rgba(255, 100, 30, 0.4);
    }
    25% {
        transform: scale(0.9);
        filter: brightness(1.8);
    }
    50% {
        transform: scale(1.05);
        filter: brightness(1.3);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
        box-shadow:
            0 0 12px rgba(255, 61, 81, 0.3),
            inset 0 0 8px rgba(255, 200, 50, 0.15);
    }
}

@keyframes explosionWave {
    0% {
        transform: scale(0.2);
        opacity: 1;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* === ПОТОПЛЕН === */
.cell.sunk {
    background: var(--cell-sunk-bg);
    border: 1px solid rgba(200, 50, 50, 0.5);
    box-shadow:
        0 0 8px rgba(139, 26, 26, 0.4),
        inset 0 0 6px rgba(0, 0, 0, 0.3);
}

.cell.sunk::after {
    content: '💀';
    font-size: 14px;
    opacity: 0.9;
    line-height: 1;
}

.board.small .cell.sunk::after {
    font-size: 10px;
}

/* ===== Шаг 4.2: Анимация потопления — последовательное проявление ===== */
.cell.sunk-anim {
    animation: sunkRevealCell 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes sunkRevealCell {
    0% {
        background: var(--cell-hit-bg);
        transform: scale(1.2);
        filter: brightness(2) saturate(1.5);
        box-shadow:
            0 0 20px rgba(255, 80, 30, 0.6),
            0 0 40px rgba(255, 60, 20, 0.3);
    }
    30% {
        transform: scale(0.85);
        filter: brightness(1.5);
    }
    60% {
        transform: scale(1.05);
        background: var(--cell-sunk-bg);
    }
    100% {
        background: var(--cell-sunk-bg);
        transform: scale(1);
        filter: brightness(1);
        box-shadow:
            0 0 8px rgba(139, 26, 26, 0.4),
            inset 0 0 6px rgba(0, 0, 0, 0.3);
    }
}

/* Анимация miss-клеток вокруг потопленного (появление волнами) */
.cell.sunk-miss-anim {
    animation: sunkMissReveal 0.4s ease-out both;
}

@keyframes sunkMissReveal {
    0% {
        transform: scale(0.5);
        opacity: 0.3;
    }
    60% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* === Превью расстановки === */
.cell.preview {
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.35), rgba(0, 140, 190, 0.25));
    border: 1.5px solid var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.cell.preview-invalid {
    background: linear-gradient(135deg, rgba(255, 61, 81, 0.3), rgba(200, 30, 50, 0.2));
    border: 1.5px solid var(--danger);
    box-shadow: 0 0 10px var(--danger-glow);
}

.cell.disabled {
    cursor: default;
}

/* Crosshair на поле противника */
.board.opponent .cell:hover:not(.miss):not(.hit):not(.sunk):not(.disabled) {
    background: linear-gradient(135deg, rgba(255, 61, 81, 0.2), rgba(200, 30, 50, 0.15));
    cursor: crosshair;
    box-shadow: 0 0 12px var(--danger-glow);
}

.board.opponent .cell:hover:not(.miss):not(.hit):not(.sunk):not(.disabled)::after {
    content: '＋';
    color: rgba(255, 100, 100, 0.6);
    font-size: 16px;
    font-weight: 300;
}

@keyframes hitPulse {
    0% { transform: scale(1.3); filter: brightness(1.8); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); filter: brightness(1); }
}

@keyframes sunkReveal {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

/* ===== Шаг 4.1: Контейнер частиц для взрывов ===== */
.explosion-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: visible;
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    will-change: transform, opacity;
}

.particle.fire {
    background: radial-gradient(circle, #ffcc00, #ff6600);
    box-shadow: 0 0 4px #ff6600;
    animation: particleFly 0.6s ease-out forwards;
}

.particle.smoke {
    background: radial-gradient(circle, rgba(80, 80, 80, 0.7), transparent);
    animation: particleSmoke 0.8s ease-out forwards;
}

.particle.spark {
    background: #ffffaa;
    box-shadow: 0 0 3px #ffcc00;
    animation: particleSpark 0.5s ease-out forwards;
}

.particle.water {
    background: radial-gradient(circle, rgba(100, 180, 240, 0.8), transparent);
    animation: particleWater 0.5s ease-out forwards;
}

@keyframes particleFly {
    0% {
        transform: translate(var(--dx, 0), var(--dy, 0)) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(calc(var(--dx, 0) * 4), calc(var(--dy, 0) * 4 - 10px)) scale(0.2);
        opacity: 0;
    }
}

@keyframes particleSmoke {
    0% {
        transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.5);
        opacity: 0.7;
    }
    100% {
        transform: translate(calc(var(--dx, 0) * 2), calc(var(--dy, 0) * 2 - 20px)) scale(2);
        opacity: 0;
    }
}

@keyframes particleSpark {
    0% {
        transform: translate(var(--dx, 0), var(--dy, 0)) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(calc(var(--dx, 0) * 6), calc(var(--dy, 0) * 6)) scale(0);
        opacity: 0;
    }
}

@keyframes particleWater {
    0% {
        transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.5);
        opacity: 0.8;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        transform: translate(calc(var(--dx, 0) * 3), calc(var(--dy, 0) * 3 + 8px)) scale(0.1);
        opacity: 0;
    }
}

/* ==================== Ships Panel (РЕДИЗАЙН) ==================== */
.ships-panel {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    padding: 0 4px;
}

.ship-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 48px;
}

.ship-item:active {
    transform: scale(0.96);
}

.ship-item.selected {
    border-color: var(--primary);
    background: rgba(0, 180, 216, 0.08);
    box-shadow: 0 0 16px var(--primary-glow);
}

.ship-item.placed {
    opacity: 0.3;
    cursor: default;
    filter: grayscale(0.5);
}

.ship-item.placed:active {
    transform: none;
}

/* Визуализация корабля из отдельных клеток */
.ship-preview {
    display: flex;
    gap: 2px;
}

.ship-cell {
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, #1e5080, #2a6898);
    border-radius: 3px;
    border: 1px solid rgba(58, 138, 191, 0.6);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
}

/* Точка в центре каждой клетки корабля */
.ship-cell::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: rgba(58, 138, 191, 0.8);
    border-radius: 50%;
}

.ship-item.selected .ship-cell {
    background: linear-gradient(135deg, #1a6090, #2a80b0);
    border-color: rgba(0, 180, 216, 0.7);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        0 0 6px rgba(0, 180, 216, 0.2);
}

.ship-item.selected .ship-cell::after {
    background: rgba(0, 200, 240, 0.9);
    box-shadow: 0 0 4px rgba(0, 200, 240, 0.5);
}

.ship-count {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
}

.ship-item.selected .ship-count {
    color: var(--primary);
}

/* ==================== Controls ==================== */
.placing-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(0, 180, 216, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 4px 20px rgba(0, 180, 216, 0.35);
}

.btn-primary:disabled {
    background: var(--border);
    cursor: not-allowed;
    opacity: 0.4;
    box-shadow: none;
    transform: none;
}

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

.btn-secondary:hover {
    background: var(--border);
    border-color: var(--text-muted);
}

.btn-full {
    width: 100%;
    padding: 14px;
    font-size: 15px;
}

/* ==================== Waiting ==================== */
.waiting-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

/* ==================== Boards wrapper (battle) ==================== */
.boards-wrapper {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
}

.board-section {
    text-align: center;
}

.board-section h3 {
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ==================== Shot feedback ==================== */
.shot-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 56px;
    pointer-events: none;
    z-index: 100;
    animation: feedbackPop 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    filter: drop-shadow(0 0 20px rgba(255, 150, 0, 0.5));
}

@keyframes feedbackPop {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.3); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
    100% { opacity: 0; transform: translate(-50%, -75%) scale(0.8); }
}

/* ==================== Error screen ==================== */
.error-message {
    text-align: center;
    padding: 40px 20px;
}

.error-message p {
    color: var(--danger);
    font-size: 15px;
    margin-bottom: 20px;
}

/* ==================== Result ==================== */
#result-screen {
    text-align: center;
    padding-top: 50px;
}

#result-screen.active {
    animation: fadeIn 0.4s ease;
}

.result-icon {
    font-size: 80px;
    margin-bottom: 16px;
    animation: resultBounce 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes resultBounce {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#result-screen h2 {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text-bright);
}

#result-screen p {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 14px;
}

.rating-change {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 28px;
    letter-spacing: -0.5px;
}

.rating-change.positive {
    color: var(--success);
    text-shadow: 0 0 20px var(--success-glow);
}

.rating-change.negative {
    color: var(--danger);
    text-shadow: 0 0 20px var(--danger-glow);
}

/* ==================== Turn Timer ==================== */
.turn-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
    min-height: 32px; /* Фиксированная высота — доска не прыгает */
    transition: opacity 0.3s;
}

/* Override generic .hidden (display:none !important) — сохраняем место в layout */
.turn-timer.hidden {
    display: flex !important;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.timer-ring {
    width: 32px;
    height: 32px;
    transform: rotate(-90deg);
}

.timer-ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 3;
}

.timer-ring-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 100.53;  /* 2 * π * 16 */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.5s linear, stroke 0.3s;
}

.timer-seconds {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    min-width: 28px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s;
}

/* Предупреждение: < 15 сек */
.turn-timer.warning .timer-ring-progress {
    stroke: var(--warning);
}
.turn-timer.warning .timer-seconds {
    color: var(--warning);
}

/* Критично: < 5 сек */
.turn-timer.critical .timer-ring-progress {
    stroke: var(--danger);
    animation: timerPulse 0.5s ease-in-out infinite;
}
.turn-timer.critical .timer-seconds {
    color: var(--danger);
    animation: timerPulse 0.5s ease-in-out infinite;
}

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

/* ===== Шаг 4.2: Тряска доски при потоплении ===== */
.board.board-shake {
    animation: boardShake 0.4s ease-out;
}

@keyframes boardShake {
    0%, 100% { transform: translate(0); }
    10% { transform: translate(-2px, 1px); }
    20% { transform: translate(2px, -1px); }
    30% { transform: translate(-1px, 2px); }
    40% { transform: translate(1px, -2px); }
    50% { transform: translate(-2px, 0); }
    60% { transform: translate(1px, 1px); }
    70% { transform: translate(-1px, -1px); }
    80% { transform: translate(0, 1px); }
    90% { transform: translate(1px, 0); }
}

/* ==================== Responsive ==================== */
@media (max-width: 360px) {
    :root {
        --cell-size: 28px;
        --cell-small: 20px;
    }

    .ship-cell {
        width: 12px;
        height: 12px;
    }

    .ship-item {
        padding: 6px 10px;
    }
}

@media (max-width: 320px) {
    :root {
        --cell-size: 25px;
        --cell-small: 18px;
    }

    .ship-cell {
        width: 10px;
        height: 10px;
    }
}
