/* Battleship client styles. */

body {
    font-family: monospace;
    background: #1a1a2e;
    color: #e0e0e0;
    margin: 0;
    padding: 20px;
}

#app {
    max-width: 900px;
    margin: 0 auto;
}

h1 {
    text-align: center;
}

/* Mode selection screen */

#mode-select {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 40px 0;
}

#mode-select button {
    font-size: 1.3em;
    padding: 20px 40px;
}

/* Multiplayer connect screen */

#mp-connect {
    text-align: center;
    margin: 40px 0;
}

#mp-create-section, #mp-join-section, #mp-server-section {
    margin: 15px 0;
}

#mp-status {
    margin: 15px 0;
    font-size: 1.1em;
    color: #a0a0c0;
    min-height: 1.5em;
}

#mp-room-input, #mp-server-input {
    font-family: monospace;
    font-size: 1em;
    padding: 8px 12px;
    background: #2a2a4e;
    color: #e0e0e0;
    border: 1px solid #4a4a6a;
    text-transform: uppercase;
}

#mp-room-input {
    width: 80px;
    text-align: center;
    letter-spacing: 4px;
}

#mp-server-input {
    width: 280px;
}

/* Game screen */

#status {
    text-align: center;
    margin: 10px 0;
    font-size: 1.2em;
}

#log {
    text-align: center;
    margin: 5px 0;
    font-size: 0.9em;
    color: #a0a0c0;
    min-height: 7em; /* 5 lines × 1.4em line-height */
}

#log div {
    line-height: 1.4em;
}

#log div:first-child {
    color: #e0e0e0;
}

#chat-bar {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 5px 0 10px;
}

#chat-bar[hidden] {
    display: none;
}

#chat-log {
    text-align: center;
    margin: 5px auto;
    max-width: 400px;
    height: calc(5.6em + 8px);  /* 4 lines × 1.4em + 8px vertical padding */
    overflow-y: auto;
    font-size: 0.85em;
    color: #8888aa;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    padding: 4px 8px;
    background: #12121f;
    box-sizing: border-box;
}

#chat-log[hidden] {
    display: none;
}

#chat-log div {
    line-height: 1.4em;
    text-align: left;
}

#chat-log div.chat-me {
    color: #a0c0e0;
}

#chat-log div.chat-them {
    color: #e0c0a0;
}

#chat-input {
    flex: 0 1 300px;
    padding: 6px 10px;
    background: #1a1a2e;
    border: 1px solid #4a4a6a;
    color: #e0e0e0;
    border-radius: 4px;
    font-size: 0.9em;
}

#chat-input:focus {
    outline: none;
    border-color: #6a6aaa;
}

#boards {
    display: flex;
    gap: 40px;
    justify-content: center;
    margin: 20px 0;
}

#boards canvas {
    border: 2px solid #4a4a6a;
    background: #0f0f1e;
    cursor: crosshair;
    /* Scale down on small screens; aspect ratio preserved. */
    max-width: 100%;
    height: auto;
    touch-action: manipulation;
}

/* Stack boards vertically on narrow screens. */
@media (max-width: 480px) {
    #boards {
        flex-direction: column;
        gap: 20px;
        align-items: center;
    }

    #boards canvas {
        width: 90vw;
        max-width: 360px;
    }

    /* Larger tap targets for touch. */
    button {
        font-size: 1.1em;
        padding: 12px 20px;
        margin: 4px 2px;
    }

    #controls {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    #mode-select {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    #chat-bar {
        flex-wrap: wrap;
    }

    #chat-input {
        flex: 1 1 200px;
    }
}

#controls {
    text-align: center;
    margin-top: 20px;
}

button {
    font-family: monospace;
    font-size: 1em;
    padding: 8px 16px;
    margin: 0 5px;
    background: #2a2a4e;
    color: #e0e0e0;
    border: 1px solid #4a4a6a;
    cursor: pointer;
}

button:hover {
    background: #3a3a6e;
}

button:disabled {
    opacity: 0.4;
    cursor: default;
}

#attribution {
    margin: 15px auto 0;
    max-width: 600px;
    font-size: 0.75em;
    color: #6a6a8e;
}

#attribution summary {
    cursor: pointer;
    text-align: center;
    padding: 4px;
    user-select: none;
}

#attribution summary:hover {
    color: #8a8aae;
}

#attribution p {
    margin: 8px 0;
    line-height: 1.4;
}

#attribution a {
    color: #8a8aae;
}
