:root {
    --bg-dark: #0b132b;
    --card-bg: rgba(28, 37, 65, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-blue: #38bdf8;
    --accent-emerald: #10b981;
    --accent-danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --radar-grid: rgba(56, 189, 248, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

html, body {
    touch-action: none;
    overscroll-behavior: none;
    overscroll-behavior-y: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    overflow: hidden;
    height: 100%;
}

body.dark-mode {
    background: radial-gradient(circle at center, #1c2541 0%, #0b132b 100%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    touch-action: none;
}

.app-container {
    width: 100%;
    max-width: 900px;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo .emoji {
    font-size: 26px;
}

.logo h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-badge {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border-color: rgba(16, 185, 129, 0.3);
}

.turn-banner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 14px;
    padding: 10px;
    border: 1px solid var(--border-color);
}

.player-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.player-card.active-turn {
    background: rgba(56, 189, 248, 0.2);
    border: 1px solid var(--accent-blue);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.player-avatar {
    font-size: 18px;
}

.player-name {
    font-weight: 700;
    font-size: 14px;
}

.vs-badge {
    font-weight: 800;
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.controls-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.btn {
    padding: 10px 18px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

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

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-success {
    background: #10b981;
    color: white;
}

.app-container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
}

.battleground {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    flex-wrap: nowrap;
}

.board-pane {
    flex: 0 0 auto;
    width: 330px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 8px;
}

.pane-title {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--accent-blue);
}

.fleet-status {
    font-size: 11px;
    color: var(--text-muted);
}

.grid-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.grid-labels-top {
    display: grid;
    grid-template-columns: 27.5px repeat(10, 28px);
    column-gap: 2px;
    height: 20px;
    line-height: 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 800;
    color: #7dd3fc;
    text-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
    text-align: center;
    margin-bottom: 3px;
    overflow: visible;
}

.grid-label-item {
    display: inline-block;
    height: 20px;
    line-height: 20px;
    transition: transform 0.15s ease, color 0.15s ease, text-shadow 0.15s ease;
    will-change: transform;
}

.grid-label-item.active-label {
    color: #38bdf8 !important;
    text-shadow: 0 0 10px #38bdf8, 0 0 16px #38bdf8 !important;
    transform: scale(1.25);
}

.grid-body {
    display: flex;
}

.grid-labels-left {
    display: grid;
    grid-template-rows: repeat(10, 28px);
    row-gap: 2px;
    padding-top: 3px;
    width: 24px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 800;
    color: #7dd3fc;
    text-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
    align-items: center;
    text-align: center;
}

.ocean-grid {
    display: grid;
    grid-template-columns: repeat(10, 28px);
    grid-template-rows: repeat(10, 28px);
    gap: 2px;
    background: var(--radar-grid);
    padding: 2px;
    border-radius: 8px;
    border: 1.5px solid rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 20px rgba(15, 23, 42, 0.8), inset 0 0 15px rgba(56, 189, 248, 0.15);
}

.cell {
    width: 28px;
    height: 28px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    overflow: visible;
}

.cell.crosshair-line {
    background: rgba(56, 189, 248, 0.15) !important;
}

.cell.crosshair-target {
    background: rgba(56, 189, 248, 0.35) !important;
    border: 1.5px solid #38bdf8 !important;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.6) !important;
}
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    overflow: visible;
}

.cell:hover {
    background: rgba(56, 189, 248, 0.25);
}

.ship-vector-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 5;
}

.ship-vector-overlay .ship-svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
}

.cell.ship {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    position: relative;
    z-index: 2;
}

.cell.ship::before {
    display: none !important;
}

/* MINIMALIST HULL DECK DOT INDICATOR (NO EMOJIS) */
.cell.ship::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 5px;
    height: 5px;
    background: #38bdf8;
    border-radius: 50%;
    box-shadow: 0 0 5px #38bdf8;
}

.cell.ship-bow-h::after, .cell.ship-bow-v::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 9px;
    height: 9px;
    border: 1.5px solid #38bdf8;
    border-radius: 50%;
}

.cell.miss {
    background: rgba(56, 189, 248, 0.1);
}

.cell.miss::after {
    content: "•";
    color: var(--accent-blue);
    font-size: 20px;
}

.cell.hit {
    background: rgba(239, 68, 68, 0.3);
    border: 1px solid var(--accent-danger);
}

.cell.hit::after {
    content: "💥";
    font-size: 14px;
}

.cell.sunk {
    background: rgba(239, 68, 68, 0.35);
    border: 1px solid rgba(220, 38, 38, 0.6);
}

.cell.sunk::after {
    display: none !important;
}

.cell.unrevealed-ship {
    background: rgba(245, 158, 11, 0.35) !important;
    border: 1px solid #f59e0b !important;
    box-shadow: inset 0 0 8px rgba(245, 158, 11, 0.6);
    animation: pulseAmber 1s infinite alternate;
}

@keyframes pulseAmber {
    0% { opacity: 0.7; }
    100% { opacity: 1; }
}

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

.timeline-pane {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 10px;
    border: 1px solid var(--border-color);
}

.timeline-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.timeline-list {
    max-height: 80px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-item {
    font-size: 12px;
    color: var(--text-main);
}

/* READINESS BADGES */
.player-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.readiness-badge {
    font-size: 10px;
    color: #f59e0b;
    font-weight: 600;
}

.readiness-badge.ready {
    color: #10b981;
}

/* PLACEMENT SECTION */
.placement-section {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.placement-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-blue);
}

.ship-dock {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 10px;
    min-height: 50px;
}

.dock-ship {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 8px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.dock-ship:hover {
    background: rgba(56, 189, 248, 0.25);
    transform: translateY(-1px);
}

.dock-ship.selected {
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.3);
}

.dock-ship.placed {
    opacity: 0.4;
    border-style: dashed;
}

.ship-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-main);
}

.ship-blocks {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ship-svg {
    display: block;
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.drag-avatar .ship-svg {
    filter: drop-shadow(0 4px 12px rgba(56, 189, 248, 0.6));
}

.dock-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.btn-dark-outline {
    background: rgba(30, 41, 59, 0.6) !important;
    color: #94a3b8 !important;
    border: 1px solid #475569 !important;
    font-size: 12px !important;
    padding: 8px 14px !important;
}

.btn-dark-outline:hover {
    background: rgba(51, 65, 85, 0.8) !important;
    color: #f8fafc !important;
}

.btn-outline-primary {
    background: rgba(56, 189, 248, 0.1) !important;
    color: #38bdf8 !important;
    border: 1px solid rgba(56, 189, 248, 0.4) !important;
    font-size: 13px !important;
    padding: 8px 16px !important;
}

.btn-outline-primary:hover {
    background: rgba(56, 189, 248, 0.25) !important;
    border-color: #38bdf8 !important;
}

@keyframes pulseReady {
    0% { box-shadow: 0 0 8px rgba(34, 197, 94, 0.5); transform: scale(1); }
    50% { box-shadow: 0 0 24px rgba(34, 197, 94, 0.9); transform: scale(1.03); }
    100% { box-shadow: 0 0 8px rgba(34, 197, 94, 0.5); transform: scale(1); }
}

.btn-ready-glowing {
    animation: pulseReady 1.5s infinite ease-in-out !important;
    background: linear-gradient(135deg, #22c55e 0%, #15803d 100%) !important;
    border-color: #4ade80 !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    padding: 10px 22px !important;
    font-size: 14px !important;
}

.drag-hint-banner {
    font-size: 11px;
    font-weight: 700;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
    border: 1px dashed rgba(56, 189, 248, 0.4);
    border-radius: 8px;
    padding: 6px 12px;
    text-align: center;
    transition: opacity 0.3s ease;
}

.dock-count-badge {
    background: #38bdf8;
    color: #0f172a;
    font-weight: 800;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

.key-hint-tag {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #f8fafc;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 4px;
}

/* PREVIEW HIGHLIGHTS ON GRID */
.cell.preview-valid {
    background: rgba(34, 197, 94, 0.35) !important;
    border: 1.5px solid #22c55e !important;
    box-shadow: inset 0 0 10px rgba(34, 197, 94, 0.6) !important;
}

.cell.preview-invalid {
    background: rgba(239, 68, 68, 0.35) !important;
    border: 1.5px solid #ef4444 !important;
    box-shadow: inset 0 0 10px rgba(239, 68, 68, 0.6) !important;
}

.status-banner {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid #f59e0b;
    color: #fbbf24;
    padding: 10px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
}

.hidden {
    display: none !important;
}

/* FLOATING TOUCH DRAG AVATAR */
.drag-avatar {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    display: none;
    gap: 3px;
    padding: 6px;
    background: rgba(56, 189, 248, 0.4);
    border: 2px solid #38bdf8;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    transform: translate(-50%, -50%);
    backdrop-filter: blur(8px);
}

.drag-avatar.v {
    flex-direction: column;
}

.drag-avatar .dock-block {
    width: 22px;
    height: 22px;
    background: #38bdf8;
    border-radius: 4px;
    box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.5);
}

/* ENDGAME & DECISION PANELS */
.endgame-panel, .closed-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 19, 43, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    padding: 20px;
}

.endgame-card, .closed-card {
    background: rgba(28, 37, 65, 0.95);
    border: 2px solid var(--accent-blue);
    border-radius: 24px;
    padding: 24px;
    text-align: center;
    max-width: 360px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.endgame-card h2, .closed-card h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-blue);
}

.endgame-card p, .closed-card p {
    font-size: 14px;
    color: var(--text-muted);
}

.endgame-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@keyframes popIn {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* RESPONSIVE LAYOUT FOR PHONES & NARROW WINDOWS (< 660px) */
@media (max-width: 660px) {
    .battleground {
        flex-direction: column;
        align-items: center;
    }

    .board-pane {
        width: 100%;
        max-width: 320px;
    }

    .grid-labels-top {
        grid-template-columns: 20px repeat(10, 24px);
        font-size: 10px;
    }

    .grid-labels-left {
        grid-template-rows: repeat(10, 24px);
        width: 20px;
        font-size: 10px;
    }

    .ocean-grid {
        grid-template-columns: repeat(10, 24px);
        grid-template-rows: repeat(10, 24px);
    }

    .cell {
        width: 24px;
        height: 24px;
    }
}

/* NATIVE SPLASH SCREEN INTRO (LEVEL 1) */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #1b263b 0%, #0b132b 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999999;
    opacity: 1;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.splash-radar {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.05);
    border: 2px solid var(--accent-blue);
    box-shadow: 0 0 30px rgba(56, 189, 248, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.radar-sweep {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(56, 189, 248, 0.4) 0deg, transparent 90deg);
    animation: radarSpin 2s linear infinite;
}

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

.splash-emoji {
    font-size: 42px;
    z-index: 2;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.5));
}

.splash-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 0.15em;
    color: #f8fafc;
    margin: 0;
    text-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}

.splash-subtitle {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--accent-blue);
    margin: 0;
}

.splash-loader {
    width: 160px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 10px;
}

.loader-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #6366f1);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* LIVING BUTTON INTERACTION (LEVEL 1) */
.btn {
    user-select: none;
    touch-action: manipulation;
    transform: translateZ(0);
    will-change: transform;
}

.btn:active {
    transform: scale(0.94) !important;
}

/* SCREEN SHAKE ANIMATION (LEVEL 9) */
.shake-effect {
    animation: screenShake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

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