* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0; height: 100%; overflow: hidden;
    background: #222; color: #eee;
    font-family: Verdana, 'DejaVu Sans', 'Bitstream Vera Sans', Geneva, sans-serif;
    -webkit-user-select: none; user-select: none;   /* clicking to interact must not select page text */
}
canvas { display: block; position: fixed; inset: 0; -webkit-user-select: none; user-select: none; }
/* the chat panel stays selectable */
#chat-overlay, #chat-list, #chat-input { -webkit-user-select: text; user-select: text; }

/* connection status (top-left) */
#status {
    position: fixed; top: 10px; left: 12px; z-index: 6;
    font-size: 12px; color: #1AC; opacity: .85; pointer-events: none;
    text-shadow: 0 1px 2px rgba(0,0,0,.7);
}

/* discrete in-world chat log (bottom-left) */
#discrete {
    position: fixed; left: 12px; bottom: 12px; z-index: 6;
    max-width: 44vw; pointer-events: none;
    display: flex; flex-direction: column; gap: 2px;
}
.d-line {
    font-size: 13px; line-height: 1.35; color: #f3f3f3; opacity: .82;
    text-shadow: 0 1px 3px rgba(0,0,0,.9);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.d-line .d-name { font-weight: bold; }
.d-line.log, .d-line.log .d-name { color: #6e6; }
.d-line.part, .d-line.part .d-name { color: #1AC; }

/* click-to-play blocker */
#blocker {
    position: fixed; inset: 0; z-index: 10;
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    background: rgba(10,20,28,.45); cursor: pointer; user-select: none; text-align: center;
}
#play-hint { font-size: 26px; font-weight: bold; letter-spacing: .5px; text-shadow: 0 2px 8px rgba(0,0,0,.7); }
#play-sub { margin-top: 10px; font-size: 14px; opacity: .85; padding: 0 16px; }

/* aiming crosshair (gaze target for name tags) — shown only while pointer-locked */
#crosshair {
    display: none; position: fixed; top: 50%; left: 50%; z-index: 5;
    width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
    background: rgba(255,255,255,.55); box-shadow: 0 0 0 1px rgba(0,0,0,.45);
    pointer-events: none;
}
body.aiming #crosshair { display: block; }

/* UI buttons (bottom-right) */
#ui-buttons { position: fixed; right: 16px; bottom: 16px; z-index: 30; display: flex; gap: 10px; }
.ui-btn {
    font-family: inherit; font-weight: 700; font-size: 14px; color: #fff;
    background: #2D8CE5; border: none; border-radius: 22px; padding: 10px 20px; cursor: pointer;
    transition: background-color 150ms ease, transform 120ms ease;
    box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.ui-btn:hover { background: #1c6fc0; transform: translateY(-1px); }
.ui-btn:active { transform: translateY(0); }
.ui-btn.active { background: #1c6fc0; box-shadow: inset 0 2px 6px rgba(0,0,0,.4); }
.ui-btn-vr { background: #7a3ff2; }
.ui-btn-vr:hover { background: #5f2bd0; }

/* VR: exit button + note + toast, and hiding the flat UI while immersed */
#vr-exit {
    display: none; position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    z-index: 60; font-family: inherit; font-weight: 700; font-size: 15px; color: #fff;
    background: #7a3ff2; border: none; border-radius: 22px; padding: 10px 22px; cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.45);
}
#vr-note {
    display: none; position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    z-index: 8; max-width: 90vw; text-align: center; font-size: 14px; color: #cdbcff;
    text-shadow: 0 1px 3px rgba(0,0,0,.8); pointer-events: none;
}
#vr-toast {
    display: none; position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%);
    z-index: 60; max-width: 92vw; text-align: center; font-size: 14px; color: #fff;
    background: rgba(20,26,30,.95); border: 1px solid #7a3ff2; border-radius: 12px;
    padding: 10px 16px; box-shadow: 0 4px 16px rgba(0,0,0,.45);
}
body.vr-cardboard #status, body.vr-cardboard #discrete, body.vr-cardboard #ui-buttons,
body.vr-cardboard #blocker, body.vr-cardboard #help-modal, body.vr-cardboard #chat-overlay,
body.vr-cardboard #crosshair {
    display: none !important;
}
body.vr-immersive #status, body.vr-immersive #discrete, body.vr-immersive #ui-buttons,
body.vr-immersive #blocker, body.vr-immersive #help-modal, body.vr-immersive #chat-overlay,
body.vr-immersive #crosshair {
    display: none !important;
}

/* help modal (modelled on the app's #timer-popup) */
#help-modal {
    display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 50; width: 360px; max-width: 88vw; padding: 22px 22px 18px;
    background: #f2fbff; color: #111; border: 1px solid #a7a7a7; border-radius: 18px;
    box-shadow: 0 0 0 100vmax rgba(0,0,0,.5), 0 8px 32px rgba(0,0,0,.35);
}
#help-modal h2 { margin: 0 0 12px; font-size: 18px; color: #1c6fc0; }
#help-modal table { width: 100%; border-collapse: collapse; font-size: 14px; }
#help-modal td { padding: 5px 4px; border-bottom: 1px solid #d4e6f2; vertical-align: top; }
#help-modal td.k { white-space: nowrap; width: 46%; }
#help-close {
    margin-top: 16px; display: block; width: 100%;
    font-family: inherit; font-weight: 700; color: #fff; background: #2D8CE5;
    border: none; border-radius: 10px; padding: 9px 0; cursor: pointer;
    transition: background-color 150ms ease;
}
#help-close:hover { background: #1c6fc0; }
.kbd {
    display: inline-block; background: #fff; border: 1px solid #9bbdd6; border-bottom-width: 2px;
    border-radius: 5px; padding: 1px 7px; font-family: monospace; font-size: 13px; color: #234; margin: 1px;
}

/* chat overlay (right-side panel) */
#chat-overlay {
    display: none; position: fixed; top: 0; right: 0; z-index: 40;
    width: 380px; max-width: 92vw; height: 100%; flex-direction: column;
    background: rgba(20,26,30,.92); border-left: 1px solid #1AC;
    box-shadow: -6px 0 24px rgba(0,0,0,.4);
}
#chat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid rgba(26,204,204,.35); }
#chat-head .title { font-weight: 700; color: #1AC; letter-spacing: .5px; }
#chat-head .x { cursor: pointer; color: #bbb; font-size: 20px; line-height: 1; padding: 2px 8px; border-radius: 8px; }
#chat-head .x:hover { background: rgba(255,255,255,.08); color: #fff; }
#chat-list { flex: 1; overflow-y: auto; padding: 8px 10px; }
.c-row { display: flex; gap: 8px; padding: 4px 0; font-size: 14px; align-items: baseline; border-bottom: 1px solid rgba(255,255,255,.04); }
.c-row .c-name { font-weight: 700; flex: 0 0 auto; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-row .c-body { flex: 1; word-break: break-word; color: #eaeaea; }
.c-row .c-time { flex: 0 0 auto; font-family: monospace; font-size: 11px; color: #1AC; opacity: .6; }
.c-row.log .c-body, .c-row.log .c-name { color: #3C3; }
.c-row.part .c-body, .c-row.part .c-name { color: #1AC; }
.c-row.me .c-body { font-style: italic; }
.c-row .c-body a { color: #7fd6ff; }
.c-row .c-body .greentext { color: #9c2; font-family: monospace; }
.c-row .c-body .spoiler, .c-row .c-body .spoiler * { filter: blur(3px); }
.c-row .c-body .spoiler:hover, .c-row .c-body .spoiler:hover * { filter: none; }
#chat-foot { padding: 10px; border-top: 1px solid rgba(26,204,204,.35); }
#chat-input {
    width: 100%; box-sizing: border-box; background: #10161a; border: 1px solid #2D8CE5;
    border-radius: 20px; color: #fff; font-family: inherit; font-size: 15px; padding: 9px 14px; outline: none;
}
#chat-input:focus { box-shadow: 0 0 0 1px rgba(45,140,229,.45); }
#chat-hint { margin-top: 6px; font-size: 11px; color: #8aa; opacity: .75; text-align: center; }
