:root {
    --bg-color: #fdfbf7;
    --line-color: #b0c4de;
    --ink-blue: #1b4f9c;
    --ink-red: #d4343a;
    --ship-fill: #a4c2f4;
    --paper-shadow: 4px 4px 0 rgba(27, 79, 156, 0.2);
}

* { box-sizing: border-box; user-select: none; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; width: 100%; height: 100dvh; overflow: hidden; }

body {
    background-color: var(--bg-color);
    font-family: 'Courier New', Courier, monospace;
    background-image: 
        linear-gradient(var(--line-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--line-color) 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--ink-blue);
}

/* --- SCREENS --- */
.screen {
    position: absolute;
    width: 100%; height: 100%;
    top: 0; left: 0;
    display: flex; flex-direction: column;
    background: var(--bg-color); /* OPAQUE BACKGROUND FOR SCREENS */
    z-index: 10;
    transition: opacity 0.3s;
}
.hidden { display: none !important; }

/* --- BUTTONS --- */
.btn-primary, .btn-secondary, button {
    font-family: inherit; font-weight: bold;
    padding: 12px 24px;
    background: white; color: var(--ink-blue);
    border: 2px solid var(--ink-blue);
    cursor: pointer;
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    box-shadow: var(--paper-shadow);
    margin: 5px;
}
.btn-primary { background: var(--ink-blue); color: white; }
button:active { transform: scale(0.98); box-shadow: none; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.icon-btn { padding: 5px 10px; font-size: 1.2rem; border: none; background: none; box-shadow: none; }

/* --- PANELS & INPUTS --- */
.paper-panel {
    background: white;
    border: 2px solid var(--ink-blue);
    padding: 20px;
    border-radius: 2px;
    box-shadow: var(--paper-shadow);
    text-align: center;
}
.center-panel {
    margin: auto; width: 90%; max-width: 350px;
    display: flex; flex-direction: column; gap: 15px;
}
input {
    padding: 10px; border: 2px solid var(--ink-blue);
    font-size: 1.1rem; text-align: center; width: 100%;
    outline: none; font-family: inherit;
    background: white;
}

/* --- MAIN MENU --- */
.profile-card {
    background: white;
    margin: 20px; padding: 15px;
    border: 2px solid var(--ink-blue);
    display: flex; align-items: center; gap: 15px;
    box-shadow: var(--paper-shadow);
}
.avatar {
    font-size: 2.5rem; border: 2px solid var(--ink-blue);
    border-radius: 50%; width: 60px; height: 60px;
    display: flex; align-items: center; justify-content: center;
}
.profile-info { flex: 1; text-align: left; }
.profile-info h2 { margin: 0; font-size: 1.2rem; }
.profile-info p { margin: 2px 0; font-size: 0.9rem; color: #666; }
.xp-bar-container {
    width: 100%; height: 8px; background: #eee;
    border: 1px solid var(--ink-blue); margin-top: 5px;
    border-radius: 4px; overflow: hidden;
}
.xp-bar { height: 100%; background: var(--ink-blue); width: 0%; transition: width 0.5s; }

.menu-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 15px; padding: 20px;
}
.menu-tile {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 120px; font-size: 1rem; gap: 10px;
}
.menu-tile span { font-size: 2.5rem; }

/* --- GAME --- */
#status-bar {
    height: 50px; background: white;
    border-bottom: 2px solid var(--ink-blue);
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 10px; font-weight: bold;
}
#boards-wrapper {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 10px;
    padding: 10px;
}
.board-container { text-align: center; width: 90%; max-width: 400px; }
.grid {
    display: grid; grid-template-columns: repeat(10, 1fr);
    aspect-ratio: 1/1;
    border: 2px solid var(--ink-blue);
    /* FIX: Opaque white background to hide body grid lines */
    background: #ffffff; 
    position: relative;
    box-shadow: var(--paper-shadow);
}
.cell { border: 0.5px solid rgba(27, 79, 156, 0.2); position: relative; }

.ship {
    position: absolute; background-color: var(--ship-fill);
    border: 2px solid var(--ink-blue); border-radius: 4px;
    z-index: 2; transition: all 0.2s;
}
.sunk-ship { background-color: #555; border-color: #000; opacity: 0.8; }

.marker {
    position: absolute; width: 100%; height: 100%; top:0; left:0;
    z-index: 5; background-size: 70%; background-position: center; background-repeat: no-repeat;
}
.hit { background-image: url('assets/hit.svg'); }
.miss { background-image: url('assets/miss.svg'); }
.surround-miss { background-image: url('assets/miss.svg'); opacity: 0.4; }

.controls-area {
    padding: 10px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;
    background: var(--bg-color);
}

/* --- FRIENDS / LISTS --- */
.paper-header {
    display: flex; align-items: center; gap: 10px; padding: 10px;
    border-bottom: 2px solid var(--ink-blue); background: white;
}
.list-container { flex: 1; overflow-y: auto; padding: 15px; }
.user-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px; background: white; margin-bottom: 10px;
    border: 1px solid var(--ink-blue); box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}
.status-dot { color: #ccc; margin-right: 5px; font-size: 1.2rem; }
.status-dot.online { color: #4caf50; }
.status-dot.playing { color: orange; }
.direct-connect { padding: 20px; background: white; border-top: 2px solid var(--ink-blue); text-align: center; }
.row { display: flex; justify-content: center; gap: 10px; margin-top: 10px; }

/* --- MODALS --- */
.modal {
    position: fixed; top:0; left:0; width:100%; height:100%;
    background: rgba(0,0,0,0.6); z-index: 100;
    display: flex; align-items: center; justify-content: center;
}
.modal-content {
    background: white; padding: 30px; border: 4px solid var(--ink-blue);
    text-align: center; width: 85%; max-width: 350px;
    box-shadow: 10px 10px 0 rgba(0,0,0,0.2);
}

/* --- RESPONSIVE --- */
@media (orientation: landscape) {
    #boards-wrapper { flex-direction: row; }
    .board-container { height: 85%; width: auto; aspect-ratio: 1/1.2; }
}
