body {
    margin: 0;
    background-color: #000;
    color: #ccc;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
}

#canvas-container {
    position: relative;
    /* Shrink-wraps the canvas; gunzFitCanvas() sizes the canvas itself */
}

canvas.emscripten {
    border: 0px none;
    background-color: black;
    outline: none;
    /* Sized by gunzFitCanvas() to the selected display rect (CSS pixels).
       Portrait displays use a centered 4:3 rect. The drawing
       buffer (width/height attributes)
       is managed separately by the C++ side and matches the internal
       render resolution. */
    display: block;
    /* The game draws its own cursor in menus; hide the system one over the canvas */
    cursor: none;
}

/* Portrait is always a letterboxed 4:3 game surface. Use viewport
   units here, rather than a JavaScript-assigned inline size, so Chrome
   device emulation cannot leave a stale wider canvas after resizing. */
@media (max-aspect-ratio: 4 / 3) {
    canvas.emscripten {
        width: 100vw !important;
        height: 75vw !important;
    }
}

#status {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: bold;
    color: #ccc;
    font-family: 'Tahoma', sans-serif;
    font-size: 13px;
    pointer-events: none;
    text-align: center;
}

#preload-bar-container {
    position: absolute;
    bottom: 18px;
    left: 27.6%;
    width: 44.8%;
    height: 14px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #444;
    display: none;
}

#preload-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, #3a6ea5, #6aafe6);
    transition: width 0.15s ease-out;
}

#output {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: rgba(0, 0, 0, 0.8);
    color: #0f0;
    font-family: monospace;
    font-size: 12px;
    overflow-y: auto;
    display: none;
    /* Hidden by default, toggle with F12 console if needed */
}

/* Text Overlay Pool Items */
.text-overlay-item {
    position: absolute;
    display: none;
    z-index: 100;
    /* Opaque: the engine draws the same text in its own edit box underneath,
       which showed through as a ghost copy. */
    background-color: #0a0a0a;
    color: #eee;
    border: 1px solid #555;
    font-family: 'Tahoma', sans-serif;
    font-size: 13px;
    padding: 2px 4px;
    outline: none;
    box-sizing: border-box;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
    transition: border-color 0.2s;
}

.text-overlay-item:focus {
    border-color: #4a9eff;
    background-color: #0c0c16;
}

/* ── Login Method Overlay ── */
/* --login-s is set on #canvas-container by positionLoginMethodOverlay(): 1 at heights up to
   600, then a third of the extra Mint scale (see LOGIN_OVERLAY_SCALE_FOLLOW). The sizes below
   are authored for the 800x600 base. Mint scales its UI by screen height / 600 but its own
   text is smaller than this overlay's, so following it 1:1 looks oversized. */
#canvas-container { --login-s: 1; }

#login-method-overlay {
    position: absolute;
    display: none;
    z-index: 200;
    pointer-events: auto;
}

#login-method-picker {
    display: flex;
    flex-direction: column;
    gap: calc(6px * var(--login-s));
    align-items: stretch;
}

#google-login-btn, #password-login-btn {
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: calc(3px * var(--login-s));
    color: #ddd;
    cursor: pointer;
    font-family: Tahoma, Arial, sans-serif;
    font-size: calc(12px * var(--login-s));
    font-weight: 500;
    height: calc(32px * var(--login-s));
    padding: 0 calc(10px * var(--login-s));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(7px * var(--login-s));
    white-space: nowrap;
    box-sizing: border-box;
    width: 100%;
    transition: background 0.1s, border-color 0.1s;
}

#google-login-btn:hover, #password-login-btn:hover {
    background: #2a2a2a;
    border-color: #666;
}

#google-login-btn svg {
    width: calc(18px * var(--login-s));
    height: calc(18px * var(--login-s));
}

#session-connect-picker {
    display: flex;
    flex-direction: column;
    gap: calc(4px * var(--login-s));
    align-items: center;
}

#session-connect-label {
    font-family: Tahoma, sans-serif;
    font-size: calc(11px * var(--login-s));
    color: #6a9abf;
    text-align: center;
}

#session-switch-link {
    font-family: Tahoma, sans-serif;
    font-size: calc(10px * var(--login-s));
    color: #6af;
    cursor: pointer;
    text-decoration: underline;
    text-align: center;
    display: block;
}

.login-method-divider {
    text-align: center;
    font-family: Tahoma, sans-serif;
    font-size: calc(10px * var(--login-s));
    color: #555;
}

#login-method-active {
    display: flex;
    flex-direction: column;
    gap: calc(4px * var(--login-s));
    align-items: center;
}

#login-method-status {
    font-family: Tahoma, sans-serif;
    font-size: calc(11px * var(--login-s));
    color: #aaa;
    text-align: center;
}

#login-switch-link {
    font-family: Tahoma, sans-serif;
    font-size: calc(10px * var(--login-s));
    color: #6af;
    cursor: pointer;
    text-decoration: underline;
    text-align: center;
}

/* ── Login Screen Discord Toast ── */
/* Slides in from the top edge of the canvas when the login screen opens,
   then slides away on its own. See showDiscordToast(). */
#login-discord-toast {
    position: absolute;
    display: none;
    left: 50%;
    top: 0;
    z-index: 200;
    pointer-events: auto;
    align-items: center;
    gap: calc(7px * var(--login-s));
    max-width: 90%;
    padding: calc(5px * var(--login-s)) calc(6px * var(--login-s)) calc(5px * var(--login-s)) calc(12px * var(--login-s));
    box-sizing: border-box;
    background: rgba(10, 10, 20, 0.85);
    border: 1px solid #3a3d52;
    border-top: 0;
    border-radius: 0 0 5px 5px;
    color: #ccc;
    font-family: Tahoma, Arial, sans-serif;
    font-size: calc(11px * var(--login-s));
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transform: translate(-50%, -110%);
    opacity: 0;
    transition: transform 0.45s ease, opacity 0.45s ease;
}

#login-discord-toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

#login-discord-toast:hover { color: #fff; border-color: #5865F2; }

#login-discord-toast svg { flex: none; fill: #7983f5; width: calc(14px * var(--login-s)); height: calc(11px * var(--login-s)); }

#login-discord-toast .discord-toast-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

#login-discord-toast .discord-toast-join {
    flex: none;
    margin-left: calc(3px * var(--login-s));
    padding: calc(4px * var(--login-s)) calc(9px * var(--login-s));
    border-radius: 3px;
    background: #5865F2;
    color: #fff;
    font-weight: 600;
}

#login-discord-toast:hover .discord-toast-join { background: #6b77f6; }

@media (prefers-reduced-motion: reduce) {
    #login-discord-toast { transition: opacity 0.2s linear; transform: translate(-50%, 0); }
}

/* ── Create Account Link ── */
#create-account-link-row {
    margin-top: calc(10px * var(--login-s));
    text-align: center;
}

#create-account-link {
    font-family: Tahoma, sans-serif;
    color: #aaa;
    font-size: calc(12px * var(--login-s));
    text-decoration: none;
}

#create-account-link:hover {
    color: #fff;
}

/* ── First-Launch Modal ── */
#launch-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#launch-panel {
    background: linear-gradient(160deg, #0d1117 0%, #131a24 100%);
    border: 1px solid #2a4060;
    box-shadow: 0 0 40px rgba(74, 158, 255, 0.15), 0 0 0 1px rgba(74, 158, 255, 0.05);
    border-radius: 6px;
    padding: 48px 56px 40px;
    text-align: center;
    max-width: 380px;
    width: 90%;
}

#launch-title {
    font-family: 'Tahoma', 'Segoe UI', sans-serif;
    font-size: 32px;
    font-weight: bold;
    color: #c8d8f0;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin: 0 0 8px;
    text-shadow: 0 0 20px rgba(74, 158, 255, 0.4);
}

#launch-subtitle {
    font-family: 'Tahoma', sans-serif;
    font-size: 12px;
    color: #4a7aaa;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0 0 36px;
}

#launch-btn {
    background: linear-gradient(180deg, #1e4080 0%, #122a55 100%);
    border: 1px solid #3a6ea5;
    border-bottom-color: #1a3e65;
    color: #a8c8f0;
    font-family: 'Tahoma', sans-serif;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 12px 40px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s, box-shadow 0.15s, color 0.15s;
    outline: none;
}

#launch-btn:hover {
    background: linear-gradient(180deg, #2a56a8 0%, #1a3c78 100%);
    box-shadow: 0 0 16px rgba(74, 158, 255, 0.3);
    color: #d0e8ff;
}

#launch-btn:active {
    background: linear-gradient(180deg, #122a55 0%, #0d1e3d 100%);
    box-shadow: none;
}

/* Language switcher (launch and login screens) */
#gunz-lang-switch {
    position: fixed;
    top: 10px;
    right: 12px;
    z-index: 10000;
    gap: 4px;
    font-family: 'Tahoma', sans-serif;
}

#gunz-lang-switch button {
    min-width: 40px;
    padding: 6px 8px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #ccc;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

#gunz-lang-switch button.active {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* The upstream Discord features (invite toast, daily reward code claimed through a Discord
   bot) are not used on this server. */
#login-discord-toast,
.gunz-daily-bounty-root { display: none !important; }
