/* ── page base ── */

body.guestbook-page {
    overflow: hidden;
    height: 100vh;
}

body.guestbook-page::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: url("/images/starry.gif") center / cover no-repeat;
    opacity: 0.25;
    pointer-events: none;
}

body.guestbook-page nav,
body.guestbook-page .navbar {
    background: var(--main-dark);
    border-bottom: 2px solid rgba(120, 88, 157, 0.35);
    z-index: 100;
}

body.guestbook-page .botbar {
    background: var(--main-dark);
    border-top-color: rgba(120, 88, 157, 0.35);
    z-index: 100;
}

/* ── stage ── */

.gb-stage {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 42px 20px 40px;
    box-sizing: border-box;
    z-index: 1;
    pointer-events: none;
}

/* ── terminal frame ── */

.gb-terminal {
    max-width: 760px;
    width: 100%;
    display: flex;
    flex-direction: column;
    border: ridge 3px var(--purple);
    background: rgba(14, 14, 14, 0.94);
    pointer-events: auto;
    overflow: hidden;
}

.gb-terminal-bar {
    flex-shrink: 0;
    padding: 5px 14px;
    background: rgba(120, 88, 157, 0.1);
    border-bottom: 2px solid rgba(120, 88, 157, 0.3);
    display: flex;
    align-items: center;
    min-height: 26px;
}

.gb-terminal-label {
    font-family: "dos", monospace;
    font-size: 17px;
    color: var(--purple);
    opacity: 0.8;
    letter-spacing: 1px;
}

.gb-terminal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 28px 32px 40px;
    scrollbar-color: var(--purple) rgba(18, 18, 18, 0.6);
    scrollbar-width: thin;
}

.gb-terminal-body::-webkit-scrollbar { width: 6px; }
.gb-terminal-body::-webkit-scrollbar-track { background: rgba(18, 18, 18, 0.6); }
.gb-terminal-body::-webkit-scrollbar-thumb { background: var(--purple); }

/* ── header ── */

.gb-header {
    text-align: center;
    margin-bottom: 0;
    animation: gb-fade-in 0.6s steps(6, end) forwards;
}

.gb-title {
    font-family: "alagard";
    font-size: 2.8rem;
    color: var(--main-light);
    margin: 0 0 16px;
    letter-spacing: 3px;
    text-shadow: 0 0 18px rgba(120, 88, 157, 0.35);
}

/* intro message (like SmartGB flavor text) */

.gb-intro {
    border: 2px solid rgba(120, 88, 157, 0.25);
    padding: 18px 24px;
    margin: 0 auto 24px;
    max-width: 520px;
    text-align: center;
    color: var(--main-light);
    opacity: 0.7;
    line-height: 1.7;
    font-style: italic;
    font-size: 0.95em;
}

.gb-intro p {
    margin: 4px 0;
    padding: 0;
}

/* CTA button: dark terminal prompt */

.gb-sign-btn {
    font-family: "dos", monospace;
    font-size: 18px;
    padding: 12px 30px;
    color: var(--orange);
    background: rgba(20, 20, 20, 0.85);
    border: 2px solid var(--purple);
    cursor: pointer;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
}

.gb-sign-btn::before {
    content: ">";
    color: var(--purple);
    margin-right: 8px;
}

.gb-sign-btn::after {
    content: "_";
    margin-left: 3px;
    animation: gb-cursor-blink 1s steps(1) infinite;
}

.gb-sign-btn:hover,
.gb-sign-btn:focus {
    color: var(--main-light);
    border-color: var(--orange);
    background: rgba(197, 140, 101, 0.1);
    text-shadow: 0 0 10px rgba(197, 140, 101, 0.35);
    outline: none;
}

.gb-sign-btn:hover::before {
    color: var(--orange);
}

@keyframes gb-cursor-blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

@keyframes gb-fade-in {
    0%   { opacity: 0; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ── stats counter ── */

.gb-stats {
    font-family: "dos", monospace;
    font-size: 14px;
    color: var(--purple);
    text-align: center;
    margin-top: 18px;
    opacity: 0.6;
    letter-spacing: 0.5px;
}

.gb-stats-num {
    color: var(--orange);
}

/* ── bg tool indicator ── */

.gb-tool[data-tool="bg"] .gb-bg-preview {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1px solid rgba(234, 231, 222, 0.4);
    vertical-align: middle;
    margin-left: 4px;
}

/* ── divider ── */

.gb-divider {
    border: none;
    border-top: 2px dashed rgba(120, 88, 157, 0.3);
    margin: 24px 0 20px;
}

/* ── entries section ── */

.gb-section-label {
    font-family: "dos", monospace;
    font-size: 17px;
    color: var(--purple);
    letter-spacing: 1.5px;
    margin-bottom: 16px;
    opacity: 0.8;
    text-transform: uppercase;
}

.gb-entries {
    display: flex;
    flex-direction: column;
    gap: 14px;
    counter-reset: gb-log;
}

.gb-entries-empty {
    color: var(--purple);
    font-family: "dos", monospace;
    font-size: 15px;
    text-align: center;
    opacity: 0.55;
    padding: 30px 0;
    margin: 0;
}

/* ── entry cards ── */

.gb-entry {
    border: 2px solid rgba(120, 88, 157, 0.4);
    background: rgba(20, 20, 20, 0.7);
    counter-increment: gb-log;
    animation: gb-entry-in 0.3s steps(4, end) forwards;
    opacity: 0;
}

@keyframes gb-entry-in {
    0%   { opacity: 0; clip-path: inset(100% 0 0 0); }
    100% { opacity: 1; clip-path: inset(0); }
}

.gb-entry:nth-child(1)  { animation-delay: 0s; }
.gb-entry:nth-child(2)  { animation-delay: 0.04s; }
.gb-entry:nth-child(3)  { animation-delay: 0.08s; }
.gb-entry:nth-child(4)  { animation-delay: 0.12s; }
.gb-entry:nth-child(5)  { animation-delay: 0.16s; }
.gb-entry:nth-child(6)  { animation-delay: 0.20s; }
.gb-entry:nth-child(n+7) { animation-delay: 0.24s; }

.gb-entry:hover {
    border-color: rgba(120, 88, 157, 0.65);
}

.gb-entry-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(24, 24, 24, 0.9);
    border-bottom: 1px solid rgba(120, 88, 157, 0.2);
    min-height: 30px;
}

.gb-entry-bar::before {
    content: "#" counter(gb-log, decimal-leading-zero);
    font-family: "dos", monospace;
    font-size: 16px;
    color: var(--purple);
    opacity: 0.8;
    flex-shrink: 0;
}

.gb-entry-name {
    font-family: "dos", monospace;
    font-size: 16px;
    color: var(--orange);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gb-entry-name.anon {
    color: var(--purple);
    font-style: italic;
    opacity: 0.65;
}

.gb-entry-date {
    font-family: "dos", monospace;
    font-size: 13px;
    color: var(--main-light);
    opacity: 0.4;
    flex-shrink: 0;
}

.gb-entry-body {
    padding: 14px 16px;
}

.gb-entry-message {
    color: var(--main-light);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    line-height: 1.6;
    font-size: 1em;
}

.gb-entry-drawing {
    margin-top: 10px;
}

.gb-entry-canvas {
    display: block;
    max-width: 100%;
    border: 2px solid rgba(120, 88, 157, 0.25);
    background: var(--main-dark);
    cursor: pointer;
}

.gb-entry-canvas:hover {
    border-color: var(--orange);
}

.gb-drawing-hint {
    font-family: "dos", monospace;
    font-size: 13px;
    color: var(--purple);
    opacity: 0.4;
    display: block;
    margin-top: 4px;
}

.gb-entry-reply {
    margin-top: 14px;
    padding: 10px 14px;
    border-left: 3px solid var(--orange);
    background: rgba(197, 140, 101, 0.04);
}

.gb-entry-reply-label {
    font-family: "dos", monospace;
    font-size: 14px;
    color: var(--orange);
    margin-bottom: 4px;
}

.gb-entry-reply-label::before {
    content: "> ";
}

.gb-entry-reply-text {
    color: var(--main-light);
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 1em;
    opacity: 0.85;
    line-height: 1.55;
}

/* ── modal ── */

.gb-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
}

.gb-modal.is-open {
    display: block;
}

.gb-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    animation: gb-backdrop-in 0.12s steps(1, end) forwards;
}

.gb-modal-window {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(640px, calc(100vw - 28px));
    max-height: min(88vh, 820px);
    overflow-y: auto;
    border: ridge 6px var(--purple);
    background: rgba(14, 14, 14, 0.97);
    transform: translate(-50%, -50%);
    animation: gb-modal-in 0.2s steps(2, end) forwards;
    scrollbar-color: var(--purple) var(--main-dark);
    scrollbar-width: thin;
}

.gb-modal-window::-webkit-scrollbar { width: 6px; }
.gb-modal-window::-webkit-scrollbar-track { background: var(--main-dark); }
.gb-modal-window::-webkit-scrollbar-thumb { background: var(--purple); }

@keyframes gb-backdrop-in {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes gb-modal-in {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* close button: subtle corner X, not floating into form */

.gb-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    background: none;
    border: none;
    padding: 0px;
    cursor: pointer;
    opacity: 0.45;
}

.gb-modal-close:hover {
    opacity: 1;
}

.gb-modal-close img {
    display: block;
    width: 22px;
    height: 22px;
    image-rendering: pixelated;
    object-fit: contain;
}

.gb-modal-body {
    padding: 16px 26px 26px;
}

/* ── form fields ── */

.hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.gb-field {
    margin-bottom: 18px;
}

.gb-field label {
    display: block;
    margin-bottom: 6px;
    color: var(--main-light);
    font-family: "dos", monospace;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.gb-optional {
    color: var(--purple);
    font-size: 0.88em;
}

.gb-input,
.gb-textarea {
    width: 100%;
    padding: 9px 12px;
    font-family: "courier prime", monospace;
    font-size: 1em;
    color: var(--main-light);
    background-color: rgba(18, 18, 18, 0.9);
    border: 2px solid rgba(120, 88, 157, 0.45);
    box-sizing: border-box;
    outline: none;
}

.gb-input:focus,
.gb-textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 2px rgba(197, 140, 101, 0.2);
}

.gb-textarea {
    resize: vertical;
    min-height: 76px;
}

.gb-charcount {
    display: block;
    margin-top: 4px;
    font-family: "dos", monospace;
    font-size: 13px;
    color: var(--purple);
    opacity: 0.5;
}

/* ── canvas + tools ── */

.gb-canvas-container {
    border: 2px solid rgba(120, 88, 157, 0.45);
    background: var(--main-dark);
    padding: 0;
    display: block;
    position: relative;
    max-width: 100%;
}

#gb-canvas {
    display: block;
    cursor: crosshair;
    background: var(--main-dark);
    width: 100%;
    touch-action: none;
}

.gb-toolbar {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.gb-tools {
    display: flex;
    gap: 4px;
}

.gb-tool {
    font-family: "dos", monospace;
    font-size: 14px;
    padding: 5px 12px;
    color: var(--main-light);
    background: rgba(18, 18, 18, 0.9);
    border: 2px solid rgba(120, 88, 157, 0.4);
    cursor: pointer;
}

.gb-tool:hover,
.gb-tool:focus {
    border-color: var(--orange);
    outline: none;
}

.gb-tool.active {
    background: var(--purple);
    color: var(--main-light);
    border-color: var(--purple);
}

.gb-palette {
    display: flex;
    gap: 3px;
    align-items: center;
}

.gb-color {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid rgba(234, 231, 222, 0.25);
    cursor: pointer;
    box-sizing: border-box;
}

.gb-color:hover,
.gb-color:focus {
    border-color: var(--main-light);
    outline: none;
}

.gb-color.active {
    border-color: var(--main-light);
    box-shadow: 0 0 5px rgba(234, 231, 222, 0.4);
}

.gb-custom-color-wrap {
    position: relative;
    width: 24px;
    height: 24px;
}

.gb-custom-color-wrap input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

.gb-custom-color-swatch {
    width: 24px;
    height: 24px;
    border: 2px dashed rgba(234, 231, 222, 0.35);
    box-sizing: border-box;
    pointer-events: none;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
}

.gb-custom-color-wrap:hover .gb-custom-color-swatch {
    border-color: var(--main-light);
}

.gb-size-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: "dos", monospace;
    font-size: 14px;
    color: var(--purple);
}

.gb-size-slider {
    width: 60px;
    accent-color: var(--purple);
    cursor: pointer;
}

.gb-size-val {
    color: var(--main-light);
    min-width: 14px;
    text-align: center;
}

.gb-expand-btn {
    margin-left: auto;
}

/* ── privacy ── */

.gb-privacy {
    border: 2px dashed rgba(120, 88, 157, 0.35);
    padding: 12px 16px;
    margin: 0 0 18px;
}

.gb-privacy legend {
    color: var(--purple);
    padding: 0 8px;
    font-family: "dos", monospace;
    font-size: 16px;
}

.gb-priv-opt {
    display: block;
    margin: 8px 0;
    cursor: pointer;
    color: var(--main-light);
    font-size: 1em;
}

.gb-priv-opt input {
    margin-right: 8px;
    accent-color: var(--purple);
}

.gb-priv-tag {
    font-family: "dos", monospace;
    color: var(--purple);
    font-size: 22px;
}

.gb-priv-tag.priv {
    color: var(--orange);
}

/* ── turnstile ── */

.gb-turnstile-row {
    margin: 14px 0;
}

.turnstile-status {
    margin-top: 6px;
    font-family: "dos", monospace;
    font-size: 13px;
    color: var(--main-light);
}

.turnstile-status-error {
    color: var(--orange);
}

/* ── submit ── */

.gb-submit-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.gb-submit-btn {
    font-family: "dos", monospace;
    font-size: 16px;
    padding: 9px 24px;
    color: var(--main-light);
    background: var(--purple);
    border: ridge 4px var(--purple);
    cursor: pointer;
    letter-spacing: 1px;
}

.gb-submit-btn:hover,
.gb-submit-btn:focus {
    background: var(--main-light);
    color: var(--purple);
    outline: none;
}

.gb-submit-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.gb-status {
    color: var(--orange);
    font-family: "dos", monospace;
    font-size: 14px;
    min-height: 1.4em;
}

.gb-status.error {
    color: #e88;
}

.gb-status.success {
    color: #8e8;
}

/* ── lightbox ── */

.gb-lightbox {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: none;
    cursor: pointer;
}

.gb-lightbox.is-open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gb-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
}

.gb-lightbox canvas {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 85vh;
    border: ridge 4px var(--purple);
}

/* ── responsive ── */

@media (max-width: 600px) {
    .gb-stage {
        padding: 36px 6px 36px;
    }

    .gb-terminal-body {
        padding: 18px 14px 28px;
    }

    .gb-title {
        font-size: 2rem;
    }

    .gb-intro {
        padding: 14px 16px;
        font-size: 0.88em;
    }

    .gb-sign-btn {
        font-size: 15px;
        padding: 10px 20px;
    }

    .gb-modal-window {
        width: calc(100vw - 12px);
        max-height: 92vh;
    }

    .gb-modal-body {
        padding: 12px 14px 18px;
    }

    .gb-toolbar {
        gap: 6px;
    }

    .gb-palette {
        flex-wrap: wrap;
    }

    .gb-entry-body {
        padding: 10px 12px;
    }

    .gb-entry-name {
        font-size: 14px;
    }
}

@media (orientation: portrait) {
    body.guestbook-page nav,
    body.guestbook-page .navbar {
        
        font-size: 0.8em;
        padding: 2px 2px;
    }

    body.guestbook-page .botbar {
        
        padding: 1px 2px;
    }

    .gb-stage {
        padding-top: 36px;
        padding-bottom: 40px;
    }
}
