@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
    --bg-sand: #e6c280;
    --sea-blue: #2b8cbe;
    --sea-blue-dim: rgba(43, 140, 190, 0.4);
    --wood-light: #8b5a2b;
    --wood-dark: #3e2723;
    --pirate-red: #cc0000;
    --pirate-gold: #ffd700;
    --glass-bg: rgba(255, 255, 255, 0.1);
    
    --font-heading: 'Press Start 2P', cursive;
    --font-body: 'VT323', monospace;
}

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

body {
    background-color: #0a1628;
    background-image: url('../assets/lobby_desktop.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: #fff;
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background-image 0.5s ease-in-out;
}

body.in-game {
    background-image: url('../assets/bg.png');
}

/* ==================== LAYOUT ==================== */
.cyber-container {
    width: 100%;
    max-width: 1200px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 10;
}

/* ==================== GLASS PANEL ==================== */
.glass-panel {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(255, 215, 0, 0.35);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.05);
}

/* ==================== HEADER ==================== */
.game-header {
    text-align: center;
    padding: 24px 40px;
    width: 100%;
    max-width: 650px;
}

.neon-title {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    color: var(--pirate-gold);
    text-shadow: 0 0 10px rgba(255,215,0,0.6), 3px 3px 0 var(--wood-dark);
    letter-spacing: 4px;
    margin-bottom: 4px;
}

.neon-subtitle {
    display: block;
    color: rgba(255,255,255,0.8);
    font-size: 1rem;
    text-shadow: 2px 2px 0 var(--wood-dark);
    margin-top: 8px;
    letter-spacing: 6px;
}

.status-panel {
    font-size: 1.4rem;
    color: var(--pirate-gold);
    background: rgba(0,0,0,0.6);
    padding: 10px 24px;
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 8px;
    display: inline-block;
    margin-top: 10px;
}

/* ==================== ACTIVE PLAYERS ==================== */
.active-players {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 215, 0, 0.2);
    padding: 10px 18px;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    letter-spacing: 1px;
}

.online-dot {
    width: 10px;
    height: 10px;
    background-color: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 6px #4ade80;
    animation: pulse-dot 2s infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px #4ade80; }
    50% { opacity: 0.5; box-shadow: 0 0 12px #4ade80; }
}

.active-players span {
    color: var(--pirate-gold);
    font-weight: bold;
    font-size: 1.2rem;
}

/* ==================== BUTTONS ==================== */
.cyber-btn {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    padding: 14px 28px;
    background: rgba(139, 90, 43, 0.6);
    color: #fff;
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 12px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transition: all 0.2s ease;
    text-shadow: 1px 1px 2px #000;
    letter-spacing: 1px;
    backdrop-filter: blur(4px);
}

.cyber-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    border-color: var(--pirate-gold);
}

.cyber-btn:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.cyber-btn:disabled {
    filter: grayscale(80%);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Primary (Hızlı Savaş) */
.btn-primary {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
    border: 2px solid rgba(255, 215, 0, 0.7);
    color: #fff;
    box-shadow: 0 0 25px rgba(185, 28, 28, 0.5), 0 4px 15px rgba(0,0,0,0.3);
    text-shadow: 2px 2px 0px rgba(0,0,0,0.6);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #dc2626, #f87171);
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.7), 0 6px 20px rgba(0,0,0,0.4);
    border-color: var(--pirate-gold);
}

/* Secondary (Özel Oda Kur / Katıl) */
.btn-secondary {
    background: linear-gradient(135deg, rgba(43, 140, 190, 0.7), rgba(77, 195, 255, 0.5));
    border: 2px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(58, 163, 212, 0.8), rgba(102, 204, 255, 0.6));
    border-color: var(--pirate-gold);
    box-shadow: 0 0 20px rgba(77, 195, 255, 0.4);
}

.btn-massive {
    font-size: 1.2rem;
    padding: 20px 30px;
    width: 100%;
    border-radius: 14px;
}

/* ==================== LOBBY ==================== */
.lobby-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

.lobby-container > .glass-panel {
    padding: 2.5rem 2.5rem;
    text-align: center;
    width: 100%;
    max-width: 550px;
}

.lobby-desc {
    font-size: 1.4rem;
    margin-bottom: 2rem;
    color: rgba(255,255,255,0.8);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    line-height: 1.4;
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.action-divider {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 6px 0;
}

.action-divider::before, .action-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

.action-divider span {
    padding: 0 16px;
    color: rgba(255,215,0,0.6);
    font-size: 0.9rem;
    font-family: var(--font-body);
    letter-spacing: 2px;
}

.join-room-section {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.cyber-input {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255, 215, 0, 0.3);
    color: #fff;
    padding: 12px 16px;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    width: 100%;
    max-width: 200px;
    text-align: center;
    border-radius: 10px;
    backdrop-filter: blur(4px);
    transition: border-color 0.2s;
}

.cyber-input::placeholder {
    color: rgba(255,255,255,0.4);
}

.cyber-input:focus {
    outline: none;
    border-color: var(--pirate-gold);
    box-shadow: 0 0 10px rgba(255,215,0,0.2);
}

/* ==================== LOBBY WAITING ==================== */
.lobby-waiting h3 {
    text-align: center;
}

.highlight-code {
    color: var(--pirate-gold);
}

.waiting-text {
    font-size: 1.3rem;
    text-align: center;
    margin-top: 10px;
    color: rgba(255,255,255,0.7);
}

.ship-config-panel {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,215,0,0.2);
    border-radius: 12px;
    padding: 1rem 1.2rem;
    margin-top: 1rem;
    text-align: left;
}

.ship-config-panel h4 {
    text-align: center;
    color: var(--pirate-gold);
    margin-bottom: 10px;
    font-size: 1rem;
}

#config-host-note {
    font-size: 0.8rem;
    color: var(--pirate-red);
    display: block;
    margin-top: 4px;
}

.config-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 1.4rem;
}

.ctrl-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-ctrl {
    background: rgba(139,90,43,0.5);
    border: 2px solid rgba(255,215,0,0.3);
    color: #fff;
    width: 36px;
    height: 36px;
    font-family: var(--font-heading);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-ctrl:hover:not(:disabled) {
    border-color: var(--pirate-gold);
    background: rgba(139,90,43,0.8);
}

.btn-ctrl:disabled { opacity: 0.4; cursor: not-allowed; }

.ship-count-val {
    font-weight: bold;
    width: 24px;
    text-align: center;
    color: var(--pirate-gold);
    font-size: 1.5rem;
}

/* ==================== GAME AREA ==================== */
.game-area {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.board-panel {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    border: 2px solid rgba(255,215,0,0.25);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 320px;
    max-width: 500px;
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--pirate-gold);
    text-shadow: 0 0 8px rgba(255,215,0,0.3);
    letter-spacing: 2px;
}

/* Boards */
.board-wrapper {
    position: relative;
    padding: 6px;
    background: rgba(0,0,0,0.3);
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 8px;
}

.board {
    display: grid;
    grid-template-columns: repeat(10, 30px);
    grid-template-rows: repeat(10, 30px);
    gap: 2px;
    background-color: rgba(43, 140, 190, 0.15);
}

.cell {
    width: 30px;
    height: 30px;
    background: rgba(43, 140, 190, 0.45);
    border: 1px solid rgba(255,255,255,0.1);
    cursor: crosshair;
    position: relative;
    border-radius: 3px;
    transition: background 0.15s;
}

.player-panel .cell:hover, .enemy-panel .cell:hover {
    background: rgba(255,255,255,0.3);
}

.board.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Cell States */
.cell.ship {
    background: rgba(139, 90, 43, 0.8);
    border: 1px solid var(--wood-light);
}

.cell.ship.ship-size-1 {
    background-image: url('../assets/chest.png');
    background-size: cover;
    background-color: transparent;
    border: none;
}

.cell.hit {
    background: var(--pirate-red) !important;
    border: 1px solid #000 !important;
}

.hit-anim {
    position: absolute;
    top: -15px;
    left: -15px;
    width: 60px;
    height: 60px;
    background-image: url('../assets/boom.png');
    background-size: cover;
    z-index: 10;
    pointer-events: none;
    animation: boom 0.6s ease-out forwards;
}

@keyframes boom {
    0% { transform: scale(0.1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

.cell.hit::after {
    content: 'X';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-heading);
    color: #000;
    font-size: 1rem;
    font-weight: bold;
}

.cell.miss {
    background: rgba(0, 0, 0, 0.5) !important;
}

.cell.miss::after {
    content: '~';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255,255,255,0.6);
    font-size: 1.5rem;
}

.cell.preview-valid { background: rgba(74, 222, 128, 0.5); }
.cell.preview-invalid { background: rgba(248, 113, 113, 0.5); }

/* Room Visibility Toggle */
.room-visibility {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 14px 0;
    padding: 10px 16px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,215,0,0.15);
    border-radius: 10px;
}

.vis-label {
    font-size: 1.2rem;
    color: rgba(255,255,255,0.7);
}

.toggle-switch {
    position: relative;
}

.toggle-switch input {
    display: none;
}

.toggle-switch label {
    display: flex;
    align-items: center;
    width: 160px;
    height: 36px;
    background: rgba(139, 90, 43, 0.4);
    border: 2px solid rgba(255,215,0,0.3);
    border-radius: 20px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.toggle-switch label::after {
    content: '';
    position: absolute;
    width: 80px;
    height: 30px;
    background: var(--pirate-red);
    border-radius: 16px;
    left: 3px;
    top: 3px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.toggle-switch input:checked + label::after {
    left: 77px;
    background: #22c55e;
}

.toggle-switch input:checked + label {
    border-color: #22c55e;
}

.toggle-off, .toggle-on {
    flex: 1;
    text-align: center;
    font-size: 0.85rem;
    font-family: var(--font-heading);
    z-index: 1;
    transition: color 0.3s;
    line-height: 36px;
}

.toggle-off {
    color: #fff;
}

.toggle-on {
    color: rgba(255,255,255,0.4);
}

.toggle-switch input:checked ~ label .toggle-off,
.toggle-switch input:checked + label .toggle-off {
    color: rgba(255,255,255,0.4);
}

.toggle-switch input:checked ~ label .toggle-on,
.toggle-switch input:checked + label .toggle-on {
    color: #fff;
}

/* Fleet Yard */
.fleet-yard {
    width: 100%;
    text-align: center;
    background: rgba(0,0,0,0.3);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

.fleet-yard h3 {
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: 10px;
}

.hint {
    font-size: 1rem;
    color: var(--pirate-gold);
    display: block;
}

.ships-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.ship-item {
    display: flex;
    gap: 2px;
    padding: 5px;
    border: 2px solid rgba(255,215,0,0.3);
    background: rgba(62, 39, 35, 0.7);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.ship-item:hover {
    border-color: var(--pirate-gold);
}

.ship-item.selected {
    border-color: var(--pirate-gold);
    box-shadow: 0 0 15px rgba(255,215,0,0.4);
}

.ship-segment {
    width: 20px;
    height: 20px;
    background: var(--wood-light);
    border: 1px solid rgba(0,0,0,0.4);
    border-radius: 3px;
}

.ship-segment.ship-size-1 {
    background-image: url('../assets/chest.png');
    background-size: cover;
    background-color: transparent;
    border: none;
    width: 24px;
    height: 24px;
}

/* Mobile Rotate Button */
.btn-rotate-mobile {
    display: none;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    padding: 12px 24px;
    background: linear-gradient(135deg, rgba(255,215,0,0.3), rgba(255,215,0,0.1));
    color: var(--pirate-gold);
    border: 2px solid rgba(255,215,0,0.5);
    border-radius: 10px;
    cursor: pointer;
    margin-top: 8px;
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.btn-rotate-mobile:active {
    background: rgba(255,215,0,0.4);
    transform: scale(0.97);
}

/* ==================== GAME OVER ==================== */
.game-over-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-over-box {
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(12px);
    padding: 3rem 4rem;
    border: 2px solid rgba(255,215,0,0.4);
    border-radius: 24px;
    box-shadow: 0 0 60px rgba(0,0,0,0.8);
    text-align: center;
    animation: zoom-in-epic 0.8s ease-out forwards;
}

@keyframes zoom-in-epic {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.game-over-art {
    width: 250px;
    height: 250px;
    margin: 0 auto 1.5rem auto;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 12px;
    border: 3px solid rgba(255,215,0,0.5);
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
}

.art-victory {
    background-image: url('../assets/victory_pixel.png');
    animation: bounce-happy 2s infinite ease-in-out;
}

@keyframes bounce-happy {
    0%, 100% { transform: translateY(0) scale(1); box-shadow: 0 0 30px rgba(255,215,0,0.5); }
    50% { transform: translateY(-15px) scale(1.05); box-shadow: 0 0 50px rgba(255,215,0,0.8); }
}

.art-defeat {
    background-image: url('../assets/defeat_pixel.png');
    animation: slash-shake 0.4s infinite;
    border-color: var(--pirate-red);
}

@keyframes slash-shake {
    0% { transform: translate(0, 0) rotate(0deg); box-shadow: 0 0 30px rgba(220,38,38,0.5); }
    25% { transform: translate(6px, 6px) rotate(4deg); }
    50% { transform: translate(0, 0) rotate(0deg); box-shadow: 0 0 60px rgba(220,38,38,0.8); }
    75% { transform: translate(-6px, 6px) rotate(-4deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

.game-over-box p {
    font-size: 1.4rem;
    margin: 1.5rem 0;
    color: rgba(255,255,255,0.8);
}

.victory-title {
    color: var(--pirate-gold);
    font-size: 3.5rem;
    text-shadow: 0 0 30px rgba(255,215,0,0.5);
}

.defeat-title {
    color: var(--pirate-red);
    font-size: 3.5rem;
    text-shadow: 0 0 30px rgba(204,0,0,0.5);
}

.btn-large {
    font-size: 1.2rem;
    padding: 16px 40px;
}

/* ==================== COUNTDOWN & WAITING ==================== */
.countdown-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    z-index: 9500;
    display: flex;
    justify-content: center;
    align-items: center;
}

.countdown-number {
    font-family: var(--font-heading);
    font-size: 15rem;
    color: var(--pirate-gold);
    text-shadow: 0 0 50px rgba(255,215,0,0.8);
    animation: pop-in 1s infinite;
}

@keyframes pop-in {
    0% { transform: scale(0.5); opacity: 0; }
    30% { transform: scale(1.2); opacity: 1; }
    70% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

.waiting-huge {
    text-align: center;
    padding: 2rem;
    border: 2px dashed var(--pirate-gold);
    border-radius: 12px;
    background: rgba(0,0,0,0.5);
    margin-top: 1rem;
    animation: pulse-border 2s infinite;
    width: 100%;
}

@keyframes pulse-border {
    0%, 100% { border-color: rgba(255,215,0,0.3); box-shadow: none; }
    50% { border-color: var(--pirate-gold); box-shadow: 0 0 20px rgba(255,215,0,0.5); }
}

/* ==================== MATCHMAKING SPINNER ==================== */
.matchmaking-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,215,0,0.2);
    border-top: 4px solid var(--pirate-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px auto;
}

.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    body:not(.in-game) {
        background-image: url('../assets/lobby_mobile.png');
        background-position: center bottom;
    }

    .active-players {
        bottom: 12px;
        left: 12px;
        padding: 8px 14px;
        font-size: 0.9rem;
        border-radius: 10px;
    }

    .active-players span {
        font-size: 1rem;
    }

    .game-header {
        padding: 16px 20px;
    }

    .neon-title {
        font-size: 1.8rem;
        letter-spacing: 2px;
    }

    .neon-subtitle {
        font-size: 0.75rem;
        letter-spacing: 3px;
    }

    .lobby-container > .glass-panel {
        padding: 2rem 1.5rem;
        max-width: 95%;
        border-radius: 16px;
    }

    .lobby-desc {
        font-size: 1.2rem;
    }

    .btn-massive {
        font-size: 1rem;
        padding: 16px 20px;
    }

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

    .board-panel {
        width: 100%;
        min-width: unset;
        padding: 1rem;
    }

    .board {
        grid-template-columns: repeat(10, 28px);
        grid-template-rows: repeat(10, 28px);
    }
    .cell {
        width: 28px;
        height: 28px;
    }

    /* Show rotate button on mobile */
    .btn-rotate-mobile {
        display: block;
    }

    .game-over-box {
        padding: 2rem;
        margin: 1rem;
    }

    .victory-title, .defeat-title {
        font-size: 2.5rem;
    }
}

@media (max-width: 400px) {
    .board {
        grid-template-columns: repeat(10, 25px);
        grid-template-rows: repeat(10, 25px);
    }
    .cell {
        width: 25px;
        height: 25px;
    }
    .neon-title {
        font-size: 1.3rem;
    }
    .cyber-btn {
        padding: 10px 16px;
        font-size: 0.7rem;
    }
    .btn-massive {
        font-size: 0.85rem;
        padding: 14px 16px;
    }
}
