/* ─── Animations ──────────────────────────────────────────────────────────── */

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@keyframes scanline {
    0% {
        top: -100%;
    }

    100% {
        top: 100%;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ─── Reset & Base ────────────────────────────────────────────────────────── */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Courier New", Courier, monospace;
    background-color: #030303;
    color: #00ff41;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* CRT scanline overlay */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 200%;
    background: repeating-linear-gradient(0deg,
            rgba(0, 255, 65, 0.03) 0px,
            rgba(0, 255, 65, 0.03) 1px,
            transparent 1px,
            transparent 3px);
    animation: scanline 8s linear infinite;
    pointer-events: none;
    z-index: 999;
}

/* ─── HUD Container ──────────────────────────────────────────────────────── */

.hud-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    background: #080808;
    border: 1px solid #00ff41;
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(0, 255, 65, 0.05), inset 0 0 20px rgba(0, 255, 65, 0.02);
    overflow-y: auto;
    animation: fadeIn 0.4s ease-out;
    z-index: 1000;
    padding: 24px 20px;
    position: relative;
    gap: 2vh;
}

/* ─── Logo ────────────────────────────────────────────────────────────────── */

.logo-container {
    text-align: center;
    animation: fadeIn 0.6s ease-out;
}

.logo-container img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    filter: drop-shadow(0 0 15px rgba(0, 255, 65, 0.6));
}

/* ─── Header ──────────────────────────────────────────────────────────────── */

.header {
    text-align: center;
}

.header h1 {
    font-size: 18px;
    font-weight: normal;
    color: #00ff41;
    letter-spacing: 1px;
}

.cursor {
    display: inline-block;
    width: 10px;
    height: 18px;
    background: #00ff41;
    margin-left: 4px;
    vertical-align: middle;
    animation: blink 1s step-end infinite;
}

/* ─── Status ──────────────────────────────────────────────────────────────── */

.status {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: -5px;
    min-height: 20px;
    transition: color 0.3s ease;
}

.status--success {
    color: #00ff41;
}

.status--error {
    color: #ff0033;
}

.status--loading {
    color: #ffbd2e;
}

.status[hidden] {
    display: none;
}

/* ─── Generate Button ─────────────────────────────────────────────────────── */

.generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 85%;
    max-width: 320px;
    margin: 15vh auto 2vh auto;
    padding: 20px 24px;
    font-family: "Courier New", Courier, monospace;
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #030303;
    background: #00ff41;
    border: 2px solid #00ff41;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: rgba(0, 255, 65, 0.15);
    touch-action: manipulation;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.2);
}

.generate-btn:hover:not(:disabled) {
    background: transparent;
    color: #00ff41;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
}

.generate-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.generate-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.generate-btn--loading {
    background: transparent;
    color: #ffbd2e;
    border-color: #ffbd2e;
    opacity: 1 !important;
}

.generate-btn--error {
    background: transparent;
    color: #ff0033;
    border-color: #ff0033;
    opacity: 1 !important;
    cursor: pointer !important;
}

.generate-btn--error:hover {
    background: #ff0033;
    color: #030303;
    box-shadow: 0 0 20px rgba(255, 0, 51, 0.3);
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: #ffbd2e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.generate-btn[hidden] {
    display: none;
}

.generate-btn--inline {
    width: 85%;
    max-width: 320px;
    margin: 0 auto;
}

.generate-btn--secondary {
    background: transparent;
    color: #a0a0a0;
    border-color: #333;
}

.generate-btn--secondary:hover:not(:disabled) {
    background: transparent;
    color: #00ff41;
    border-color: #00ff41;
    box-shadow: 0 0 16px rgba(0, 255, 65, 0.15);
}

/* ─── New Session Button ──────────────────────────────────────────────────── */

.new-session-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 60%;
    max-width: 240px;
    margin: 0 auto;
    padding: 12px 18px;
    font-family: "Courier New", Courier, monospace;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #a0a0a0;
    background: transparent;
    border: 1px solid #333;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: rgba(0, 255, 65, 0.15);
    touch-action: manipulation;
}

.new-session-btn:hover {
    color: #ff0033;
    border-color: #ff0033;
    box-shadow: 0 0 12px rgba(255, 0, 51, 0.15);
}

.new-session-btn:active {
    transform: scale(0.96);
}

.new-session-btn[hidden] {
    display: none;
}

/* ─── Idle Screen ─────────────────────────────────────────────────────────── */

.idle-screen {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    font-size: 11px;
    color: rgba(0, 255, 65, 0.4);
    pointer-events: none;
    margin-top: 16px;
    min-height: 120px;
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
    mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
}

.idle-screen[hidden] {
    display: none;
}

.idle-line {
    word-break: break-all;
    line-height: 1.5;
    font-family: monospace;
    opacity: 0.8;
}

.idle-line span.hex {
    color: rgba(0, 255, 65, 0.7);
}

.idle-line span.addr {
    color: rgba(0, 255, 65, 0.3);
}

/* ─── Section Label ───────────────────────────────────────────────────────── */

.section-label {
    color: #a0a0a0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 4px;
}

.section-label[hidden] {
    display: none;
}

/* ─── Logs ────────────────────────────────────────────────────────────────── */

.logs {
    background: #050505;
    border: 1px solid #1a1a1a;
    border-radius: 8px;
    padding: 16px;
    list-style-type: none;
    font-size: 12px;
    max-height: 25vh;
    overflow-y: auto;
    line-height: 1.6;
    flex-shrink: 0;
}

.logs[hidden] {
    display: none;
}

.logs li {
    color: #00cc33;
    word-break: break-all;
    margin-bottom: 4px;
}

.logs li:last-child {
    margin-bottom: 0;
}

.logs li .prompt {
    color: #00ff41;
    font-weight: bold;
    margin-right: 4px;
}

.logs li .log-error {
    color: #ff0033;
}

.logs::-webkit-scrollbar {
    width: 4px;
}

.logs::-webkit-scrollbar-track {
    background: #050505;
}

.logs::-webkit-scrollbar-thumb {
    background: #00ff41;
    border-radius: 2px;
}

/* ─── Timer ───────────────────────────────────────────────────────────────── */

.timer-container {
    text-align: center;
    padding: 20px;
    border: 1px solid #1a1a1a;
    border-radius: 8px;
    background: #050505;
    animation: fadeIn 0.6s ease-out 0.2s both;
    flex-shrink: 0;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: rgba(0, 255, 65, 0.1);
    touch-action: manipulation;
}

.timer-container:hover {
    border-color: #00ff41;
    box-shadow: 0 0 12px rgba(0, 255, 65, 0.15);
}

.timer-container:active {
    transform: scale(0.98);
}

.timer-container[hidden] {
    display: none;
}

.timer-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
    position: relative;
}

.timer-label {
    color: #a0a0a0;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.refresh-icon {
    position: absolute;
    right: 0;
    color: #00ff41;
    font-size: 18px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.timer-container:hover .refresh-icon {
    opacity: 1;
}

.refresh-icon.spinning {
    animation: spin 1s linear infinite;
    opacity: 1;
    color: #ffbd2e;
}

.timer {
    font-size: 32px;
    font-weight: bold;
    color: #00ff41;
    letter-spacing: 2px;
    font-variant-numeric: tabular-nums;
}

.timer-bar-track {
    width: 100%;
    height: 4px;
    background: #1a1a1a;
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.timer-bar-fill {
    width: 100%;
    height: 100%;
    background: #00ff41;
    border-radius: 2px;
    transition: width 1s linear, background 0.5s ease;
}

/* ─── QR Code ─────────────────────────────────────────────────────────────── */

.qr-container {
    text-align: center;
    padding: 20px;
    border: 1px dashed #00ff41;
    border-radius: 8px;
    background: #050505;
    animation: fadeIn 0.6s ease-out 0.4s both;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
}

.qr-container[hidden] {
    display: none;
}

.qr-label {
    color: #a0a0a0;
    font-size: 11px;
    margin-bottom: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.qr-link {
    display: inline-block;
    padding: 6px;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: border-color 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: rgba(0, 255, 65, 0.15);
    touch-action: manipulation;
}

.qr-link:active {
    transform: scale(0.96);
    border-color: #00ff41;
}

.qr-container img {
    max-width: 240px;
    width: 60vw;
    image-rendering: pixelated;
    border-radius: 6px;
}

.qr-hint {
    color: #888888;
    font-size: 11px;
    margin-top: 12px;
    animation: pulse 2s ease-in-out infinite;
}

.app-id-display {
    color: #00ff41;
    font-size: 13px;
    margin-top: 14px;
    letter-spacing: 1px;
    word-break: break-all;
    user-select: all;
    background: rgba(0, 255, 65, 0.05);
    padding: 6px 12px;
    border: 1px solid rgba(0, 255, 65, 0.2);
    border-radius: 6px;
}

.app-id-display[hidden] {
    display: none;
}

/* ─── Fullscreen QR Overlay ───────────────────────────────────────────────── */

.qr-overlay {
    position: fixed;
    inset: 0;
    background: #000000;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    animation: fadeIn 0.3s ease-out;
}

.qr-overlay-card {
    background: #ffffff;
    border-radius: 32px;
    padding: 32px 24px 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 85vw;
    max-width: 320px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    cursor: default;
}

.qr-overlay-username {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 17px;
    font-weight: 400;
    color: #1a1a1a;
    margin-bottom: 2px;
    text-align: center;
    letter-spacing: 0;
}

.qr-overlay-tier {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    font-weight: 400;
    color: #888888;
    font-style: normal;
    margin-bottom: 16px;
    text-align: center;
    letter-spacing: 0;
}

.qr-overlay-card img {
    width: 100%;
    max-width: 270px;
    image-rendering: pixelated;
    border-radius: 4px;
}

.qr-overlay-instructions {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #666666;
    text-align: center;
    margin-top: 16px;
    line-height: 1.4;
    max-width: 250px;
    letter-spacing: 0;
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */

.footer {
    color: #888888;
    font-size: 11px;
    padding-top: 16px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
    z-index: 1000;
}

.footer a {
    color: #cccccc;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: #ffffff;
    text-decoration: underline;
}

.version-display {
    margin-top: 6px;
    opacity: 0.5;
    font-size: 10px;
    letter-spacing: 1px;
}

/* ─── Inline Screens ─────────────────────────────────────────────────────── */

.inline-screen {
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: fadeIn 0.25s ease-out;
}

.inline-screen[hidden] {
    display: none;
}

.inline-screen-title {
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #00ff41;
    text-align: center;
    margin-bottom: 4px;
}

.inline-screen-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ─── Credentials Form ────────────────────────────────────────────────────── */

.credentials-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.credentials-label {
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #a0a0a0;
    margin-top: 6px;
}

.credentials-input {
    width: 100%;
    padding: 12px 14px;
    font-family: "Courier New", Courier, monospace;
    font-size: 13px;
    color: #00ff41;
    background: #050505;
    border: 1px solid #1a1a1a;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    margin-bottom: 4px;
}

.credentials-input::placeholder {
    color: #333;
}

.credentials-input:focus {
    border-color: #00ff41;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.1);
}

.credentials-input:invalid:not(:placeholder-shown) {
    border-color: #ff0033;
}

.credentials-form .generate-btn {
    margin: 16px auto 8px auto;
}