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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0d1117;
    color: #e6edf3;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

.hidden { display: none !important; }

/* --- Login Screen --- */
#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background: #0d1117;
}

.login-box {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 40px 32px;
    max-width: 380px;
    width: 90%;
    text-align: center;
}

.login-box h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #f0f6fc;
}

.login-box p {
    font-size: 0.875rem;
    color: #8b949e;
    margin-bottom: 24px;
}

.login-box input {
    width: 100%;
    padding: 10px 14px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #f0f6fc;
    font-size: 1rem;
    outline: none;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.login-box input:focus {
    border-color: #58a6ff;
}

.login-box button {
    width: 100%;
    padding: 10px;
    background: #238636;
    border: 1px solid #2ea043;
    border-radius: 6px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box button:hover {
    background: #2ea043;
}

/* --- Main Screen --- */
#main-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* --- Status Bar --- */
#status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
    z-index: 10;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: #8b949e;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #484f58;
    flex-shrink: 0;
}

.dot.on { background: #3fb950; }
.dot.off { background: #f85149; }

#fps-display {
    font-variant-numeric: tabular-nums;
    min-width: 60px;
}

.toolbar-btn {
    padding: 4px 10px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #8b949e;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: #30363d;
    color: #e6edf3;
}

.toolbar-btn.active {
    background: #1f6feb;
    border-color: #388bfd;
    color: #fff;
}

/* --- Screen Container --- */
#screen-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    background: #010409;
    cursor: default;
}

#screen-container.mouse-active {
    cursor: crosshair;
}

#screen {
    max-width: 100%;
    max-height: 100%;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: auto;
}

#overlay-offline {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(13, 17, 23, 0.85);
    z-index: 5;
}

#overlay-offline span {
    font-size: 1.4rem;
    color: #8b949e;
    padding: 16px 32px;
    border: 1px solid #30363d;
    border-radius: 8px;
    background: #161b22;
}

/* --- Mobile Keyboard Input (oculto) --- */
#mobile-keyboard-input {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* --- Actions Modal --- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.modal-content {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #30363d;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f0f6fc;
}

.modal-close {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover {
    color: #f0f6fc;
}

.actions-grid {
    padding: 16px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.actions-empty {
    color: #484f58;
    text-align: center;
    padding: 20px 0;
    font-size: 0.9rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 8px;
    color: #e6edf3;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    width: 100%;
}

.action-btn:hover {
    background: #30363d;
    border-color: #484f58;
}

.action-btn:active {
    transform: scale(0.98);
}

.action-btn.running {
    border-color: #1f6feb;
    opacity: 0.7;
    pointer-events: none;
}

.action-btn .action-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    color: #8b949e;
}

.action-btn .action-label {
    flex: 1;
}

.action-btn .action-type {
    font-size: 0.7rem;
    color: #484f58;
    text-transform: uppercase;
}

.actions-toast {
    padding: 10px 20px;
    font-size: 0.8rem;
    border-top: 1px solid #30363d;
    text-align: center;
    transition: opacity 0.3s;
}

.actions-toast.success { color: #3fb950; }
.actions-toast.error { color: #f85149; }

/* --- Mobile adjustments --- */
@media (max-width: 600px) {
    #status-bar {
        flex-wrap: wrap;
        gap: 6px;
        padding: 6px 8px;
    }

    .status-left, .status-right {
        gap: 8px;
    }

    .toolbar-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

/* --- Fullscreen: hide status bar option --- */
body.fullscreen #status-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    opacity: 0;
    transition: opacity 0.3s;
}

body.fullscreen #status-bar:hover {
    opacity: 1;
}

body.fullscreen #screen-container {
    height: 100vh;
}
