/* Account / Save-Load box - bottom-center overlay, hidden until the HUD's
   "Save / Load Character" button opens it (init.ts).  Kept as plain HTML (not in-canvas
   UI) so password managers work; opening it releases pointer lock and sets Away. */
#auth-panel {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.95);
    color: #fff;
    font-family: system-ui, sans-serif;
    font-size: 14px;
    z-index: 1000;
    border-radius: 8px;
    min-width: 280px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* Fold header: click to collapse to just the title */
#auth-fold-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    border-radius: 8px;
    color: #8cf;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#auth-fold-toggle:hover {
    background: rgba(140, 200, 255, 0.12);
}

#auth-fold-toggle .fold-chevron {
    font-size: 14px;
    transition: transform 0.25s ease;
}

#auth-panel.folded #auth-fold-toggle:hover .fold-chevron {
    transform: translateY(2px);
}

#auth-panel:not(.folded) #auth-fold-toggle .fold-chevron {
    transform: rotate(180deg);
}

/* Body drops down/up via the grid 0fr->1fr trick (no magic max-height) */
#auth-panel-body {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.25s ease;
}

#auth-panel.folded #auth-panel-body {
    grid-template-rows: 0fr;
}

#auth-panel-body-clip {
    overflow: hidden;
    min-height: 0;
}

#auth-panel-body-inner {
    padding: 4px 16px 16px;
}

#auth-panel h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #8cf;
}

#auth-panel form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#auth-panel input {
    padding: 8px 10px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #111;
    color: #fff;
    font-size: 14px;
}

#auth-panel input:focus {
    outline: none;
    border-color: #68f;
}

#auth-panel .btn-row {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

#auth-panel button {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background: #446;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

#auth-panel button:hover {
    background: #558;
}

#auth-panel button.primary {
    background: #38a;
}

#auth-panel button.primary:hover {
    background: #4ac;
}

#auth-panel button.danger {
    background: #744;
}

#auth-panel button.danger:hover {
    background: #966;
}

#auth-panel .status {
    margin-top: 12px;
    padding: 8px;
    background: #111;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
}

#auth-panel .status-label {
    color: #888;
    margin-bottom: 4px;
}

#auth-panel .status-value {
    color: #aef;
    word-break: break-all;
}

#auth-panel .status-value.error {
    color: #f88;
}

#auth-panel .status-value.success {
    color: #8f8;
}

/* Condensed feedback line under the forms (full readout lives in the Debug HUD) */
#auth-panel #auth-status {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.4;
}

#auth-panel .hidden {
    display: none;
}

#auth-panel .link-btn {
    background: none;
    border: none;
    color: #68f;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 0;
    text-decoration: underline;
}

#auth-panel .link-btn:hover {
    color: #8af;
}

/* Session over (src/session.ts): displaced by another tab/device, or the connection
   dropped.  Covers the whole window on purpose — rendering has stopped, so what's behind
   it is a frozen last frame, not a world anyone can play in. */
#session-ended {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.72);
    font-family: system-ui, sans-serif;
    color: #fff;
}

#session-ended-card {
    max-width: 420px;
    margin: 24px;
    padding: 24px 28px;
    background: rgba(30, 30, 30, 0.97);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.6);
    text-align: center;
}

#session-ended-title {
    margin: 0 0 12px;
    font-size: 20px;
    color: #8cf;
}

#session-ended-text {
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.5;
    color: #cde;
}

#session-ended button {
    padding: 9px 20px;
    border: none;
    border-radius: 4px;
    background: #38a;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    transition: background 0.2s;
}

#session-ended button:hover {
    background: #4ac;
}
