/* Canvas fills the window; the HUD floats on top of it. */

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    background: #0b1d2a;
    font-family: "Segoe UI", system-ui, sans-serif;
}

canvas {
    display: block;
}

/* ---------- HUD ---------- */

#hud {
    position: fixed;
    top: 16px;
    left: 16px;
    padding: 14px 18px;
    color: #eaf6ff;
    background: rgba(8, 24, 36, 0.55);
    border: 1px solid rgba(160, 220, 255, 0.25);
    border-radius: 12px;
    backdrop-filter: blur(6px);
    user-select: none;
    pointer-events: none;
}

#hud-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

#hud-controls {
    font-size: 0.85rem;
    line-height: 1.5;
    opacity: 0.85;
}

#hud-sail {
    margin-top: 8px;
    font-size: 0.9rem;
}

#sail-state {
    font-weight: 600;
    color: #ffd98a;
}

#hud-bottles {
    margin-top: 4px;
    font-size: 0.9rem;
}

#bottle-count {
    font-weight: 600;
    color: #ffd98a;
}

/* ---------- FPS counter ---------- */

#fps {
    position: fixed;
    top: 16px;
    right: 16px;
    padding: 8px 12px;
    color: #eaf6ff;
    background: rgba(8, 24, 36, 0.55);
    border: 1px solid rgba(160, 220, 255, 0.25);
    border-radius: 10px;
    backdrop-filter: blur(6px);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums; /* digits don't shift width as they change */
    user-select: none;
    pointer-events: none;
}

#fps-value {
    font-weight: 600;
    color: #ffd98a;
}

/* ---------- Bottom-left control panel (built by ui.js) ---------- */

#panel {
    position: fixed;
    bottom: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    background: rgba(8, 24, 36, 0.55);
    border: 1px solid rgba(160, 220, 255, 0.25);
    border-radius: 12px;
    backdrop-filter: blur(6px);
    user-select: none;
}

.panel-row {
    display: flex;
    gap: 8px;
}

#panel button {
    padding: 6px 14px;
    font: inherit;
    font-size: 0.85rem;
    color: #eaf6ff;
    background: rgba(160, 220, 255, 0.12);
    border: 1px solid rgba(160, 220, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

#panel button:hover {
    background: rgba(160, 220, 255, 0.28);
}

#panel button.active {
    background: rgba(255, 217, 138, 0.35);
    border-color: #ffd98a;
}

/* ---------- "Found a message" toast ---------- */

#message-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 18px;
    color: #eaf6ff;
    background: rgba(8, 24, 36, 0.75);
    border: 1px solid rgba(255, 217, 138, 0.4);
    border-radius: 10px;
    font-size: 0.9rem;
    backdrop-filter: blur(6px);
    pointer-events: none;
    user-select: none;
}

/* ---------- Start / pause overlay ---------- */

body.paused canvas {
    filter: blur(6px);
}

body.paused #hud,
body.paused #panel,
body.paused #fps,
body.paused #message-toast {
    display: none;
}

#pause-overlay {
    position: fixed;
    inset: 0;
    display: none; /* shown by body.paused below */
    align-items: center;
    justify-content: center;
    background: rgba(4, 12, 20, 0.25);
    z-index: 20;
    cursor: pointer;
}

body.paused #pause-overlay {
    display: flex;
}

#pause-prompt {
    padding: 18px 40px;
    font: inherit;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: #eaf6ff;
    background: rgba(8, 24, 36, 0.7);
    border: 1px solid rgba(160, 220, 255, 0.4);
    border-radius: 16px;
    backdrop-filter: blur(6px);
    cursor: pointer;
    transition: background 0.15s;
}

#pause-prompt:hover {
    background: rgba(160, 220, 255, 0.22);
}

/* ---------- Sailor's journal ---------- */

#journal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 12, 20, 0.45);
    z-index: 30; /* above #pause-overlay (20) so the startup welcome page reads on top of it */
}

#journal-book {
    display: flex;
    flex-direction: column;
    width: min(600px, 92vw);
    height: min(480px, 86vh);
    padding: 26px 34px;
    background: #f2e6c8;
    color: #3a2c1a;
    font-family: Georgia, 'Times New Roman', serif;
    border-radius: 6px 14px 14px 6px;
    border-left: 10px solid #6b4a2a;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

#journal-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: 1px solid rgba(58, 44, 26, 0.35);
    padding-bottom: 8px;
}

#journal-title {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

#journal-close {
    border: none;
    background: none;
    color: #6b4a2a;
    font-size: 1rem;
    cursor: pointer;
}

#journal-text {
    flex: 1;
    margin-top: 14px;
    font-size: 1.02rem;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-y: auto;
}

#journal-editor {
    flex: 1;
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

#journal-editor input,
#journal-editor textarea {
    font: inherit;
    color: inherit;
    background: rgba(255, 252, 240, 0.7);
    border: 1px solid rgba(58, 44, 26, 0.35);
    border-radius: 6px;
    padding: 8px 10px;
}

#journal-editor textarea {
    flex: 1;
    resize: none;
    line-height: 1.5;
}

#journal-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(58, 44, 26, 0.35);
}

#journal-spacer { flex: 1; }

#journal-pageno {
    font-size: 0.85rem;
    opacity: 0.75;
}

#journal-footer button {
    font: inherit;
    font-size: 0.9rem;
    padding: 4px 12px;
    color: #f2e6c8;
    background: #6b4a2a;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

#journal-footer button:disabled {
    opacity: 0.35;
    cursor: default;
}
