:root {
    --primary: #6c5ce7;
    --primary-dark: #5649c0;
    --secondary: #00cec9;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-light: #f8fafc;
    --text-dim: #94a3b8;
    --accent-hit: #ff7675;
    --accent-miss: #74b9ff;
    --accent-ship: #00b894;
    --glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

#app {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
}

header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

h1 {
    font-weight: 800;
    font-size: 20px;
    background: linear-gradient(135deg, var(--text-light), var(--text-dim));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-badge {
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--glass);
    border: 1px solid var(--border);
    font-weight: 600;
}

/* Lobby */
#lobby-container,
#setup-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
}

.card {
    background: var(--bg-card);
    padding: 20px 16px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.icon-wrapper {
    font-size: 48px;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 20px rgba(108, 92, 231, 0.3));
}

h2 {
    margin-bottom: 8px;
    font-size: 20px;
}

h3 {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 8px;
    text-align: center;
}

p.subtext {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 12px;
    min-height: 18px;
}

.btn {
    border: none;
    outline: none;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    border-radius: 12px;
    transition: transform 0.1s, box-shadow 0.2s;
    width: 100%;
    padding: 14px;
    font-size: 15px;
    margin-top: 12px;
}

.btn:active {
    transform: scale(0.98);
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.btn.primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.secondary {
    background: var(--glass);
    color: var(--text-light);
    border: 1px solid var(--border);
}

/* Ship Selector */
.ship-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin: 10px 0;
}

.ship-option {
    padding: 6px 10px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 11px;
    cursor: grab;
    transition: all 0.2s;
}

.ship-option.selected {
    background: var(--primary);
    border-color: var(--primary);
}

.ship-option.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.ship-option.placed {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Game Area */
#game-container {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-board {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 10px;
    background: var(--bg-card);
    padding: 10px;
    border-radius: 14px;
    border: 1px solid var(--border);
}

.player {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.player.active {
    opacity: 1;
}

.player .avatar {
    font-size: 22px;
    margin-bottom: 4px;
}

.player .name {
    font-size: 11px;
    font-weight: 600;
}

.player .ships-left {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 2px;
}

.vs {
    display: flex;
    align-items: center;
    font-weight: 800;
    color: var(--text-dim);
    font-size: 13px;
}

.boards-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.board-wrapper {
    width: 100%;
}

.board,
.setup-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 2px;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    background: var(--bg-card);
    padding: 6px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.setup-board {
    margin: 10px auto;
}

.cell {
    aspect-ratio: 1;
    background: var(--bg-dark);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
}

.cell:hover {
    background: rgba(255, 255, 255, 0.08);
}

.cell.ship {
    background: var(--accent-ship);
    box-shadow: 0 0 8px rgba(0, 184, 148, 0.4);
}

.cell.hit {
    background: var(--accent-hit);
    box-shadow: 0 0 8px rgba(255, 118, 117, 0.5);
}

.cell.hit::after {
    content: '💥';
    font-size: 14px;
}

.cell.miss {
    background: rgba(116, 185, 255, 0.3);
}

.cell.miss::after {
    content: '•';
    color: var(--accent-miss);
    font-size: 16px;
}

.cell.sunk {
    background: #d63031;
}

/* Drag preview styles */
.cell.preview-valid {
    background: rgba(0, 184, 148, 0.5);
    border: 2px solid var(--accent-ship);
    animation: pulse 0.5s ease-in-out infinite;
}

.cell.preview-invalid {
    background: rgba(255, 118, 117, 0.5);
    border: 2px solid var(--accent-hit);
}

.enemy-board .cell {
    cursor: pointer;
}

.my-board .cell {
    cursor: default;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 24px;
    text-align: center;
    border: 1px solid var(--border);
    width: 85%;
    max-width: 300px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

.modal h2 {
    font-size: 26px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff, #bbb);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal p {
    color: var(--text-dim);
    margin-bottom: 20px;
    font-size: 14px;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}